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

[FIXED] KeyStore exception android.os.ServiceSpecificException: (code 7) #42

Open ajdevy opened 5 years ago

ajdevy commented 5 years ago

Fixed secure preferences initialization with Android KeyStore, as described in https://stackoverflow.com/questions/52024752/android-p-keystore-exception-android-os-servicespecificexception?rq=1

ajdevy commented 5 years ago

@EdgarJan can you give a bit more details?

EdgarJan commented 5 years ago

@EdgarJan can you give a bit more details?

W/KeyStore: KeyStore exception
    android.os.ServiceSpecificException:  (code 7)
        at android.os.Parcel.createException(Parcel.java:1956)
        at android.os.Parcel.readException(Parcel.java:1910)
        at android.os.Parcel.readException(Parcel.java:1860)
        at android.security.IKeystoreService$Stub$Proxy.get(IKeystoreService.java:786)
        at android.security.KeyStore.get(KeyStore.java:195)
        at android.security.keystore.AndroidKeyStoreSpi.engineGetCertificate(AndroidKeyStoreSpi.java:144)
        at java.security.KeyStoreSpi.engineEntryInstanceOf(KeyStoreSpi.java:583)
        at java.security.KeyStore.entryInstanceOf(KeyStore.java:1631)
        at devliving.online.securedpreferencestore.EncryptionManager.loadKey(EncryptionManager.java:690)
        at devliving.online.securedpreferencestore.EncryptionManager.setup(EncryptionManager.java:228)
        at devliving.online.securedpreferencestore.EncryptionManager.<init>(EncryptionManager.java:201)
        at devliving.online.securedpreferencestore.SecuredPreferenceStore.<init>(SecuredPreferenceStore.java:79)
        at devliving.online.securedpreferencestore.SecuredPreferenceStore.init(SecuredPreferenceStore.java:134)

I suggest remove check for mStore.entryInstanceOf(AES_KEY_ALIAS, KeyStore.SecretKeyEntry.class).

BlueHeisenberg commented 4 years ago

Why is this not merged already?