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

Store data in an encrypted local database #4

Open
ferndot opened this issue Mar 20, 2020 · 12 comments
Open

Store data in an encrypted local database #4

ferndot opened this issue Mar 20, 2020 · 12 comments
Labels
difficulty: 3 help wanted Extra attention is needed type: feature New feature or request
Projects

Comments

@ferndot
Copy link
Collaborator

ferndot commented Mar 20, 2020

Is your feature request related to a problem? Please describe.
Future versions of this app will require secure local storage of sensitive data.

Describe the solution you'd like
Set up a secure and encrypted local storage pattern.

Describe alternatives you've considered

Additional context

  • Bonus for supporting encryption with a biometric and PIN
@ferndot ferndot added type: feature New feature or request help wanted Extra attention is needed difficulty: 3 labels Mar 20, 2020
@ferndot ferndot added this to To do in v1.0 Mar 22, 2020
@dnfield
Copy link
Contributor

dnfield commented Mar 22, 2020

May want to consider https://pub.dev/packages/flutter_secure_storage - it may be usable with the other packages.

@ferndot
Copy link
Collaborator Author

ferndot commented Mar 23, 2020

@dnfield this package integrates flutter_secure_storage with hydrated_bloc. https://pub.dev/packages/knox

@ferndot
Copy link
Collaborator Author

ferndot commented Mar 23, 2020

We could also easily create our own custom storage class to link hydrated_bloc and flutter_secure_storage

@dnfield
Copy link
Contributor

dnfield commented Mar 23, 2020

So flutter_secure_storage is really meant for storing a key, rather than storing larger amounts of data. If there's only a smaller amount of data to store it's probably fine, but this would really be where we'd want to store the key or password for some other encrypted resource normally.

@edman
Copy link

edman commented Mar 23, 2020

Is there a plugin with support for biometry or lock screen bound keys (e.g. as in keys generated with setUserAuthenticationRequired)? I couldn't find any.

If not, local_auth could be used to gate access without crypto guarantees on the stored data. Then we'd also need a fallback strategy, like an in-app password screen.

Expanding on the suggestions so far we could:

  • Generate an AES key with Random.secure()
  • Persist the key with flutter_secure_storage
  • Use local_auth or fallback to password screen for authentication
  • Use the key with hive or sqflite_sqlcipher

@dnfield
Copy link
Contributor

dnfield commented Mar 23, 2020

The general workflow should be:

  • use local_auth to guard access to the keys
  • store the keys using flutter_secure_storage
  • use the keys to decrypt whatever is stored locally (e.g. SQLCipher, a file, whatever).

It would be best to avoid packages which have either hand rolled encryption or have not really been battle tested.

@dnfield
Copy link
Contributor

dnfield commented Mar 23, 2020

Another option is to just use a simple file to store this that we encrypt. E.g. something encoded with JSON codec or the FlutterStandardCodec.

@edman
Copy link

edman commented Mar 23, 2020

How do you suggest we encrypt this file? The crypto packages I find in pub don't look very battle tested.

@dnfield
Copy link
Contributor

dnfield commented Mar 23, 2020

I think right now our best bet would be to use native platform APIs with a custom plugin. I'm going to do a quick experiment on this.

@dnfield dnfield self-assigned this Mar 24, 2020
@the1220
Copy link

the1220 commented Mar 30, 2020

would this be any help to you all https://bitbucket.org/wmtp/dha-encryption/src/master/README.md

@ferndot ferndot changed the title [FEATURE] Store data in an encrypted local database Store data in an encrypted local database Mar 30, 2020
@ferndot
Copy link
Collaborator Author

ferndot commented Apr 2, 2020

@the1220 thanks for suggesting that! Unfortunately, it is for JavaScript applications, so it won't work for this project.

@ferndot
Copy link
Collaborator Author

ferndot commented Apr 2, 2020

Postponing this issue until the MVP is launched--there is no sensitive data stored locally in the first version.

@dnfield dnfield removed their assignment Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: 3 help wanted Extra attention is needed type: feature New feature or request
Projects
No open projects
v1.0
  
To do
Development

No branches or pull requests

4 participants