Skip to content

Commit a6b0f8b

Browse files
committed
crypto: improve SenderData stored with room key bundle data
If we already have cross-signing details for the owner of the device at the point we receive the to-device message, we should store that rather than just the device info.
1 parent c8dfc81 commit a6b0f8b

File tree

1 file changed

+9
-1
lines changed
  • crates/matrix-sdk-crypto/src/machine

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,9 +952,17 @@ impl OlmMachine {
952952
return Ok(());
953953
};
954954

955+
// We already checked that `sender_device_keys` matches the actual sender of the
956+
// message when we decrypted the message, which included doing
957+
// `DeviceData::try_from` on it, so it can't fail.
958+
959+
let sender_device_data =
960+
DeviceData::try_from(sender_device_keys).expect("failed to verify sender device keys");
961+
let sender_device = self.store().wrap_device_data(sender_device_data).await?;
962+
955963
changes.received_room_key_bundles.push(StoredRoomKeyBundleData {
956964
sender_user: event.sender.clone(),
957-
sender_data: SenderData::device_info(sender_device_keys.clone()),
965+
sender_data: SenderData::from_device(&sender_device),
958966
bundle_data: event.content.clone(),
959967
});
960968
Ok(())

0 commit comments

Comments
 (0)