Skip to content

Commit

Permalink
crypto: Log the received device keys on an encrypted olm message
Browse files Browse the repository at this point in the history
Attempt to summarise the received keys.
  • Loading branch information
richvdh committed Sep 2, 2024
1 parent 4636a91 commit ca42657
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/matrix-sdk-crypto/src/machine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,11 @@ impl OlmMachine {
decrypted: &mut OlmDecryptionInfo,
changes: &mut Changes,
) -> OlmResult<()> {
debug!("Received a decrypted to-device event");
debug!(
sender_device_keys =
?decrypted.result.event.sender_device_keys().map(|k| (k.curve25519_key(), k.ed25519_key())).unwrap_or((None, None)),
"Received a decrypted to-device event",
);

match &*decrypted.result.event {
AnyDecryptedOlmEvent::RoomKey(e) => {
Expand Down
11 changes: 11 additions & 0 deletions crates/matrix-sdk-crypto/src/types/events/olm_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,17 @@ impl AnyDecryptedOlmEvent {
AnyDecryptedOlmEvent::Dummy(e) => e.content.event_type(),
}
}

/// The sender's device keys, if supplied in the message as per MSC4147
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(),
}
}
}

/// An `m.olm.v1.curve25519-aes-sha2` decrypted to-device event.
Expand Down

0 comments on commit ca42657

Please sign in to comment.