refactor: rename fingerprint_equals_sender to verify_sender_by_fingerprint

This commit is contained in:
link2xt
2024-01-07 21:38:21 +00:00
parent 457b012910
commit c2df00332f
2 changed files with 11 additions and 6 deletions

View File

@@ -203,7 +203,7 @@ async fn info_chat_id(context: &Context, contact_id: ContactId) -> Result<ChatId
/// Checks fingerprint and marks the contact as forward verified /// Checks fingerprint and marks the contact as forward verified
/// if fingerprint matches. /// if fingerprint matches.
async fn fingerprint_equals_sender( async fn verify_sender_by_fingerprint(
context: &Context, context: &Context,
fingerprint: &Fingerprint, fingerprint: &Fingerprint,
contact_id: ContactId, contact_id: ContactId,
@@ -374,7 +374,7 @@ pub(crate) async fn handle_securejoin_handshake(
.await?; .await?;
return Ok(HandshakeMessage::Ignore); return Ok(HandshakeMessage::Ignore);
} }
if !fingerprint_equals_sender(context, &fingerprint, contact_id).await? { if !verify_sender_by_fingerprint(context, &fingerprint, contact_id).await? {
could_not_establish_secure_connection( could_not_establish_secure_connection(
context, context,
contact_id, contact_id,

View File

@@ -11,7 +11,7 @@ use anyhow::Result;
use rusqlite::Connection; use rusqlite::Connection;
use super::qrinvite::QrInvite; use super::qrinvite::QrInvite;
use super::{encrypted_and_signed, fingerprint_equals_sender}; use super::{encrypted_and_signed, verify_sender_by_fingerprint};
use crate::chat::{self, ChatId}; use crate::chat::{self, ChatId};
use crate::config::Config; use crate::config::Config;
use crate::contact::{Contact, Origin}; use crate::contact::{Contact, Origin};
@@ -90,7 +90,8 @@ impl BobState {
chat_id: ChatId, chat_id: ChatId,
) -> Result<(Self, BobHandshakeStage, Vec<Self>)> { ) -> Result<(Self, BobHandshakeStage, Vec<Self>)> {
let (stage, next) = let (stage, next) =
if fingerprint_equals_sender(context, invite.fingerprint(), invite.contact_id()).await? if verify_sender_by_fingerprint(context, invite.fingerprint(), invite.contact_id())
.await?
{ {
// The scanned fingerprint matches Alice's key, we can proceed to step 4b. // The scanned fingerprint matches Alice's key, we can proceed to step 4b.
info!(context, "Taking securejoin protocol shortcut"); info!(context, "Taking securejoin protocol shortcut");
@@ -268,8 +269,12 @@ impl BobState {
.await?; .await?;
return Ok(Some(BobHandshakeStage::Terminated(reason))); return Ok(Some(BobHandshakeStage::Terminated(reason)));
} }
if !fingerprint_equals_sender(context, self.invite.fingerprint(), self.invite.contact_id()) if !verify_sender_by_fingerprint(
.await? context,
self.invite.fingerprint(),
self.invite.contact_id(),
)
.await?
{ {
self.update_next(&context.sql, SecureJoinStep::Terminated) self.update_next(&context.sql, SecureJoinStep::Terminated)
.await?; .await?;