feat: verify contacts via Autocrypt-Gossip

This mechanism replaces `Chat-Verified` header.
New parameter `_verified=1` in `Autocrypt-Gossip`
header marks that the sender has the gossiped key
verified.

Using `_verified=1` instead of `_verified`
because it is less likely to cause troubles
with existing Autocrypt header parsers.
This is also how https://www.rfc-editor.org/rfc/rfc2045
defines parameter syntax.
This commit is contained in:
link2xt
2025-08-15 22:16:07 +00:00
parent 58f6b841e3
commit 9048c5d6a6
5 changed files with 159 additions and 99 deletions

View File

@@ -742,7 +742,7 @@ pub(crate) async fn receive_imf_inner(
let verified_encryption = has_verified_encryption(context, &mime_parser, from_id).await?;
if verified_encryption == VerifiedEncryption::Verified {
mark_recipients_as_verified(context, from_id, &to_ids, &mime_parser).await?;
mark_recipients_as_verified(context, from_id, &mime_parser).await?;
}
let received_msg = if let Some(received_msg) = received_msg {
@@ -3678,7 +3678,6 @@ async fn has_verified_encryption(
async fn mark_recipients_as_verified(
context: &Context,
from_id: ContactId,
to_ids: &[Option<ContactId>],
mimeparser: &MimeMessage,
) -> Result<()> {
let verifier_id = Some(from_id).filter(|&id| id != ContactId::SELF);
@@ -3700,18 +3699,6 @@ async fn mark_recipients_as_verified(
ChatId::set_protection_for_contact(context, to_id, mimeparser.timestamp_sent).await?;
}
if mimeparser.get_header(HeaderDef::ChatVerified).is_none() {
return Ok(());
}
for to_id in to_ids.iter().filter_map(|&x| x) {
if to_id == ContactId::SELF || to_id == from_id {
continue;
}
mark_contact_id_as_verified(context, to_id, verifier_id).await?;
ChatId::set_protection_for_contact(context, to_id, mimeparser.timestamp_sent).await?;
}
Ok(())
}