1 Return-Path: <jrollins@finestructure.net>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 5A47C431FCB
\r
6 for <notmuch@notmuchmail.org>; Sun, 16 Mar 2014 21:52:40 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id RDJywR7wH0U9 for <notmuch@notmuchmail.org>;
\r
16 Sun, 16 Mar 2014 21:52:34 -0700 (PDT)
\r
17 Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu
\r
19 by olra.theworths.org (Postfix) with ESMTP id B73C5431FBF
\r
20 for <notmuch@notmuchmail.org>; Sun, 16 Mar 2014 21:52:34 -0700 (PDT)
\r
21 Received: from earth-doxen.imss.caltech.edu (localhost [127.0.0.1])
\r
22 by earth-doxen-postvirus (Postfix) with ESMTP id 72CC966E0026
\r
23 for <notmuch@notmuchmail.org>; Sun, 16 Mar 2014 21:52:32 -0700 (PDT)
\r
24 X-Spam-Scanned: at Caltech-IMSS on earth-doxen by amavisd-new
\r
25 Received: from finestructure.net (96-39-203-108.dhcp.mdfd.or.charter.com
\r
26 [96.39.203.108]) (Authenticated sender: jrollins)
\r
27 by earth-doxen-submit (Postfix) with ESMTP id 9255966E013D
\r
28 for <notmuch@notmuchmail.org>; Sun, 16 Mar 2014 21:52:31 -0700 (PDT)
\r
29 Received: by finestructure.net (Postfix, from userid 1000)
\r
30 id A3B886009F; Sun, 16 Mar 2014 21:52:28 -0700 (PDT)
\r
31 From: Jameson Graef Rollins <jrollins@finestructure.net>
\r
32 To: Notmuch Mail <notmuch@notmuchmail.org>
\r
33 Subject: [PATCH 1/2] cli: S/MIME verification/decryption support
\r
34 Date: Sun, 16 Mar 2014 21:52:23 -0700
\r
35 Message-Id: <1395031944-15557-2-git-send-email-jrollins@finestructure.net>
\r
36 X-Mailer: git-send-email 1.9.0
\r
37 In-Reply-To: <1395031944-15557-1-git-send-email-jrollins@finestructure.net>
\r
38 References: <1340995101-9616-1-git-send-email-jrollins@finestructure.net>
\r
39 <1395031944-15557-1-git-send-email-jrollins@finestructure.net>
\r
40 X-BeenThere: notmuch@notmuchmail.org
\r
41 X-Mailman-Version: 2.1.13
\r
43 List-Id: "Use and development of the notmuch mail system."
\r
44 <notmuch.notmuchmail.org>
\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
46 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
48 List-Post: <mailto:notmuch@notmuchmail.org>
\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
51 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
52 X-List-Received-Date: Mon, 17 Mar 2014 04:52:41 -0000
\r
54 The notmuch-show flags --decrypt and --verify will now also process
\r
55 S/MIME multiparts if encountered. Requires gmime-2.6 and gpgsm.
\r
57 crypto.c | 20 ++++++++++++++++++++
\r
58 notmuch-client.h | 5 +++--
\r
59 2 files changed, 23 insertions(+), 2 deletions(-)
\r
61 diff --git a/crypto.c b/crypto.c
\r
62 index 6f4a6db..d66aa66 100644
\r
65 @@ -88,6 +88,21 @@ notmuch_crypto_get_context (notmuch_crypto_t *crypto, const char *protocol)
\r
66 fprintf (stderr, "Failed to construct gpg context.\n");
\r
68 cryptoctx = crypto->gpgctx;
\r
69 +#ifdef GMIME_ATLEAST_26
\r
70 + } else if ((strcasecmp (protocol, "application/pkcs7-signature") == 0)
\r
71 + || (strcasecmp (protocol, "application/x-pkcs7-signature") == 0)
\r
72 + || (strcasecmp (protocol, "application/pkcs7-encrypted") == 0)) {
\r
73 + if (! crypto->pkcs7ctx) {
\r
74 + /* TODO: GMimePasswordRequestFunc */
\r
75 + crypto->pkcs7ctx = g_mime_pkcs7_context_new (NULL);
\r
76 + if (crypto->pkcs7ctx) {
\r
77 + g_mime_pkcs7_context_set_always_trust ((GMimePkcs7Context*) crypto->pkcs7ctx, FALSE);
\r
79 + fprintf (stderr, "Failed to construct pkcs7 context.\n");
\r
82 + cryptoctx = crypto->pkcs7ctx;
\r
85 fprintf (stderr, "Unknown or unsupported cryptographic protocol.\n");
\r
87 @@ -103,5 +118,10 @@ notmuch_crypto_cleanup (notmuch_crypto_t *crypto)
\r
88 crypto->gpgctx = NULL;
\r
91 + if (crypto->pkcs7ctx) {
\r
92 + g_object_unref (crypto->pkcs7ctx);
\r
93 + crypto->pkcs7ctx = NULL;
\r
98 diff --git a/notmuch-client.h b/notmuch-client.h
\r
99 index 278b498..9b80107 100644
\r
100 --- a/notmuch-client.h
\r
101 +++ b/notmuch-client.h
\r
102 @@ -78,6 +78,7 @@ typedef struct notmuch_show_format {
\r
104 typedef struct notmuch_crypto {
\r
105 notmuch_crypto_context_t* gpgctx;
\r
106 + notmuch_crypto_context_t* pkcs7ctx;
\r
107 notmuch_bool_t verify;
\r
108 notmuch_bool_t decrypt;
\r
109 } notmuch_crypto_t;
\r
110 @@ -411,8 +412,8 @@ struct mime_node {
\r
111 /* Construct a new MIME node pointing to the root message part of
\r
112 * message. If crypto->verify is true, signed child parts will be
\r
113 * verified. If crypto->decrypt is true, encrypted child parts will be
\r
114 - * decrypted. If crypto->gpgctx is NULL, it will be lazily
\r
116 + * decrypted. If the crypto contexts (crypto->gpgctx or
\r
117 + * crypto->pkcs7) are NULL, they will be lazily initialized.
\r