flutter_secure_storage
flutter_secure_storage copied to clipboard
PlatformException (PlatformException(Exception encountered, read, javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT
Hi, I have used secure storage plugin flutter_secure_storage: 9.0.0. Below is the complete error.
Exception has occurred. PlatformException (PlatformException(Exception encountered, read, javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT at com.android.org.conscrypt.NativeCrypto.EVP_CipherFinal_ex(Native Method) at com.android.org.conscrypt.OpenSSLEvpCipher.doFinalInternal(OpenSSLEvpCipher.java:152) at com.android.org.conscrypt.OpenSSLCipher.engineDoFinal(OpenSSLCipher.java:374) at javax.crypto.Cipher.doFinal(Cipher.java:2055) at com.it_nomads.fluttersecurestorage.ciphers.StorageCipher18Implementation.decrypt(StorageCipher18Implementation.java:93) at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.decodeRawValue(FlutterSecureStorage.java:249) at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.read(FlutterSecureStorage.java:69) at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin$MethodRunner.run(FlutterSecureStoragePlugin.java:156) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:236) at android.os.HandlerThread.run(HandlerThread.java:67) , null))
The line is throwing this error is secureStorage.read(key: 'key').
I have tried the below code but still this issue is happening. any news?
final FlutterSecureStorage storage = const FlutterSecureStorage( aOptions: AndroidOptions( encryptedSharedPreferences: true, ), );
The error originates from the legacy part of encryptedSharedPreferences, that is being phased out in v10.0.0.
This is what the android docs have to say about it
// Note that {@link BadPaddingException} includes {@link AEADBadTagException}. // This may happen if the encrypted keyset is corrupted, or if it was encrypted // with a different master key. You need to decide how to handle this. You may recover from // this by creating a new encrypted keyset, but then you need to delete all data that had // been encrypted with the old key.
You can use resetOnError which removes all data if such an error occurs.
The error originates from the legacy part of encryptedSharedPreferences, that is being phased out in v10.0.0.
This is what the android docs have to say about it
// Note that {@link BadPaddingException} includes {@link AEADBadTagException}. // This may happen if the encrypted keyset is corrupted, or if it was encrypted // with a different master key. You need to decide how to handle this. You may recover from // this by creating a new encrypted keyset, but then you need to delete all data that had // been encrypted with the old key.
You can use
resetOnErrorwhich removes all data if such an error occurs.
any idea when the 10 will be released?
Hello, only customers have reported this issue and I cannot reproduce it. In order to confirm the fix, how do I reproduce it?
my customers have same problem on v9.0.0 && v9.2.4 Does it resolve on ^10.0.0-beta.4? v10.0.0-bata.4 also need to set resetOnError?
I have the same issue on Samsung.
Has anyone found a solution?
Using version ^10.0.0-beta.4 resolved the error.
@pooja96km are u reproduce or test this issue on 10.0.0-beta.4?
⚠️ This issue has been marked as stale because it has been open for 60 days with no activity.
If this issue is still relevant, please comment to keep it active. Otherwise, it will be closed in 60 days.
Has anyone found a solution?
⚠️ This issue has been marked as stale because it has been open for 60 days with no activity.
If this issue is still relevant, please comment to keep it active. Otherwise, it will be closed in 60 days.
I was able to reproduce this issue on a Samsung S23 Ultra when executing the read instruction of FlutterSecureStorage. Upgrading flutter_secure_storage from 9.2.4 to 10.0.0-beta.4 resolves the problem:
- flutter_secure_storage: ^9.2.4
+ flutter_secure_storage: 10.0.0-beta.4