A Flutter plugin to store data in secure storage

Overview

flutter_secure_storage

A Flutter plugin to store data in secure storage:

  • Keychain is used for iOS
  • AES encryption is used for Android. AES secret key is encrypted with RSA and RSA key is stored in KeyStore
  • libsecret is used for Linux.

Note KeyStore was introduced in Android 4.3 (API level 18). The plugin wouldn't work for earlier versions.

Getting Started

import 'package:flutter_secure_storage/flutter_secure_storage.dart';

// Create storage
final storage = new FlutterSecureStorage();

// Read value 
String value = await storage.read(key: key);

// Read all values
Map<String, String> allValues = await storage.readAll();

// Delete value 
await storage.delete(key: key);

// Delete all 
await storage.deleteAll();

// Write value 
await storage.write(key: key, value: value);

Configure Android version

In [project]/android/app/build.gradle set minSdkVersion to >= 18.

android {
    ...
    
    defaultConfig {
        ...
        minSdkVersion 18
        ...
    }

}

Note By default Android backups data on Google Drive. It can cause exception java.security.InvalidKeyException:Failed to unwrap key. You need to

Linux

You need libsecret-1-dev and libjsoncpp-dev on your machine to build the project, and libsecret-1-0 and libjsoncpp1 to run the application (add it as a dependency after packaging your app). If you using snapcraft to build the project use the following

parts:
  uet-lms:
    source: .
    plugin: flutter
    flutter-target: lib/main.dart 
    build-packages:
     - libsecret-1-dev
     - libjsoncpp-dev
    stage-packages:
     - libsecret-1-dev
     - libjsoncpp1-dev

Integration Tests

Run the following command from example directory

flutter drive --target=test_driver/app.dart
Comments
  • Unhandled Exception: PlatformException(Exception encountered, read, javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT

    Unhandled Exception: PlatformException(Exception encountered, read, javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT

    How to fix this problem?

    E/flutter (29195): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: PlatformException(Exception encountered, read, javax.crypto.BadPaddingException: error:1e000065:Cipher functions:OPENSSL_internal:BAD_DECRYPT
    E/flutter (29195): 	at com.android.org.conscrypt.NativeCrypto.EVP_CipherFinal_ex(Native Method)
    E/flutter (29195): 	at com.android.org.conscrypt.OpenSSLCipher$EVP_CIPHER.doFinalInternal(OpenSSLCipher.java:570)
    E/flutter (29195): 	at com.android.org.conscrypt.OpenSSLCipher.engineDoFinal(OpenSSLCipher.java:351)
    E/flutter (29195): 	at javax.crypto.Cipher.doFinal(Cipher.java:1741)
    E/flutter (29195): 	at com.it_nomads.fluttersecurestorage.ciphers.StorageCipher18Implementation.decrypt(StorageCipher18Implementation.java:91)
    E/flutter (29195): 	at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin.decodeRawValue(FlutterSecureStoragePlugin.java:163)
    E/flutter (29195): 	at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin.read(FlutterSecureStoragePlugin.java:144)
    E/flutter (29195): 	at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin.access$300(FlutterSecureStoragePlugin.java:29)
    E/flutter (29195): 	at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin$MethodRunner.run(FlutterSecureStoragePlugin.java:197)
    E/flutter (29195): 	at java.lang.Thread.run(Thread.java:764)
    E/flutter (29195): , null)
    
    opened by JAICHANGPARK 75
  • MissingPluginException - lets fix this

    MissingPluginException - lets fix this

    There are currently all these open issues for flutter_secure_storage, all mention the exception MissingPluginException(No implementation found for method read on channel plugins.it_nomads.com/flutter_secure_storage) in the issue or in the comments:

    #5 - Sporadic finalizer exceptions for underlying KeyStore on Android #49 - MissingPluginException (MissingPluginException(No implementation found for method read on channel plugins.it_nomads.com/flutter_secure_storage)) #71 - MissingPluginException #83 - MissingPluginException(No implementation found for method write on channel plugins.it_nomads.com/flutter_secure_storage) #85 - doesn't work on api level 23 #118 - Android 4.4.2: MissingPluginException(No implementation found for method write on cannel plugins.it_nomads.com/flutter_secure_storage)) #129 - Not Working in android 5.1.1 and 4.4.4 #136 - Can't run flutter test due to MissingPluginException in flutter_secure_storage

    I'm also experiencing this exception with my end users, but with 8 open issues it's difficult to have to a sensible conversation - can I suggest we use this one thread to resolve this?

    Most suggested "solutions" are to uninstall / reinstall the app, flutter clean, etc. however this simply isn't a solution - you can't ask end users to reinstall your app.

    One suggestion I have is that based on the data below, it looks like this is an Android only problem - so perhaps there is a problem with how the plugin is registered on Android? The fact that it only happens sometimes, for some users, then occasionally it magically disappears, also suggests it is a timing issue.

    Affected versions

    After a quick survey of the issues, the exception has been reported on the following versions:

    • Flutter versions: 1.17.0, 1.17.5, 1.7.8, 1.12.13,
    • Android versions: 4.4.4, 5.1.1, 6, 8, 10

    Affected devices

    • Emulator and real devices
    • Devices: Samsung J3, Samsung Galaxy Grand 2, Galaxy Tabs, Moto e5, pixel 3a, Galaxy J7 2015, Samsung note 3

    Some questions for flutter_secure_storage developers

    To try to help, when looking through the code the following questions came to mind (I'm not a plugin developer so you may have to bear with me!)

    Silently swallowing exceptions There are a couple of places where you catch Exceptions, but then just Log and do nothing else:

    try {
              applicationContext = context.getApplicationContext();
              ...
              channel.setMethodCallHandler(this);
          } catch (Exception e) {
              Log.e("FlutterSecureStoragePl", "Registration failed", e);
          }
    
    try {
        Log.d("FlutterSecureStoragePl", "Initializing StorageCipher");
        storageCipher = new StorageCipher18Implementation(applicationContext);
        Log.d("FlutterSecureStoragePl", "StorageCipher initialization complete");
    } catch (Exception e) {
        Log.e("FlutterSecureStoragePl", "StorageCipher initialization failed", e);
    }
    

    Could these be surfaced to flutter via an error Result instead of silently discarded? This might reveal where there are actual problems when encountered.

    Use of volatile You're using volatile here:

    private volatile StorageCipher storageCipher;
    

    and link to a very long and complicated article on double-checked locking. Can you explain the reason behind using this instead of simply using an AsyncTask to perform work on a separate thread? If I had to bet money on why we get MissingPluginException, this would be it - edge case race conditions caused by complex multi-threading code.

    Are you passing the right context? In initInstance you are doing this:

    applicationContext = context.getApplicationContext();
    preferences = context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    charset = Charset.forName("UTF-8");
    
    StorageCipher18Implementation.moveSecretFromPreferencesIfNeeded(preferences, context);
    

    Notice you are getting and assigning the application context first, but then passing the context from the parameter to the moveSecretFromPreferencesIfNeeded method - is that right? I have no idea if that's a problem, just thought I should ask the question.

    BinaryMessenger

    It looks like you're getting a BinaryMessenger directly from the binding object here to give to the MethodChannel:

    @Override
    public void onAttachedToEngine(FlutterPluginBinding binding) {
       initInstance(binding.getBinaryMessenger(), binding.getApplicationContext());
    }
    

    However the latest plugin template gets the BinaryMessenger via the flutter engine like this:

    channel = MethodChannel(flutterPluginBinding.binaryMessenger.getFlutterEngine().getDartExecutor(), "flutter_plugin")
    

    Is that a problem do you think?

    Setting method channel to null

    onDetachedFromEngine you're setting channel to null. Is this necessary? Might it not cause a problem if channel is accessed after this is called? The latest plugin template doesn't do this, it just sets channel.setMethodCallHandler(null) and nothing else.

    @Override
    public void onDetachedFromEngine(FlutterPluginBinding binding) {
       channel.setMethodCallHandler(null);
       channel = null;
    }
    
    bug question 
    opened by jamesncl 58
  • MissingPluginException(No implementation found for method write on channel plugins.it_nomads.com/flutter_secure_storage)

    MissingPluginException(No implementation found for method write on channel plugins.it_nomads.com/flutter_secure_storage)

    flutter doctor -v

    [✓] Flutter (Channel unknown, v1.7.8+hotfix.3, on Mac OS X 10.14.6 18G95, locale en-GB)
        • Flutter version 1.7.8+hotfix.3 at /Users/paul/flutter
        • Framework revision b712a172f9 (2 months ago), 2019-07-09 13:14:38 -0700
        • Engine revision 54ad777fd2
        • Dart version 2.4.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
        • Android SDK at /Users/paul/Library/Android/sdk
        • Android NDK location not configured (optional; useful for native profiling support)
        • Platform android-28, build-tools 28.0.3
        • ANDROID_HOME = /Users/paul/Library/Android/sdk
        • ANDROID_SDK_ROOT = /Users/paul/Library/Android/sdk
        • Java binary at: /Users/paul/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/191.5791312/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 10.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 10.3, Build version 10G8
        • CocoaPods version 1.7.5
    
    [✓] iOS tools - develop for iOS devices
        • ios-deploy 1.9.4
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 3.5)
        • Android Studio at /Users/paul/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/191.5791312/Android Studio.app/Contents
        • Flutter plugin version 38.2.1
        • Dart plugin version 183.6270
        • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2019.2.2)
        • IntelliJ at /Users/paul/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
        • Flutter plugin version 35.3.2
        • Dart plugin version 191.7019
    
    [✓] Connected device (3 available)
        • Android SDK built for x86 64 • emulator-5554 • android-x64    • Android 8.0.0 (API 26) (emulator)
        • macOS                        • macOS         • darwin-x64     • Mac OS X 10.14.6 18G95
        • web                          • web           • web-javascript • Google Chrome 76.0.3809.132 
    
    
    • No issues found!
    

    Stack trace during scripted build/launch (MacOS 10.14.6, homebrew up to date):

    Restarted application in 2,710ms.
    Hot Restarted!
    I/flutter (23832): Start Integration App...
    I/flutter (23832): Error caught by Crashlytics plugin <recordError>:
    I/flutter (23832): MissingPluginException(No implementation found for method readAll on channel plugins.it_nomads.com/flutter_secure_storage)
    I/flutter (23832):
    I/flutter (23832): #0      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:314:7)
    I/flutter (23832): <asynchronous suspension>
    I/flutter (23832): #1      FlutterSecureStorage.readAll (package:flutter_secure_storage/flutter_secure_storage.dart:40:40)
    I/flutter (23832): <asynchronous suspension>
    I/flutter (23832): #2      PreferencesService.loadFromStorage (package:myapp/data/services/preference_service.dart:37:33)
    I/flutter (23832): <asynchronous suspension>
    I/flutter (23832): #3      main (package:myapp/main.dart:109:30)
    

    Version in pubspec.yaml -> v3.2.1+1

    Building on API 28, deploying to API 26 .... could that be the issue? There's a minimum supported version? Should it fail more gracefully?

    opened by paul-hammant 42
  • Deprecation warning during compilation on Android 10 (API 29)

    Deprecation warning during compilation on Android 10 (API 29)

    Deprecation warning during compilation on Android

    Note: ..../.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.4/android/src/main/java/com/it_nomads/fluttersecurestorage/ciphers/RSACipher18Implementation.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    

    Flutter doctor:

    [✓] Flutter (Channel stable, 1.20.4, on Mac OS X 10.15.6 19G2021, locale ru-UA)
        • Flutter version 1.20.4 at ....
        • Framework revision fba99f6cf9 (9 days ago), 2020-09-14 15:32:52 -0700
        • Engine revision d1bc06f032
        • Dart version 2.9.2
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
        • Android SDK at .....
        • Platform android-29, build-tools 28.0.3
        • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 12.0)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 12.0, Build version 12A7209
        • CocoaPods version 1.8.3
    
    [✓] Android Studio (version 4.0)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin version 49.0.2
        • Dart plugin version 193.7547
        • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    
    [✓] Connected device (1 available)
        • Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)
    

    Steps to reproduce

    • Run flutter clean
    • build an application for Android
    enhancement 
    opened by TatsuUkraine 39
  • `containsKey` always returning true

    `containsKey` always returning true

    I've just started using flutter_secure_storage in a new project, for some reason containsKey is returning true for every key value I give it.

    In the below image (showing a debug session) you can see that containsKey is returning true even though readAll returns an empty map, and I even try deleting the value associated with the key but containsKey still returns true. This is running on an iOS simulator.

    Screenshot 2021-11-20 at 20 20 18

    Versions:

    • Flutter - 2.5.3
    • Dart - 2.14.4
    • Xcode - 13.0
    • iOS - 15.0
    • flutter_secure_storage - 5.0.2
    bug ios 
    opened by MichaelM97 30
  • Linux Desktop Build Failed: cannot find -lpkgcfg_lib_LIBSECRET_secret-1-NOTFOUND

    Linux Desktop Build Failed: cannot find -lpkgcfg_lib_LIBSECRET_secret-1-NOTFOUND

    I get the following error when building for Linux Desktop on Ubuntu 20.04

    [2/6] Linking CXX shared library plugins/flutter_secure_storage/libflutter_secure_storage_plugin.so [ ] FAILED: plugins/flutter_secure_storage/libflutter_secure_storage_plugin.so

    I've followed the instructions for Linux

    opened by arh-68 27
  • Getting Platform Exception on writing data after updating the app

    Getting Platform Exception on writing data after updating the app

    I am storing values (such as tokens) on user login, using this library. While testing in devices, it's working fine. However, I am facing an issue when the app gets updated. The error log I have traced is as follows:

    PlatformException(Exception encountered, write, java.lang.NullPointerException: Attempt to invoke interface method 'byte[] c.g.a.b.c.a(byte[])' on a null object reference at c.g.a.a.a(Unknown Source:8) at c.g.a.a.a(Unknown Source:0) at c.g.a.a$b.run(Unknown Source:165) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:192) at android.os.HandlerThread.run(HandlerThread.java:65) , null)

    And according to the logs so far, this issue is occuring in certain android devices.

    I am using version 3.3.3 of the library, and following is the flutter doctor summary screenshot.

    Screen Shot 2021-01-22 at 17 03 26

    How can this problem be solved?

    question 
    opened by Sujal1 24
  • Sporadic finalizer exceptions for underlying KeyStore on Android

    Sporadic finalizer exceptions for underlying KeyStore on Android

    Using Version 2.0.0 [✓] Flutter (Channel dev, v0.2.4, on Mac OS X 10.13.3 17D102, locale en-US) [✓] Android toolchain - develop for Android devices (Android SDK 27.0.3) [✓] iOS toolchain - develop for iOS devices (Xcode 9.2) [✓] Android Studio (version 3.0) [✓] IntelliJ IDEA Ultimate Edition (version 2017.3) [✓] Connected devices (3 available) Using Android Emulators of various versions (26+), and a physical Pixel (27)

    Every now and then, but consistently once it happens once, flutter_secure_storage throws an exception when reading/writing a key.

    Flutter throws the error: E/MethodChannel#plugins.it_nomads.com/flutter_secure_storage( 8518): Failed to handle method call E/MethodChannel#plugins.it_nomads.com/flutter_secure_storage( 8518): java.lang.IllegalArgumentException: Unsupported value: javax.crypto.IllegalBlockSizeException E/MethodChannel#plugins.it_nomads.com/flutter_secure_storage( 8518): at io.flutter.plugin.common.StandardMessageCodec.writeValue(StandardMessageCodec.java:293) E/MethodChannel#plugins.it_nomads.com/flutter_secure_storage( 8518): at io.flutter.plugin.common.StandardMethodCodec.encodeErrorEnvelope(StandardMethodCodec.java:70) E/MethodChannel#plugins.it_nomads.com/flutter_secure_storage( 8518): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:199) E/MethodChannel#plugins.it_nomads.com/flutter_secure_storage( 8518): at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin.onMethodCall(FlutterSecureStoragePlugin.java:77) E/MethodChannel#plugins.it_nomads.com/flutter_secure_storage( 8518): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:191) E/MethodChannel#plugins.it_nomads.com/flutter_secure_storage( 8518): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:136) E/MethodChannel#plugins.it_nomads.com/flutter_secure_storage( 8518): at android.os.MessageQueue.nativePollOnce(Native Method) E/MethodChannel#plugins.it_nomads.com/flutter_secure_storage( 8518): at android.os.MessageQueue.next(MessageQueue.java:325) E/MethodChannel#plugins.it_nomads.com/flutter_secure_storage( 8518): at android.os.Looper.loop(Looper.java:142) E/MethodChannel#plugins.it_nomads.com/flutter_secure_storage( 8518): at android.app.ActivityThread.main(ActivityThread.java:6494) E/MethodChannel#plugins.it_nomads.com/flutter_secure_storage( 8518): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#plugins.it_nomads.com/flutter_secure_storage( 8518): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) E/MethodChannel#plugins.it_nomads.com/flutter_secure_storage( 8518): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

    However, this is caused by a system exception:

    E/System ( 8518): java.lang.IllegalStateException: Binder has been finalized! E/System ( 8518): at android.os.BinderProxy.transactNative(Native Method) E/System ( 8518): at android.os.BinderProxy.transact(Binder.java:764) E/System ( 8518): at android.security.IKeystoreService$Stub$Proxy.abort(IKeystoreService.java:1373) E/System ( 8518): at android.security.KeyStore.abort(KeyStore.java:531) E/System ( 8518): at android.security.keystore.AndroidKeyStoreCipherSpiBase.finalize(AndroidKeyStoreCipherSpiBase.java:744) E/System ( 8518): at android.security.keystore.AndroidKeyStoreRSACipherSpi$PKCS1Padding.finalize(Unknown Source:0) E/System ( 8518): at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:250) E/System ( 8518): at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:237) E/System ( 8518): at java.lang.Daemons$Daemon.run(Daemons.java:103) E/System ( 8518): at java.lang.Thread.run(Thread.java:764)

    The only ways I've resolved the issue is to do a hard restore of the device/emulator, as well as a full clean and rebuild of the project. It does not seem to happen on formal builds, just after a lot of debugging sessions, but nothing specific.

    opened by alexwhiteside1 23
  • Update to use platform interface and implement web, windows, macOS and split Linux into it's own project per best practices guidance from Google

    Update to use platform interface and implement web, windows, macOS and split Linux into it's own project per best practices guidance from Google

    Per: #252 here's the PR to merge this and implement web with full platform interface support. I also incidently fixed a bug in the iOS example project todo with the plugin name space. And I implemented macOs and windows options ready for those PRs to be merged (which could be their own projects as could the linux one now if you so desire to make them function that way as suggested by the flutter team for plugin development)

    I have tested that I didn't break anything on Android, and tested the web functionality which appears to be done correctly. It is my understanding from the referenced white papers that this results in the private key still be stored in the browser. I have tested this between browsers with the information that is stored in localstorage and I was not able to reverse the encryption on a second browser.

    opened by jhancock4d 21
  • App built in release mode does not start

    App built in release mode does not start

    My app built in release mode does not get past the launch screen. When built in debug mode, everything works fine.

    In my main method, I have the following code that will check if a previous login session exists so the user does not need to log in again each time.

    Future<null> main(List<String> args) async {
        // ...
        final storage = FlutterSecureStorage();
        final hasExisting = await storage.read(key: "isExisting");
        // ...
        runApp(MyApp(hasExisting: hasExisting));
    }
    

    And I can confirm that this plugin is the one causing the problem because when I change the code to the following

    Future<null> main(List<String> args) async {
        // ...
        // final storage = FlutterSecureStorage();
        // final hasExisting = await storage.read(key: "isExisting");
        final hasExisting = false;
        // ...
        runApp(MyApp(hasExisting: hasExisting));
    }
    

    Everything works, but of course the desired function is not the same.

    I can confirm it was working as of March 5, but it no longer does.

    bug question 
    opened by novemberisms 21
  • App Crashes on Startup (Android 4.4)

    App Crashes on Startup (Android 4.4)

    App Crashes on Samsung Galaxy S3 Neo (Android 4.4). Exception in Logcat:

        Process: com.it_nomads.fluttersecurestorageexample, PID: 3794
        java.lang.VerifyError: com/it_nomads/fluttersecurestorage/ciphers/RSACipher18Implementation
            at com.it_nomads.fluttersecurestorage.ciphers.StorageCipher18Implementation.<init>(StorageCipher18Implementation.java:31)
            at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin.<init>(FlutterSecureStoragePlugin.java:46)
            at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin.registerWith(FlutterSecureStoragePlugin.java:33)
            at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:14)
            at com.it_nomads.fluttersecurestorageexample.MainActivity.onCreate(MainActivity.java:12)
            at android.app.Activity.performCreate(Activity.java:5451)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2386)
            at android.app.ActivityThread.access$900(ActivityThread.java:169)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5476)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
            at dalvik.system.NativeStart.main(Native Method)
    

    I think the problem is the StrongBoxUnavailableException in the createKeys method (RSACipher18Implementation). I tried to comment it out and it works, but I have no idea how to replace it properly.

    opened by RuckyZucky 21
  • keyset not found, will generate a new one. can't read keyset; the pref value __androidx_security_crypto_encrypted_prefs_key_keyset__ does not exist

    keyset not found, will generate a new one. can't read keyset; the pref value __androidx_security_crypto_encrypted_prefs_key_keyset__ does not exist

    There was no such problem before. I'm not sure if the error is related to this package.

    /AndroidKeysetManager( 1749): keyset not found, will generate a new one. can't read keyset; the pref value androidx_security_crypto_encrypted_prefs_key_keyset does not exist

    Flutter: 3.3.10 API 32

    opened by bugrevealingbme 0
  • v7.0.1 PlatformException(Exception encountered, readAll, java.lang.SecurityException: Could not decrypt key. decryption failed

    v7.0.1 PlatformException(Exception encountered, readAll, java.lang.SecurityException: Could not decrypt key. decryption failed

    Hello, I think the option encryptedSharedPreferences: true works for read but not readAll. I can read value by specific key but cannot retrieve all values.

    Errors thrown on some devices Android version 11, 12, 13.

    Non-fatal Exception: io.flutter.plugins.firebase.crashlytics.FlutterError: PlatformException(Exception encountered, readAll, java.lang.SecurityException: Could not decrypt key. decryption failed
    	at androidx.security.crypto.EncryptedSharedPreferences.decryptKey(EncryptedSharedPreferences.java:7)
    	at androidx.security.crypto.EncryptedSharedPreferences.getAll(EncryptedSharedPreferences.java:4)
    	at p9.a.l(FlutterSecureStorage.java:2)
    	at p9.e$b.run(FlutterSecureStoragePlugin.java:13)
    	at android.os.Handler.handleCallback(Handler.java:938)
    	at android.os.Handler.dispatchMessage(Handler.java:99)
    	at android.os.Looper.loopOnce(Looper.java:226)
    	at android.os.Looper.loop(Looper.java:313)
    	at android.os.HandlerThread.run(HandlerThread.java:67)
    Caused by: java.security.GeneralSecurityException: decryption failed
    	at o4.c$a.b(DeterministicAeadWrapper.java:15)
    	at androidx.security.crypto.EncryptedSharedPreferences.decryptKey(EncryptedSharedPreferences.java:4)
    	... 8 more
    , null). Error thrown depricated2.exportAll error
    error:PlatformException(Exception encountered, readAll, java.lang.SecurityException: Could not decrypt key. decryption failed
    	at androidx.security.crypto.EncryptedSharedPreferences.decryptKey(EncryptedSharedPreferences.java:7)
    	at androidx.security.crypto.EncryptedSharedPreferences.getAll(EncryptedSharedPreferences.java:4)
    	at p9.a.l(FlutterSecureStorage.java:2)
    	at p9.e$b.run(FlutterSecureStoragePlugin.java:13)
    	at android.os.Handler.handleCallback(Handler.java:938)
    	at android.os.Handler.dispatchMessage(Handler.java:99)
    	at android.os.Looper.loopOnce(Looper.java:226)
    	at android.os.Looper.loop(Looper.java:313)
    	at android.os.HandlerThread.run(HandlerThread.java:67)
    Caused by: java.security.GeneralSecurityException: decryption failed
    	at o4.c$a.b(DeterministicAeadWrapper.java:15)
    	at androidx.security.crypto.EncryptedSharedPreferences.decryptKey(EncryptedSharedPreferences.java:4)
    	... 8 more
    , null).
    
    opened by meomap 1
  • Flutter build fails on macos

    Flutter build fails on macos

    If I upgrade the project to flutter_secure_storage 7 and flutter_secure_storage_macos 2.0.1, I get this error if I run flutter run macos:

       [!] CocoaPods could not find compatible versions for pod "flutter_secure_storage_macos":
                     In Podfile:
                       flutter_secure_storage_macos (from `Flutter/ephemeral/.symlinks/plugins/flutter_secure_storage_macos/macos`)
    
                   Specs satisfying the `flutter_secure_storage_macos (from `Flutter/ephemeral/.symlinks/plugins/flutter_secure_storage_macos/macos`)` dependency were found, but they required a higher minimum deployment target.
    

    I'm currently running on macOS 11.7.2

    opened by CodeDoctorDE 1
  • Rewrite (write on existing value) value not working

    Rewrite (write on existing value) value not working

      @override
      Future<void> put(String key, String data) async {
        debugPrint('----------\nvalue before write: ${await get(key)}');
        debugPrint('trying to write: $data');
        await secureStorage.write(key: key, value: data);
        debugPrint('value after wrote: ${await get(key)}\n----------');
      }
    

    flutter: ---------- flutter: value before write: null flutter: trying to write: Test0 flutter: value after wrote: Test0 flutter: ----------

    after trying to write again with same key:

    flutter: ---------- flutter: value before write: Test0 flutter: trying to write: Test1 flutter: value after wrote: Test0 flutter: ----------

    but after deleting and writing new it's working:

      @override
      Future<void> put(String key, String data) async {
        debugPrint('----------\nvalue before write: ${await get(key)}');
        debugPrint('trying to write: $data');
        await secureStorage.delete(key: key);
        await secureStorage.write(key: key, value: data);
        debugPrint('value after wrote: ${await get(key)}\n----------');
      }
    

    flutter: ---------- flutter: value before write: Test0 flutter: trying to write: Test2 flutter: value after wrote: Test2 flutter: ----------

    using latest version:

    flutter_secure_storage 7.0.1 flutter_secure_storage_linux 1.1.2 flutter_secure_storage_macos 2.0.1 flutter_secure_storage_platform_interface 1.0.1 flutter_secure_storage_web 1.1.1 flutter_secure_storage_windows 1.1.3

    Flutter (Channel stable, 3.3.10, on macOS 13.0.1 22A400 darwin-x64, locale en-US) Dart version 2.18.6

    opened by Shahriyar13 0
  • [iOS] Set access control flags through IOSOptions

    [iOS] Set access control flags through IOSOptions

    opened by Coyote79 1
Releases(v7.0.0)
  • v7.0.0(Dec 9, 2022)

    Breaking changes:

    • [macOS] The minimum macOS version supported is now 10.13.

    Other changes:

    • [Android] Fixed double initialization of the SharedPreferences which caused containsKey and other functions to not work properly.
    • [macOS] Upgraded codebase to swift which fixed containsKey always returning true.
    Source code(tar.gz)
    Source code(zip)
  • v6.1.0(Nov 24, 2022)

    • [iOS] (From 6.1.0-beta.1) Migrated from objective C to Swift. This also fixes issues with constainsKey and possibly other issues.
    • [Android] Upgrade security-crypto from 1.1.0-alpha03 to 1.1.0-alpha04
    • [Android] Fix deprecation warnings.
    • [All] Migrated from flutter_lints to lint and applied suggestions.
    Source code(tar.gz)
    Source code(zip)
  • v6.1.0-beta.1(Sep 30, 2022)

  • v6.0.0(Aug 16, 2022)

  • 5.1.0(Aug 4, 2022)

    • [Android] You can now select your own key prefix or database name.
    • [Android] Upgraded to Android SDK 33.
    • [Android] You can now select the keyCipherAlgorithm and storageCipherAlgorithm.
    • [Linux] Fixed an issue where no error was being reported if there was something wrong accessing the secret service.
    • [macOS] Fixed an memory-leak.
    • [macOS] You can now select the same options as for iOS.
    Source code(tar.gz)
    Source code(zip)
  • v5.0.2(Nov 15, 2021)

  • 5.0.1(Nov 15, 2021)

  • 5.0.0+1(Nov 12, 2021)

    First stable release of flutter_secure_storage for multi-platform! Please see all beta release notes for changes.

    This first release also fixes several stability issues on Android regarding encrypted shared preferences.

    Source code(tar.gz)
    Source code(zip)
  • v5.0.0-beta.5(Aug 31, 2021)

    • [Linux, iOS & macOS] Add containsKey function.
    • [Linux] Fix for use of undeclared identifier 'flutter_secure_storage_linux_plugin_register_with_registrar'
    Source code(tar.gz)
    Source code(zip)
  • v5.0.0-beta.4(Aug 20, 2021)

    • [Windows] Fixed application crashing when key doesn't exists.
    • [Web] Added prefix to local storage key when deleting, fixing items that wouldn't delete.
    Source code(tar.gz)
    Source code(zip)
  • v5.0.0-beta.3(Aug 10, 2021)

    • [Android] Add possibility to reset data when an error occurs.
    • [Windows] Add readAll, deleteAll and containsKey functions.
    • [All] Refactor option defaults.
    Source code(tar.gz)
    Source code(zip)
  • 5.0.0-beta.2(Aug 4, 2021)

    • [Android] Improved EncryptedSharedPreferences by not loading unused Cipher.
    • [Android] Removed deprecated classes
    • [Web] Improved containsKey function
    Source code(tar.gz)
    Source code(zip)
  • 5.0.0(Aug 4, 2021)

    Initial BETA support for macOS, web & Windows. Development is still ongoing so expect some functions to not work correctly! Please read the readme.md for information about every platform.

    • Migrated to a federated project structure. #254. Thanks jhancock4d
    • Added support for encrypted shared preferences on Android. #259
    Source code(tar.gz)
    Source code(zip)
  • 4.2.1(Jul 29, 2021)

Owner
German Saprykin
Mobile, Dart, Swift, ObjC, Kotlin
German Saprykin
A SECURE personal data Analysis and Storage system.

Magic Data Bottle Our goal is to design and implement a secure personal data analysis and storage system. Repo Structure app An android app written in

Xinpeng Wei 3 Sep 27, 2022
An implementation for flutter secure file storage

Flutter secure file storage An implementation for flutter secure file storage. F

icapps 6 Oct 29, 2022
A flutter plugin that provides external storage path and external public storage path

ext_storage ext_storage is minimal flutter plugin that provides external storage path and external public storage path

null 0 Nov 16, 2021
A lightweight flutter plugin to check if your app is up-to-date on Google Play Store or Apple App Store

App Version Checker this package is used to check if your app has a new version on playstore or apple app store. or you can even check what is the lat

Iheb Briki 6 Dec 14, 2022
State Persistence - Persist state across app launches. By default this library store state as a local JSON file called `data.json` in the applications data directory. Maintainer: @slightfoot

State Persistence Persist state across app launches. By default this library store state as a local JSON file called data.json in the applications dat

Flutter Community 70 Sep 28, 2022
Phone-Store-App-UI-Flutter - Flutter Phone E-Store App UI with support for dark and light mode

Phone-Store-App-UI-Flutter - Flutter Phone E-Store App UI with support for dark and light mode

Jakub Sobański 2 Apr 30, 2022
Shoes-Store-App-UI-Flutter - Beautiful Shoes Store App UI with support for dark and light mode

Flutter Shoes Store App UI with support for dark and light mode. Flutter 2.8.1 N

Jakub Sobański 4 Nov 23, 2022
[Flutter package] An easy and quick way to check if the local app is updated with the same version in their respective stores (Play Store / Apple Store ).

Retrieve version and url for local app update against store app Android and iOS Features Using as reference packages like in_app_update , version_chec

Kauê Murakami 11 Nov 9, 2022
Flutter plugin to store data behind biometric authentication (ie. fingerprint)

biometric_storage Encrypted file store, optionally secured by biometric lock for Android, iOS, MacOS and partial support for Linux, Windows and Web. M

AuthPass 127 Jan 6, 2023
Flutter plugin to store data behind biometric authentication (ie. fingerprint)

biometric_storage Encrypted file store, optionally secured by biometric lock for Android, iOS, MacOS and partial support for Linux, Windows and Web. M

AuthPass 125 Dec 28, 2022
ToDo App made with flutter which stores your todos based on their categories. The data is stored in external application storage in your device in JSON file.

⭐ My ToDo ⭐ Built with ❤︎ by Akash Debnath This is my second project on Flutter. This app hepls you to keep record of your ToDos. You can create your

Akash Debnath 38 Dec 25, 2022
Blood Bank is cross platform mobile application that is developed using technologies like Flutter/Dart for frontend and Firebase for data storage

Blood Bank is cross platform mobile application that is developed using technologies like Flutter/Dart for frontend and Firebase for data storage. The sole goal of this application is to make blood donation resourceful and accessible all round the world.

Sajan Poudel 4 Nov 5, 2022
An example todo list back end project that uses gRPC for client-server communication and Firestore for data storage

An example todo list back end project that uses gRPC for client-server communication and Firestore for data storage

Lucas Coelho 2 Apr 18, 2022
Data Migrator - provide a universal translator for data by being portable, diverse, and efficient in migrating and converting data across discrete schemas

Data Migrator - provide a universal translator for data by being portable, diverse, and efficient in migrating and converting data across discrete schemas

Tanner Meade 77 Jan 2, 2023
Flutter integration for Supabase. This package makes it simple for developers to build secure and scalable products.

supabase_flutter Flutter package for Supabase. What is Supabase Supabase is an open source Firebase alternative. We are a service to: listen to databa

Supabase 251 Jan 7, 2023
Flutter App to save notes secure, using cryptography, clean architecture and some design patterns.

notes A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this is

Gabriel Scotá 6 Mar 28, 2022
A beautiful, secure and simple authenticator app that supports multiple protocols and services. Free and open source. Written in Flutter and Dart.

OpenAuth A beautiful, secure and simple authenticator app that supports multiple protocols and services. Free and open source. Written in Flutter and

Isaiah Collins Abetong 31 Oct 5, 2022
Appwrite is a secure end-to-end backend server for Web, Mobile, and Flutter developers that is packaged as a set of Docker containers for easy deployment 🚀

A complete backend solution for your [Flutter / Vue / Angular / React / iOS / Android / *ANY OTHER*] app Appwrite 0.12 has been released! Learn what's

Appwrite 28.2k Jan 3, 2023
Natrium - Fast, Robust & Secure NANO Wallet, now written with Flutter.

Natrium - Fast, Robust & Secure NANO Wallet What is Natrium? Natrium is a cross-platform mobile wallet for the NANO cryptocurrency. It is written in D

Appditto 702 Dec 30, 2022
Flutter Satellite.im Minimal Secure Chat Client

Uplink Flutter Satellite.im Minimal Secure Chat Client Getting Started ?? To run this project either use the launch configuration in VSCode or use the

Satellite 27 Dec 21, 2022