Skip to content

Commit 031f4ec

Browse files
BillCarsonFrpoljar
authored andcommitted
review: Remove encryption_info. Will be part of another PR
1 parent 4bf103d commit 031f4ec

File tree

7 files changed

+6
-298
lines changed

7 files changed

+6
-298
lines changed

bindings/matrix-sdk-crypto-ffi/src/machine.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,8 +932,6 @@ impl OlmMachine {
932932
},
933933
}
934934
}
935-
// Should not happen
936-
_ => panic!("Unsupported algorithm in room"),
937935
})
938936
}
939937

crates/matrix-sdk-common/src/deserialized_responses.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,6 @@ pub enum AlgorithmInfo {
282282
/// key.
283283
sender_claimed_keys: BTreeMap<DeviceKeyAlgorithm, String>,
284284
},
285-
286-
OlmV1Curve25519AesSha2 {
287-
// The sender key of the device that encrypted the message
288-
curve25519_key: String,
289-
},
290285
}
291286

292287
/// Struct containing information on how an event was decrypted.
@@ -626,8 +621,6 @@ pub enum ProcessedToDeviceEvent {
626621
Decrypted {
627622
/// The decrypted to device event
628623
decrypted_event: Raw<AnyToDeviceEvent>,
629-
/// Sender encryption information
630-
encryption_info: EncryptionInfo,
631624
},
632625

633626
/// An encrypted event which could not be decrypted.

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

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,13 +1372,7 @@ impl OlmMachine {
13721372
}
13731373
}
13741374

1375-
let encryption_info =
1376-
self.get_olm_encryption_info(&e.sender, decrypted.result.sender_key).await;
1377-
1378-
Some(ProcessedToDeviceEvent::Decrypted {
1379-
decrypted_event: raw_event,
1380-
encryption_info,
1381-
})
1375+
Some(ProcessedToDeviceEvent::Decrypted { decrypted_event: raw_event })
13821376
}
13831377

13841378
e => {
@@ -1388,60 +1382,6 @@ impl OlmMachine {
13881382
}
13891383
}
13901384

1391-
/// Get the sender information for a successfully decrypted olm message.
1392-
///
1393-
/// # Arguments
1394-
///
1395-
/// * `sender` - The claimed user_id retrieved from the event.
1396-
///
1397-
/// * `sender_key` - The `Curve25519PublicKey` linked to the olm session
1398-
/// that decrypted the message.
1399-
///
1400-
/// # Returns
1401-
///
1402-
/// A [`EncryptionInfo`] struct.
1403-
async fn get_olm_encryption_info(
1404-
&self,
1405-
sender: &UserId,
1406-
sender_key: Curve25519PublicKey,
1407-
) -> EncryptionInfo {
1408-
let device =
1409-
self.store().get_device_from_curve_key(sender, sender_key).await.unwrap_or(None);
1410-
1411-
let state = if let Some(device) = &device {
1412-
if device.is_cross_signed_by_owner() {
1413-
if device.is_device_owner_verified() {
1414-
VerificationState::Verified
1415-
} else {
1416-
let identity = device
1417-
.device_owner_identity
1418-
.as_ref()
1419-
.expect("This device is cross-signed, so the identity exists");
1420-
if identity.was_previously_verified() {
1421-
VerificationState::Unverified(VerificationLevel::VerificationViolation)
1422-
} else {
1423-
VerificationState::Unverified(VerificationLevel::UnverifiedIdentity)
1424-
}
1425-
}
1426-
} else {
1427-
VerificationState::Unverified(VerificationLevel::UnsignedDevice)
1428-
}
1429-
} else {
1430-
VerificationState::Unverified(VerificationLevel::None(DeviceLinkProblem::MissingDevice))
1431-
};
1432-
1433-
EncryptionInfo {
1434-
sender: sender.to_owned(),
1435-
sender_device: device.map(|d| d.device_id().to_owned()),
1436-
algorithm_info: AlgorithmInfo::OlmV1Curve25519AesSha2 {
1437-
curve25519_key: sender_key.to_base64(),
1438-
},
1439-
verification_state: state,
1440-
// Only relevant for megolm
1441-
session_id: None,
1442-
}
1443-
}
1444-
14451385
/// Decide whether a decrypted to-device event was sent from a dehydrated
14461386
/// device.
14471387
///

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

Lines changed: 3 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use std::collections::BTreeMap;
1919

2020
use as_variant::as_variant;
21-
use matrix_sdk_common::deserialized_responses::ProcessedToDeviceEvent;
2221
use matrix_sdk_test::{ruma_response_from_json, test_json};
2322
use ruma::{
2423
api::client::keys::{
@@ -30,20 +29,14 @@ use ruma::{
3029
encryption::OneTimeKey,
3130
events::dummy::ToDeviceDummyEventContent,
3231
serde::Raw,
33-
to_device::DeviceIdOrAllDevices,
3432
user_id, DeviceId, OwnedOneTimeKeyId, TransactionId, UserId,
3533
};
36-
use serde_json::{json, Value};
34+
use serde_json::json;
3735

3836
use crate::{
39-
machine::tests,
4037
store::{Changes, MemoryStore},
41-
types::{
42-
events::ToDeviceEvent,
43-
requests::{AnyOutgoingRequest, ToDeviceRequest},
44-
},
45-
utilities::json_convert,
46-
CrossSigningBootstrapRequests, DeviceData, EncryptionSyncChanges, OlmMachine,
38+
types::{events::ToDeviceEvent, requests::AnyOutgoingRequest},
39+
CrossSigningBootstrapRequests, DeviceData, OlmMachine,
4740
};
4841

4942
/// These keys need to be periodically uploaded to the server.
@@ -283,51 +276,3 @@ pub fn bootstrap_requests_to_keys_query_response(
283276

284277
ruma_response_from_json(&kq_response)
285278
}
286-
287-
/// Encrypt and send a given to device event from the sender to the recipient.
288-
///
289-
/// Simulates the reception by having the recipient machine receiving a sync
290-
/// with the encrypted message.
291-
/// Returns the event as received by the recipient.
292-
pub async fn encrypt_to_device_helper(
293-
sender: &OlmMachine,
294-
recipient: &OlmMachine,
295-
event_type: &str,
296-
event_content: Value,
297-
) -> ProcessedToDeviceEvent {
298-
let device =
299-
sender.get_device(recipient.user_id(), recipient.device_id(), None).await.unwrap().unwrap();
300-
let raw_encrypted = device
301-
.encrypt_event_raw(event_type, &event_content)
302-
.await
303-
.expect("Should have encrypted the content");
304-
305-
let request = ToDeviceRequest::new(
306-
recipient.user_id(),
307-
DeviceIdOrAllDevices::DeviceId(recipient.device_id().to_owned()),
308-
"m.room.encrypted",
309-
raw_encrypted.cast(),
310-
);
311-
312-
let encrypted_event = ToDeviceEvent::new(
313-
sender.user_id().to_owned(),
314-
tests::to_device_requests_to_content(vec![request.clone().into()]),
315-
);
316-
317-
let encrypted_event = json_convert(&encrypted_event).unwrap();
318-
319-
let sync_changes = EncryptionSyncChanges {
320-
to_device_events: vec![encrypted_event],
321-
changed_devices: &Default::default(),
322-
one_time_keys_counts: &Default::default(),
323-
unused_fallback_keys: None,
324-
next_batch_token: None,
325-
};
326-
327-
let (to_devices, _) = recipient
328-
.receive_sync_changes(sync_changes)
329-
.await
330-
.expect("Receive Sync changes should not fail");
331-
332-
to_devices.first().unwrap().clone()
333-
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ use crate::{
8282
mod decryption_verification_state;
8383
mod interactive_verification;
8484
mod megolm_sender_data;
85-
mod olm_decryption_encryption_info;
8685
mod olm_encryption;
8786
mod room_settings;
8887
mod send_encrypted_to_device;

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

Lines changed: 0 additions & 149 deletions
This file was deleted.

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

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
// limitations under the License.
1414

1515
use assert_matches2::{assert_let, assert_matches};
16-
use matrix_sdk_common::deserialized_responses::{
17-
AlgorithmInfo, ProcessedToDeviceEvent, VerificationLevel, VerificationState,
18-
};
16+
use matrix_sdk_common::deserialized_responses::ProcessedToDeviceEvent;
1917
use matrix_sdk_test::async_test;
2018
use ruma::{events::AnyToDeviceEvent, serde::Raw, to_device::DeviceIdOrAllDevices};
2119
use serde_json::{json, value::to_raw_value};
@@ -210,23 +208,7 @@ async fn test_processed_to_device_variants() {
210208
assert_eq!(4, processed.len());
211209

212210
let processed_event = &processed[0];
213-
214-
assert_let!(ProcessedToDeviceEvent::Decrypted { encryption_info, .. } = processed_event);
215-
216-
assert_eq!(alice.user_id().to_owned(), encryption_info.sender);
217-
assert_eq!(Some(alice.device_id().to_owned()), encryption_info.sender_device);
218-
219-
assert_let!(
220-
AlgorithmInfo::OlmV1Curve25519AesSha2 { curve25519_key } = &encryption_info.algorithm_info
221-
);
222-
223-
assert_eq!(curve25519_key.to_owned(), alice_curve.to_base64());
224-
225-
assert_eq!(encryption_info.session_id, None);
226-
assert_eq!(
227-
encryption_info.verification_state,
228-
VerificationState::Unverified(VerificationLevel::UnsignedDevice)
229-
);
211+
assert_matches!(processed_event, ProcessedToDeviceEvent::Decrypted { .. });
230212

231213
let processed_event = &processed[1];
232214
assert_matches!(processed_event, ProcessedToDeviceEvent::PlainText(_));

0 commit comments

Comments
 (0)