In Android fingerprint sample code FingerprintDialog, the method that starts fingerprint hardware FingerprintManager#authenticate takes a parameter of FingerprintManager.CryptoObject. According to the documentation, it's the object associated with the call or null if none required
. The description is still not clear for me. Would someone explain when I should or should not use crypto Thanks.
CryptoObjects are used to unlock auth-per-use keys via BiometricPrompt#authenticate(CryptoObject, CancellationSignal, Executor, AuthenticationCallback) , whereas time-based keys are unlocked for their specified duration any time the user authenticates with the specified authenticators (e.g. unlocking keyguard).
From Settings, tap Biometrics and security, and then tap Fingerprints. Enter your secure screen lock credentials and then tap Add fingerprint. Follow the on-screen prompts to add the fingerprint, and then tap Done.
Your fingerprint data isn't shared with Google or any apps on your device. Apps are notified only whether your fingerprint was verified. If you're ready to get started using your fingerprint to unlock your phone, learn how to set up your fingerprints.
The FingerprintDialog sample provided in the Android Samples is a bit dense so let's break down what's happening:
KeyGenParameterSpec.Builder.setAuthenticated(true)
.FingerprintCrypto.CryptoObject()
with the Cipher from Step 2FingerprintManager.authenticate()
Cipher.doFinal()
.If you try to modify step 4 by passing in null
to FingerprintManager.authenticate()
, then step 6 will fail because you have not been authenticated to use the key.
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With