為數位憑證實作採用專屬硬體的認證機制

在典型的數位憑證核發流程中,使用 OpenID for Verifiable Credential Issuance (OpenID4VCI) 規格時,核發者必須知道要簽署的憑證中的金鑰儲存在安全位置。android_keystore_attestation 證明類型 (OpenID4VCI 專用格式) 會提供Android Keystore 的硬體簽署報告,確保金鑰鎖定在受信任的執行環境 (TEE) 或 StrongBox 中,無法匯出或複製。

硬體驗證總覽

在 Android Keystore 中產生金鑰時,系統可以產生認證憑證。這個憑證是由裝置硬體保護的金鑰簽署,並回溯至 Google 持有的信任根。

android_keystore_attestation 證明是 X.509 憑證鏈的陣列。每個鏈結代表單一驗證金鑰,結構為分葉憑證,後接中繼憑證。

  • 分葉憑證:內含金鑰和 Android 專屬的驗證擴充功能。
  • 中繼憑證:將葉片連線至 Android 根目錄。

驗證步驟

簽發機構應對認證執行多項驗證。

  • 找出鏈結中包含 Android 認證擴充資料的憑證 (通常是分葉憑證)。這項憑證包含 Android Keystore 鑄造的金鑰認證資料。
  • 確認擴充功能的 attestationChallenge 欄位與通訊協定提供的 c_nonce 相符,以免遭到重播攻擊。
  • 驗證您感興趣的擴充功能中所有斷言的值。
  • 對 Android Keystore 憑證執行撤銷檢查。

認證證明中的值來自多個來源:

  • 發行者:發行者會提供各種值,最常見的值會以發行者中繼資料格式提供,以便在簡報中進行篩選。
  • 持有者:套件名稱和簽章等值來自持有者。這些資訊不會透過標準核發程序分享,必須由持有人自行取得。
  • 通訊協定:值 (例如含有 attestationChallenge 的隨機值) 來自通訊協定。

如需驗證認證資料的完整操作說明,請參閱下列資源:

驗證證明格式

在憑證要求中,android_keystore_attestation 證明會包含在下列範例中:

{
  "type": "array",
  "description": "An array of certificate chains. Each chain attests a single key.",
  "items": {
    "type": "array",
    "description": "An X.509 certificate chain. Each certificate is a Base64-encoded string. The first element in the chain is the leaf certificate with the extension, the last is the Android Keystore root certificate.",
    "items": {
      "type": "string",
      "description": "A single X.509 certificate (Base64-NoWrap padded DER encoded)."
    },
    "minItems": 1
  },
  "minItems": 1
}

然後儲存在憑證要求的 proofs 物件中。

{
  "credential_configuration_id": "org.iso.18013.5.1.mDL",
  "proofs": {
    "android_keystore_attestation": [
      [
        "MII...", // Leaf certificate (contains Keystore extension)
        "MII...", // Intermediate certificate
        "MII..."  // Android Root certificate
      ],
      [ "MII...", "MII...", "MII..." ] // second proof
    ]
  }
}

發卡機構中繼資料格式

核發機構會在特定憑證設定的 proof_types_supported 物件中加入 android_keystore_attestation 物件,指出支援的驗證類型。

以下是發卡機構的 android_keystore_attestation 物件範例:

{
  "type": "object",
  "properties": {
    "proof_signing_alg_values_supported": {
      "type": "array",
      "description": "REQUIRED. As defined in OpenID4VCI 1.0 Section 12.2.4.",
      "items": {
        "type": "string",
        "description": "Cryptographic algorithm identifiers used in the proof_signing_alg_values_supported Credential Issuer metadata parameter for this proof type are case sensitive strings and SHOULD be one of those defined in [IANA.JOSE]."
      },
      "minItems": 1
    },
    "key_attestations_required": {
      "type": "object",
      "description": "OPTIONAL. Specifies the minimum attestation requirements.",
      "properties": {
        "key_mint_security_level": {
          "type": "string",
          "description": "OPTIONAL. Minimum accepted keyMintSecurityLevel. Values defined in https://source.android.com/docs/security/features/keystore/attestation#securitylevel-values.",
          "enum": ["Software", "TrustedEnvironment", "StrongBox"],
          "default": "TrustedEnvironment"
        },
        "user_auth_types": {
          "type": "array",
          "description": "OPTIONAL. A list of authentication types which can authorize the use of the key. If empty, no authentication is required. If multiple, any are allowed.",
          "items": {
            "type": "string",
            "description": "Allowed values are 'LSKF' and 'BIOMETRIC'. These values are meant to mimic the values used during the key generation process here.",
            "enum": ["LSKF", "BIOMETRIC"]
          },
          "default": []
        }
      }
    }
  },
  "required": ["proof_signing_alg_values_supported"]
}

這是外部 proof_types_supported 物件的範例:

{
  "credential_configurations_supported": {
    "org.iso.18013.5.1.mDL": {
      "format": "mso_mdoc",
      "doctype": "org.iso.18013.5.1.mDL",
      "cryptographic_binding_methods_supported": [
        "cose_key"
      ],
      "credential_signing_alg_values_supported": [
        -7, -9
      ],
      "proof_types_supported": {
        "android_keystore_attestation": {
          "proof_signing_alg_values_supported": [
            "ES256" // ecdsaWithSHA256
          ],
          "key_attestations_required" : {
            // OPTIONAL String - Representing the minimum accepted value for keyMintSecurityLevel values
            // defined here ("Software"|"TrustedEnvironment"|"StrongBox"). Default value: "TrustedEnvironment"
            "key_mint_security_level": "TrustedEnvironment",
            // OPTIONAL List of Strings - Representing all allowed values for userAuthType values defined here.
            // [] value will represent noAuthRequired. Default value: [].
            "user_auth_types": ["LSKF", "BIOMETRIC"]
          }
        }
      }
    }
  }
}

將 VCI 驗證聲明對應至 Android Keystore

下表提供資訊對應,可協助熟悉標準 OpenID4VCI 認證證明類型的實體,瞭解 Android Keystore 認證中類似概念的位置。

VCI 認證聲明

android_keystore_attestation 個地點

預期價值位置

iss

Keystore 根憑證的公開金鑰

不適用

iat

認證擴充功能中的 creationDateTime

不適用

exp

分葉憑證中的 validUntil 欄位

不適用

attested_keys

每個鏈結的葉子憑證中包含的公開金鑰

不適用

key_storage

認證擴充功能中的 keyMintSecurityLevel

選取的發卡機構:發行者中繼資料中的 key_mint_security_level 欄位

user_authentication

認證擴充功能中的 userAuthTypenoAuthRequired

選取的發卡機構:發行者中繼資料中的 user_auth_types 欄位

Nonce

認證擴充功能中的 attestationChallenge

來自通訊協定:VCI 中說明的 nonce 端點c_nonce

認證

不適用

不適用

狀態

不適用

不適用