Skip to content

Commit 1b2ba33

Browse files
committed
Record the sender key when decrypting room events
This used to be the case previously, but it seems that things got lost when we reshuffled the code here.
1 parent 631b51f commit 1b2ba33

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,12 +1249,6 @@ impl OlmMachine {
12491249
})
12501250
}
12511251

1252-
#[instrument(
1253-
skip_all,
1254-
// This function is only ever called by decrypt_room_event, so
1255-
// room_id, sender, algorithm and session_id are recorded already
1256-
fields(sender_key, event_type),
1257-
)]
12581252
async fn decrypt_megolm_events(
12591253
&self,
12601254
room_id: &RoomId,
@@ -1264,7 +1258,12 @@ impl OlmMachine {
12641258
if let Some(session) =
12651259
self.store().get_inbound_group_session(room_id, content.session_id()).await?
12661260
{
1267-
tracing::Span::current().record("sender_key", session.sender_key().to_base64());
1261+
// This function is only ever called by decrypt_room_event, so
1262+
// room_id, sender, algorithm and session_id are recorded already
1263+
//
1264+
// While we already record the sender key in some cases from the event, the
1265+
// sender key in the event is deprecated, so let's record it now.
1266+
tracing::Span::current().record("sender_key", debug(session.sender_key()));
12681267

12691268
let result = session.decrypt(event).await;
12701269
match result {
@@ -1317,7 +1316,7 @@ impl OlmMachine {
13171316
/// * `event` - The event that should be decrypted.
13181317
///
13191318
/// * `room_id` - The ID of the room where the event was sent to.
1320-
#[instrument(skip_all, fields(?room_id, event_id, sender, algorithm, session_id))]
1319+
#[instrument(skip_all, fields(?room_id, event_id, sender, algorithm, session_id, sender_key))]
13211320
pub async fn decrypt_room_event(
13221321
&self,
13231322
event: &Raw<EncryptedEvent>,
@@ -1331,7 +1330,10 @@ impl OlmMachine {
13311330
.record("algorithm", debug(event.content.algorithm()));
13321331

13331332
let content: SupportedEventEncryptionSchemes<'_> = match &event.content.scheme {
1334-
RoomEventEncryptionScheme::MegolmV1AesSha2(c) => c.into(),
1333+
RoomEventEncryptionScheme::MegolmV1AesSha2(c) => {
1334+
tracing::Span::current().record("sender_key", debug(c.sender_key));
1335+
c.into()
1336+
}
13351337
#[cfg(feature = "experimental-algorithms")]
13361338
RoomEventEncryptionScheme::MegolmV2AesSha2(c) => c.into(),
13371339
RoomEventEncryptionScheme::Unknown(_) => {

0 commit comments

Comments
 (0)