Skip to content

Commit 84a030a

Browse files
committed
crypto: Support for encrypting and sending room key history bundle data
For each device belonging to the user, encrypt and send to-device messages containing the bundle data
1 parent 7b25a50 commit 84a030a

File tree

4 files changed

+346
-17
lines changed

4 files changed

+346
-17
lines changed

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)