husaynhakeem / android-playground

Playground for Android samples

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BiometricSample - not necessary assertion when running on SDK 30

java-crypto opened this issue · comments

First of all - Thanks for your excellent code regarding Biometric on Android, I did not find any examples
that are so extensive and are running "out of the box".

My point is not really an issue, but maybe you like to correct it.

When running your code on SDK 30 and choosing the option "Device credential" only
(so no checked "Strong biometric" and "Weak biometric" option) and using "Authenticate + Encrypt"
I get the error message "Authentication type must be strong to authenticate with crypto on API levels >= 30" that is caused
by line 76 of BiometricAuthenticatorApi30.kt:

private fun canAuthenticateWithCrypto(): Boolean {
    if (getSecretKeyType() and KeyProperties.AUTH_BIOMETRIC_STRONG == 0) {
        listener.onNewMessage(
            "Authentication type must be strong to authenticate with crypto" +
                    " on API levels >= 30"
        )
        return false
    }
    return true
}

This assertion seems to be not correct, the docs say nothing about this:

https://developer.android.com/training/sign-in/biometric-auth#java

When deactivating the function (or, for testing purposes, change "return false" to "return true" as well)
the program is running and gives an encrypted output.

Warm greetings
Michael