Skip to content

Commit 8414465

Browse files
committed
refactor: remove {vc-contact-confirm,vg-member-added}-received steps
1 parent 1394137 commit 8414465

File tree

2 files changed

+14
-66
lines changed

2 files changed

+14
-66
lines changed

src/securejoin.rs

+14-46
Original file line numberDiff line numberDiff line change
@@ -515,12 +515,8 @@ pub(crate) async fn handle_securejoin_handshake(
515515
}
516516

517517
"vg-member-added-received" | "vc-contact-confirm-received" => {
518-
/*==========================================================
519-
==== Alice - the inviter side ====
520-
==== Step 8 in "Out-of-band verified groups" protocol ====
521-
==========================================================*/
522-
523-
Ok(HandshakeMessage::Done) // "Done" deletes the message
518+
// Deprecated steps, delete them immediately.
519+
Ok(HandshakeMessage::Done)
524520
}
525521
_ => {
526522
warn!(context, "invalid step: {}", step);
@@ -541,10 +537,10 @@ pub(crate) async fn handle_securejoin_handshake(
541537
/// before sending vg-member-added/vc-contact-confirm - so, if we observe vg-member-added/vc-contact-confirm,
542538
/// we can mark the peer as verified as well.
543539
///
544-
/// - if we see the self-sent-message vg-member-added-received
540+
/// - if we see the self-sent-message vg-request-with-auth/vc-request-with-auth
545541
/// we know that we're an joiner-observer.
546-
/// the joining device has marked the peer as verified on vg-member-added/vc-contact-confirm
547-
/// before sending vg-member-added-received - so, if we observe vg-member-added-received,
542+
/// the joining device has marked the peer as verified
543+
/// before sending vg-request-with-auth/vc-request-with-auth - so, if we observe vg-member-added-received,
548544
/// we can mark the peer as verified as well.
549545
pub(crate) async fn observe_securejoin_on_other_device(
550546
context: &Context,
@@ -563,9 +559,7 @@ pub(crate) async fn observe_securejoin_on_other_device(
563559
"vg-request-with-auth"
564560
| "vc-request-with-auth"
565561
| "vg-member-added"
566-
| "vc-contact-confirm"
567-
| "vg-member-added-received"
568-
| "vc-contact-confirm-received" => {
562+
| "vc-contact-confirm" => {
569563
if !encrypted_and_signed(
570564
context,
571565
mime_message,
@@ -941,27 +935,16 @@ mod tests {
941935
.unwrap();
942936
assert_eq!(contact_bob.is_verified(&bob.ctx).await.unwrap(), false);
943937

944-
// Step 7: Bob receives vc-contact-confirm, sends vc-contact-confirm-received
938+
// Step 7: Bob receives vc-contact-confirm
945939
bob.recv_msg(&sent).await;
946940
assert_eq!(contact_alice.is_verified(&bob.ctx).await.unwrap(), true);
947941

948942
// Check Bob got the verified message in his 1:1 chat.
949-
{
950-
let chat = bob.create_chat(&alice).await;
951-
let msg = get_chat_msg(&bob, chat.get_id(), 0, 1).await;
952-
assert!(msg.is_info());
953-
let expected_text = chat_protection_enabled(&bob).await;
954-
assert_eq!(msg.get_text(), expected_text);
955-
}
956-
957-
// Check Bob sent the final message
958-
let sent = bob.pop_sent_msg().await;
959-
let msg = alice.parse_msg(&sent).await;
960-
assert!(msg.was_encrypted());
961-
assert_eq!(
962-
msg.get_header(HeaderDef::SecureJoin).unwrap(),
963-
"vc-contact-confirm-received"
964-
);
943+
let chat = bob.create_chat(&alice).await;
944+
let msg = get_chat_msg(&bob, chat.get_id(), 0, 1).await;
945+
assert!(msg.is_info());
946+
let expected_text = chat_protection_enabled(&bob).await;
947+
assert_eq!(msg.get_text(), expected_text);
965948
}
966949

967950
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
@@ -1073,17 +1056,10 @@ mod tests {
10731056
let contact_alice = Contact::get_by_id(&bob.ctx, contact_alice_id).await?;
10741057
assert_eq!(contact_bob.is_verified(&bob.ctx).await?, false);
10751058

1076-
// Step 7: Bob receives vc-contact-confirm, sends vc-contact-confirm-received
1059+
// Step 7: Bob receives vc-contact-confirm
10771060
bob.recv_msg(&sent).await;
10781061
assert_eq!(contact_alice.is_verified(&bob.ctx).await?, true);
10791062

1080-
let sent = bob.pop_sent_msg().await;
1081-
let msg = alice.parse_msg(&sent).await;
1082-
assert!(msg.was_encrypted());
1083-
assert_eq!(
1084-
msg.get_header(HeaderDef::SecureJoin).unwrap(),
1085-
"vc-contact-confirm-received"
1086-
);
10871063
Ok(())
10881064
}
10891065

@@ -1248,7 +1224,7 @@ mod tests {
12481224
let contact_alice = Contact::get_by_id(&bob.ctx, contact_alice_id).await?;
12491225
assert_eq!(contact_bob.is_verified(&bob.ctx).await?, false);
12501226

1251-
// Step 7: Bob receives vg-member-added, sends vg-member-added-received
1227+
// Step 7: Bob receives vg-member-added
12521228
bob.recv_msg(&sent).await;
12531229
{
12541230
// Bob has Alice verified, message shows up in the group chat.
@@ -1268,14 +1244,6 @@ mod tests {
12681244
}
12691245
}
12701246

1271-
let sent = bob.pop_sent_msg().await;
1272-
let msg = alice.parse_msg(&sent).await;
1273-
assert!(msg.was_encrypted());
1274-
assert_eq!(
1275-
msg.get_header(HeaderDef::SecureJoin).unwrap(),
1276-
"vg-member-added-received"
1277-
);
1278-
12791247
let bob_chat = Chat::load_from_db(&bob.ctx, bob_chatid).await?;
12801248
assert!(bob_chat.is_protected());
12811249
assert!(bob_chat.typ == Chattype::Group);

src/securejoin/bobstate.rs

-20
Original file line numberDiff line numberDiff line change
@@ -345,17 +345,6 @@ impl BobState {
345345
.await?;
346346
context.emit_event(EventType::ContactsChanged(None));
347347

348-
self.send_handshake_message(context, BobHandshakeMsg::ContactConfirmReceived)
349-
.await
350-
.map_err(|_| {
351-
warn!(
352-
context,
353-
"Failed to send vc-contact-confirm-received/vg-member-added-received"
354-
);
355-
})
356-
// This is not an error affecting the protocol outcome.
357-
.ok();
358-
359348
self.update_next(&context.sql, SecureJoinStep::Completed)
360349
.await?;
361350
Ok(Some(BobHandshakeStage::Completed))
@@ -401,9 +390,6 @@ async fn send_handshake_message(
401390
msg.param.set(Param::Arg2, invite.authcode());
402391
msg.param.set_int(Param::GuaranteeE2ee, 1);
403392
}
404-
BobHandshakeMsg::ContactConfirmReceived => {
405-
msg.param.set_int(Param::GuaranteeE2ee, 1);
406-
}
407393
};
408394

409395
// Sends our own fingerprint in the Secure-Join-Fingerprint header.
@@ -425,8 +411,6 @@ enum BobHandshakeMsg {
425411
Request,
426412
/// vc-request-with-auth or vg-request-with-auth
427413
RequestWithAuth,
428-
/// vc-contact-confirm-received or vg-member-added-received
429-
ContactConfirmReceived,
430414
}
431415

432416
impl BobHandshakeMsg {
@@ -454,10 +438,6 @@ impl BobHandshakeMsg {
454438
QrInvite::Contact { .. } => "vc-request-with-auth",
455439
QrInvite::Group { .. } => "vg-request-with-auth",
456440
},
457-
Self::ContactConfirmReceived => match invite {
458-
QrInvite::Contact { .. } => "vc-contact-confirm-received",
459-
QrInvite::Group { .. } => "vg-member-added-received",
460-
},
461441
}
462442
}
463443
}

0 commit comments

Comments
 (0)