|
38 | 38 | import java.util.concurrent.Executors; |
39 | 39 |
|
40 | 40 | import javax.crypto.Cipher; |
| 41 | +import javax.crypto.IllegalBlockSizeException; |
41 | 42 | import javax.crypto.KeyGenerator; |
42 | 43 | import javax.crypto.SecretKey; |
43 | 44 | import javax.crypto.SecretKeyFactory; |
@@ -425,6 +426,18 @@ public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult re |
425 | 426 | pm.reject(keyResetError); |
426 | 427 | } |
427 | 428 | pm.reject(e); |
| 429 | + } catch (IllegalBlockSizeException e){ |
| 430 | + if(e.getCause() != null && e.getCause().getMessage().contains("Key user not authenticated")) { |
| 431 | + try { |
| 432 | + mKeyStore.deleteEntry(KEY_ALIAS_AES); |
| 433 | + prepareKey(); |
| 434 | + pm.reject(AppConstants.KM_ERROR_KEY_USER_NOT_AUTHENTICATED, e.getCause().getMessage()); |
| 435 | + } catch (Exception keyResetError) { |
| 436 | + pm.reject(keyResetError); |
| 437 | + } |
| 438 | + } else { |
| 439 | + pm.reject(e); |
| 440 | + } |
428 | 441 | } catch (SecurityException e) { |
429 | 442 | pm.reject(e); |
430 | 443 | } catch (Exception e) { |
@@ -530,6 +543,18 @@ public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult re |
530 | 543 | pm.reject(keyResetError); |
531 | 544 | } |
532 | 545 | pm.reject(e); |
| 546 | + } catch (IllegalBlockSizeException e){ |
| 547 | + if(e.getCause() != null && e.getCause().getMessage().contains("Key user not authenticated")) { |
| 548 | + try { |
| 549 | + mKeyStore.deleteEntry(KEY_ALIAS_AES); |
| 550 | + prepareKey(); |
| 551 | + pm.reject(AppConstants.KM_ERROR_KEY_USER_NOT_AUTHENTICATED, e.getCause().getMessage()); |
| 552 | + } catch (Exception keyResetError) { |
| 553 | + pm.reject(keyResetError); |
| 554 | + } |
| 555 | + } else { |
| 556 | + pm.reject(e); |
| 557 | + } |
533 | 558 | } catch (SecurityException e) { |
534 | 559 | pm.reject(e); |
535 | 560 | } catch (Exception e) { |
|
0 commit comments