38
38
import java .security .PrivateKey ;
39
39
import java .security .PublicKey ;
40
40
import java .util .Calendar ;
41
+ import java .security .UnrecoverableKeyException ;
41
42
import java .util .HashMap ;
42
43
import java .util .Map ;
43
44
import java .util .concurrent .Executor ;
@@ -360,7 +361,7 @@ private void initFingerprintKeyStore() {
360
361
prepareKey ();
361
362
}
362
363
} catch (Exception e ) {
363
- e . printStackTrace ();
364
+ //
364
365
}
365
366
}
366
367
@@ -401,7 +402,6 @@ private void putExtraWithAES(final String key, final String value, final SharedP
401
402
cipher = Cipher .getInstance (AES_DEFAULT_TRANSFORMATION );
402
403
cipher .init (Cipher .ENCRYPT_MODE , secretKey );
403
404
404
-
405
405
// Retrieve information about the SecretKey from the KeyStore.
406
406
SecretKeyFactory factory = SecretKeyFactory .getInstance (
407
407
secretKey .getAlgorithm (), ANDROID_KEYSTORE_PROVIDER );
@@ -468,6 +468,7 @@ public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult re
468
468
}
469
469
return ;
470
470
}
471
+
471
472
byte [] encryptedBytes = cipher .doFinal (value .getBytes ());
472
473
473
474
// Encode the initialization vector (IV) and encryptedBytes to Base64.
@@ -478,7 +479,7 @@ public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult re
478
479
479
480
putExtra (key , result , mSharedPreferences );
480
481
pm .resolve (value );
481
- } catch (InvalidKeyException e ) {
482
+ } catch (InvalidKeyException | UnrecoverableKeyException e ) {
482
483
try {
483
484
mKeyStore .deleteEntry (KEY_ALIAS_AES );
484
485
prepareKey ();
@@ -586,7 +587,7 @@ public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult re
586
587
}
587
588
byte [] decryptedBytes = cipher .doFinal (cipherBytes );
588
589
pm .resolve (new String (decryptedBytes ));
589
- } catch (InvalidKeyException e ) {
590
+ } catch (InvalidKeyException | UnrecoverableKeyException e ) {
590
591
try {
591
592
mKeyStore .deleteEntry (KEY_ALIAS_AES );
592
593
prepareKey ();
0 commit comments