BODY *pbody = NULL, *tmp_pbody = NULL;
BODY *tmp_smime_pbody = NULL;
BODY *tmp_pgp_pbody = NULL;
+ ENVELOPE *protected_headers = NULL;
int flags = (WithCrypto & APPLICATION_PGP)? msg->security: 0;
int i;
crypt_pgp_set_sender (msg->env->from->mailbox);
}
+ if (option (OPTCRYPTPROTHDRSWRITE))
+ {
+ protected_headers = mutt_new_envelope ();
+ mutt_str_replace (&protected_headers->subject, msg->env->subject);
+ /* Note: if other headers get added, such as to, cc, then a call to
+ * mutt_env_to_intl() will need to be added here too. */
+ mutt_prepare_envelope (protected_headers, 0);
+
+ mutt_free_envelope (&msg->content->mime_headers);
+ msg->content->mime_headers = protected_headers;
+ }
+
if (msg->security & SIGN)
{
if ((WithCrypto & APPLICATION_SMIME)
&& (msg->security & APPLICATION_SMIME))
{
if (!(tmp_pbody = crypt_smime_sign_message (msg->content)))
- return -1;
+ goto bail;
pbody = tmp_smime_pbody = tmp_pbody;
}
&& (!(flags & ENCRYPT) || option (OPTPGPRETAINABLESIG)))
{
if (!(tmp_pbody = crypt_pgp_sign_message (msg->content)))
- return -1;
+ goto bail;
flags &= ~SIGN;
pbody = tmp_pgp_pbody = tmp_pbody;
keylist)))
{
/* signed ? free it! */
- return (-1);
+ goto bail;
}
/* free tmp_body if messages was signed AND encrypted ... */
if (tmp_smime_pbody != msg->content && tmp_smime_pbody != tmp_pbody)
mutt_free_body (&tmp_pgp_pbody->next);
}
- return (-1);
+ goto bail;
}
/* destroy temporary signature envelope when doing retainable
}
}
- if(pbody)
- msg->content = pbody;
+ if (pbody)
+ {
+ msg->content = pbody;
+ return 0;
+ }
- return 0;
+bail:
+ mutt_free_envelope (&msg->content->mime_headers);
+ return -1;
}
** Protected headers are stored inside the encrypted or signed part of an
** an email, to prevent disclosure or tampering.
** For more information see https://github.com/autocrypt/memoryhole.
+ ** Currently Mutt only supports the Subject header.
+ ** .pp
+ ** Encrypted messages using protected headers often substitute the exposed
+ ** Subject header with a dummy value (see $$crypt_protected_headers_subject).
+ ** Mutt will update its concept of the correct subject \fBafter\fP the
+ ** message is opened, i.e. via the \fC<display-message>\fP function.
+ ** If you reply to a message before opening it, Mutt will end up using
+ ** the dummy Subject header, so be sure to open such a message first.
+ ** (Crypto only)
+ */
+ { "crypt_protected_headers_write", DT_BOOL, R_NONE, OPTCRYPTPROTHDRSWRITE, 0 },
+ /*
+ ** .pp
+ ** When set, Mutt will generate protected headers ("Memory Hole") for
+ ** signed and encrypted emails.
+ **
+ ** Protected headers are stored inside the encrypted or signed part of an
+ ** an email, to prevent disclosure or tampering.
+ ** For more information see https://github.com/autocrypt/memoryhole.
**
** Currently Mutt only supports the Subject header.
+ ** (Crypto only)
+ */
+ { "crypt_protected_headers_subject", DT_STR, R_NONE, UL &ProtHdrSubject, UL "Encrypted subject" },
+ /*
+ ** .pp
+ ** When $$crypt_protected_headers_write is set, and the message is marked
+ ** for encryption, this will be substituted into the Subject field in the
+ ** message headers.
+ **
+ ** To prevent a subject from being substituted, unset this variable, or set it
+ ** to the empty string.
** (Crypto only)
*/
{ "pgp_replyencrypt", DT_SYN, R_NONE, UL "crypt_replyencrypt", 1 },