
Unwrap Key Failed Error:
E/StorageCipher18Impl(14871): unwrap key failed
E/StorageCipher18Impl(14871): java.security.InvalidKeyException: Failed to unwrap key
E/StorageCipher18Impl(14871): at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineUnwrap(AndroidKeyStoreCipherSpiBase.java:699)
E/StorageCipher18Impl(14871): at javax.crypto.Cipher.unwrap(Cipher.java:2440)
E/StorageCipher18Impl(14871): at com.it_nomads.fluttersecurestorage.ciphers.RSACipher18Implementation.unwrap(RSACipher18Implementation.java:51)
E/StorageCipher18Impl(14871): at com.it_nomads.fluttersecurestorage.ciphers.StorageCipher18Implementation.<init>(StorageCipher18Implementation.java:41)
E/StorageCipher18Impl(14871): at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin.ensureInitialized(FlutterSecureStoragePlugin.java:95)
E/StorageCipher18Impl(14871): at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin.access$100(FlutterSecureStoragePlugin.java:37)
E/StorageCipher18Impl(14871): at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin$MethodRunner.run(FlutterSecureStoragePlugin.java:299)
Solution:
Added the last two lines on AndroidManifest.xml located on android/app/src/main
<application
android:label="Ecommerce Online"
android:icon="@mipmap/ic_launcher"
android:fullBackupContent="false"
android:allowBackup="false">
This solution is given on GitHub. Here’s the link to the solution: 3.1.0: Failed to unwrap key ยท Issue #13
New Error:
If it doesn’t work and you get Unhandled Exception: PlatformException(Exception encountered, read, javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT
The solution should be to Clear ALL the data of the App from the Device. Not uninstall but clear the app data.
It will work.
Note: Previously, I added the above two lines and then cleared the data. But only clearing the data also did the job.
The reason for this issue is discussed on the Github mentioned above.