--- /dev/null
+Return-Path: <jrollins@finestructure.net>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 5A47C431FCB\r
+ for <notmuch@notmuchmail.org>; Sun, 16 Mar 2014 21:52:40 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id RDJywR7wH0U9 for <notmuch@notmuchmail.org>;\r
+ Sun, 16 Mar 2014 21:52:34 -0700 (PDT)\r
+Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu\r
+ [131.215.239.19])\r
+ by olra.theworths.org (Postfix) with ESMTP id B73C5431FBF\r
+ for <notmuch@notmuchmail.org>; Sun, 16 Mar 2014 21:52:34 -0700 (PDT)\r
+Received: from earth-doxen.imss.caltech.edu (localhost [127.0.0.1])\r
+ by earth-doxen-postvirus (Postfix) with ESMTP id 72CC966E0026\r
+ for <notmuch@notmuchmail.org>; Sun, 16 Mar 2014 21:52:32 -0700 (PDT)\r
+X-Spam-Scanned: at Caltech-IMSS on earth-doxen by amavisd-new\r
+Received: from finestructure.net (96-39-203-108.dhcp.mdfd.or.charter.com\r
+ [96.39.203.108]) (Authenticated sender: jrollins)\r
+ by earth-doxen-submit (Postfix) with ESMTP id 9255966E013D\r
+ for <notmuch@notmuchmail.org>; Sun, 16 Mar 2014 21:52:31 -0700 (PDT)\r
+Received: by finestructure.net (Postfix, from userid 1000)\r
+ id A3B886009F; Sun, 16 Mar 2014 21:52:28 -0700 (PDT)\r
+From: Jameson Graef Rollins <jrollins@finestructure.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH 1/2] cli: S/MIME verification/decryption support\r
+Date: Sun, 16 Mar 2014 21:52:23 -0700\r
+Message-Id: <1395031944-15557-2-git-send-email-jrollins@finestructure.net>\r
+X-Mailer: git-send-email 1.9.0\r
+In-Reply-To: <1395031944-15557-1-git-send-email-jrollins@finestructure.net>\r
+References: <1340995101-9616-1-git-send-email-jrollins@finestructure.net>\r
+ <1395031944-15557-1-git-send-email-jrollins@finestructure.net>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 17 Mar 2014 04:52:41 -0000\r
+\r
+The notmuch-show flags --decrypt and --verify will now also process\r
+S/MIME multiparts if encountered. Requires gmime-2.6 and gpgsm.\r
+---\r
+ crypto.c | 20 ++++++++++++++++++++\r
+ notmuch-client.h | 5 +++--\r
+ 2 files changed, 23 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/crypto.c b/crypto.c\r
+index 6f4a6db..d66aa66 100644\r
+--- a/crypto.c\r
++++ b/crypto.c\r
+@@ -88,6 +88,21 @@ notmuch_crypto_get_context (notmuch_crypto_t *crypto, const char *protocol)\r
+ fprintf (stderr, "Failed to construct gpg context.\n");\r
+ }\r
+ cryptoctx = crypto->gpgctx;\r
++#ifdef GMIME_ATLEAST_26\r
++ } else if ((strcasecmp (protocol, "application/pkcs7-signature") == 0)\r
++ || (strcasecmp (protocol, "application/x-pkcs7-signature") == 0)\r
++ || (strcasecmp (protocol, "application/pkcs7-encrypted") == 0)) {\r
++ if (! crypto->pkcs7ctx) {\r
++ /* TODO: GMimePasswordRequestFunc */\r
++ crypto->pkcs7ctx = g_mime_pkcs7_context_new (NULL);\r
++ if (crypto->pkcs7ctx) {\r
++ g_mime_pkcs7_context_set_always_trust ((GMimePkcs7Context*) crypto->pkcs7ctx, FALSE);\r
++ } else {\r
++ fprintf (stderr, "Failed to construct pkcs7 context.\n");\r
++ }\r
++ }\r
++ cryptoctx = crypto->pkcs7ctx;\r
++#endif\r
+ } else {\r
+ fprintf (stderr, "Unknown or unsupported cryptographic protocol.\n");\r
+ }\r
+@@ -103,5 +118,10 @@ notmuch_crypto_cleanup (notmuch_crypto_t *crypto)\r
+ crypto->gpgctx = NULL;\r
+ }\r
+ \r
++ if (crypto->pkcs7ctx) {\r
++ g_object_unref (crypto->pkcs7ctx);\r
++ crypto->pkcs7ctx = NULL;\r
++ }\r
++\r
+ return 0;\r
+ }\r
+diff --git a/notmuch-client.h b/notmuch-client.h\r
+index 278b498..9b80107 100644\r
+--- a/notmuch-client.h\r
++++ b/notmuch-client.h\r
+@@ -78,6 +78,7 @@ typedef struct notmuch_show_format {\r
+ \r
+ typedef struct notmuch_crypto {\r
+ notmuch_crypto_context_t* gpgctx;\r
++ notmuch_crypto_context_t* pkcs7ctx;\r
+ notmuch_bool_t verify;\r
+ notmuch_bool_t decrypt;\r
+ } notmuch_crypto_t;\r
+@@ -411,8 +412,8 @@ struct mime_node {\r
+ /* Construct a new MIME node pointing to the root message part of\r
+ * message. If crypto->verify is true, signed child parts will be\r
+ * verified. If crypto->decrypt is true, encrypted child parts will be\r
+- * decrypted. If crypto->gpgctx is NULL, it will be lazily\r
+- * initialized.\r
++ * decrypted. If the crypto contexts (crypto->gpgctx or\r
++ * crypto->pkcs7) are NULL, they will be lazily initialized.\r
+ *\r
+ * Return value:\r
+ *\r
+-- \r
+1.9.0\r
+\r