Skip to content

Commit

Permalink
task(crypto): Support receiving stable identifier for MSC4147
Browse files Browse the repository at this point in the history
  • Loading branch information
andybalaam committed Dec 16, 2024
1 parent 34ea42a commit 723cb6a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
4 changes: 4 additions & 0 deletions crates/matrix-sdk-crypto/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ All notable changes to this project will be documented in this file.

## [Unreleased] - ReleaseDate

- Accept stable identifier `sender_device_keys` for MSC4147 (Including device
keys with Olm-encrypted events).
([#4420](https://github.com/matrix-org/matrix-rust-sdk/pull/4420))

- Expose new API `DehydratedDevices::get_dehydrated_device_pickle_key`, `DehydratedDevices::save_dehydrated_device_pickle_key`
and `DehydratedDevices::delete_dehydrated_device_pickle_key` to store/load the dehydrated device pickle key.
This allows client to automatically rotate the dehydrated device to avoid one-time-keys exhaustion and to_device accumulation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl<'a> SenderDataFinder<'a> {
room_key_event: &'a DecryptedRoomKeyEvent,
) -> Result<SenderData, SessionDeviceKeysCheckError> {
// 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.
Expand Down
2 changes: 1 addition & 1 deletion crates/matrix-sdk-crypto/src/olm/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,6 @@ mod tests {
// DecryptedOlmV1Event
let event: DecryptedOlmV1Event<DummyEventContent> =
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());
}
}
2 changes: 1 addition & 1 deletion crates/matrix-sdk-crypto/src/store/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
};

Expand Down
12 changes: 6 additions & 6 deletions crates/matrix-sdk-crypto/src/types/events/olm_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}
}
Expand All @@ -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<DeviceKeys>,
pub sender_device_keys: Option<DeviceKeys>,
/// The type of the event.
pub content: C,
}
Expand All @@ -201,7 +201,7 @@ impl<C: EventType + Debug + Sized + Serialize> DecryptedOlmV1Event<C> {
recipient: recipient.to_owned(),
keys: OlmV1Keys { ed25519: key },
recipient_keys: OlmV1Keys { ed25519: key },
device_keys,
sender_device_keys: device_keys,
content,
}
}
Expand Down

0 comments on commit 723cb6a

Please sign in to comment.