Month: September 2016

Recent Posts

S/MIME Self-Encrypt Patch for Mutt

To save sent items when using S/MIME, the item must be encrypted using a different key than the one for sending the message. When using Mutt, this is not a feature that's not available in the base installation. A patch is required. This patch works for mutt-1.6.2:

diff -pruN mutt-1.6.2-orig/PATCHES mutt-1.6.2/PATCHES
--- mutt-1.6.2-orig/PATCHES 2016-07-07 03:35:02.000000000 +1000
+++ mutt-1.6.2/PATCHES 2016-09-30 18:23:31.000000000 +1000
@@ -0,0 +1 @@
+patch-1.5.6.ow.smime-encrypt-self.2
diff -pruN mutt-1.6.2-orig/crypt.c mutt-1.6.2/crypt.c
--- mutt-1.6.2-orig/crypt.c 2016-07-07 03:35:18.000000000 +1000
+++ mutt-1.6.2/crypt.c 2016-09-30 18:22:09.000000000 +1000
@@ -231,8 +231,18 @@ int mutt_protect (HEADER *msg, char *key
if ((WithCrypto & APPLICATION_SMIME)
&& (msg->security & APPLICATION_SMIME))
{
- if (!(tmp_pbody = crypt_smime_build_smime_entity (tmp_smime_pbody,
- keylist)))
+ char *new_keylist = keylist;
+
+ if (SmimeDefaultKey && query_quadoption(OPT_SMIMEENCRYPTSELF, _("Encrypt message to S/MIME Default Key also?")) == M_YES)
+ {
+ int size = mutt_strlen(keylist) + mutt_strlen (SmimeDefaultKey) + 2; /* +1 for NULL, +1 for \n */
+ new_keylist = safe_malloc(size);
+ snprintf(new_keylist, size, "%s%s\n", keylist, SmimeDefaultKey);
+ }
+
+ tmp_pbody = crypt_smime_build_smime_entity (tmp_smime_pbody, new_keylist);
+ safe_free((void **)&new_keylist);
+ if (!tmp_pbody)
{
/* signed ? free it! */
return (-1);
diff -pruN mutt-1.6.2-orig/init.h mutt-1.6.2/init.h
--- mutt-1.6.2-orig/init.h 2016-07-07 03:35:18.000000000 +1000
+++ mutt-1.6.2/init.h 2016-09-30 18:22:31.000000000 +1000
@@ -2914,6 +2914,11 @@ struct option_t MuttVars[] = {
** possible \fCprintf(3)\fP-like sequences.
** (S/MIME only)
*/
+ { "smime_encrypt_self", DT_QUAD, R_NONE, OPT_SMIMEENCRYPTSELF, M_YES },
+ /*
+ ** .pp
+ ** Encrypt the message to smime_default_key too.
+ */
{ "smime_timeout", DT_NUM, R_NONE, UL &SmimeTimeout, 300 },
/*
** .pp
diff -pruN mutt-1.6.2-orig/mutt.h mutt-1.6.2/mutt.h
--- mutt-1.6.2-orig/mutt.h 2016-07-07 03:35:18.000000000 +1000
+++ mutt-1.6.2/mutt.h 2016-09-30 18:22:48.000000000 +1000
@@ -275,6 +275,7 @@ enum
OPT_QUIT,
OPT_REPLYTO,
OPT_RECALL,
+ OPT_SMIMEENCRYPTSELF, /* Encrypt the message to self also */
#if defined(USE_SSL)
OPT_SSLSTARTTLS,
#endif

If you're using homebrew as per this post, you can edit your homebrew file as follows:

 patch do
 url "file:///path/to/smime.patch"
 sha256 "bb498405d71eb3eb48f91be7a0c1a3147b5961407a2ad26ae925700f45e3c6e1"
 end if build.with? "smime-self-patch"