diff --git a/src/olm/account/mod.rs b/src/olm/account/mod.rs index 6c22c7f6..2dd00bce 100644 --- a/src/olm/account/mod.rs +++ b/src/olm/account/mod.rs @@ -806,6 +806,7 @@ mod dehydrated_device { #[derive(Encode, Decode, Zeroize, ZeroizeOnDrop)] pub(crate) struct OneTimeKey { + #[secret] pub(crate) private_key: Box<[u8; 32]>, } @@ -872,7 +873,9 @@ mod dehydrated_device { /// [MSC3814](https://github.com/matrix-org/matrix-spec-proposals/pull/3814). pub(super) struct Pickle { version: u32, + #[secret] private_curve25519_key: Box<[u8; 32]>, + #[secret] private_ed25519_key: Box<[u8; 32]>, one_time_keys: Vec, opt_fallback_key: OptFallbackKey, @@ -1459,7 +1462,7 @@ mod test { } #[test] - fn decrypt_with_dehydrated_device() -> Result<()> { + fn decrypt_with_dehydrated_device() { let mut alice = Account::new(); let bob = Account::new(); let carol = Account::new(); @@ -1478,7 +1481,7 @@ mod test { .one_time_keys() .iter() .next() - .context("Failed getting alice's OTK, which should never happen here.")? + .expect("Failed getting alice's OTK, which should never happen here.") .1, ); @@ -1490,7 +1493,7 @@ mod test { .fallback_key() .iter() .next() - .context("Failed getting alice's fallback key, which should never happen here.")? + .expect("Failed getting alice's fallback key, which should never happen here.") .1, ); @@ -1507,23 +1510,25 @@ mod test { // make sure we can decrypt both messages let prekey_message = assert_matches!(bob_olm_message, OlmMessage::PreKey(m) => m); - let InboundCreationResult { session: alice_session, plaintext } = - alice_rehydrated.create_inbound_session(bob.curve25519_key(), &prekey_message)?; + let InboundCreationResult { session: alice_session, plaintext } = alice_rehydrated + .create_inbound_session(bob.curve25519_key(), &prekey_message) + .expect("Alice should be able to create an inbound session from Bob's pre-key message"); assert_eq!(alice_session.session_id(), bob_session.session_id()); assert_eq!(message.as_bytes(), plaintext); let prekey_message = assert_matches!(carol_olm_message, OlmMessage::PreKey(m) => m); - let InboundCreationResult { session: alice_session, plaintext } = - alice_rehydrated.create_inbound_session(carol.curve25519_key(), &prekey_message)?; + let InboundCreationResult { session: alice_session, plaintext } = alice_rehydrated + .create_inbound_session(carol.curve25519_key(), &prekey_message) + .expect( + "Alice should be able to create an inbound session from Carol's pre-key message", + ); assert_eq!(alice_session.session_id(), carol_session.session_id()); assert_eq!(message.as_bytes(), plaintext); - - Ok(()) } #[test] - fn fails_to_rehydrate_with_wrong_key() -> Result<()> { + fn fails_to_rehydrate_with_wrong_key() { let mut alice = Account::new(); alice.generate_one_time_keys(alice.max_number_of_one_time_keys()); @@ -1531,6 +1536,7 @@ mod test { let alice_dehydrated_result = alice.to_dehydrated_device(&PICKLE_KEY).expect("Should be able to dehydrate device"); + assert!(Account::from_dehydrated_device( &alice_dehydrated_result.ciphertext, &alice_dehydrated_result.nonce, @@ -1544,8 +1550,6 @@ mod test { &PICKLE_KEY, ) .is_err()); - - Ok(()) } #[derive(Encode, Decode)] @@ -1555,7 +1559,7 @@ mod test { } #[test] - fn encodes_optional_fallback_key() -> Result<()> { + fn encodes_optional_fallback_key() { use std::io::Cursor; let data_to_pickle = OptFallbackPickleTest { @@ -1578,8 +1582,6 @@ mod test { assert!(unpickled_data.fallback1.fallback_key.is_some()); assert!(unpickled_data.fallback2.fallback_key.is_none()); - - Ok(()) } #[test]