From 5bc353ed83c91b71893c1cd01272c05923fd6932 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Mon, 16 Dec 2024 17:17:56 +0000 Subject: [PATCH] task(crypto): Support receiving stable identifier for MSC4147 --- .../src/olm/group_sessions/sender_data_finder.rs | 2 +- crates/matrix-sdk-crypto/src/olm/session.rs | 2 +- .../matrix-sdk-crypto/src/store/integration_tests.rs | 2 +- crates/matrix-sdk-crypto/src/types/events/olm_v1.rs | 12 ++++++------ 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/matrix-sdk-crypto/src/olm/group_sessions/sender_data_finder.rs b/crates/matrix-sdk-crypto/src/olm/group_sessions/sender_data_finder.rs index fcf0394a81b..0f23f013f48 100644 --- a/crates/matrix-sdk-crypto/src/olm/group_sessions/sender_data_finder.rs +++ b/crates/matrix-sdk-crypto/src/olm/group_sessions/sender_data_finder.rs @@ -171,7 +171,7 @@ impl<'a> SenderDataFinder<'a> { room_key_event: &'a DecryptedRoomKeyEvent, ) -> Result { // Does the to-device message contain the device_keys property from MSC4147? - if let Some(sender_device_keys) = &room_key_event.device_keys { + if let Some(sender_device_keys) = &room_key_event.sender_device_keys { // Yes: use the device keys to continue. // Validate the signature of the DeviceKeys supplied. diff --git a/crates/matrix-sdk-crypto/src/olm/session.rs b/crates/matrix-sdk-crypto/src/olm/session.rs index 939c488e74d..a51fbaa9dfe 100644 --- a/crates/matrix-sdk-crypto/src/olm/session.rs +++ b/crates/matrix-sdk-crypto/src/olm/session.rs @@ -380,6 +380,6 @@ mod tests { // DecryptedOlmV1Event let event: DecryptedOlmV1Event = serde_json::from_str(&bob_session_result.plaintext).unwrap(); - assert_eq!(event.device_keys.unwrap(), alice.device_keys()); + assert_eq!(event.sender_device_keys.unwrap(), alice.device_keys()); } } diff --git a/crates/matrix-sdk-crypto/src/store/integration_tests.rs b/crates/matrix-sdk-crypto/src/store/integration_tests.rs index 410d8dbde04..908415db347 100644 --- a/crates/matrix-sdk-crypto/src/store/integration_tests.rs +++ b/crates/matrix-sdk-crypto/src/store/integration_tests.rs @@ -1027,7 +1027,7 @@ macro_rules! cryptostore_integration_tests { recipient_keys: OlmV1Keys { ed25519: account.identity_keys().ed25519, }, - device_keys: None, + sender_device_keys: None, content: SecretSendContent::new(id.to_owned(), secret.to_owned()), }; diff --git a/crates/matrix-sdk-crypto/src/types/events/olm_v1.rs b/crates/matrix-sdk-crypto/src/types/events/olm_v1.rs index c9a04910b3f..697cc362edf 100644 --- a/crates/matrix-sdk-crypto/src/types/events/olm_v1.rs +++ b/crates/matrix-sdk-crypto/src/types/events/olm_v1.rs @@ -153,10 +153,10 @@ impl AnyDecryptedOlmEvent { pub fn sender_device_keys(&self) -> Option<&DeviceKeys> { match self { AnyDecryptedOlmEvent::Custom(_) => None, - AnyDecryptedOlmEvent::RoomKey(e) => e.device_keys.as_ref(), - AnyDecryptedOlmEvent::ForwardedRoomKey(e) => e.device_keys.as_ref(), - AnyDecryptedOlmEvent::SecretSend(e) => e.device_keys.as_ref(), - AnyDecryptedOlmEvent::Dummy(e) => e.device_keys.as_ref(), + AnyDecryptedOlmEvent::RoomKey(e) => e.sender_device_keys.as_ref(), + AnyDecryptedOlmEvent::ForwardedRoomKey(e) => e.sender_device_keys.as_ref(), + AnyDecryptedOlmEvent::SecretSend(e) => e.sender_device_keys.as_ref(), + AnyDecryptedOlmEvent::Dummy(e) => e.sender_device_keys.as_ref(), } } } @@ -177,7 +177,7 @@ where pub recipient_keys: OlmV1Keys, /// The device keys if supplied as per MSC4147 #[serde(rename = "org.matrix.msc4147.device_keys")] - pub device_keys: Option, + pub sender_device_keys: Option, /// The type of the event. pub content: C, } @@ -201,7 +201,7 @@ impl DecryptedOlmV1Event { recipient: recipient.to_owned(), keys: OlmV1Keys { ed25519: key }, recipient_keys: OlmV1Keys { ed25519: key }, - device_keys, + sender_device_keys: device_keys, content, } }