When I delete the app storage and run the app from a clean state, FlutterSecureStorage throws a KeyStore exception.
When I set encryptedSharedPreferences: true and migrateOnAlgorithmChange: false, this does not happen.
I think this happens, because the fresh installs always trigger migration (due to no markers).
I/FlutterSecureStorage(28800): Detected non-biometric migration: FROM=com.it_nomads.fluttersecurestorage.ciphers.KeyCipherImplementationRSA18@400341d, TO=AES_GCM_NoPadding
I/FlutterSecureStorage(28800): Starting non-biometric migration (no authentication required)...
D/FlutterSecureStorage(28800): Step 1/6: Initializing saved cipher...
D/FlutterSecureStorage(28800): Step 2/6: Decrypting all data with saved cipher...
D/FlutterSecureStorage(28800): Successfully decrypted 0 items with saved cipher
D/FlutterSecureStorage(28800): Step 3/6: Deleting old RSA key from Android KeyStore...
D/FlutterSecureStorage(28800): Old key deleted from KeyStore
D/FlutterSecureStorage(28800): Step 4/6: Updating algorithm markers to current...
D/FlutterSecureStorage(28800): Algorithm markers updated to current
D/FlutterSecureStorage(28800): Step 5/6: Initializing current cipher with fresh AES key...
W/KeyStore(28800): KeyStore exception
W/KeyStore(28800): android.os.ServiceSpecificException: (code 7)
W/KeyStore(28800): at android.os.Parcel.createException(Parcel.java:1965)
W/KeyStore(28800): at android.os.Parcel.readException(Parcel.java:1919)
W/KeyStore(28800): at android.os.Parcel.readException(Parcel.java:1869)
W/KeyStore(28800): at android.security.IKeystoreService$Stub$Proxy.get(IKeystoreService.java:786)
W/KeyStore(28800): at android.security.KeyStore.get(KeyStore.java:195)
W/KeyStore(28800): at android.security.keystore.AndroidKeyStoreSpi.engineGetCertificate(AndroidKeyStoreSpi.java:144)
W/KeyStore(28800): at java.security.KeyStore.getCertificate(KeyStore.java:1120)
W/KeyStore(28800): at com.it_nomads.fluttersecurestorage.ciphers.KeyCipherImplementationRSA18.createRSAKeysIfNeeded(KeyCipherImplementationRSA18.java:124)
W/KeyStore(28800): at com.it_nomads.fluttersecurestorage.ciphers.KeyCipherImplementationRSA18.<init>(KeyCipherImplementationRSA18.java:37)
W/KeyStore(28800): at com.it_nomads.fluttersecurestorage.ciphers.KeyCipherImplementationRSAOAEP.<init>(KeyCipherImplementationRSAOAEP.java:25)
W/KeyStore(28800): at com.it_nomads.fluttersecurestorage.ciphers.KeyCipherAlgorithm$$ExternalSyntheticLambda1.apply(D8$$SyntheticClass:0)
W/KeyStore(28800): at com.it_nomads.fluttersecurestorage.ciphers.StorageCipherFactory.getCurrentStorageCipher(StorageCipherFactory.java:71)
W/KeyStore(28800): at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.migrateNonBiometric(FlutterSecureStorage.java:477)
W/KeyStore(28800): at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.migrateData(FlutterSecureStorage.java:355)
W/KeyStore(28800): at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.handleKeyMismatch(FlutterSecureStorage.java:843)
W/KeyStore(28800): at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.initializeStorageCipher(FlutterSecureStorage.java:268)
W/KeyStore(28800): at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.initialize(FlutterSecureStorage.java:258)
W/KeyStore(28800): at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin$MethodRunner.run(FlutterSecureStoragePlugin.java:127)
W/KeyStore(28800): at android.os.Handler.handleCallback(Handler.java:873)
W/KeyStore(28800): at android.os.Handler.dispatchMessage(Handler.java:99)
W/KeyStore(28800): at android.os.Looper.loop(Looper.java:193)
W/KeyStore(28800): at android.os.HandlerThread.run(HandlerThread.java:65)
I/FlutterSecureStorage(28800): Step 6/6: No data to migrate, continuing...
I/FlutterSecureStorage(28800): Non-biometric migration completed successfully! Migrated 0 items.
I/FlutterSecureStorage(28800): Data migration completed successfully!
When I delete the app storage and run the app from a clean state, FlutterSecureStorage throws a KeyStore exception.
When I set
encryptedSharedPreferences: trueandmigrateOnAlgorithmChange: false, this does not happen.I think this happens, because the fresh installs always trigger migration (due to no markers).