Snap for 14624019 from 267567a5c8cde340b61cb4d3563d330b8300326d to 26Q2-release

Change-Id: Ia418edebe87fc9b5ddec4ec44cd859d5e75d40e9
tree: 6fcb0fde08b645c324f03a699c3b74b63cd493ad
  1. .github/
  2. gradle/
  3. src/
  4. testdata/
  5. Android.bp
  6. build.gradle.kts
  7. CONTRIBUTING.md
  8. gradle.properties
  9. gradlew
  10. gradlew.bat
  11. LICENSE
  12. METADATA
  13. MODULE_LICENSE_APACHE2
  14. OWNERS
  15. README.md
  16. roots.json
  17. settings.gradle.kts
README.md

Android Key Attestation Verifier

A Kotlin library for verifying Android key attestation certificate chains.

Usage

// Create a verifier with trust anchors, revocation info, and time source
val verifier = Verifier(
  { setOf(TrustAnchor(rootCertificate, null)) },  // Trust anchors source
  { setOf<String>() },                            // Revoked serials source
  { Instant.now() }                               // Time source
)

// Verify an attestation certificate chain
val result = verifier.verify(certificateChain)

// Handle the verification result
when (result) {
  is VerificationResult.Success -> {
    // Access verified information
    val publicKey = result.publicKey
    val securityLevel = result.securityLevel
    val verifiedBootState = result.verifiedBootState
    val deviceInformation = result.deviceInformation
  }
  is VerificationResult.ChallengeMismatch -> // Handle challenge mismatch
  is VerificationResult.PathValidationFailure -> // Handle validation failure
  is VerificationResult.ChainParsingFailure -> // Handle parsing failure
  is VerificationResult.ExtensionParsingFailure -> // Handle extension parsing issues
  is VerificationResult.ExtensionConstraintViolation -> // Handle constraint violations
}

If there is additional verification you'd like to perform on the challenge associated with the attestation certificate chain, pass in a ChallengeChecker when verifying. For example, if you expect the challenge to be equal to “challenge123”, then usage would look like

// Create a ChallengeChecker
val challengeChecker = ChallengeMatcher("challenge123")

// Verify an attestation certificate chain with the checker
val result = verifier.verify(certificateChain, challengeChecker)

If the implementations in challengecheckers/ don't fit your needs, simply extend the ChallengeChecker interface.

Building

./gradlew build

Testing

./gradlew test

Roots

Android Key Attestation root certificates are documented here.

Getting Revoked Serials

The revoked serials may be retrieved from https://android.googleapis.com/attestation/status.

See here for more information about the format of the data.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.