I am using the android Biometricx library for face and fingerprint authentication. When only FaceID is registered and I try to create secret key I am getting "IllegalStatException: At least one biometric must be enrolled to create keys that require user authentication"
I am trying to create secretKey like this
try {
mKeyGenerator.init(new KeyGenParameterSpec.Builder(KEY_NAME,
KeyProperties.PURPOSE_ENCRYPT |
KeyProperties.PURPOSE_DECRYPT)
.setBlockModes(KeyProperties.BLOCK_MODE_CBC)
// Require the user to authenticate with a fingerprint to authorize every use
// of the key
.setUserAuthenticationRequired(true)
.setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_PKCS7)
.build());
secretKey = mKeyGenerator.generateKey();
} catch (NoSuchAlgorithmException | InvalidAlgorithmParameterException
| CertificateException | IOException e) {
Toast.makeText(this,"Create Key "+ e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
}
The code works fine when fingerprint is registered. This happens only when FaceId is registered. What am I missing here?