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

Extract common crypto interface for all flavors #8470

Merged
merged 4 commits into from
May 30, 2023

Conversation

BillCarsonFr
Copy link
Member

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

The full realmCrypto store API was still available in the rust flavor, it's problematic because several things have moved from realm and are now stored in the rust sdk.
As an example EventEditValidator was calling deviceWithIdentityKey from the legacy realm store on rust flavor, thus getting absent or outdated information.

As a solution for that a IMXCommonCryptoStore interface has been extracted, that contains API that both falvors are still using. The RealmCryptoStore (IMXCryptoStore) full API has been moved to the kotlinCrypto flavor, and a RustCryptoStore has been introduced for the rustCryptoFalvor.
In a following PR we will see how to complitely remove the need for a realm crypto store, some changes are needed on the rust sdk in order to do it now (partial support is there, but not yet integrated, and some more might be needed).

One exception to that rule, the rust flavor is migrating megolm sessions lazyly, so it needs to access the legacy store for a moment.

Also added some defensive coding for some crash reported on sentry when trying to import megolm session from legacy store (added a log and tryOrNull in RequestSender for now).

The logic has changed in EventEditValidator because the rust-sdk doesn't have an API to get a device from a senderKey, you need to provide a userId as well in rust. Updated the test accordingly.

Motivation and context

Screenshots / GIFs

Tests

  • Step 1
  • Step 2
  • Step ...

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@BillCarsonFr BillCarsonFr requested a review from bmarty May 26, 2023 08:15
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

LGTM (static review). Thanks

@@ -246,7 +246,7 @@ internal abstract class CryptoModule {
abstract fun bindVerificationService(service: RustVerificationService): VerificationService

@Binds
abstract fun bindCryptoStore(store: RealmCryptoStore): IMXCryptoStore
abstract fun bindCryptoStore(store: RustCryptoStore): IMXCommonCryptoStore
Copy link
Member

Choose a reason for hiding this comment

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

This is the location of the fix, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Mainly yes.
The IMXCryptoStore, RealmCryptoStore, InboundGroupSessionStore, OlmSessionStore have all moved to the kotlin flavour source folder.
And there is the new RustCryptoStore in the rust flavour sources

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 12 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@BillCarsonFr BillCarsonFr merged commit 8379534 into develop May 30, 2023
@BillCarsonFr BillCarsonFr deleted the feature/bca/extract_common_crypto branch May 30, 2023 07:09
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.

2 participants