Skip to content

crypto: encrypt, upload and share keys for room history #4864

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

Merged
merged 7 commits into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/matrix-sdk-crypto/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ All notable changes to this project will be documented in this file.

### Features

- Add experimental APIs for sharing encrypted room key history with new members, `Store::build_room_key_bundle` and `OlmMachine::share_room_key_bundle_data`.
([#4775](https://github.com/matrix-org/matrix-rust-sdk/pull/4775), [#4864](https://github.com/matrix-org/matrix-rust-sdk/pull/4864))

- Check the `sender_device_keys` field on *all* incoming Olm-encrypted to-device messages
and ignore any to-device messages which include the field but whose data is invalid
(as per [MSC4147](https://github.com/matrix-org/matrix-spec-proposals/pull/4147)).
Expand Down
21 changes: 19 additions & 2 deletions crates/matrix-sdk-crypto/src/machine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ use crate::{
RoomEventEncryptionScheme, SupportedEventEncryptionSchemes,
},
room_key::{MegolmV1AesSha2Content, RoomKeyContent},
room_key_bundle::RoomKeyBundleContent,
room_key_withheld::{
MegolmV1AesSha2WithheldContent, RoomKeyWithheldContent, RoomKeyWithheldEvent,
},
Expand All @@ -98,8 +99,8 @@ use crate::{
},
utilities::timestamp_to_iso8601,
verification::{Verification, VerificationMachine, VerificationRequest},
CrossSigningKeyExport, CryptoStoreError, DecryptionSettings, DeviceData, LocalTrust,
RoomEventDecryptionResult, SignatureError, TrustRequirement,
CollectStrategy, CrossSigningKeyExport, CryptoStoreError, DecryptionSettings, DeviceData,
LocalTrust, RoomEventDecryptionResult, SignatureError, TrustRequirement,
};

/// State machine implementation of the Olm/Megolm encryption protocol used for
Expand Down Expand Up @@ -1089,6 +1090,22 @@ impl OlmMachine {
self.inner.group_session_manager.share_room_key(room_id, users, encryption_settings).await
}

/// Collect the devices belonging to the given user, and send the details of
/// a room key bundle to those devices.
///
/// Returns a list of to-device requests which must be sent.
pub async fn share_room_key_bundle_data(
&self,
user_id: &UserId,
collect_strategy: &CollectStrategy,
bundle_data: RoomKeyBundleContent,
) -> OlmResult<Vec<ToDeviceRequest>> {
self.inner
.group_session_manager
.share_room_key_bundle_data(user_id, collect_strategy, bundle_data)
.await
}

/// Receive an unencrypted verification event.
///
/// This method can be used to pass verification events that are happening
Expand Down
Loading
Loading