duo-labs / android-webauthn-authenticator

A WebAuthn Authenticator for Android leveraging hardware-backed key storage and biometric user verification.
BSD 3-Clause "New" or "Revised" License
110 stars 20 forks source link

Attestation object length #12

Open andras-the-android opened 2 years ago

andras-the-android commented 2 years ago

Hi,

I'm experimenting and constructAttestationObject() fails on the assertion because authenticatorData is 164 bytes long instead of 141 and seemingly it's because the encodedPublicKey in constructAttestedCredentialData() is longer than expected. I'm using a Pixel 3 with Android 12 and here is the code snippet I'm useing to call your library:

fun register() {
        val authenticator = Authenticator(context, false, false)
        val options = AuthenticatorMakeCredentialOptions().apply {
            clientDataHash = generateId(32)
            credTypesAndPubKeyAlgs = listOf(Pair("public-key", -7))
            requireUserPresence = true
            rpEntity = RpEntity().apply { name = "Test.Company"; id = "testCompany" }
            userEntity = UserEntity().apply { name = "testUser"; displayName = "Test User"; id = generateId(32) }
        }
        val attestationObject = authenticator.makeCredential(options)
        Log.d(TAG, "attestation object id: ${attestationObject.credentialIdBase64}")
    }

    private fun generateId(length: Int): ByteArray {
        val random = SecureRandom()
        val bytes = ByteArray(length)
        random.nextBytes(bytes)
        return bytes
    }

Thanks in advance!