--- /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 9DAD2431FD6\r
+ for <notmuch@notmuchmail.org>; Fri, 29 Jun 2012 11:38:30 -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 4szEgKtnTe2V for <notmuch@notmuchmail.org>;\r
+ Fri, 29 Jun 2012 11:38:30 -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 0DFAE431FCF\r
+ for <notmuch@notmuchmail.org>; Fri, 29 Jun 2012 11:38:30 -0700 (PDT)\r
+Received: from earth-doxen.imss.caltech.edu (localhost [127.0.0.1])\r
+ by earth-doxen-postvirus (Postfix) with ESMTP id C1FB866E030A\r
+ for <notmuch@notmuchmail.org>; Fri, 29 Jun 2012 11:38:27 -0700 (PDT)\r
+X-Spam-Scanned: at Caltech-IMSS on earth-doxen by amavisd-new\r
+Received: from finestructure.net (gwave-70.ligo.caltech.edu [131.215.114.70])\r
+ (Authenticated sender: jrollins)\r
+ by earth-doxen-submit (Postfix) with ESMTP id F1E4466E0306\r
+ for <notmuch@notmuchmail.org>; Fri, 29 Jun 2012 11:38:25 -0700 (PDT)\r
+Received: by finestructure.net (Postfix, from userid 1000)\r
+ id D50D62E97; Fri, 29 Jun 2012 11:38:25 -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: Fri, 29 Jun 2012 11:38:20 -0700\r
+Message-Id: <1340995101-9616-2-git-send-email-jrollins@finestructure.net>\r
+X-Mailer: git-send-email 1.7.10\r
+In-Reply-To: <1340995101-9616-1-git-send-email-jrollins@finestructure.net>\r
+References: <1340995101-9616-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: Fri, 29 Jun 2012 18:38:31 -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 | 21 +++++++++++++++++++++\r
+ notmuch-client.h | 5 +++--\r
+ 2 files changed, 24 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/crypto.c b/crypto.c\r
+index fbe5aeb..551ffc5 100644\r
+--- a/crypto.c\r
++++ b/crypto.c\r
+@@ -52,6 +52,22 @@ notmuch_crypto_get_context (notmuch_crypto_t *crypto, const char *protocol)\r
+ }\r
+ cryptoctx = crypto->gpgctx;\r
+ \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
++\r
++#endif\r
+ } else {\r
+ fprintf (stderr, "Unknown or unsupported cryptographic protocol.\n");\r
+ }\r
+@@ -67,5 +83,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 9b63eae..72edd50 100644\r
+--- a/notmuch-client.h\r
++++ b/notmuch-client.h\r
+@@ -79,6 +79,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
+@@ -353,8 +354,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.7.10\r
+\r