mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 21:36:29 +03:00
feat: mark 1:1 chat as verified for Bob early
Mark 1:1 chat as verified as soon as Alice is forward-verified so Bob can already start sending Chat-Verified headers. This way Alice and Bob can scan each other's QR codes and even if all Secure-Join headers are dropped from the network, still get forward verifications via QR-code scans and backward verifications via Chat-Verified messages in 1:1 chat.
This commit is contained in:
@@ -495,9 +495,6 @@ pub(crate) async fn handle_securejoin_handshake(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bobstate.step_contact_confirm(context).await?;
|
bobstate.step_contact_confirm(context).await?;
|
||||||
bobstate
|
|
||||||
.notify_peer_verified(context, mime_message.timestamp_sent)
|
|
||||||
.await?;
|
|
||||||
bobstate.emit_progress(context, JoinerProgress::Succeeded);
|
bobstate.emit_progress(context, JoinerProgress::Succeeded);
|
||||||
}
|
}
|
||||||
Ok(HandshakeMessage::Ignore)
|
Ok(HandshakeMessage::Ignore)
|
||||||
@@ -527,9 +524,6 @@ pub(crate) async fn handle_securejoin_handshake(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bobstate.step_contact_confirm(context).await?;
|
bobstate.step_contact_confirm(context).await?;
|
||||||
bobstate
|
|
||||||
.notify_peer_verified(context, mime_message.timestamp_sent)
|
|
||||||
.await?;
|
|
||||||
bobstate.emit_progress(context, JoinerProgress::Succeeded);
|
bobstate.emit_progress(context, JoinerProgress::Succeeded);
|
||||||
}
|
}
|
||||||
Ok(HandshakeMessage::Propagate)
|
Ok(HandshakeMessage::Propagate)
|
||||||
|
|||||||
@@ -100,6 +100,9 @@ pub(super) async fn handle_auth_required(
|
|||||||
let chat_id = bobstate.joining_chat_id(context).await?;
|
let chat_id = bobstate.joining_chat_id(context).await?;
|
||||||
chat::add_info_msg(context, chat_id, &msg, time()).await?;
|
chat::add_info_msg(context, chat_id, &msg, time()).await?;
|
||||||
}
|
}
|
||||||
|
bobstate
|
||||||
|
.notify_peer_verified(context, message.timestamp_sent)
|
||||||
|
.await?;
|
||||||
bobstate.emit_progress(context, JoinerProgress::RequestWithAuthSent);
|
bobstate.emit_progress(context, JoinerProgress::RequestWithAuthSent);
|
||||||
Ok(HandshakeMessage::Done)
|
Ok(HandshakeMessage::Done)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ use crate::mimeparser::{MimeMessage, SystemMessage};
|
|||||||
use crate::param::Param;
|
use crate::param::Param;
|
||||||
use crate::securejoin::Peerstate;
|
use crate::securejoin::Peerstate;
|
||||||
use crate::sql::Sql;
|
use crate::sql::Sql;
|
||||||
|
use crate::tools::time;
|
||||||
|
|
||||||
/// The stage of the [`BobState`] securejoin handshake protocol state machine.
|
/// The stage of the [`BobState`] securejoin handshake protocol state machine.
|
||||||
///
|
///
|
||||||
@@ -89,22 +90,26 @@ impl BobState {
|
|||||||
invite: QrInvite,
|
invite: QrInvite,
|
||||||
chat_id: ChatId,
|
chat_id: ChatId,
|
||||||
) -> Result<(Self, BobHandshakeStage, Vec<Self>)> {
|
) -> Result<(Self, BobHandshakeStage, Vec<Self>)> {
|
||||||
let (stage, next) =
|
let peer_verified =
|
||||||
if verify_sender_by_fingerprint(context, invite.fingerprint(), invite.contact_id())
|
verify_sender_by_fingerprint(context, invite.fingerprint(), invite.contact_id())
|
||||||
.await?
|
.await?;
|
||||||
{
|
|
||||||
// The scanned fingerprint matches Alice's key, we can proceed to step 4b.
|
let (stage, next);
|
||||||
info!(context, "Taking securejoin protocol shortcut");
|
if peer_verified {
|
||||||
send_handshake_message(context, &invite, chat_id, BobHandshakeMsg::RequestWithAuth)
|
// The scanned fingerprint matches Alice's key, we can proceed to step 4b.
|
||||||
.await?;
|
info!(context, "Taking securejoin protocol shortcut");
|
||||||
(
|
send_handshake_message(context, &invite, chat_id, BobHandshakeMsg::RequestWithAuth)
|
||||||
BobHandshakeStage::RequestWithAuthSent,
|
.await?;
|
||||||
SecureJoinStep::ContactConfirm,
|
|
||||||
)
|
stage = BobHandshakeStage::RequestWithAuthSent;
|
||||||
} else {
|
next = SecureJoinStep::ContactConfirm;
|
||||||
send_handshake_message(context, &invite, chat_id, BobHandshakeMsg::Request).await?;
|
} else {
|
||||||
(BobHandshakeStage::RequestSent, SecureJoinStep::AuthRequired)
|
send_handshake_message(context, &invite, chat_id, BobHandshakeMsg::Request).await?;
|
||||||
};
|
|
||||||
|
stage = BobHandshakeStage::RequestSent;
|
||||||
|
next = SecureJoinStep::AuthRequired;
|
||||||
|
};
|
||||||
|
|
||||||
let (id, aborted_states) =
|
let (id, aborted_states) =
|
||||||
Self::insert_new_db_entry(context, next, invite.clone(), chat_id).await?;
|
Self::insert_new_db_entry(context, next, invite.clone(), chat_id).await?;
|
||||||
let state = Self {
|
let state = Self {
|
||||||
@@ -113,6 +118,12 @@ impl BobState {
|
|||||||
next,
|
next,
|
||||||
chat_id,
|
chat_id,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if peer_verified {
|
||||||
|
// Mark 1:1 chat as verified already.
|
||||||
|
state.notify_peer_verified(context, time()).await?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok((state, stage, aborted_states))
|
Ok((state, stage, aborted_states))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user