Skip to content

Commit 73cfc13

Browse files
committed
crypto: Store sender_data in InboundGroupSessions
1 parent 3ffeef5 commit 73cfc13

File tree

11 files changed

+387
-17
lines changed

11 files changed

+387
-17
lines changed

bindings/matrix-sdk-crypto-ffi/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub use logger::{set_logger, Logger};
3131
pub use machine::{KeyRequestPair, OlmMachine, SignatureVerification};
3232
use matrix_sdk_common::deserialized_responses::ShieldState as RustShieldState;
3333
use matrix_sdk_crypto::{
34-
olm::{IdentityKeys, InboundGroupSession, Session},
34+
olm::{IdentityKeys, InboundGroupSession, SenderData, Session},
3535
store::{Changes, CryptoStore, PendingChanges, RoomSettings as RustRoomSettings},
3636
types::{EventEncryptionAlgorithm as RustEventEncryptionAlgorithm, SigningKey},
3737
EncryptionSettings as RustEncryptionSettings,
@@ -471,6 +471,7 @@ fn collect_sessions(
471471
Ok((algorithm, key))
472472
})
473473
.collect::<anyhow::Result<_>>()?,
474+
sender_data: SenderData::legacy(),
474475
room_id: RoomId::parse(session.room_id)?,
475476
imported: session.imported,
476477
backed_up: session.backed_up,

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ use crate::{
6363
identities::{user::UserIdentities, Device, IdentityManager, UserDevices},
6464
olm::{
6565
Account, CrossSigningStatus, EncryptionSettings, IdentityKeys, InboundGroupSession,
66-
OlmDecryptionInfo, PrivateCrossSigningIdentity, SessionType, StaticAccountData,
66+
OlmDecryptionInfo, PrivateCrossSigningIdentity, SenderData, SessionType, StaticAccountData,
6767
},
6868
requests::{IncomingResponse, OutgoingRequest, UploadSigningKeysRequest},
6969
session_manager::{GroupSessionManager, SessionManager},
@@ -806,11 +806,14 @@ impl OlmMachine {
806806
event: &DecryptedRoomKeyEvent,
807807
content: &MegolmV1AesSha2Content,
808808
) -> OlmResult<Option<InboundGroupSession>> {
809+
let sender_data = SenderData::unknown();
810+
809811
let session = InboundGroupSession::new(
810812
sender_key,
811813
event.keys.ed25519,
812814
&content.room_id,
813815
&content.session_key,
816+
sender_data,
814817
event.content.algorithm(),
815818
None,
816819
);
@@ -2263,7 +2266,8 @@ pub(crate) mod tests {
22632266
error::{EventError, SetRoomSettingsError},
22642267
machine::{EncryptionSyncChanges, OlmMachine},
22652268
olm::{
2266-
BackedUpRoomKey, ExportedRoomKey, InboundGroupSession, OutboundGroupSession, VerifyJson,
2269+
BackedUpRoomKey, ExportedRoomKey, InboundGroupSession, OutboundGroupSession,
2270+
SenderData, VerifyJson,
22672271
},
22682272
store::{BackupDecryptionKey, Changes, CryptoStore, MemoryStore, RoomSettings},
22692273
types::{
@@ -3556,6 +3560,7 @@ pub(crate) mod tests {
35563560
Ed25519PublicKey::from_base64("loz5i40dP+azDtWvsD0L/xpnCjNkmrcvtXVXzCHX8Vw").unwrap(),
35573561
fake_room_id,
35583562
&olm,
3563+
SenderData::unknown(),
35593564
EventEncryptionAlgorithm::MegolmV1AesSha2,
35603565
None,
35613566
)
@@ -3573,6 +3578,7 @@ pub(crate) mod tests {
35733578
Ed25519PublicKey::from_base64("48f3WQAMGwYLBg5M5qUhqnEVA8yeibjZpPsShoWMFT8").unwrap(),
35743579
fake_room_id,
35753580
&olm,
3581+
SenderData::unknown(),
35763582
EventEncryptionAlgorithm::MegolmV1AesSha2,
35773583
None,
35783584
)

crates/matrix-sdk-crypto/src/olm/account.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ use crate::{
6161
dehydrated_devices::DehydrationError,
6262
error::{EventError, OlmResult, SessionCreationError},
6363
identities::ReadOnlyDevice,
64+
olm::SenderData,
6465
requests::UploadSigningKeysRequest,
6566
store::{Changes, Store},
6667
types::{
@@ -220,6 +221,7 @@ impl StaticAccountData {
220221
signing_key,
221222
room_id,
222223
&outbound.session_key().await,
224+
SenderData::unknown(),
223225
algorithm,
224226
Some(visibility),
225227
)?;

0 commit comments

Comments
 (0)