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.
562 stars 97 forks source link

java.security.ProviderException - HTC M8 #23

Closed matthew-niemann closed 6 years ago

matthew-niemann commented 6 years ago

I don't believe this to be an issue with your library, but having turned up empty with web research, I'm just here as a last resort to see if you might have any insight or suggestions.

Device: HTC M8 Android OS: 6.0.1 Reinstall resolves issue: No Users affected: 1 Reproducible: Only by one remote user (unable to physically debug device)

The only thing I can think of asking this user is if they have recently removed their screen lock. However, I am skeptical of this as the source, since this case has historically produced exceptions under a different name (usually java.lang.IllegalStateException).

Package: com.xxxxxxxxx
Version Code: YY
Version Name: Z.Z.Z
Android: 6.0.1
Android Build: MMB29M release-keys
Manufacturer: HTC
Model: HTC M8
Thread: main-1
CrashReporter Key: 0D2E8E80-8D22-39DB-3740-F7C66634F01214BA4CB1
Start Date: Thu Nov 16 20:16:33 GMT+01:00 2017
Date: Thu Nov 16 20:16:34 GMT+01:00 2017

java.lang.RuntimeException: Unable to create application com.xxxxxxxxx.ZZZApplication: java.security.ProviderException: Keystore operation failed
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java)
    at android.app.ActivityThread.access$1600(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
    at android.os.Handler.dispatchMessage(Handler.java)
    at android.os.Looper.loop(Looper.java)
    at android.app.ActivityThread.main(ActivityThread.java)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
Caused by: java.security.ProviderException: Keystore operation failed
    at android.security.keystore.AndroidKeyStoreKeyGeneratorSpi.engineGenerateKey(AndroidKeyStoreKeyGeneratorSpi.java)
    at javax.crypto.KeyGenerator.generateKey(KeyGenerator.java)
    at devliving.online.securedpreferencestore.EncryptionManager.generateAESKey(EncryptionManager.java:502)
    at devliving.online.securedpreferencestore.EncryptionManager.generateKey(EncryptionManager.java:472)
    at devliving.online.securedpreferencestore.EncryptionManager.setup(EncryptionManager.java:145)
    at devliving.online.securedpreferencestore.EncryptionManager.<init>(EncryptionManager.java:124)
    at devliving.online.securedpreferencestore.SecuredPreferenceStore.<init>(SecuredPreferenceStore.java:42)
    at devliving.online.securedpreferencestore.SecuredPreferenceStore.init(SecuredPreferenceStore.java:87)
    at com.xxxxxxxxx.preferences.LoginPreferences.initKeyStore(LoginPreferences.java:213)
    at com.xxxxxxxxx.ZZZApplication.setupKeyStore(ZZZApplication.java:107)
    at com.xxxxxxxxx.ZZZApplication.onCreate(ZZZApplication.java:60)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java)
    ... 9 more
Caused by: android.security.KeyStoreException: System error
    at android.security.KeyStore.getKeyStoreException(KeyStore.java)
    ... 21 more

Exception source: android.security.keystore.AndroidKeyStoreKeyGeneratorSpi [Line 303]

iamMehedi commented 6 years ago

Looks like it was thrown due to a system error. So my guess is it wasn't because of the user not having a screen lock.