Skip to content

Commit ed232df

Browse files
authored
Merge pull request #4864 from matrix-org/rav/history_sharing/upload_bundle
crypto: encrypt, upload and share keys for room history
2 parents dc6fe93 + 1a4f6ef commit ed232df

File tree

10 files changed

+593
-26
lines changed

10 files changed

+593
-26
lines changed

crates/matrix-sdk-crypto/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ All notable changes to this project will be documented in this file.
88

99
### Features
1010

11+
- Add experimental APIs for sharing encrypted room key history with new members, `Store::build_room_key_bundle` and `OlmMachine::share_room_key_bundle_data`.
12+
([#4775](https://github.com/matrix-org/matrix-rust-sdk/pull/4775), [#4864](https://github.com/matrix-org/matrix-rust-sdk/pull/4864))
13+
1114
- Check the `sender_device_keys` field on *all* incoming Olm-encrypted to-device messages
1215
and ignore any to-device messages which include the field but whose data is invalid
1316
(as per [MSC4147](https://github.com/matrix-org/matrix-spec-proposals/pull/4147)).

crates/matrix-sdk-crypto/src/machine/mod.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ use crate::{
8585
RoomEventEncryptionScheme, SupportedEventEncryptionSchemes,
8686
},
8787
room_key::{MegolmV1AesSha2Content, RoomKeyContent},
88+
room_key_bundle::RoomKeyBundleContent,
8889
room_key_withheld::{
8990
MegolmV1AesSha2WithheldContent, RoomKeyWithheldContent, RoomKeyWithheldEvent,
9091
},
@@ -98,8 +99,8 @@ use crate::{
9899
},
99100
utilities::timestamp_to_iso8601,
100101
verification::{Verification, VerificationMachine, VerificationRequest},
101-
CrossSigningKeyExport, CryptoStoreError, DecryptionSettings, DeviceData, LocalTrust,
102-
RoomEventDecryptionResult, SignatureError, TrustRequirement,
102+
CollectStrategy, CrossSigningKeyExport, CryptoStoreError, DecryptionSettings, DeviceData,
103+
LocalTrust, RoomEventDecryptionResult, SignatureError, TrustRequirement,
103104
};
104105

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

1093+
/// Collect the devices belonging to the given user, and send the details of
1094+
/// a room key bundle to those devices.
1095+
///
1096+
/// Returns a list of to-device requests which must be sent.
1097+
pub async fn share_room_key_bundle_data(
1098+
&self,
1099+
user_id: &UserId,
1100+
collect_strategy: &CollectStrategy,
1101+
bundle_data: RoomKeyBundleContent,
1102+
) -> OlmResult<Vec<ToDeviceRequest>> {
1103+
self.inner
1104+
.group_session_manager
1105+
.share_room_key_bundle_data(user_id, collect_strategy, bundle_data)
1106+
.await
1107+
}
1108+
10921109
/// Receive an unencrypted verification event.
10931110
///
10941111
/// This method can be used to pass verification events that are happening

0 commit comments

Comments
 (0)