Skip to content

protonmail: implement attachment signature support#323

Open
alicetulpa wants to merge 1 commit intoemersion:masterfrom
alicetulpa:fix-attachment-signatures
Open

protonmail: implement attachment signature support#323
alicetulpa wants to merge 1 commit intoemersion:masterfrom
alicetulpa:fix-attachment-signatures

Conversation

@alicetulpa
Copy link

Problem

Sending emails with attachments via hydroxide fails with Proton API error [2011]: 'One or more attachments are missing a signature'.

The Encrypt() function in protonmail/attachments.go had two TODO comments noting that signature support was never implemented — the signing entity was passed as nil to symetricallyEncrypt, and no Signature form field was uploaded in CreateAttachment().

Fix

  1. Encrypt() — Extracts the signing key from the private key entity and passes it to symetricallyEncrypt for inline signing. Additionally wraps the plaintext writer in an attachmentSignWriter that tees plaintext into a SHA512 hash, generating a detached PGP signature on Close(), stored base64-encoded in att.Signature.

  2. CreateAttachment() — Uploads att.Signature as a Signature form field when non-empty.

Testing

Tested by sending emails with text file attachments through the patched hydroxide bridge. Emails are accepted by the Proton API and delivered successfully to both ProtonMail and external recipients.

Previously, attachment encryption did not generate signatures, causing
Proton API error [2011] ('One or more attachments are missing a
signature') when sending emails with attachments.

This commit:
- Passes the signing key to symetricallyEncrypt in Encrypt(), enabling
  inline signing of the encrypted attachment data
- Wraps the plaintext writer to tee data into a SHA512 hash, generating
  a detached PGP signature on Close()
- Stores the base64-encoded detached signature in att.Signature
- Uploads att.Signature as a 'Signature' form field in CreateAttachment()

Resolves the two TODO comments in attachments.go that noted missing
signature implementation.
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