From: Jameson Graef Rollins <jrollins@finestructure.net>
To: Notmuch Mail <notmuch@notmuchmail.org>
Subject: [PATCH 1/2] cli: S/MIME verification/decryption support
Date: Sun, 16 Mar 2014 21:52:23 -0700 [thread overview]
Message-ID: <1395031944-15557-2-git-send-email-jrollins@finestructure.net> (raw)
In-Reply-To: <1395031944-15557-1-git-send-email-jrollins@finestructure.net>
The notmuch-show flags --decrypt and --verify will now also process
S/MIME multiparts if encountered. Requires gmime-2.6 and gpgsm.
---
crypto.c | 20 ++++++++++++++++++++
notmuch-client.h | 5 +++--
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/crypto.c b/crypto.c
index 6f4a6db..d66aa66 100644
--- a/crypto.c
+++ b/crypto.c
@@ -88,6 +88,21 @@ notmuch_crypto_get_context (notmuch_crypto_t *crypto, const char *protocol)
fprintf (stderr, "Failed to construct gpg context.\n");
}
cryptoctx = crypto->gpgctx;
+#ifdef GMIME_ATLEAST_26
+ } else if ((strcasecmp (protocol, "application/pkcs7-signature") == 0)
+ || (strcasecmp (protocol, "application/x-pkcs7-signature") == 0)
+ || (strcasecmp (protocol, "application/pkcs7-encrypted") == 0)) {
+ if (! crypto->pkcs7ctx) {
+ /* TODO: GMimePasswordRequestFunc */
+ crypto->pkcs7ctx = g_mime_pkcs7_context_new (NULL);
+ if (crypto->pkcs7ctx) {
+ g_mime_pkcs7_context_set_always_trust ((GMimePkcs7Context*) crypto->pkcs7ctx, FALSE);
+ } else {
+ fprintf (stderr, "Failed to construct pkcs7 context.\n");
+ }
+ }
+ cryptoctx = crypto->pkcs7ctx;
+#endif
} else {
fprintf (stderr, "Unknown or unsupported cryptographic protocol.\n");
}
@@ -103,5 +118,10 @@ notmuch_crypto_cleanup (notmuch_crypto_t *crypto)
crypto->gpgctx = NULL;
}
+ if (crypto->pkcs7ctx) {
+ g_object_unref (crypto->pkcs7ctx);
+ crypto->pkcs7ctx = NULL;
+ }
+
return 0;
}
diff --git a/notmuch-client.h b/notmuch-client.h
index 278b498..9b80107 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -78,6 +78,7 @@ typedef struct notmuch_show_format {
typedef struct notmuch_crypto {
notmuch_crypto_context_t* gpgctx;
+ notmuch_crypto_context_t* pkcs7ctx;
notmuch_bool_t verify;
notmuch_bool_t decrypt;
} notmuch_crypto_t;
@@ -411,8 +412,8 @@ struct mime_node {
/* Construct a new MIME node pointing to the root message part of
* message. If crypto->verify is true, signed child parts will be
* verified. If crypto->decrypt is true, encrypted child parts will be
- * decrypted. If crypto->gpgctx is NULL, it will be lazily
- * initialized.
+ * decrypted. If the crypto contexts (crypto->gpgctx or
+ * crypto->pkcs7) are NULL, they will be lazily initialized.
*
* Return value:
*
--
1.9.0
next prev parent reply other threads:[~2014-03-17 4:52 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-29 18:38 S/MIME support Jameson Graef Rollins
2012-06-29 18:38 ` [PATCH 1/2] cli: S/MIME verification/decryption support Jameson Graef Rollins
2012-06-29 18:38 ` [PATCH 2/2] debian: Recommend gpgsm for S/MIME support Jameson Graef Rollins
2012-07-09 18:33 ` Bryant, Daniel B.
2012-07-10 7:40 ` Jameson Graef Rollins
2012-08-31 19:50 ` David Bremner
2014-03-17 4:52 ` S/MIME support, rebased Jameson Graef Rollins
2014-03-17 4:52 ` Jameson Graef Rollins [this message]
2014-03-17 4:52 ` [PATCH 2/2] debian: Recommend gpgsm for S/MIME support Jameson Graef Rollins
2014-07-01 10:55 ` [PATCH 1/2] cli: S/MIME verification/decryption support David Bremner
2014-07-06 17:36 ` Jameson Graef Rollins
2014-07-06 18:18 ` David Bremner
2015-01-17 10:51 ` SMIME patches v3, with some tests David Bremner
2015-01-17 10:51 ` [PATCH 1/4] test: initial tests for smime David Bremner
2015-01-17 10:51 ` [PATCH 2/4] cli: S/MIME verification/decryption support David Bremner
2015-01-17 10:51 ` [PATCH 3/4] test: add S/MIME signature verification test for notmuch CLI David Bremner
2015-01-17 10:51 ` [PATCH 4/4] debian: Recommend gpgsm for S/MIME support David Bremner
2015-01-17 20:07 ` SMIME patches v3, with some tests Jameson Graef Rollins
2015-01-17 21:38 ` [PATCH] test: initial tests for smime David Bremner
2015-01-17 21:59 ` Jameson Graef Rollins
2015-01-17 22:29 ` David Bremner
2015-01-17 22:54 ` Jameson Graef Rollins
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1395031944-15557-2-git-send-email-jrollins@finestructure.net \
--to=jrollins@finestructure.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).