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

Support encryption key in configuration #920

Merged
merged 16 commits into from
Oct 10, 2022
Merged

Conversation

desistefanova
Copy link
Contributor

Support encryption key used to encrypt the entire [Realm].
Its length is forced to be 64bytes.
If null encryption is not enabled.
Fixes #88

@cla-bot cla-bot bot added the cla: yes label Sep 23, 2022
Copy link
Member

@nirinchev nirinchev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, just a few suggestions and would like to see more tests.

lib/src/native/realm_core.dart Outdated Show resolved Hide resolved
lib/src/configuration.dart Outdated Show resolved Hide resolved
test/realm_test.dart Outdated Show resolved Hide resolved
@coveralls
Copy link

Pull Request Test Coverage Report for Build 3111528733

  • 0 of 4 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+5.5%) to 93.128%

Totals Coverage Status
Change from base Build 3097932778: 5.5%
Covered Lines: 393
Relevant Lines: 422

💛 - Coveralls

@coveralls
Copy link

coveralls commented Sep 23, 2022

Pull Request Test Coverage Report for Build 3218450209

  • 11 of 11 (100.0%) changed or added relevant lines in 2 files are covered.
  • 150 unchanged lines in 8 files lost coverage.
  • Overall coverage increased (+4.5%) to 92.558%

Files with Coverage Reduction New Missed Lines %
lib/src/list.dart 2 88.68%
lib/src/session.dart 2 89.66%
lib/src/subscription.dart 2 91.03%
lib/src/results.dart 3 91.53%
lib/src/scheduler.dart 3 61.54%
lib/src/realm_object.dart 5 85.85%
lib/src/realm_class.dart 13 91.71%
lib/src/native/realm_core.dart 120 88.45%
Totals Coverage Status
Change from base Build 3181931773: 4.5%
Covered Lines: 398
Relevant Lines: 430

💛 - Coveralls

lib/src/configuration.dart Show resolved Hide resolved
@desistefanova desistefanova self-assigned this Sep 26, 2022
Copy link
Member

@nirinchev nirinchev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One final question from me, otherwise it looks good.

test/configuration_test.dart Show resolved Hide resolved
@desistefanova desistefanova merged commit c501973 into master Oct 10, 2022
@desistefanova desistefanova deleted the ds/config_encryption_key branch October 10, 2022 10:51
@richard457
Copy link

I am writing to request clarification on the encryption key when passed, when added to realm later will it encrypt the existing realm?

@richard457
Copy link

also the example from docs shows encrypting local realm

// Generate encryption key
--
final key = List<int>.generate(64, (i) => Random().nextInt(256));
 
final encryptedConfig = Configuration.local([Car.schema],
// Include the encryption key in the configuration
encryptionKey: key);
final encryptedRealm = Realm(encryptedConfig);

does it work on flexible sync as well @desistefanova

@nirinchev
Copy link
Member

Yes, it works with flexible sync and no - you cannot change the encryption of a file after it was created. You can use Realm.writeCopy to create an encrypted copy of the file, but that only works for local files. For synchronized realms, you can just recreate the file and re-fetch the data.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Config: Support encryption keys
6 participants