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

Encrypted Storage Bugfixes #303

Closed
wants to merge 2 commits into from
Closed

Conversation

georgeflug
Copy link

@georgeflug georgeflug commented Jan 3, 2023

This fixes a few issues I've seen in a production app with encrypted storage.

This moves the initWithEncryptionWithoutSecureStorage call higher up because the app was crashing when trying to access secure storage on an instance that did not use secure storage. It was going down the if (IDStore.exists(id)) path which ultimately tried to encrypt with a key stored in secure storage even though it was configured to not use secure storage. This fixes #265

This also moves the initWithEncryptionUsingNewKey call higher up because the app got into a bad state where the IDStore.exists(id) call was returning true but the mmkvJsiModule.getSecureKey call was returning nothing. I'm not sure how it got into the bad state but it may be related to the problem that was fixed by 0.8.0. If the secure key does not exist, it should use a new key instead of continually trying to use the nonexistent key.

@vercel
Copy link

vercel bot commented Jan 3, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
rnmmkv ✅ Ready (Inspect) Visit Preview Jan 3, 2023 at 6:00PM (UTC)

@ammarahm-ed
Copy link
Owner

Hi, using a new key if the existing key did not exist means the data encrypted with older key will not exist anymore. It will be wiped and replaced with new data. I am not sure if it's a good solution yet to immediately create a new key & and a new storage instance.

@georgeflug georgeflug closed this Sep 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Custom Encryption Crashes if no Secure Storage
2 participants