Closed Bug 1882832 Opened 7 months ago Closed 1 day ago

Improve encryption detection in the MimeTreeEmitter class

Categories

(Thunderbird :: Add-Ons: Extensions API, task)

Tracking

(thunderbird_esr128 affected)

RESOLVED FIXED
132 Branch
Tracking Status
thunderbird_esr128 --- affected

People

(Reporter: TbSync, Assigned: TbSync)

References

Details

Attachments

(3 files)

This is a performance improvement based on Kai's input to minimize the
computational work required to determine whether a message is encrypted.

Assignee: nobody → john
Status: NEW → ASSIGNED
Flags: needinfo?(kaie)
Blocks: 1852746
Attachment #9388453 - Attachment description: Bug 1882832 - Process encrypted MIME parts based on headers, avoid peeking into MIME parts. r=kaie → WIP: Bug 1882832 - Process encrypted MIME parts based on headers, avoid peeking into MIME parts.

This is a test message, with a plain text main part, and an OpenPGP-encrypted attachment, which can be decrypted using alice@openpgp.example-0xf231550c4f47e38e-secret.asc

Attachment #9388453 - Attachment description: WIP: Bug 1882832 - Process encrypted MIME parts based on headers, avoid peeking into MIME parts. → WIP: Bug 1882832 - Process encrypted MIME parts based on headers, minimize reading MIME parts.

Kai: When we first talked about this performance improvement, one of the goals was to dynamically include attachments, if they are encrypted, and drop them otherwise (so these parts could later be decrypted and parsed). The classes this code is embedded into have changed since then, and this is currently no longer a requirement (it actually would not help). The caller defines, if attachments should be included or not.

The code which checks the body parts in endPart() (isEncryptedINLINE() and isPgpEncryptedAttachment()) needs a bit of the body data. This is achieved by introducing a threshold, keeping the first few bits of the data in deliverPartData(), if encryption detection is requested, but attachments are not requested. These partial bodies are purged in endPart() after the encryption detection code has run.

In the WebExtension API, this case occurs by calling browser.messages.getFull(<msgId>, { decrypt: false }). The returned mimeTree of an encrypted message should not include any attachments, but include decryptionStatus: skipped, to indicate that the message is encrypted (but not decrypted).

In your original proposal, you introduced this.#currentlyProcessingEncryptedPartNum to keep track of containers which may contain nested parts relevant for encryption. Since we do not need to keep these nested parts now, the flag is not needed. However, I would like to hold on to it, to keep the concept in the code, so we can use it later, if needed. I am also fine with turning it into a comment or removing it altogether.

Attached file inline-enc.eml

Another test message, again encrypted to Alice.

This time, this isn't MIME, but rather an "inline" encrypted message.

Attachment #9388453 - Attachment description: WIP: Bug 1882832 - Process encrypted MIME parts based on headers, minimize reading MIME parts. → Bug 1882832 - Process encrypted MIME parts based on headers, minimize reading MIME parts. r=kaie

This patch also fixed a bug which existed since at least TB78. The WebExtension code is now using this code path in TB128 and I may have a report, that this unfixed bug caused a regression for TB128. I will therefore request uplift.

Flags: needinfo?(kaie)

Pushed by toby@thunderbird.net:
https://hg.mozilla.org/comm-central/rev/1ecd684ec903
Process encrypted MIME parts based on headers, minimize reading MIME parts. r=kaie

Status: ASSIGNED → RESOLVED
Closed: 1 day ago
Resolution: --- → FIXED
Target Milestone: --- → 132 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: