MAC sender ID

This commit is contained in:
Rolfe Schmidt
2026-04-01 10:22:54 -07:00
committed by GitHub
parent 3d4e950848
commit 81afdfe2fa
30 changed files with 603 additions and 275 deletions

View File

@@ -77,7 +77,7 @@ fn test_basic_prekey() -> TestResult {
let original_message = "L'homme est condamné à être libre";
let outgoing_message = encrypt(alice_store, &bob_address, original_message).await?;
let outgoing_message = encrypt(alice_store, &bob_address, &alice_address, original_message).await?;
assert_eq!(
outgoing_message.message_type(),
@@ -127,7 +127,7 @@ fn test_basic_prekey() -> TestResult {
assert_eq!(bobs_session_with_alice.alice_base_key()?.len(), 32 + 1);
let bob_outgoing =
encrypt(&mut bob_store_builder.store, &alice_address, bobs_response).await?;
encrypt(&mut bob_store_builder.store, &alice_address, &bob_address, bobs_response).await?;
assert_eq!(bob_outgoing.message_type(), CiphertextMessageType::Whisper);
@@ -170,7 +170,8 @@ fn test_basic_prekey() -> TestResult {
.await?;
let outgoing_message =
encrypt(&mut alter_alice_store, &bob_address, original_message).await?;
encrypt(&mut alter_alice_store, &bob_address, &alice_address, original_message)
.await?;
assert!(matches!(
decrypt(&mut bob_store_builder.store, &alice_address, &bob_address, &outgoing_message)
@@ -280,11 +281,22 @@ fn test_chain_jump_over_limit() -> TestResult {
pub const MAX_FORWARD_JUMPS: usize = 25_000;
for _i in 0..(MAX_FORWARD_JUMPS + 1) {
let _msg =
encrypt(alice_store, &bob_address, "Yet another message for you").await?;
let _msg = encrypt(
alice_store,
&bob_address,
&alice_address,
"Yet another message for you",
)
.await?;
}
let too_far = encrypt(alice_store, &bob_address, "Now you have gone too far").await?;
let too_far = encrypt(
alice_store,
&bob_address,
&alice_address,
"Now you have gone too far",
)
.await?;
assert!(
decrypt(
@@ -345,12 +357,22 @@ fn test_chain_jump_over_limit_with_self() -> TestResult {
pub const MAX_FORWARD_JUMPS: usize = 25_000;
for _i in 0..(MAX_FORWARD_JUMPS + 1) {
let _msg =
encrypt(a1_store, &a2_address, "Yet another message for yourself").await?;
let _msg = encrypt(
a1_store,
&a2_address,
&a1_address,
"Yet another message for yourself",
)
.await?;
}
let too_far =
encrypt(a1_store, &a2_address, "This is the song that never ends").await?;
let too_far = encrypt(
a1_store,
&a2_address,
&a1_address,
"This is the song that never ends",
)
.await?;
let ptext = decrypt(
&mut a2_store_builder.store,
@@ -484,8 +506,10 @@ fn test_repeat_bundle_message() -> TestResult {
let original_message = "L'homme est condamné à être libre";
let outgoing_message1 = encrypt(alice_store, &bob_address, original_message).await?;
let outgoing_message2 = encrypt(alice_store, &bob_address, original_message).await?;
let outgoing_message1 =
encrypt(alice_store, &bob_address, &alice_address, original_message).await?;
let outgoing_message2 =
encrypt(alice_store, &bob_address, &alice_address, original_message).await?;
assert_eq!(
outgoing_message1.message_type(),
@@ -515,6 +539,7 @@ fn test_repeat_bundle_message() -> TestResult {
let bob_outgoing = encrypt(
&mut bob_store_builder.store,
&alice_address,
&bob_address,
original_message,
)
.await?;
@@ -547,6 +572,7 @@ fn test_repeat_bundle_message() -> TestResult {
let bob_outgoing = encrypt(
&mut bob_store_builder.store,
&alice_address,
&bob_address,
original_message,
)
.await?;
@@ -618,7 +644,8 @@ fn test_bad_message_bundle() -> TestResult {
let original_message = "L'homme est condamné à être libre";
assert!(bob_store.get_pre_key(pre_key_id).await.is_ok());
let outgoing_message = encrypt(alice_store, &bob_address, original_message).await?;
let outgoing_message =
encrypt(alice_store, &bob_address, &alice_address, original_message).await?;
assert_eq!(
outgoing_message.message_type(),
@@ -711,7 +738,8 @@ fn test_optional_one_time_prekey() -> TestResult {
let original_message = "L'homme est condamné à être libre";
let outgoing_message = encrypt(alice_store, &bob_address, original_message).await?;
let outgoing_message =
encrypt(alice_store, &bob_address, &alice_address, original_message).await?;
assert_eq!(
outgoing_message.message_type(),
@@ -781,7 +809,13 @@ fn test_message_key_limits() -> TestResult {
for i in 0..TOO_MANY_MESSAGES {
inflight.push(
encrypt(&mut alice_store, &bob_address, &format!("It's over {i}")).await?,
encrypt(
&mut alice_store,
&bob_address,
&alice_address,
&format!("It's over {i}"),
)
.await?,
);
}
@@ -885,8 +919,10 @@ fn test_basic_simultaneous_initiate() -> TestResult {
)
.await?;
let message_for_bob = encrypt(alice_store, &bob_address, "hi bob").await?;
let message_for_alice = encrypt(bob_store, &alice_address, "hi alice").await?;
let message_for_bob =
encrypt(alice_store, &bob_address, &alice_address, "hi bob").await?;
let message_for_alice =
encrypt(bob_store, &alice_address, &bob_address, "hi alice").await?;
assert_eq!(
message_for_bob.message_type(),
@@ -942,7 +978,8 @@ fn test_basic_simultaneous_initiate() -> TestResult {
!is_session_id_equal(alice_store, &alice_address, bob_store, &bob_address).await?
);
let alice_response = encrypt(alice_store, &bob_address, "nice to see you").await?;
let alice_response =
encrypt(alice_store, &bob_address, &alice_address, "nice to see you").await?;
assert_eq!(
alice_response.message_type(),
@@ -967,7 +1004,8 @@ fn test_basic_simultaneous_initiate() -> TestResult {
is_session_id_equal(alice_store, &alice_address, bob_store, &bob_address).await?
);
let bob_response = encrypt(bob_store, &alice_address, "you as well").await?;
let bob_response =
encrypt(bob_store, &alice_address, &bob_address, "you as well").await?;
assert_eq!(bob_response.message_type(), CiphertextMessageType::Whisper);
@@ -1055,8 +1093,10 @@ fn test_simultaneous_initiate_with_lossage() -> TestResult {
)
.await?;
let message_for_bob = encrypt(alice_store, &bob_address, "hi bob").await?;
let message_for_alice = encrypt(bob_store, &alice_address, "hi alice").await?;
let message_for_bob =
encrypt(alice_store, &bob_address, &alice_address, "hi bob").await?;
let message_for_alice =
encrypt(bob_store, &alice_address, &bob_address, "hi alice").await?;
assert_eq!(
message_for_bob.message_type(),
@@ -1094,7 +1134,8 @@ fn test_simultaneous_initiate_with_lossage() -> TestResult {
expected_session_version
);
let alice_response = encrypt(alice_store, &bob_address, "nice to see you").await?;
let alice_response =
encrypt(alice_store, &bob_address, &alice_address, "nice to see you").await?;
assert_eq!(alice_response.message_type(), CiphertextMessageType::PreKey);
@@ -1116,7 +1157,8 @@ fn test_simultaneous_initiate_with_lossage() -> TestResult {
is_session_id_equal(alice_store, &alice_address, bob_store, &bob_address).await?
);
let bob_response = encrypt(bob_store, &alice_address, "you as well").await?;
let bob_response =
encrypt(bob_store, &alice_address, &bob_address, "you as well").await?;
assert_eq!(bob_response.message_type(), CiphertextMessageType::Whisper);
@@ -1204,8 +1246,10 @@ fn test_simultaneous_initiate_lost_message() -> TestResult {
)
.await?;
let message_for_bob = encrypt(alice_store, &bob_address, "hi bob").await?;
let message_for_alice = encrypt(bob_store, &alice_address, "hi alice").await?;
let message_for_bob =
encrypt(alice_store, &bob_address, &alice_address, "hi bob").await?;
let message_for_alice =
encrypt(bob_store, &alice_address, &bob_address, "hi alice").await?;
assert_eq!(
message_for_bob.message_type(),
@@ -1261,7 +1305,8 @@ fn test_simultaneous_initiate_lost_message() -> TestResult {
!is_session_id_equal(alice_store, &alice_address, bob_store, &bob_address).await?
);
let alice_response = encrypt(alice_store, &bob_address, "nice to see you").await?;
let alice_response =
encrypt(alice_store, &bob_address, &alice_address, "nice to see you").await?;
assert_eq!(
alice_response.message_type(),
@@ -1272,7 +1317,8 @@ fn test_simultaneous_initiate_lost_message() -> TestResult {
!is_session_id_equal(alice_store, &alice_address, bob_store, &bob_address).await?
);
let bob_response = encrypt(bob_store, &alice_address, "you as well").await?;
let bob_response =
encrypt(bob_store, &alice_address, &bob_address, "you as well").await?;
assert_eq!(bob_response.message_type(), CiphertextMessageType::Whisper);
@@ -1358,10 +1404,20 @@ fn test_simultaneous_initiate_repeated_messages() -> TestResult {
)
.await?;
let message_for_bob =
encrypt(&mut alice_store_builder.store, &bob_address, "hi bob").await?;
let message_for_alice =
encrypt(&mut bob_store_builder.store, &alice_address, "hi alice").await?;
let message_for_bob = encrypt(
&mut alice_store_builder.store,
&bob_address,
&alice_address,
"hi bob",
)
.await?;
let message_for_alice = encrypt(
&mut bob_store_builder.store,
&alice_address,
&bob_address,
"hi alice",
)
.await?;
assert_eq!(
message_for_bob.message_type(),
@@ -1431,10 +1487,20 @@ fn test_simultaneous_initiate_repeated_messages() -> TestResult {
}
for _ in 0..50 {
let message_for_bob =
encrypt(&mut alice_store_builder.store, &bob_address, "hi bob").await?;
let message_for_alice =
encrypt(&mut bob_store_builder.store, &alice_address, "hi alice").await?;
let message_for_bob = encrypt(
&mut alice_store_builder.store,
&bob_address,
&alice_address,
"hi bob",
)
.await?;
let message_for_alice = encrypt(
&mut bob_store_builder.store,
&alice_address,
&bob_address,
"hi alice",
)
.await?;
assert_eq!(
message_for_bob.message_type(),
@@ -1506,6 +1572,7 @@ fn test_simultaneous_initiate_repeated_messages() -> TestResult {
let alice_response = encrypt(
&mut alice_store_builder.store,
&bob_address,
&alice_address,
"nice to see you",
)
.await?;
@@ -1525,8 +1592,13 @@ fn test_simultaneous_initiate_repeated_messages() -> TestResult {
.await?
);
let bob_response =
encrypt(&mut bob_store_builder.store, &alice_address, "you as well").await?;
let bob_response = encrypt(
&mut bob_store_builder.store,
&alice_address,
&bob_address,
"you as well",
)
.await?;
assert_eq!(bob_response.message_type(), CiphertextMessageType::Whisper);
@@ -1606,6 +1678,7 @@ fn test_simultaneous_initiate_lost_message_repeated_messages() -> TestResult {
let lost_message_for_bob = encrypt(
&mut alice_store_builder.store,
&bob_address,
&alice_address,
"it was so long ago",
)
.await?;
@@ -1639,10 +1712,20 @@ fn test_simultaneous_initiate_lost_message_repeated_messages() -> TestResult {
)
.await?;
let message_for_bob =
encrypt(&mut alice_store_builder.store, &bob_address, "hi bob").await?;
let message_for_alice =
encrypt(&mut bob_store_builder.store, &alice_address, "hi alice").await?;
let message_for_bob = encrypt(
&mut alice_store_builder.store,
&bob_address,
&alice_address,
"hi bob",
)
.await?;
let message_for_alice = encrypt(
&mut bob_store_builder.store,
&alice_address,
&bob_address,
"hi alice",
)
.await?;
assert_eq!(
message_for_bob.message_type(),
@@ -1712,10 +1795,20 @@ fn test_simultaneous_initiate_lost_message_repeated_messages() -> TestResult {
}
for _ in 0..50 {
let message_for_bob =
encrypt(&mut alice_store_builder.store, &bob_address, "hi bob").await?;
let message_for_alice =
encrypt(&mut bob_store_builder.store, &alice_address, "hi alice").await?;
let message_for_bob = encrypt(
&mut alice_store_builder.store,
&bob_address,
&alice_address,
"hi bob",
)
.await?;
let message_for_alice = encrypt(
&mut bob_store_builder.store,
&alice_address,
&bob_address,
"hi alice",
)
.await?;
assert_eq!(
message_for_bob.message_type(),
@@ -1787,6 +1880,7 @@ fn test_simultaneous_initiate_lost_message_repeated_messages() -> TestResult {
let alice_response = encrypt(
&mut alice_store_builder.store,
&bob_address,
&alice_address,
"nice to see you",
)
.await?;
@@ -1806,8 +1900,13 @@ fn test_simultaneous_initiate_lost_message_repeated_messages() -> TestResult {
.await?
);
let bob_response =
encrypt(&mut bob_store_builder.store, &alice_address, "you as well").await?;
let bob_response = encrypt(
&mut bob_store_builder.store,
&alice_address,
&bob_address,
"you as well",
)
.await?;
assert_eq!(bob_response.message_type(), CiphertextMessageType::Whisper);
@@ -1859,8 +1958,13 @@ fn test_simultaneous_initiate_lost_message_repeated_messages() -> TestResult {
.await?
);
let bob_response =
encrypt(&mut bob_store_builder.store, &alice_address, "so it was").await?;
let bob_response = encrypt(
&mut bob_store_builder.store,
&alice_address,
&bob_address,
"so it was",
)
.await?;
assert_eq!(bob_response.message_type(), CiphertextMessageType::Whisper);
@@ -1936,7 +2040,13 @@ fn test_zero_is_a_valid_prekey_id() -> TestResult {
let original_message = "L'homme est condamné à être libre";
let outgoing_message = encrypt(&mut alice_store, &bob_address, original_message).await?;
let outgoing_message = encrypt(
&mut alice_store,
&bob_address,
&alice_address,
original_message,
)
.await?;
assert_eq!(
outgoing_message.message_type(),
@@ -1972,6 +2082,8 @@ fn test_unacknowledged_sessions_eventually_expire() -> TestResult {
const WELL_PAST_EXPIRATION: Duration = Duration::from_secs(60 * 60 * 24 * 90);
let mut csprng = OsRng.unwrap_err();
let alice_address =
ProtocolAddress::new("+14151111111".to_owned(), DeviceId::new(1).unwrap());
let bob_address =
ProtocolAddress::new("+14151111112".to_owned(), DeviceId::new(1).unwrap());
@@ -2029,6 +2141,7 @@ fn test_unacknowledged_sessions_eventually_expire() -> TestResult {
let outgoing_message = message_encrypt(
original_message.as_bytes(),
&bob_address,
&alice_address,
&mut alice_store.session_store,
&mut alice_store.identity_store,
SystemTime::UNIX_EPOCH + Duration::from_secs(1),
@@ -2067,6 +2180,7 @@ fn test_unacknowledged_sessions_eventually_expire() -> TestResult {
let error = message_encrypt(
original_message.as_bytes(),
&bob_address,
&alice_address,
&mut alice_store.session_store,
&mut alice_store.identity_store,
SystemTime::UNIX_EPOCH + WELL_PAST_EXPIRATION,
@@ -2120,6 +2234,7 @@ fn prekey_message_failed_decryption_does_not_update_stores() -> TestResult {
let message = message_encrypt(
"from Bob".as_bytes(),
&alice_address,
&bob_address,
&mut bob_store.session_store,
&mut bob_store.identity_store,
SystemTime::UNIX_EPOCH,
@@ -2224,7 +2339,7 @@ fn prekey_message_failed_decryption_does_not_update_stores_even_when_previously_
.expect("can receive bundle");
// Bob sends a message that decrypts just fine.
let bob_ciphertext = encrypt(&mut bob_store, &alice_address, "from Bob")
let bob_ciphertext = encrypt(&mut bob_store, &alice_address, &bob_address, "from Bob")
.await
.expect("valid");
_ = decrypt(
@@ -2265,6 +2380,7 @@ fn prekey_message_failed_decryption_does_not_update_stores_even_when_previously_
let message = message_encrypt(
"from Bob".as_bytes(),
&alice_address,
&bob_address,
&mut bob_store.session_store,
&mut bob_store.identity_store,
SystemTime::now(),
@@ -2374,7 +2490,7 @@ fn prekey_message_to_archived_session() -> TestResult {
.await
.expect("can receive bundle");
let bob_ciphertext = encrypt(&mut bob_store, &alice_address, "from Bob")
let bob_ciphertext = encrypt(&mut bob_store, &alice_address, &bob_address, "from Bob")
.await
.expect("valid");
assert_eq!(bob_ciphertext.message_type(), CiphertextMessageType::PreKey);
@@ -2403,16 +2519,17 @@ fn prekey_message_to_archived_session() -> TestResult {
.expect("can receive bundle");
// (This is technically unnecessary, the process_prekey_bundle is sufficient, but it's illustrative.)
let unsent_alice_ciphertext = encrypt(&mut alice_store, &bob_address, "from Alice")
.await
.expect("valid");
let unsent_alice_ciphertext =
encrypt(&mut alice_store, &bob_address, &alice_address, "from Alice")
.await
.expect("valid");
assert_eq!(
unsent_alice_ciphertext.message_type(),
CiphertextMessageType::PreKey
);
// But before Alice can send the message, she gets a second message from Bob.
let bob_ciphertext_2 = encrypt(&mut bob_store, &alice_address, "from Bob 2")
let bob_ciphertext_2 = encrypt(&mut bob_store, &alice_address, &bob_address, "from Bob 2")
.await
.expect("valid");
assert_eq!(
@@ -2476,7 +2593,13 @@ fn run_session_interaction(alice_session: SessionRecord, bob_session: SessionRec
.await?;
let alice_plaintext = "This is Alice's message";
let alice_ciphertext = encrypt(&mut alice_store, &bob_address, alice_plaintext).await?;
let alice_ciphertext = encrypt(
&mut alice_store,
&bob_address,
&alice_address,
alice_plaintext,
)
.await?;
let bob_decrypted = decrypt(
&mut bob_store,
&alice_address,
@@ -2491,7 +2614,8 @@ fn run_session_interaction(alice_session: SessionRecord, bob_session: SessionRec
let bob_plaintext = "This is Bob's reply";
let bob_ciphertext = encrypt(&mut bob_store, &alice_address, bob_plaintext).await?;
let bob_ciphertext =
encrypt(&mut bob_store, &alice_address, &bob_address, bob_plaintext).await?;
let alice_decrypted = decrypt(
&mut alice_store,
&bob_address,
@@ -2511,7 +2635,7 @@ fn run_session_interaction(alice_session: SessionRecord, bob_session: SessionRec
for i in 0..ALICE_MESSAGE_COUNT {
let ptext = format!("смерть за смерть {i}");
let ctext = encrypt(&mut alice_store, &bob_address, &ptext).await?;
let ctext = encrypt(&mut alice_store, &bob_address, &alice_address, &ptext).await?;
alice_messages.push((ptext, ctext));
}
@@ -2537,7 +2661,7 @@ fn run_session_interaction(alice_session: SessionRecord, bob_session: SessionRec
for i in 0..BOB_MESSAGE_COUNT {
let ptext = format!("Relax in the safety of your own delusions. {i}");
let ctext = encrypt(&mut bob_store, &alice_address, &ptext).await?;
let ctext = encrypt(&mut bob_store, &alice_address, &bob_address, &ptext).await?;
bob_messages.push((ptext, ctext));
}
@@ -2599,7 +2723,7 @@ async fn run_interaction(
) -> TestResult {
let alice_ptext = "It's rabbit season";
let alice_message = encrypt(alice_store, bob_address, alice_ptext).await?;
let alice_message = encrypt(alice_store, bob_address, alice_address, alice_ptext).await?;
assert_eq!(alice_message.message_type(), CiphertextMessageType::Whisper);
assert_eq!(
String::from_utf8(decrypt(bob_store, alice_address, bob_address, &alice_message).await?)
@@ -2609,7 +2733,7 @@ async fn run_interaction(
let bob_ptext = "It's duck season";
let bob_message = encrypt(bob_store, alice_address, bob_ptext).await?;
let bob_message = encrypt(bob_store, alice_address, bob_address, bob_ptext).await?;
assert_eq!(bob_message.message_type(), CiphertextMessageType::Whisper);
assert_eq!(
String::from_utf8(decrypt(alice_store, bob_address, alice_address, &bob_message).await?)
@@ -2619,7 +2743,7 @@ async fn run_interaction(
for i in 0..10 {
let alice_ptext = format!("A->B message {i}");
let alice_message = encrypt(alice_store, bob_address, &alice_ptext).await?;
let alice_message = encrypt(alice_store, bob_address, alice_address, &alice_ptext).await?;
assert_eq!(alice_message.message_type(), CiphertextMessageType::Whisper);
assert_eq!(
String::from_utf8(
@@ -2632,7 +2756,7 @@ async fn run_interaction(
for i in 0..10 {
let bob_ptext = format!("B->A message {i}");
let bob_message = encrypt(bob_store, alice_address, &bob_ptext).await?;
let bob_message = encrypt(bob_store, alice_address, bob_address, &bob_ptext).await?;
assert_eq!(bob_message.message_type(), CiphertextMessageType::Whisper);
assert_eq!(
String::from_utf8(
@@ -2647,13 +2771,13 @@ async fn run_interaction(
for i in 0..10 {
let alice_ptext = format!("A->B OOO message {i}");
let alice_message = encrypt(alice_store, bob_address, &alice_ptext).await?;
let alice_message = encrypt(alice_store, bob_address, alice_address, &alice_ptext).await?;
alice_ooo_messages.push((alice_ptext, alice_message));
}
for i in 0..10 {
let alice_ptext = format!("A->B post-OOO message {i}");
let alice_message = encrypt(alice_store, bob_address, &alice_ptext).await?;
let alice_message = encrypt(alice_store, bob_address, alice_address, &alice_ptext).await?;
assert_eq!(alice_message.message_type(), CiphertextMessageType::Whisper);
assert_eq!(
String::from_utf8(
@@ -2666,7 +2790,7 @@ async fn run_interaction(
for i in 0..10 {
let bob_ptext = format!("B->A message post-OOO {i}");
let bob_message = encrypt(bob_store, alice_address, &bob_ptext).await?;
let bob_message = encrypt(bob_store, alice_address, bob_address, &bob_ptext).await?;
assert_eq!(bob_message.message_type(), CiphertextMessageType::Whisper);
assert_eq!(
String::from_utf8(
@@ -2739,11 +2863,13 @@ fn test_signedprekey_not_saved() -> TestResult {
let original_message = "L'homme est condamné à être libre";
// We encrypt a first message
let outgoing_message = encrypt(alice_store, &bob_address, original_message).await?;
let outgoing_message =
encrypt(alice_store, &bob_address, &alice_address, original_message).await?;
// We encrypt a second message
let original_message2 = "L'homme est condamné à nouveau à être libre";
let outgoing_message2 = encrypt(alice_store, &bob_address, original_message2).await?;
let outgoing_message2 =
encrypt(alice_store, &bob_address, &alice_address, original_message2).await?;
assert_eq!(
outgoing_message.message_type(),
@@ -2995,14 +3121,14 @@ fn test_longer_sessions() -> TestResult {
log::debug!("Send message to Alice");
to_alice.push_back((
false,
encrypt(bob_store, &alice_address, "wheee1").await?,
encrypt(bob_store, &alice_address, &bob_address, "wheee1").await?,
));
}
LongerSessionActions::BobSend => {
log::debug!("Send message to Bob");
to_bob.push_back((
false,
encrypt(alice_store, &bob_address, "wheee2").await?,
encrypt(alice_store, &bob_address, &alice_address, "wheee2").await?,
));
}
LongerSessionActions::AliceRecv => match to_alice.pop_front() {
@@ -3099,7 +3225,13 @@ fn test_duplicate_message_error_returned() -> TestResult {
)
.await?;
let msg = encrypt(alice_store, &bob_address, "this_will_be_a_dup").await?;
let msg = encrypt(
alice_store,
&bob_address,
&alice_address,
"this_will_be_a_dup",
)
.await?;
decrypt(bob_store, &alice_address, &bob_address, &msg).await?;
let err = decrypt(bob_store, &alice_address, &bob_address, &msg)
.await
@@ -3146,15 +3278,15 @@ fn test_pqr_state_and_message_contents_nonempty() -> TestResult {
)
.await?;
let msg = encrypt(alice_store, &bob_address, "msg1").await?;
let msg = encrypt(alice_store, &bob_address, &alice_address, "msg1").await?;
assert_matches!(&msg, CiphertextMessage::PreKeySignalMessage(m) if !m.message().pq_ratchet().is_empty());
decrypt(bob_store, &alice_address, &bob_address, &msg).await?;
let msg = encrypt(bob_store, &alice_address, "msg2").await?;
let msg = encrypt(bob_store, &alice_address, &bob_address, "msg2").await?;
assert_matches!(&msg, CiphertextMessage::SignalMessage(m) if !m.pq_ratchet().is_empty());
decrypt(alice_store, &bob_address, &alice_address, &msg).await?;
let msg = encrypt(alice_store, &bob_address, "msg3").await?;
let msg = encrypt(alice_store, &bob_address, &alice_address, "msg3").await?;
assert_matches!(&msg, CiphertextMessage::SignalMessage(m) if !m.pq_ratchet().is_empty());
assert!(!alice_store
@@ -3211,9 +3343,10 @@ fn x3dh_prekey_rejected_as_invalid_message_specifically() {
.await
.expect("valid");
let pre_key_message = support::encrypt(&mut alice_store, &bob_address, "bad")
.await
.expect("valid");
let pre_key_message =
support::encrypt(&mut alice_store, &bob_address, &alice_address, "bad")
.await
.expect("valid");
let mut bob_one_off_store = bob_store_builder.store.clone();
_ = support::decrypt(
@@ -3289,9 +3422,10 @@ fn x3dh_established_session_is_or_is_not_usable() {
.await
.expect("valid");
let pre_key_message = support::encrypt(&mut alice_store, &bob_address, "bad")
.await
.expect("valid");
let pre_key_message =
support::encrypt(&mut alice_store, &bob_address, &alice_address, "bad")
.await
.expect("valid");
let bob_store = &mut bob_store_builder.store;
_ = support::decrypt(bob_store, &alice_address, &bob_address, &pre_key_message)
@@ -3391,9 +3525,10 @@ fn prekey_message_sent_from_different_user_is_rejected() {
.await
.expect("valid");
let pre_key_message = support::encrypt(&mut alice_store, &bob_address, "bad")
.await
.expect("valid");
let pre_key_message =
support::encrypt(&mut alice_store, &bob_address, &alice_address, "bad")
.await
.expect("valid");
let bob_store = &mut bob_store_builder.store;
_ = support::decrypt(bob_store, &alice_address, &bob_address, &pre_key_message)
@@ -3463,9 +3598,10 @@ fn prekey_message_rejects_wrong_local_recipient_address() {
.await
.expect("valid");
let pre_key_message = support::encrypt(&mut alice_store, &bob_address, "hi bob")
.await
.expect("valid");
let pre_key_message =
support::encrypt(&mut alice_store, &bob_address, &alice_address, "hi bob")
.await
.expect("valid");
let err = support::decrypt(
&mut bob_store_builder.store,