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

Android encryption migration #328

Merged
merged 5 commits into from
Nov 12, 2021
Merged

Conversation

juliansteenbakker
Copy link
Owner

This PR probably fixes #161, #248, #278, #312

This PR enables the migration of data to encryptedSharedPreference when enabled.
This PR also adds some other checks to ensure initialization performs correctly.

@juliansteenbakker juliansteenbakker merged commit 2834105 into develop Nov 12, 2021
@juliansteenbakker juliansteenbakker deleted the android-encryption-migration branch November 12, 2021 14:06
@justoke
Copy link

justoke commented Dec 8, 2021

Hi. When would this change be available in the stable channel?

@juliansteenbakker
Copy link
Owner Author

This is already available in version 5.0.2

@justoke
Copy link

justoke commented Dec 8, 2021

I've been running into the issue #248 where this exception is hit on release builds, and even after trying version 5.0.2 it still occurs. On Android you have to open the App settings and clear data and cache. Then restarting the app it will start up. On iOS there is no recovery and the app is unable to start - at least if you are trying to access secure storage.

Should I raise another issue on this?

D/FlutterSecureStoragePl(20913): Initializing StorageCipher
D/FlutterSecureStoragePl(20913): StorageCipher initialization complete
I/flutter (20913): PlatformException(Exception encountered, read, javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT
I/flutter (20913):      at com.android.org.conscrypt.NativeCrypto.EVP_CipherFinal_ex(Native Method)
I/flutter (20913):      at com.android.org.conscrypt.OpenSSLEvpCipher.doFinalInternal(OpenSSLEvpCipher.java:152)
I/flutter (20913):      at com.android.org.conscrypt.OpenSSLCipher.engineDoFinal(OpenSSLCipher.java:374)
I/flutter (20913):      at javax.crypto.Cipher.doFinal(Cipher.java:2055)
I/flutter (20913):      at b.c.a.g.b.b(Unknown Source:30)
I/flutter (20913):      at b.c.a.f.l(Unknown Source:11)
I/flutter (20913):      at b.c.a.f.r(Unknown Source:7)
I/flutter (20913):      at b.c.a.f.e(Unknown Source:0)
I/flutter (20913):      at b.c.a.e.run(Unknown Source:134)
I/flutter (20913):      at android.os.Handler.handleCallback(Handler.java:938)
I/flutter (20913):      at android.os.Handler.dispatchMessage(Handler.java:99)
I/flutter (20913):      at android.os.Looper.loop(Looper.java:246)
I/flutter (20913):      at android.os.HandlerThread.run(HandlerThread.java:67)

@juliansteenbakker
Copy link
Owner Author

If the exception is also occurring on iOS you should open a new ticket. I am not aware of this problem on iOS. For Android, are you using the following?:

  AndroidOptions _getAndroidOptions() => const AndroidOptions(
        encryptedSharedPreferences: true,
      );

@justoke
Copy link

justoke commented Dec 8, 2021

Not to worry I figured it out. Thank you

I'm not using those options, please could you explain where this code should be placed and is this platform specific? Thank you.

@grafovdenis
Copy link

Hey, @justoke!
How did you fixed this out?

@justoke
Copy link

justoke commented Jan 15, 2022

Hey, @justoke! How did you fixed this out?
I resolved this by upgrading to the latest version, but also had to upgrade a third party dependency to use the latest 5.0.2 version. I see people having issues with earlier versions - like 4.2 on Android 11. I'd recommend upgrading to 5.0.2. This resolved all the issues I had.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment