Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android CryptoObject usage in fingerprint

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.

like image 849
Dino Tw Avatar asked Jan 12 '16 22:01

Dino Tw


People also ask

What is CryptoObject?

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).

How can I use my Android phone as a biometric device?

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.

Does Android share biometric data?

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.


1 Answers

The FingerprintDialog sample provided in the Android Samples is a bit dense so let's break down what's happening:

  1. Configure and generate cryptographic Keys. In this step you can specify that the Key can only be used if KeyGenParameterSpec.Builder.setAuthenticated(true).
  2. Initialize a Cipher object with the cipherMode (encrypt/decrypt) and the Key generated from Step 1
  3. Initialize a FingerprintCrypto.CryptoObject() with the Cipher from Step 2
  4. Start the Fingerprint scanner and pass in the CryptoObject from step 3 by calling FingerprintManager.authenticate()
  5. User successfully authenticates with their fingerprint. The Android OS will set the "authenticated" bit in the Key from 0 to 1.
  6. Now that the key has been authenticated for use, it can be used to do any crypto operation by calling 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.

like image 181
Android Noob Avatar answered Oct 25 '22 17:10

Android Noob