Skip to content

#30 part 7: encrypting what the owner sends - #1116

Merged
benandez merged 34 commits into
mainfrom
feat/30-encrypting
Dec 1, 2026
Merged

benandez merged 34 commits into
mainfrom
feat/30-encrypting

Conversation

@benandez

@benandez benandez commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Builds on #1036

Part 7 of #30: outgoing mail can be Encrypted at Send.

What changes for the person

  • Options › Encrypt in a message being written; an account can also "Encrypt when every recipient has a key". Before Send, the composer says whether the message will be Encrypted, to how many people, in which form, and whether any key only came with their mail and was never checked by the owner.
  • S/MIME (enveloped data) or OpenPGP (PGP/MIME), to the Public keys kept for each recipient and to the owner's own key, so the Sent copy stays readable to the owner. Signed first when Sign is on too, with the signed message inside. Each Bcc recipient gets a message of their own, so the others' copies never name them.
  • A recipient with no key stops Send and names them: Send unencrypted, Remove those recipients, or Cancel. Send unencrypted is a button in the window, not a parameter. Commands and agents get an error, and an agent can turn Encrypt on but not off.
  • A message that can't be encrypted (no own key, a failing random source, an expired key) is held in the Outbox with the reason and is never sent in the clear. SMTP, Graph sendMail, Graph draft send, EWS and JMAP all refuse a message that is to be Encrypted and isn't. JMAP accounts can't turn Encrypt on yet.

Drafts

  • A draft with Encrypt on stays on this computer only. It is never uploaded on any kind of account (Graph, EWS, IMAP, JMAP), and it is kept Encrypted to the owner's own key when one is found.
  • If a copy was saved on the server before Encrypt was turned on, it is deleted there the way a discarded draft is. The server may keep it among its deleted or recoverable items for a while, and the composer says it is "being deleted", never that it is gone. If the copy can't be taken out here, the old draft stays in Drafts, still linked to the server's copy, and the composer says it is still there. A copy that a run in flight creates as Encrypt is turned on is deleted when that run reports back.
  • Split out: uploading Encrypted drafts to the server and purging earlier clear copies permanently are left for a later change (branch feat/30-encrypted-drafts-upload, no PR yet).

Crypto choices

  • S/MIME: CMS EnvelopedData, AES-256-CBC, key transport per recipient, named by issuer and serial. The key goes with rsaEncryption (PKCS#1 v1.5), which every mail program reads, or with RSAES-OAEP (RFC 3560) when the certificate's key is an id-RSAES-OAEP one (SHA-224 or longer, MGF1 on the same hash, no label). RSA certificates only; EC certificates are refused for now.
  • OpenPGP via rPGP: SEIPD v1 with the strongest of AES-256/192/128 that every recipient lists, or AES-128 otherwise. SEIPD v2 (AES-256, OCB) is used only when every recipient key is version 6. It encrypts to the newest valid encryption subkey, else the primary key. Revoked, expired, not-yet-valid and weak keys are refused.
  • The random source is passed in, from the operating system in the host. If the source fails, the output is discarded. Only Public keys are used; no private-key operation is added.
  • Key choice: a key the owner imported or marked Verified is used before one only collected from mail. Once one exists for an address and form, collected keys are never used for it.

How it was checked

  • Round trips with secret halves made from seeds in tests: S/MIME, OpenPGP ECDH, RSA subkey, v6 AEAD, several recipients, sign-then-encrypt, Bcc copies.
  • Also tested: refusals, a failing random source, a 3 MB message, and property tests that feed arbitrary bytes.
  • Engine tests cover the commands, the stop, Remove, the account default, form choice, the Outbox decision and the agent gate. They also check that a draft with Encrypt on never goes up on any kind of account, and that a clear copy is deleted or reported. hostile_params_never_panic stays green.
  • New calls in the openpgp and smime fuzz targets.
  • Local cargo xtask ci passes, apart from one test (opening_kind_tests) that depends on the desktop it runs on and is known to fail on this machine. Nothing was tried against a real mailbox, server or card.

What was left out

  • Uploading Encrypted drafts (split out, see above).
  • Web Key Directory look-ups: not built. PRIVACY.md says no key is looked up and no revocation is checked online.
  • EC S/MIME certificates.
  • Decrypting what is received is a later part.

Human-reviewed, AI-assisted, nobody's mailbox harmed.

Summary by CodeRabbit

  • New Features
    • Send messages encrypted with S/MIME or OpenPGP. Review and choose recipient keys, remove recipients, or send unencrypted when offered.
    • Set encryption as an account default or per message. Bcc recipients receive separate encrypted copies, while the main message is filed in Sent Items.
    • Encrypted drafts stay on your computer and are encrypted to your key when possible. Compose shows encryption and draft status.
  • Bug Fixes
    • Messages that can’t meet required encryption are held rather than sent unencrypted. Interrupted sends track Bcc deliveries and warn when a copy may be missing.
    • Previously uploaded clear drafts are removed when possible; failures are reported, and the clear copy may remain on the server. Encrypted messages can’t be opened, edited, or resent until decryption is supported.
  • Documentation
    • Privacy information covers stored keys, revocations, draft encryption, Sent Items, and server key lookup limitations.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant