From b52f3fb11fb8b0abaf766f72887472610be52d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Tue, 1 Jun 2021 10:02:16 +0200 Subject: [PATCH] crypto: Remove an allocation when calculating the SAS MAC --- matrix_sdk_crypto/src/verification/sas/helpers.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/matrix_sdk_crypto/src/verification/sas/helpers.rs b/matrix_sdk_crypto/src/verification/sas/helpers.rs index b0092383..d4638d0c 100644 --- a/matrix_sdk_crypto/src/verification/sas/helpers.rs +++ b/matrix_sdk_crypto/src/verification/sas/helpers.rs @@ -198,8 +198,9 @@ pub fn receive_mac_event( ids.other_device.device_id() ); - let mut keys = content.mac().keys().cloned().collect::>(); + let mut keys = content.mac().keys().map(|k| k.as_str()).collect::>(); keys.sort(); + let keys = sas .calculate_mac(&keys.join(","), &format!("{}KEY_IDS", &info)) .expect("Can't calculate SAS MAC"); @@ -215,6 +216,7 @@ pub fn receive_mac_event( sender, ids.other_device.device_id() ); + let key_id: DeviceKeyId = match key_id.as_str().try_into() { Ok(id) => id, Err(_) => continue,