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

@@ -21,7 +21,7 @@ fn test_basic_prekey() {
let original_message = "L'homme est condamné à être libre".as_bytes();
let (outgoing_message, outgoing_message_type) =
alice_store.encrypt(bob_name, original_message);
alice_store.encrypt(bob_name, alice_name, original_message);
assert_eq!(outgoing_message_type, CiphertextMessageType::PreKey);
let ptext = bob_store.decrypt(
@@ -33,7 +33,8 @@ fn test_basic_prekey() {
assert_eq!(&ptext, original_message);
let bobs_response = "Who watches the watchers?".as_bytes();
let (bob_outgoing, bob_outgoing_type) = bob_store.encrypt(alice_name, bobs_response);
let (bob_outgoing, bob_outgoing_type) =
bob_store.encrypt(alice_name, bob_name, bobs_response);
assert_eq!(bob_outgoing_type, CiphertextMessageType::Whisper);
let alice_decrypts =
@@ -52,7 +53,8 @@ fn run_interaction(
) {
let alice_ptext = b"It's rabbit season";
let (alice_message, alice_message_type) = alice_store.encrypt(bob_name, alice_ptext);
let (alice_message, alice_message_type) =
alice_store.encrypt(bob_name, alice_name, alice_ptext);
assert_eq!(alice_message_type, CiphertextMessageType::Whisper);
assert_eq!(
&bob_store.decrypt(alice_name, bob_name, &alice_message, alice_message_type),
@@ -61,7 +63,7 @@ fn run_interaction(
let bob_ptext = b"It's duck season";
let (bob_message, bob_message_type) = bob_store.encrypt(alice_name, bob_ptext);
let (bob_message, bob_message_type) = bob_store.encrypt(alice_name, bob_name, bob_ptext);
assert_eq!(bob_message_type, CiphertextMessageType::Whisper);
assert_eq!(
&alice_store.decrypt(bob_name, alice_name, &bob_message, bob_message_type),
@@ -71,7 +73,7 @@ fn run_interaction(
for i in 0..10 {
let alice_ptext = format!("A->B message {}", i);
let (alice_message, alice_message_type) =
alice_store.encrypt(bob_name, alice_ptext.as_bytes());
alice_store.encrypt(bob_name, alice_name, alice_ptext.as_bytes());
assert_eq!(alice_message_type, CiphertextMessageType::Whisper);
assert_eq!(
&bob_store.decrypt(alice_name, bob_name, &alice_message, alice_message_type),
@@ -81,7 +83,8 @@ fn run_interaction(
for i in 0..10 {
let bob_ptext = format!("B->A message {}", i);
let (bob_message, bob_message_type) = bob_store.encrypt(alice_name, bob_ptext.as_bytes());
let (bob_message, bob_message_type) =
bob_store.encrypt(alice_name, bob_name, bob_ptext.as_bytes());
assert_eq!(bob_message_type, CiphertextMessageType::Whisper);
assert_eq!(
&alice_store.decrypt(bob_name, alice_name, &bob_message, bob_message_type),
@@ -93,13 +96,13 @@ fn run_interaction(
for i in 0..10 {
let alice_ptext = format!("A->B OOO message {}", i);
let (alice_message, _) = alice_store.encrypt(bob_name, alice_ptext.as_bytes());
let (alice_message, _) = alice_store.encrypt(bob_name, alice_name, alice_ptext.as_bytes());
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, _) = alice_store.encrypt(bob_name, alice_ptext.as_bytes());
let (alice_message, _) = alice_store.encrypt(bob_name, alice_name, alice_ptext.as_bytes());
assert_eq!(
&bob_store.decrypt(
alice_name,
@@ -113,7 +116,7 @@ fn run_interaction(
for i in 0..10 {
let bob_ptext = format!("B->A message post-OOO {}", i);
let (bob_message, _) = bob_store.encrypt(alice_name, bob_ptext.as_bytes());
let (bob_message, _) = bob_store.encrypt(alice_name, bob_name, bob_ptext.as_bytes());
assert_eq!(
&alice_store.decrypt(
bob_name,