For the most part, the application works fine. At times I get the following exception:
android.security.KeyStoreException: Invalid operation handle
Here is the stack trace:
android.security.KeyStore.getKeyStoreException KeyStore.java:1550
android.security.keystore.KeyStoreCryptoOperationChunkedStreamer.doFinal KeyStoreCryptoOperationChunkedStreamer.java:224
android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal AndroidKeyStoreCipherSpiBase.java:506
android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal AndroidKeyStoreCipherSpiBase.java:531
javax.crypto.Cipher.doFinal Cipher.java:2267
com.google.crypto.tink.integration.android.AndroidKeystoreAesGcm.encrypt AndroidKeystoreAesGcm.java:71
androidx.security.crypto.EncryptedSharedPreferences.create EncryptedSharedPreferences.java:153
androidx.security.crypto.EncryptedSharedPreferences.create EncryptedSharedPreferences.java:119
Code:
fun getEncryptedSharedPreferences(): SharedPreferences {
val context = appContext
val masterKey = MasterKey.Builder(context)
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
.build()
return EncryptedSharedPreferences.create(
context,
SHARED_PREFERENCES_NAME,
masterKey,
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
)
}
I have no idea what to make of this. How do I handle this?