AttestationVerifier

class AttestationVerifier(val makoto: Makoto, val attestationProofOID: ObjectIdentifier = WardenDefaults.OIDs.ATTESTATION_PROOF, val genericDeviceNameOID: ObjectIdentifier? = WardenDefaults.OIDs.DEVICE_NAME, val defaultKeyConstraints: KeyConstraints? = WardenDefaults.KeyConstraints.p256Signer, val nonceValidity: Duration = makoto.longestValidityDuration ?: IosAttestationConfiguration.DEFAULT_VALIDITY_SECONDS.seconds, val toBeAttestedAttributes: AttestationChallenge.CertificationRequestAttributeAttestationDescriptor? = null, val dataAuth: DataAuthentication = DataAuthentication.Signature, val maxAttestationPayloadBytes: Int = WardenDefaults.DEFAULT_MAX_ATTESTATION_PAYLOAD_BYTES, nonceGenerator: NonceGenerator = WardenDefaults.nonceGenerator, challengeValidator: ChallengeValidator = InMemoryChallengeCache( makoto.clock, -makoto.verificationTimeOffset ))(source)

Verifies attestation statements and issues certificates on success. Expects a preconfigured Makoto instance defining which apps and devices are considered trustworthy.

attestationProofOID identifies the TBS CSR attribute carrying the attestation statement. It defaults to WardenDefaults.OIDs.ATTESTATION_PROOF. dataAuth selects the default authentication mode for issued challenges: signed PKCS#10 with proof of possession, or hash-bound unsigned TBS CSR without proof of possession. toBeAttestedAttributes optionally requests ordered client-provided values which are encoded into the TBS CSR and authenticated by the selected mode. When defaultKeyConstraints is specified, all issued challenges will automatically convey this, unless overridden. Note that key constraints cannot be reliably enforced due to technical client limitations. Not all platforms can restrict key usage and properties! Still, Warden Supreme's client will respect the key constraints and create keys as specified.

genericDeviceNameOID indicates whether to include a generic make and model (such as "Google Pixel 8", or "iPhone 16") with the attestation proof. On its own, this is not the device's nickname and therefore cannot identify a person in its own. Defaults to WardenDefaults.OIDs.DEVICE_NAME as it is very useful technical, non-personally-identifying data. Can be set to null to not include device names.

The nonceGenerator's responsibility is to generate nonces to ensure freshness of issues challenges. Defaults to WardenDefaults.nonceGenerator, which generates secure, random 64-byte nonces

nonceValidity indicates how long issued nonces remain valid. This defaults to the maximum of the passed makoto's IosAttestationConfiguration.attestationStatementValiditySeconds and AndroidAttestationConfiguration.attestationStatementValiditySeconds.

maxAttestationPayloadBytes the upper bound of payloads exchanged between client and verifier

Constructors

Link copied to clipboard
constructor(makoto: Makoto, attestationProofOID: ObjectIdentifier = WardenDefaults.OIDs.ATTESTATION_PROOF, genericDeviceNameOID: ObjectIdentifier? = WardenDefaults.OIDs.DEVICE_NAME, defaultKeyConstraints: KeyConstraints? = WardenDefaults.KeyConstraints.p256Signer, nonceValidity: Duration = makoto.longestValidityDuration ?: IosAttestationConfiguration.DEFAULT_VALIDITY_SECONDS.seconds, toBeAttestedAttributes: AttestationChallenge.CertificationRequestAttributeAttestationDescriptor? = null, dataAuth: DataAuthentication = DataAuthentication.Signature, maxAttestationPayloadBytes: Int = WardenDefaults.DEFAULT_MAX_ATTESTATION_PAYLOAD_BYTES, nonceGenerator: NonceGenerator = WardenDefaults.nonceGenerator, challengeValidator: ChallengeValidator = InMemoryChallengeCache( makoto.clock, -makoto.verificationTimeOffset ))

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val attestationProofOID: ObjectIdentifier
Link copied to clipboard
Link copied to clipboard
val genericDeviceNameOID: ObjectIdentifier?
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Decodes an HTTP attestation-proof payload after enforcing AttestationVerifier.maxAttestationPayloadBytes.

Link copied to clipboard
suspend fun issueChallenge(postEndpoint: String, timeZone: TimeZone? = null, keyConstraints: KeyConstraints? = defaultKeyConstraints, toBeAttestedAttributes: AttestationChallenge.CertificationRequestAttributeAttestationDescriptor? = this.toBeAttestedAttributes, dataAuth: DataAuthentication = this.dataAuth): AttestationChallenge

Issues a new attestation challenge using a nonce generated by nonceGenerator, valid for nonceValidity, and expecting an attestation proof to be HTTP POSTed to postEndpoint. The response is a signed CSR or unsigned TBS CSR according to dataAuth. It is possible, to pass a timeZone, but this is purely informational and is not fed into validity checks.

Link copied to clipboard
suspend fun verifyAttestation(attestationProof: AttestationProof, onChallengeValidated: suspend AttestationChallenge.(attestationProof: AttestationProof) -> Unit = { }, onPreAttestationError: suspend PreAttestationError.() -> String? = { null }, onAttestationError: suspend AttestationResult.Error.(debugInfo: WardenDebugAttestationStatement) -> String? = { null }, onAttestationSuccess: suspend AttestationResult.Verified.(CryptoPublicKey) -> Unit = { }, additionalVerifications: suspend AttestationChallenge.(attestationProof: AttestationProof, AttestationResult.Verified) -> AttestationResponse.Failure? = { _, _ -> null }, certificateIssuer: ProofToChain): AttestationResponse

Verifies a signed CSR or hash-authenticated unsigned TBS CSR.

suspend fun verifyAttestation(csr: Pkcs10CertificationRequest, onChallengeValidated: suspend AttestationChallenge.(Pkcs10CertificationRequest) -> Unit = { }, onPreAttestationError: suspend PreAttestationError.() -> String? = { null }, onAttestationError: suspend AttestationResult.Error.(debugInfo: WardenDebugAttestationStatement) -> String? = { null }, onAttestationSuccess: suspend AttestationResult.Verified.(CryptoPublicKey) -> Unit = { }, additionalVerifications: suspend AttestationChallenge.(Pkcs10CertificationRequest, AttestationResult.Verified) -> AttestationResponse.Failure? = { _, _ -> null }, certificateIssuer: CertificateIssuer): AttestationResponse

Verifies a received signed CSR. This compatibility overload always uses DataAuthentication.Signature: