android / security-samples

Multiple samples showing the best practices in security APIs on Android.
Apache License 2.0
938 stars 395 forks source link

KeyPermanentlyInvalidatedException not thrown all the time after enrolling new fingerprint #9

Closed codingjeremy closed 4 years ago

codingjeremy commented 5 years ago

Issue by TheNephilim88 Monday Nov 30, 2015 at 20:18 GMT Originally opened as https://github.com/googlesamples/android-FingerprintDialog/issues/21


The initCipher()-method checks if lockscreen has been disabled or new fingerprints have been enrolled. For this it checks if a KeyPermanentlyInvalidatedException will be thrown or not. If it wil lbe thrown, any of above reasons apply.

But this does not seem to trigger all the time. It only triggers randomly on my device (Nexus 5X) after adding new fingerprints. Most of the time I get normal fingerprint-authentication dialog and it works as nothing has been changed. Only very few times I get "A new fingerprint was added to this device"-message to reauthenticate.

Can anyone tell me why this is not triggering all the time when new fingerprints have been enrolled? Is this a bug or a feature? :D

Is it possible to check for fingerprint-changes in another way?

codingjeremy commented 5 years ago

Comment by thagikura Monday Dec 07, 2015 at 03:48 GMT


Hi,

Detecting a new fingerprint is not triggered randomly. One thing I'm guessing is that you may have created a new key after new fingerprints were added.

This sample creates a new key in onCreate, so if you launch the sample app after you add a new fingerprint, KeyPermanentlyInvalidatedException is not thrown because at the time the key is created, a set of fingerprints include the new created one.

If you want to test that KeyPermanentlyInvalidatedException, please try to add a new fingerprint while keeping the app open.

codingjeremy commented 5 years ago

Comment by tajchert Friday Oct 06, 2017 at 11:11 GMT


Also this is a case for me - I get (API 26 both emulator and Nexus 5x) IllegalBlockSizeException instead of KeyPermanentlyInvalidatedException after adding new imprint.

codingjeremy commented 5 years ago

Comment by tajchert Monday Oct 09, 2017 at 15:42 GMT


I believe this is the reason of this issue: https://issuetracker.google.com/issues/65578763

Morteza-Rastgoo commented 5 years ago

So to avoid creating a new key, how to load previous key?