crypto: Log the received device keys on an encrypted olm message

Attempt to summarise the received keys.
This commit is contained in:
Richard van der Hoff
2024-08-09 12:51:36 +01:00
committed by Richard van der Hoff
parent 4636a9177e
commit ca42657abb
2 changed files with 16 additions and 1 deletions
+5 -1
View File
@@ -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) => {
@@ -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.