mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
refactor: remove {vc-contact-confirm,vg-member-added}-received steps
This commit is contained in:
@@ -515,12 +515,8 @@ pub(crate) async fn handle_securejoin_handshake(
|
|||||||
}
|
}
|
||||||
|
|
||||||
"vg-member-added-received" | "vc-contact-confirm-received" => {
|
"vg-member-added-received" | "vc-contact-confirm-received" => {
|
||||||
/*==========================================================
|
// Deprecated steps, delete them immediately.
|
||||||
==== Alice - the inviter side ====
|
Ok(HandshakeMessage::Done)
|
||||||
==== Step 8 in "Out-of-band verified groups" protocol ====
|
|
||||||
==========================================================*/
|
|
||||||
|
|
||||||
Ok(HandshakeMessage::Done) // "Done" deletes the message
|
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
warn!(context, "invalid step: {}", step);
|
warn!(context, "invalid step: {}", step);
|
||||||
@@ -541,10 +537,10 @@ pub(crate) async fn handle_securejoin_handshake(
|
|||||||
/// before sending vg-member-added/vc-contact-confirm - so, if we observe vg-member-added/vc-contact-confirm,
|
/// before sending vg-member-added/vc-contact-confirm - so, if we observe vg-member-added/vc-contact-confirm,
|
||||||
/// we can mark the peer as verified as well.
|
/// we can mark the peer as verified as well.
|
||||||
///
|
///
|
||||||
/// - if we see the self-sent-message vg-member-added-received
|
/// - if we see the self-sent-message vg-request-with-auth/vc-request-with-auth
|
||||||
/// we know that we're an joiner-observer.
|
/// we know that we're an joiner-observer.
|
||||||
/// the joining device has marked the peer as verified on vg-member-added/vc-contact-confirm
|
/// the joining device has marked the peer as verified
|
||||||
/// before sending vg-member-added-received - so, if we observe vg-member-added-received,
|
/// before sending vg-request-with-auth/vc-request-with-auth - so, if we observe vg-member-added-received,
|
||||||
/// we can mark the peer as verified as well.
|
/// we can mark the peer as verified as well.
|
||||||
pub(crate) async fn observe_securejoin_on_other_device(
|
pub(crate) async fn observe_securejoin_on_other_device(
|
||||||
context: &Context,
|
context: &Context,
|
||||||
@@ -563,9 +559,7 @@ pub(crate) async fn observe_securejoin_on_other_device(
|
|||||||
"vg-request-with-auth"
|
"vg-request-with-auth"
|
||||||
| "vc-request-with-auth"
|
| "vc-request-with-auth"
|
||||||
| "vg-member-added"
|
| "vg-member-added"
|
||||||
| "vc-contact-confirm"
|
| "vc-contact-confirm" => {
|
||||||
| "vg-member-added-received"
|
|
||||||
| "vc-contact-confirm-received" => {
|
|
||||||
if !encrypted_and_signed(
|
if !encrypted_and_signed(
|
||||||
context,
|
context,
|
||||||
mime_message,
|
mime_message,
|
||||||
@@ -941,12 +935,11 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(contact_bob.is_verified(&bob.ctx).await.unwrap(), false);
|
assert_eq!(contact_bob.is_verified(&bob.ctx).await.unwrap(), false);
|
||||||
|
|
||||||
// Step 7: Bob receives vc-contact-confirm, sends vc-contact-confirm-received
|
// Step 7: Bob receives vc-contact-confirm
|
||||||
bob.recv_msg(&sent).await;
|
bob.recv_msg(&sent).await;
|
||||||
assert_eq!(contact_alice.is_verified(&bob.ctx).await.unwrap(), true);
|
assert_eq!(contact_alice.is_verified(&bob.ctx).await.unwrap(), true);
|
||||||
|
|
||||||
// Check Bob got the verified message in his 1:1 chat.
|
// Check Bob got the verified message in his 1:1 chat.
|
||||||
{
|
|
||||||
let chat = bob.create_chat(&alice).await;
|
let chat = bob.create_chat(&alice).await;
|
||||||
let msg = get_chat_msg(&bob, chat.get_id(), 0, 1).await;
|
let msg = get_chat_msg(&bob, chat.get_id(), 0, 1).await;
|
||||||
assert!(msg.is_info());
|
assert!(msg.is_info());
|
||||||
@@ -954,16 +947,6 @@ mod tests {
|
|||||||
assert_eq!(msg.get_text(), expected_text);
|
assert_eq!(msg.get_text(), expected_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check Bob sent the final message
|
|
||||||
let sent = bob.pop_sent_msg().await;
|
|
||||||
let msg = alice.parse_msg(&sent).await;
|
|
||||||
assert!(msg.was_encrypted());
|
|
||||||
assert_eq!(
|
|
||||||
msg.get_header(HeaderDef::SecureJoin).unwrap(),
|
|
||||||
"vc-contact-confirm-received"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn test_setup_contact_bad_qr() {
|
async fn test_setup_contact_bad_qr() {
|
||||||
let bob = TestContext::new_bob().await;
|
let bob = TestContext::new_bob().await;
|
||||||
@@ -1073,17 +1056,10 @@ mod tests {
|
|||||||
let contact_alice = Contact::get_by_id(&bob.ctx, contact_alice_id).await?;
|
let contact_alice = Contact::get_by_id(&bob.ctx, contact_alice_id).await?;
|
||||||
assert_eq!(contact_bob.is_verified(&bob.ctx).await?, false);
|
assert_eq!(contact_bob.is_verified(&bob.ctx).await?, false);
|
||||||
|
|
||||||
// Step 7: Bob receives vc-contact-confirm, sends vc-contact-confirm-received
|
// Step 7: Bob receives vc-contact-confirm
|
||||||
bob.recv_msg(&sent).await;
|
bob.recv_msg(&sent).await;
|
||||||
assert_eq!(contact_alice.is_verified(&bob.ctx).await?, true);
|
assert_eq!(contact_alice.is_verified(&bob.ctx).await?, true);
|
||||||
|
|
||||||
let sent = bob.pop_sent_msg().await;
|
|
||||||
let msg = alice.parse_msg(&sent).await;
|
|
||||||
assert!(msg.was_encrypted());
|
|
||||||
assert_eq!(
|
|
||||||
msg.get_header(HeaderDef::SecureJoin).unwrap(),
|
|
||||||
"vc-contact-confirm-received"
|
|
||||||
);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1248,7 +1224,7 @@ mod tests {
|
|||||||
let contact_alice = Contact::get_by_id(&bob.ctx, contact_alice_id).await?;
|
let contact_alice = Contact::get_by_id(&bob.ctx, contact_alice_id).await?;
|
||||||
assert_eq!(contact_bob.is_verified(&bob.ctx).await?, false);
|
assert_eq!(contact_bob.is_verified(&bob.ctx).await?, false);
|
||||||
|
|
||||||
// Step 7: Bob receives vg-member-added, sends vg-member-added-received
|
// Step 7: Bob receives vg-member-added
|
||||||
bob.recv_msg(&sent).await;
|
bob.recv_msg(&sent).await;
|
||||||
{
|
{
|
||||||
// Bob has Alice verified, message shows up in the group chat.
|
// Bob has Alice verified, message shows up in the group chat.
|
||||||
@@ -1268,14 +1244,6 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let sent = bob.pop_sent_msg().await;
|
|
||||||
let msg = alice.parse_msg(&sent).await;
|
|
||||||
assert!(msg.was_encrypted());
|
|
||||||
assert_eq!(
|
|
||||||
msg.get_header(HeaderDef::SecureJoin).unwrap(),
|
|
||||||
"vg-member-added-received"
|
|
||||||
);
|
|
||||||
|
|
||||||
let bob_chat = Chat::load_from_db(&bob.ctx, bob_chatid).await?;
|
let bob_chat = Chat::load_from_db(&bob.ctx, bob_chatid).await?;
|
||||||
assert!(bob_chat.is_protected());
|
assert!(bob_chat.is_protected());
|
||||||
assert!(bob_chat.typ == Chattype::Group);
|
assert!(bob_chat.typ == Chattype::Group);
|
||||||
|
|||||||
@@ -345,17 +345,6 @@ impl BobState {
|
|||||||
.await?;
|
.await?;
|
||||||
context.emit_event(EventType::ContactsChanged(None));
|
context.emit_event(EventType::ContactsChanged(None));
|
||||||
|
|
||||||
self.send_handshake_message(context, BobHandshakeMsg::ContactConfirmReceived)
|
|
||||||
.await
|
|
||||||
.map_err(|_| {
|
|
||||||
warn!(
|
|
||||||
context,
|
|
||||||
"Failed to send vc-contact-confirm-received/vg-member-added-received"
|
|
||||||
);
|
|
||||||
})
|
|
||||||
// This is not an error affecting the protocol outcome.
|
|
||||||
.ok();
|
|
||||||
|
|
||||||
self.update_next(&context.sql, SecureJoinStep::Completed)
|
self.update_next(&context.sql, SecureJoinStep::Completed)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(Some(BobHandshakeStage::Completed))
|
Ok(Some(BobHandshakeStage::Completed))
|
||||||
@@ -401,9 +390,6 @@ async fn send_handshake_message(
|
|||||||
msg.param.set(Param::Arg2, invite.authcode());
|
msg.param.set(Param::Arg2, invite.authcode());
|
||||||
msg.param.set_int(Param::GuaranteeE2ee, 1);
|
msg.param.set_int(Param::GuaranteeE2ee, 1);
|
||||||
}
|
}
|
||||||
BobHandshakeMsg::ContactConfirmReceived => {
|
|
||||||
msg.param.set_int(Param::GuaranteeE2ee, 1);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Sends our own fingerprint in the Secure-Join-Fingerprint header.
|
// Sends our own fingerprint in the Secure-Join-Fingerprint header.
|
||||||
@@ -425,8 +411,6 @@ enum BobHandshakeMsg {
|
|||||||
Request,
|
Request,
|
||||||
/// vc-request-with-auth or vg-request-with-auth
|
/// vc-request-with-auth or vg-request-with-auth
|
||||||
RequestWithAuth,
|
RequestWithAuth,
|
||||||
/// vc-contact-confirm-received or vg-member-added-received
|
|
||||||
ContactConfirmReceived,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BobHandshakeMsg {
|
impl BobHandshakeMsg {
|
||||||
@@ -454,10 +438,6 @@ impl BobHandshakeMsg {
|
|||||||
QrInvite::Contact { .. } => "vc-request-with-auth",
|
QrInvite::Contact { .. } => "vc-request-with-auth",
|
||||||
QrInvite::Group { .. } => "vg-request-with-auth",
|
QrInvite::Group { .. } => "vg-request-with-auth",
|
||||||
},
|
},
|
||||||
Self::ContactConfirmReceived => match invite {
|
|
||||||
QrInvite::Contact { .. } => "vc-contact-confirm-received",
|
|
||||||
QrInvite::Group { .. } => "vg-member-added-received",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user