Error after Fingerprint touched on Samsung phones: android.security.KeyStoreException: Key user not authenticated

后端 未结 9 1126
醉酒成梦
醉酒成梦 2020-12-14 19:48

My app uses Android 6.0 Fingerprint API to protect AES key in the Android KeyStore. The stored key can be used only when user is authenticated by fingerprint sensor because

相关标签:
9条回答
  • 2020-12-14 20:19

    Setting KeyGenParameterSpec.setUserAuthenticationRequired(false) can be a potential security issue. The above error should be handled similar to KeyPermanentlyInvalidatedException. KeyPermanentlyInvalidatedException is thrown on Cipher initialization if new fingerprints are added after your SecretKey is created. But, if the Cipher is initialized before the new fingerprints are added, you'll get the above KeyStoreException for Key User not authenticated, when you're trying to encrypt or decrypt with that Cipher.

    It's easy to reproduce this error. While your app's fingerprint verification screen is in the background, try adding a new fingerprint. Now switch back to the app, and enter the fingerprint, the encryption or decryption methods would throw this error. I could resolve this issue by catching the exception and treating it the same way as KeyPermanentlyInvalidatedException.

    0 讨论(0)
  • 2020-12-14 20:24

    This seems to be a bug in Android that arises after an update.

    I had it on a OnePlus. I removed the device lock from the settings and set it again. After that, the issue was gone.

    0 讨论(0)
  • 2020-12-14 20:25

    Do NOT listen to the "setUserAuthenticationRequired(false)"

    I have been able to reproduce this on Samsung by listening twice. What I think is happening is, you listen twice, authenticate on the one call, but reference it through another.

    add Logs and check that you only start listening for fingerprint once and once only.

    0 讨论(0)
提交回复
热议问题