iamMehedi / Secured-Preference-Store

A cryptography library and a SharedPreferences wrapper for Android that encrypts the content with 256 bit AES encryption. The Encryption key is securely stored in device's KeyStore.
563 stars 97 forks source link

could not generate key in keystore error #6

Open skhugh opened 7 years ago

skhugh commented 7 years ago

When beta testing my app, one user out of around 1,000 users experienced "could not generate key in keystore" error and could not log in to my service with the following exception.

Caused by java.lang.IllegalStateException: could not generate key in keystore android.security.AndroidKeyPairGenerator.generateKeyPair (AndroidKeyPairGenerator.java:99) java.security.KeyPairGenerator$KeyPairGeneratorImpl.generateKeyPair (KeyPairGenerator.java:276) devliving.online.securedpreferencestore.EncryptionManager.generateRSAKeys (EncryptionManager.java:488) devliving.online.securedpreferencestore.EncryptionManager.generateKey (EncryptionManager.java:348) devliving.online.securedpreferencestore.EncryptionManager.<init> (EncryptionManager.java:95) devliving.online.securedpreferencestore.SecuredPreferenceStore.<init> (SecuredPreferenceStore.java:36) devliving.online.securedpreferencestore.SecuredPreferenceStore.getSharedInstance (SecuredPreferenceStore.java:42)

Is there any solutions to this problem?

I'm using minSdk 21 and target 25. The device info is:-

Manufacturer: Samsung Model: SHV-E470S Board: Msm8974 Android API: 21 Android OS: 5.0.1

iamMehedi commented 7 years ago

Most probably due to this issue, which is not supposed to happen on API level >= 21 but here it is!