summaryrefslogtreecommitdiffstats
path: root/crypt-gpgme.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2018-12-11 14:11:30 -0800
committerKevin McCarthy <kevin@8t8.us>2018-12-17 13:30:53 -0800
commitcac6705aa51f281f6eba22136f6ce51490c62dff (patch)
treefda22ce1f6b238407047a5304bfc3bd58dfe8133 /crypt-gpgme.c
parent09dd4a5d7b69dc688c4a7f3c07b74b66bea7315f (diff)
Add protected header received email support.
Add $crypt_protected_headers_read config variable to enable reading and updating the index/header cache. Print protected Subject header in the pager as parts are rendered. Once opened, update the index, subject hash, and header cache.
Diffstat (limited to 'crypt-gpgme.c')
-rw-r--r--crypt-gpgme.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/crypt-gpgme.c b/crypt-gpgme.c
index 7f824f38..d1cd407e 100644
--- a/crypt-gpgme.c
+++ b/crypt-gpgme.c
@@ -2901,11 +2901,23 @@ int pgp_gpgme_encrypted_handler (BODY *a, STATE *s)
tattach->goodsig = is_signed > 0;
if (s->flags & MUTT_DISPLAY)
+ {
state_attach_puts (is_signed?
_("[-- The following data is PGP/MIME signed and encrypted --]\n\n"):
_("[-- The following data is PGP/MIME encrypted --]\n\n"),
s);
+ mutt_protected_headers_handler (tattach, s);
+ }
+
+ /* Store any protected headers in the parent so they can be
+ * accessed for index updates after the handler recursion is done.
+ * This is done before the handler to prevent a nested encrypted
+ * handler from freeing the headers. */
+ mutt_free_envelope (&a->mime_headers);
+ a->mime_headers = tattach->mime_headers;
+ tattach->mime_headers = NULL;
+
{
FILE *savefp = s->fpin;
s->fpin = fpout;
@@ -2913,6 +2925,18 @@ int pgp_gpgme_encrypted_handler (BODY *a, STATE *s)
s->fpin = savefp;
}
+ /* Embedded multipart signed protected headers override the
+ * encrypted headers. We need to do this after the handler so
+ * they can be printed in the pager. */
+ if (mutt_is_multipart_signed (tattach) &&
+ tattach->parts &&
+ tattach->parts->mime_headers)
+ {
+ mutt_free_envelope (&a->mime_headers);
+ a->mime_headers = tattach->parts->mime_headers;
+ tattach->parts->mime_headers = NULL;
+ }
+
/*
* if a multipart/signed is the _only_ sub-part of a
* multipart/encrypted, cache signature verification
@@ -2958,6 +2982,10 @@ int smime_gpgme_application_handler (BODY *a, STATE *s)
dprint (2, (debugfile, "Entering smime_encrypted handler\n"));
+ /* clear out any mime headers before the handler, so they can't be
+ * spoofed. */
+ mutt_free_envelope (&a->mime_headers);
+
a->warnsig = 0;
mutt_mktemp (tempfile, sizeof (tempfile));
if (!(fpout = safe_fopen (tempfile, "w+")))
@@ -2974,11 +3002,23 @@ int smime_gpgme_application_handler (BODY *a, STATE *s)
tattach->goodsig = is_signed > 0;
if (s->flags & MUTT_DISPLAY)
+ {
state_attach_puts (is_signed?
_("[-- The following data is S/MIME signed --]\n\n"):
_("[-- The following data is S/MIME encrypted --]\n\n"),
s);
+ mutt_protected_headers_handler (tattach, s);
+ }
+
+ /* Store any protected headers in the parent so they can be
+ * accessed for index updates after the handler recursion is done.
+ * This is done before the handler to prevent a nested encrypted
+ * handler from freeing the headers. */
+ mutt_free_envelope (&a->mime_headers);
+ a->mime_headers = tattach->mime_headers;
+ tattach->mime_headers = NULL;
+
{
FILE *savefp = s->fpin;
s->fpin = fpout;
@@ -2986,6 +3026,18 @@ int smime_gpgme_application_handler (BODY *a, STATE *s)
s->fpin = savefp;
}
+ /* Embedded multipart signed protected headers override the
+ * encrypted headers. We need to do this after the handler so
+ * they can be printed in the pager. */
+ if (mutt_is_multipart_signed (tattach) &&
+ tattach->parts &&
+ tattach->parts->mime_headers)
+ {
+ mutt_free_envelope (&a->mime_headers);
+ a->mime_headers = tattach->parts->mime_headers;
+ tattach->parts->mime_headers = NULL;
+ }
+
/*
* if a multipart/signed is the _only_ sub-part of a
* multipart/encrypted, cache signature verification