Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App getting stuck on splash screen due to encrypted shared preference intialization issue #810

Open
akashkharmale107 opened this issue Oct 28, 2024 · 1 comment

Comments

@akashkharmale107
Copy link

akashkharmale107 commented Oct 28, 2024

It is occurring in specific devices only.

E unwrap key failed
java.security.InvalidKeyException: Failed to unwrap key
at android.security.keystore2.AndroidKeyStoreCipherSpiBase.engineUnwrap(AndroidKeyStoreCipherSpiBase.java:792)
at javax.crypto.Cipher.unwrap(Cipher.java:2459)
at com.it_nomads.fluttersecurestorage.ciphers.RSACipher18Implementation.unwrap(RSACipher18Implementation.java:58)
at com.it_nomads.fluttersecurestorage.ciphers.StorageCipher18Implementation.(StorageCipher18Implementation.java:39)
at com.it_nomads.fluttersecurestorage.ciphers.StorageCipherAlgorithm$$ExternalSyntheticLambda0.apply(Unknown Source:2)
at com.it_nomads.fluttersecurestorage.ciphers.StorageCipherFactory.getSavedStorageCipher(StorageCipherFactory.java:78)
at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.initStorageCipher(FlutterSecureStorage.java:185)
at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.ensureInitialized(FlutterSecureStorage.java:162)
at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.containsKey(FlutterSecureStorage.java:64)
at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin$MethodRunner.run(FlutterSecureStoragePlugin.java:147)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:240)
at android.os.Looper.loop(Looper.java:351)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: javax.crypto.IllegalBlockSizeException
at android.security.keystore2.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:613)
at android.security.keystore2.AndroidKeyStoreCipherSpiBase.engineUnwrap(AndroidKeyStoreCipherSpiBase.java:790)
at javax.crypto.Cipher.unwrap(Cipher.java:2459) 
at com.it_nomads.fluttersecurestorage.ciphers.RSACipher18Implementation.unwrap(RSACipher18Implementation.java:58) 
at com.it_nomads.fluttersecurestorage.ciphers.StorageCipher18Implementation.(StorageCipher18Implementation.java:39) 
at com.it_nomads.fluttersecurestorage.ciphers.StorageCipherAlgorithm$$ExternalSyntheticLambda0.apply(Unknown Source:2) 
at com.it_nomads.fluttersecurestorage.ciphers.StorageCipherFactory.getSavedStorageCipher(StorageCipherFactory.java:78) 
at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.initStorageCipher(FlutterSecureStorage.java:185) 
at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.ensureInitialized(FlutterSecureStorage.java:162) 
at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.containsKey(FlutterSecureStorage.java:64) 
at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin$MethodRunner.run(FlutterSecureStoragePlugin.java:147) 
at android.os.Handler.handleCallback(Handler.java:942) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loopOnce(Looper.java:240) 
at android.os.Looper.loop(Looper.java:351) 
at android.os.HandlerThread.run(HandlerThread.java:67) 
Caused by: android.security.KeyStoreException: Unknown error (internal Keystore code: -1000 message: In KeystoreOperation::finish

                                                                                                Caused by:
                                                                                                    0: In finish: KeyMint::finish failed.
                                                                                                    1: Error::Km(ErrorCode(-1000))) (public error code: 10 internal Keystore code: -1000)
                                                                                                	at android.security.KeyStore2.getKeyStoreException(KeyStore2.java:369)
                                                                                                	at android.security.KeyStoreOperation.handleExceptions(KeyStoreOperation.java:78)
                                                                                                	at android.security.KeyStoreOperation.finish(KeyStoreOperation.java:128)
                                                                                                	at android.security.keystore2.KeyStoreCryptoOperationChunkedStreamer$MainDataStream.finish(KeyStoreCryptoOperationChunkedStreamer.java:228)
                                                                                                	at android.security.keystore2.KeyStoreCryptoOperationChunkedStreamer.doFinal(KeyStoreCryptoOperationChunkedStreamer.java:181)
                                                                                                	at android.security.keystore2.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:603)
                                                                                                	... 15 more

2024-10-28 11:46:56.038 16225-16278 SecureStorageAndroid com.anacity.alfuttaim E EncryptedSharedPreferences initialization failed
javax.crypto.AEADBadTagException
at android.security.keystore2.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:611)
at javax.crypto.Cipher.doFinal(Cipher.java:2132)
at com.google.crypto.tink.integration.android.AndroidKeystoreAesGcm.decryptInternal(AndroidKeystoreAesGcm.java:118)
at com.google.crypto.tink.integration.android.AndroidKeystoreAesGcm.decrypt(AndroidKeystoreAesGcm.java:101)
at com.google.crypto.tink.KeysetHandle.decrypt(KeysetHandle.java:919)
at com.google.crypto.tink.KeysetHandle.readWithAssociatedData(KeysetHandle.java:804)
at com.google.crypto.tink.KeysetHandle.read(KeysetHandle.java:785)
at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.readMasterkeyDecryptAndParseKeyset(AndroidKeysetManager.java:381)
at com.google.crypto.tink.integration.android.AndroidKeysetManager$Builder.build(AndroidKeysetManager.java:297)
at androidx.security.crypto.EncryptedSharedPreferences.create(EncryptedSharedPreferences.java:169)
at androidx.security.crypto.EncryptedSharedPreferences.create(EncryptedSharedPreferences.java:130)
at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.initializeEncryptedSharedPreferencesManager(FlutterSecureStorage.java:248)
at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.ensureInitialized(FlutterSecureStorage.java:170)
at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.containsKey(FlutterSecureStorage.java:64)
at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin$MethodRunner.run(FlutterSecureStoragePlugin.java:147)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:240)
at android.os.Looper.loop(Looper.java:351)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: android.security.KeyStoreException: Signature/MAC verification failed (internal Keystore code: -30 message: In KeystoreOperation::finish

                                                                                                Caused by:
                                                                                                    0: In finish: KeyMint::finish failed.
                                                                                                    1: Error::Km(ErrorCode(-30))) (public error code: 10 internal Keystore code: -30)
                                                                                                	at android.security.KeyStore2.getKeyStoreException(KeyStore2.java:369)
                                                                                                	at android.security.KeyStoreOperation.handleExceptions(KeyStoreOperation.java:78)
                                                                                                	at android.security.KeyStoreOperation.finish(KeyStoreOperation.java:128)
                                                                                                	at android.security.keystore2.KeyStoreCryptoOperationChunkedStreamer$MainDataStream.finish(KeyStoreCryptoOperationChunkedStreamer.java:228)
                                                                                                	at android.security.keystore2.KeyStoreCryptoOperationChunkedStreamer.doFinal(KeyStoreCryptoOperationChunkedStreamer.java:181)
                                                                                                	at android.security.keystore2.AndroidKeyStoreAuthenticatedAESCipherSpi$BufferAllOutputUntilDoFinalStreamer.doFinal(AndroidKeyStoreAuthenticatedAESCipherSpi.java:396)
                                                                                                	at android.security.keystore2.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:603)
                                                                                                	... 19 more
@berkanaslan
Copy link

berkanaslan commented Nov 18, 2024

Same issue in Android13 here. Nothing was found with further investigations. Any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants