From: David Bremner <david@tethera.net>
To: Daniel Kahn Gillmor <dkg@fifthhorseman.net>,
Notmuch Mail <notmuch@notmuchmail.org>
Subject: Re: [PATCH 1/5] crypto: prepare for decryption of inline PGP encrypted messages
Date: Thu, 03 May 2018 18:34:43 -0300 [thread overview]
Message-ID: <87in84e83w.fsf@tethera.net> (raw)
In-Reply-To: <20171212071553.6440-2-dkg@fifthhorseman.net>
Daniel Kahn Gillmor <dkg@fifthhorseman.net> writes:
> Inline PGP encrypted messages are clearly worse than PGP/MIME
> structured encrypted messages. There are no standards for how they
> are formed, and they don't offer any structured metadata about how to
> interpret the bytestream produced by decrypting them.
>
> However, some other MUAs and end-user workflows may make creation of
> inline PGP encrypted messages the only available option for message
> encryption, and when Notmuch encounters such a message, it should make
> a reasonable best-effort to render the cleartext to the user.
>
> Due to ambiguities in interpretation of signatures on inline messages
> (e.g. which parts of the message were actually signed? what character
> encoding should the bytestream be interpreted as), we continue to
> ignore inline-signed messages entirely, and we do not look at the
> validity of any signatures that might be found when decrypting inline
> PGP encrypted messages.
>
> We make use here of GMime's optimization function for detecting the
> presence of inline PGP encrypted content, which is only found in GMime
> 3.0 or later.
I already objected to "here", since that doesn't happen in this commit.
>
> This change prepares the internal codebase for decrypting inline
> encrypted messages, but does not yet actually use the capability.
The ratio of backstory to "what is going on here" is a little high.
Perhaps moving the last few lines to the top would help.
> ---
> + if (GMIME_IS_PART (part) || /* must be inline */
For some reason it wasn't obvious that you meant "inline PGP" where you
wrote "inline"
> #if (GMIME_MAJOR_VERSION < 3)
> - ret = g_mime_multipart_encrypted_decrypt_session (part,
> + ret = g_mime_multipart_encrypted_decrypt_session (GMIME_MULTIPART_ENCRYPTED (part),
> crypto_ctx,
> notmuch_message_properties_value (list),
> decrypt_result, err);
that lo
> #else
> - ret = g_mime_multipart_encrypted_decrypt (part,
> - GMIME_DECRYPT_NONE,
> - notmuch_message_properties_value (list),
> - decrypt_result, err);
> + if (GMIME_IS_MULTIPART_ENCRYPTED (part)) {
> + ret = g_mime_multipart_encrypted_decrypt (GMIME_MULTIPART_ENCRYPTED (part),
> + GMIME_DECRYPT_NONE,
> + notmuch_message_properties_value (list),
> + decrypt_result, err);
> + } else if (GMIME_IS_PART (part) &&
> g_mime_part_get_openpgp_data (GMIME_PART (part)) ==
> GMIME_OPENPGP_DATA_ENCRYPTED) {
Some of these lines are getting pretty long. devel/STYLE suggests 70 or
80 columns
> break;
> @@ -214,8 +225,16 @@ _notmuch_crypto_decrypt (bool *attempted,
> GMimeDecryptFlags flags = GMIME_DECRYPT_NONE;
> if (decrypt == NOTMUCH_DECRYPT_TRUE && decrypt_result)
> flags |= GMIME_DECRYPT_EXPORT_SESSION_KEY;
> - ret = g_mime_multipart_encrypted_decrypt(part, flags, NULL,
> - decrypt_result, err);
> + if (GMIME_IS_MULTIPART_ENCRYPTED (part)) {
> + ret = g_mime_multipart_encrypted_decrypt(GMIME_MULTIPART_ENCRYPTED (part), flags, NULL,
> + decrypt_result, err);
> + } else if (GMIME_IS_PART (part) && g_mime_part_get_openpgp_data (GMIME_PART (part)) == GMIME_OPENPGP_DATA_ENCRYPTED) {
> + *decrypt_result = g_mime_part_openpgp_decrypt (GMIME_PART (part), flags, NULL, err);
> + if (decrypt_result) {
> + ret = part;
> + g_object_ref (ret);
> + }
> + }
> #endif
This looks like somewhat duplicated code. Did you try a little static function?
next prev parent reply other threads:[~2018-05-03 21:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-12 7:15 cope with inline PGP encrypted messages Daniel Kahn Gillmor
2017-12-12 7:15 ` [PATCH 1/5] crypto: prepare for decryption of " Daniel Kahn Gillmor
2018-04-30 11:24 ` David Bremner
2018-04-30 11:42 ` David Bremner
2018-05-01 17:42 ` Daniel Kahn Gillmor
2018-05-03 21:34 ` David Bremner [this message]
2017-12-12 7:15 ` [PATCH 2/5] cli/{show, reply}: try to decrypt " Daniel Kahn Gillmor
2017-12-12 7:15 ` [PATCH 3/5] index: tag text parts with inline PGP encryption as "encrypted" Daniel Kahn Gillmor
2017-12-12 7:15 ` [PATCH 4/5] index: _index_encrypted_mime_part returns success or failure Daniel Kahn Gillmor
2017-12-12 7:15 ` [PATCH 5/5] index: try indexing the cleartext of inline PGP encrypted text parts Daniel Kahn Gillmor
2018-05-09 21:53 ` cope with inline PGP encrypted messages Daniel Kahn Gillmor
2018-05-10 12:39 ` David Bremner
2018-05-11 17:42 ` Daniel Kahn Gillmor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87in84e83w.fsf@tethera.net \
--to=david@tethera.net \
--cc=dkg@fifthhorseman.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).