Skip to content

Commit ca42657

Browse files
committed
crypto: Log the received device keys on an encrypted olm message
Attempt to summarise the received keys.
1 parent 4636a91 commit ca42657

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,11 @@ impl OlmMachine {
11091109
decrypted: &mut OlmDecryptionInfo,
11101110
changes: &mut Changes,
11111111
) -> OlmResult<()> {
1112-
debug!("Received a decrypted to-device event");
1112+
debug!(
1113+
sender_device_keys =
1114+
?decrypted.result.event.sender_device_keys().map(|k| (k.curve25519_key(), k.ed25519_key())).unwrap_or((None, None)),
1115+
"Received a decrypted to-device event",
1116+
);
11131117

11141118
match &*decrypted.result.event {
11151119
AnyDecryptedOlmEvent::RoomKey(e) => {

crates/matrix-sdk-crypto/src/types/events/olm_v1.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,17 @@ impl AnyDecryptedOlmEvent {
148148
AnyDecryptedOlmEvent::Dummy(e) => e.content.event_type(),
149149
}
150150
}
151+
152+
/// The sender's device keys, if supplied in the message as per MSC4147
153+
pub fn sender_device_keys(&self) -> Option<&DeviceKeys> {
154+
match self {
155+
AnyDecryptedOlmEvent::Custom(_) => None,
156+
AnyDecryptedOlmEvent::RoomKey(e) => e.device_keys.as_ref(),
157+
AnyDecryptedOlmEvent::ForwardedRoomKey(e) => e.device_keys.as_ref(),
158+
AnyDecryptedOlmEvent::SecretSend(e) => e.device_keys.as_ref(),
159+
AnyDecryptedOlmEvent::Dummy(e) => e.device_keys.as_ref(),
160+
}
161+
}
151162
}
152163

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

0 commit comments

Comments
 (0)