validateAndroidKeyAttestation

suspend fun validateAndroidKeyAttestation(chain: X509CertChain, challenge: ByteString?, requireGmsAttestation: Boolean = true, requireVerifiedBootGreen: Boolean = true, requireKeyMintSecurityLevel: AndroidKeystoreSecurityLevel = AndroidKeystoreSecurityLevel.TRUSTED_ENVIRONMENT, requireAppSignatureCertificateDigests: Set<ByteString> = emptySet(), requireAppPackages: Set<String> = emptySet(), validateAt: Instant = Clock.System.now(), validateCaValidity: Boolean = false, checkRevocation: Boolean = false, revokedSerials: Set<String>? = null): ByteString

Checks if Android key attestation is valid according to the given criteria.

On JVM platforms, this uses the com.android.keyattestation:keyattestation library to validate the certificate chain and attestation extension, which accounts for various device-specific KeyMint/Keymaster quirks and distinguishes between factory-provisioned and remotely-provisioned (RKP) certificate chains.

Return

challenge/nonce used during key creation

Parameters

chain

Android key attestation

challenge

challenge/nonce used during key creation (if needs to be checked)

requireGmsAttestation

check that certificate chain is rooted in a known Google key

requireVerifiedBootGreen

check that the device has booted securely

requireKeyMintSecurityLevel

identifies acceptable security level

requireAppSignatureCertificateDigests

identifies trusted app signing keys

requireAppPackages

identifies trusted app package names

validateAt

time instant used to validate certificate validity intervals

validateCaValidity

whether to validate validity intervals for CA certificates in the chain (ignored on JVM where CA validity rules are determined by the provisioning method of the chain)

checkRevocation

whether to fetch and check Google's certificate revocation status list from https://android.googleapis.com/attestation/status (only supported on JVM when revokedSerials is null)

revokedSerials

optional explicit set of lowercase hexadecimal serial numbers of revoked certificates to reject, or null to defer to checkRevocation

Throws

if Android key attestation is not valid