--- /dev/null
+Return-Path: <dkg@fifthhorseman.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 arlo.cworth.org (Postfix) with ESMTP id C19BA6DE098A\r
+ for <notmuch@notmuchmail.org>; Fri, 8 Jul 2016 03:13:47 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at cworth.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.067\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.067 tagged_above=-999 required=5 tests=[AWL=0.067]\r
+ autolearn=disabled\r
+Received: from arlo.cworth.org ([127.0.0.1])\r
+ by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id IrPYMG9PZmAP for <notmuch@notmuchmail.org>;\r
+ Fri, 8 Jul 2016 03:13:39 -0700 (PDT)\r
+Received: from che.mayfirst.org (che.mayfirst.org [162.247.75.118])\r
+ by arlo.cworth.org (Postfix) with ESMTP id 0ECE76DE02D9\r
+ for <notmuch@notmuchmail.org>; Fri, 8 Jul 2016 03:13:12 -0700 (PDT)\r
+Received: from fifthhorseman.net (unknown [88.128.80.54])\r
+ by che.mayfirst.org (Postfix) with ESMTPSA id 65A49F98B\r
+ for <notmuch@notmuchmail.org>; Fri, 8 Jul 2016 06:13:11 -0400 (EDT)\r
+Received: by fifthhorseman.net (Postfix, from userid 1000)\r
+ id 8754120DE3; Fri, 8 Jul 2016 11:27:34 +0200 (CEST)\r
+From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
+To: Notmuch Mail <notmuch@notmuchmail.org>\r
+Subject: [PATCH v4 02/16] Move crypto.c into libutil\r
+Date: Fri, 8 Jul 2016 11:27:13 +0200\r
+Message-Id: <1467970047-8013-3-git-send-email-dkg@fifthhorseman.net>\r
+X-Mailer: git-send-email 2.8.1\r
+In-Reply-To: <1467970047-8013-1-git-send-email-dkg@fifthhorseman.net>\r
+References: <1467970047-8013-1-git-send-email-dkg@fifthhorseman.net>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=UTF-8\r
+Content-Transfer-Encoding: 8bit\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.20\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <https://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: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 08 Jul 2016 10:13:47 -0000\r
+\r
+This prepares us for using the crypto object in both the library and\r
+the client.\r
+\r
+i've prefixed notmuch_crypto with _ to indicate that while this can be\r
+built into the library when needed, it's not something to be exported\r
+or used externally.\r
+---\r
+ Makefile.local | 1 -\r
+ crypto.c | 134 --------------------------------------------------\r
+ mime-node.c | 12 ++---\r
+ notmuch-client.h | 23 ++-------\r
+ notmuch-reply.c | 2 +-\r
+ notmuch-show.c | 2 +-\r
+ util/Makefile.local | 2 +-\r
+ util/crypto.c | 138 ++++++++++++++++++++++++++++++++++++++++++++++++++++\r
+ util/crypto.h | 25 ++++++++++\r
+ 9 files changed, 175 insertions(+), 164 deletions(-)\r
+ delete mode 100644 crypto.c\r
+ create mode 100644 util/crypto.c\r
+ create mode 100644 util/crypto.h\r
+\r
+diff --git a/Makefile.local b/Makefile.local\r
+index f2ad0c1..c13ba76 100644\r
+--- a/Makefile.local\r
++++ b/Makefile.local\r
+@@ -293,7 +293,6 @@ notmuch_client_srcs = \\r
+ sprinter-text.c \\r
+ query-string.c \\r
+ mime-node.c \\r
+- crypto.c \\r
+ tag-util.c\r
+ \r
+ notmuch_client_modules = $(notmuch_client_srcs:.c=.o)\r
+diff --git a/crypto.c b/crypto.c\r
+deleted file mode 100644\r
+index 3e8ce7c..0000000\r
+--- a/crypto.c\r
++++ /dev/null\r
+@@ -1,134 +0,0 @@\r
+-/* notmuch - Not much of an email program, (just index and search)\r
+- *\r
+- * Copyright © 2012 Jameson Rollins\r
+- *\r
+- * This program is free software: you can redistribute it and/or modify\r
+- * it under the terms of the GNU General Public License as published by\r
+- * the Free Software Foundation, either version 3 of the License, or\r
+- * (at your option) any later version.\r
+- *\r
+- * This program is distributed in the hope that it will be useful,\r
+- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+- * GNU General Public License for more details.\r
+- *\r
+- * You should have received a copy of the GNU General Public License\r
+- * along with this program. If not, see https://www.gnu.org/licenses/ .\r
+- *\r
+- * Authors: Jameson Rollins <jrollins@finestructure.net>\r
+- */\r
+-\r
+-#include "notmuch-client.h"\r
+-\r
+-/* Create a GPG context (GMime 2.6) */\r
+-static notmuch_crypto_context_t *\r
+-create_gpg_context (notmuch_crypto_t *crypto)\r
+-{\r
+- notmuch_crypto_context_t *gpgctx;\r
+-\r
+- if (crypto->gpgctx)\r
+- return crypto->gpgctx;\r
+-\r
+- /* TODO: GMimePasswordRequestFunc */\r
+- gpgctx = g_mime_gpg_context_new (NULL, crypto->gpgpath ? crypto->gpgpath : "gpg");\r
+- if (! gpgctx) {\r
+- fprintf (stderr, "Failed to construct gpg context.\n");\r
+- return NULL;\r
+- }\r
+- crypto->gpgctx = gpgctx;\r
+-\r
+- g_mime_gpg_context_set_use_agent ((GMimeGpgContext *) gpgctx, TRUE);\r
+- g_mime_gpg_context_set_always_trust ((GMimeGpgContext *) gpgctx, FALSE);\r
+-\r
+- return gpgctx;\r
+-}\r
+-\r
+-/* Create a PKCS7 context (GMime 2.6) */\r
+-static notmuch_crypto_context_t *\r
+-create_pkcs7_context (notmuch_crypto_t *crypto)\r
+-{\r
+- notmuch_crypto_context_t *pkcs7ctx;\r
+-\r
+- if (crypto->pkcs7ctx)\r
+- return crypto->pkcs7ctx;\r
+-\r
+- /* TODO: GMimePasswordRequestFunc */\r
+- pkcs7ctx = g_mime_pkcs7_context_new (NULL);\r
+- if (! pkcs7ctx) {\r
+- fprintf (stderr, "Failed to construct pkcs7 context.\n");\r
+- return NULL;\r
+- }\r
+- crypto->pkcs7ctx = pkcs7ctx;\r
+-\r
+- g_mime_pkcs7_context_set_always_trust ((GMimePkcs7Context *) pkcs7ctx,\r
+- FALSE);\r
+-\r
+- return pkcs7ctx;\r
+-}\r
+-static const struct {\r
+- const char *protocol;\r
+- notmuch_crypto_context_t *(*get_context) (notmuch_crypto_t *crypto);\r
+-} protocols[] = {\r
+- {\r
+- .protocol = "application/pgp-signature",\r
+- .get_context = create_gpg_context,\r
+- },\r
+- {\r
+- .protocol = "application/pgp-encrypted",\r
+- .get_context = create_gpg_context,\r
+- },\r
+- {\r
+- .protocol = "application/pkcs7-signature",\r
+- .get_context = create_pkcs7_context,\r
+- },\r
+- {\r
+- .protocol = "application/x-pkcs7-signature",\r
+- .get_context = create_pkcs7_context,\r
+- },\r
+-};\r
+-\r
+-/* for the specified protocol return the context pointer (initializing\r
+- * if needed) */\r
+-notmuch_crypto_context_t *\r
+-notmuch_crypto_get_context (notmuch_crypto_t *crypto, const char *protocol)\r
+-{\r
+- notmuch_crypto_context_t *cryptoctx = NULL;\r
+- size_t i;\r
+-\r
+- if (! protocol) {\r
+- fprintf (stderr, "Cryptographic protocol is empty.\n");\r
+- return cryptoctx;\r
+- }\r
+-\r
+- /* As per RFC 1847 section 2.1: "the [protocol] value token is\r
+- * comprised of the type and sub-type tokens of the Content-Type".\r
+- * As per RFC 1521 section 2: "Content-Type values, subtypes, and\r
+- * parameter names as defined in this document are\r
+- * case-insensitive." Thus, we use strcasecmp for the protocol.\r
+- */\r
+- for (i = 0; i < ARRAY_SIZE (protocols); i++) {\r
+- if (strcasecmp (protocol, protocols[i].protocol) == 0)\r
+- return protocols[i].get_context (crypto);\r
+- }\r
+-\r
+- fprintf (stderr, "Unknown or unsupported cryptographic protocol %s.\n",\r
+- protocol);\r
+-\r
+- return NULL;\r
+-}\r
+-\r
+-int\r
+-notmuch_crypto_cleanup (notmuch_crypto_t *crypto)\r
+-{\r
+- if (crypto->gpgctx) {\r
+- g_object_unref (crypto->gpgctx);\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/mime-node.c b/mime-node.c\r
+index c9b8233..14873ce 100644\r
+--- a/mime-node.c\r
++++ b/mime-node.c\r
+@@ -33,7 +33,7 @@ typedef struct mime_node_context {\r
+ GMimeMessage *mime_message;\r
+ \r
+ /* Context provided by the caller. */\r
+- notmuch_crypto_t *crypto;\r
++ _notmuch_crypto_t *crypto;\r
+ } mime_node_context_t;\r
+ \r
+ static int\r
+@@ -56,7 +56,7 @@ _mime_node_context_free (mime_node_context_t *res)\r
+ \r
+ notmuch_status_t\r
+ mime_node_open (const void *ctx, notmuch_message_t *message,\r
+- notmuch_crypto_t *crypto, mime_node_t **root_out)\r
++ _notmuch_crypto_t *crypto, mime_node_t **root_out)\r
+ {\r
+ const char *filename = notmuch_message_get_filename (message);\r
+ mime_node_context_t *mctx;\r
+@@ -151,7 +151,7 @@ set_signature_list_destructor (mime_node_t *node)\r
+ /* Verify a signed mime node (GMime 2.6) */\r
+ static void\r
+ node_verify (mime_node_t *node, GMimeObject *part,\r
+- notmuch_crypto_context_t *cryptoctx)\r
++ GMimeCryptoContext *cryptoctx)\r
+ {\r
+ GError *err = NULL;\r
+ \r
+@@ -172,7 +172,7 @@ node_verify (mime_node_t *node, GMimeObject *part,\r
+ /* Decrypt and optionally verify an encrypted mime node (GMime 2.6) */\r
+ static void\r
+ node_decrypt_and_verify (mime_node_t *node, GMimeObject *part,\r
+- notmuch_crypto_context_t *cryptoctx)\r
++ GMimeCryptoContext *cryptoctx)\r
+ {\r
+ GError *err = NULL;\r
+ GMimeDecryptResult *decrypt_result = NULL;\r
+@@ -207,7 +207,7 @@ static mime_node_t *\r
+ _mime_node_create (mime_node_t *parent, GMimeObject *part)\r
+ {\r
+ mime_node_t *node = talloc_zero (parent, mime_node_t);\r
+- notmuch_crypto_context_t *cryptoctx = NULL;\r
++ GMimeCryptoContext *cryptoctx = NULL;\r
+ \r
+ /* Set basic node properties */\r
+ node->part = part;\r
+@@ -244,7 +244,7 @@ _mime_node_create (mime_node_t *parent, GMimeObject *part)\r
+ || (GMIME_IS_MULTIPART_SIGNED (part) && node->ctx->crypto->verify)) {\r
+ GMimeContentType *content_type = g_mime_object_get_content_type (part);\r
+ const char *protocol = g_mime_content_type_get_parameter (content_type, "protocol");\r
+- cryptoctx = notmuch_crypto_get_context (node->ctx->crypto, protocol);\r
++ cryptoctx = _notmuch_crypto_get_gmime_context (node->ctx->crypto, protocol);\r
+ }\r
+ \r
+ /* Handle PGP/MIME parts */\r
+diff --git a/notmuch-client.h b/notmuch-client.h\r
+index 9ce2aef..a65bb6d 100644\r
+--- a/notmuch-client.h\r
++++ b/notmuch-client.h\r
+@@ -30,10 +30,6 @@\r
+ \r
+ #include <gmime/gmime.h>\r
+ \r
+-typedef GMimeCryptoContext notmuch_crypto_context_t;\r
+-/* This is automatically included only since gmime 2.6.10 */\r
+-#include <gmime/gmime-pkcs7-context.h>\r
+-\r
+ #include "notmuch.h"\r
+ \r
+ /* This is separate from notmuch-private.h because we're trying to\r
+@@ -53,6 +49,7 @@ typedef GMimeCryptoContext notmuch_crypto_context_t;\r
+ #include <ctype.h>\r
+ \r
+ #include "talloc-extra.h"\r
++#include "crypto.h"\r
+ \r
+ #define unused(x) x __attribute__ ((unused))\r
+ \r
+@@ -70,21 +67,13 @@ typedef struct notmuch_show_format {\r
+ const struct notmuch_show_params *params);\r
+ } notmuch_show_format_t;\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
+- const char *gpgpath;\r
+-} notmuch_crypto_t;\r
+-\r
+ typedef struct notmuch_show_params {\r
+ notmuch_bool_t entire_thread;\r
+ notmuch_bool_t omit_excluded;\r
+ notmuch_bool_t output_body;\r
+ notmuch_bool_t raw;\r
+ int part;\r
+- notmuch_crypto_t crypto;\r
++ _notmuch_crypto_t crypto;\r
+ notmuch_bool_t include_html;\r
+ } notmuch_show_params_t;\r
+ \r
+@@ -167,12 +156,6 @@ typedef struct _notmuch_config notmuch_config_t;\r
+ void\r
+ notmuch_exit_if_unsupported_format (void);\r
+ \r
+-notmuch_crypto_context_t *\r
+-notmuch_crypto_get_context (notmuch_crypto_t *crypto, const char *protocol);\r
+-\r
+-int\r
+-notmuch_crypto_cleanup (notmuch_crypto_t *crypto);\r
+-\r
+ int\r
+ notmuch_count_command (notmuch_config_t *config, int argc, char *argv[]);\r
+ \r
+@@ -423,7 +406,7 @@ struct mime_node {\r
+ */\r
+ notmuch_status_t\r
+ mime_node_open (const void *ctx, notmuch_message_t *message,\r
+- notmuch_crypto_t *crypto, mime_node_t **node_out);\r
++ _notmuch_crypto_t *crypto, mime_node_t **node_out);\r
+ \r
+ /* Return a new MIME node for the requested child part of parent.\r
+ * parent will be used as the talloc context for the returned child\r
+diff --git a/notmuch-reply.c b/notmuch-reply.c\r
+index 4951373..42aef47 100644\r
+--- a/notmuch-reply.c\r
++++ b/notmuch-reply.c\r
+@@ -862,7 +862,7 @@ notmuch_reply_command (notmuch_config_t *config, int argc, char *argv[])\r
+ if (reply_format_func (config, config, query, ¶ms, reply_all, sp) != 0)\r
+ return EXIT_FAILURE;\r
+ \r
+- notmuch_crypto_cleanup (¶ms.crypto);\r
++ _notmuch_crypto_cleanup (¶ms.crypto);\r
+ notmuch_query_destroy (query);\r
+ notmuch_database_destroy (notmuch);\r
+ \r
+diff --git a/notmuch-show.c b/notmuch-show.c\r
+index 22fa655..8ebf4ff 100644\r
+--- a/notmuch-show.c\r
++++ b/notmuch-show.c\r
+@@ -1171,7 +1171,7 @@ notmuch_show_command (notmuch_config_t *config, int argc, char *argv[])\r
+ ret = do_show (config, query, format, sprinter, ¶ms);\r
+ }\r
+ \r
+- notmuch_crypto_cleanup (¶ms.crypto);\r
++ _notmuch_crypto_cleanup (¶ms.crypto);\r
+ notmuch_query_destroy (query);\r
+ notmuch_database_destroy (notmuch);\r
+ \r
+diff --git a/util/Makefile.local b/util/Makefile.local\r
+index 8b2b91b..7590618 100644\r
+--- a/util/Makefile.local\r
++++ b/util/Makefile.local\r
+@@ -5,7 +5,7 @@ extra_cflags += -I$(srcdir)/$(dir)\r
+ \r
+ libutil_c_srcs := $(dir)/xutil.c $(dir)/error_util.c $(dir)/hex-escape.c \\r
+ $(dir)/string-util.c $(dir)/talloc-extra.c $(dir)/zlib-extra.c \\r
+- $(dir)/util.c $(dir)/search-path.c\r
++ $(dir)/util.c $(dir)/search-path.c $(dir)/crypto.c\r
+ \r
+ libutil_modules := $(libutil_c_srcs:.c=.o)\r
+ \r
+diff --git a/util/crypto.c b/util/crypto.c\r
+new file mode 100644\r
+index 0000000..48c20bb\r
+--- /dev/null\r
++++ b/util/crypto.c\r
+@@ -0,0 +1,138 @@\r
++/* notmuch - Not much of an email program, (just index and search)\r
++ *\r
++ * Copyright © 2012 Jameson Rollins\r
++ *\r
++ * This program is free software: you can redistribute it and/or modify\r
++ * it under the terms of the GNU General Public License as published by\r
++ * the Free Software Foundation, either version 3 of the License, or\r
++ * (at your option) any later version.\r
++ *\r
++ * This program is distributed in the hope that it will be useful,\r
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
++ * GNU General Public License for more details.\r
++ *\r
++ * You should have received a copy of the GNU General Public License\r
++ * along with this program. If not, see https://www.gnu.org/licenses/ .\r
++ *\r
++ * Authors: Jameson Rollins <jrollins@finestructure.net>\r
++ * Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
++ */\r
++\r
++#include "notmuch.h"\r
++#include "crypto.h"\r
++#include <string.h>\r
++\r
++#define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0]))\r
++\r
++/* Create a GPG context (GMime 2.6) */\r
++static GMimeCryptoContext*\r
++create_gpg_context (_notmuch_crypto_t *crypto)\r
++{\r
++ GMimeCryptoContext *gpgctx;\r
++\r
++ if (crypto->gpgctx) {\r
++ return crypto->gpgctx;\r
++ }\r
++\r
++ /* TODO: GMimePasswordRequestFunc */\r
++ gpgctx = g_mime_gpg_context_new (NULL, crypto->gpgpath ? crypto->gpgpath : "gpg");\r
++ if (! gpgctx) {\r
++ fprintf (stderr, "Failed to construct gpg context.\n");\r
++ return NULL;\r
++ }\r
++ crypto->gpgctx = gpgctx;\r
++\r
++ g_mime_gpg_context_set_use_agent ((GMimeGpgContext *) gpgctx, TRUE);\r
++ g_mime_gpg_context_set_always_trust ((GMimeGpgContext *) gpgctx, FALSE);\r
++\r
++ return crypto->gpgctx;\r
++}\r
++\r
++/* Create a PKCS7 context (GMime 2.6) */\r
++static notmuch_crypto_context_t *\r
++create_pkcs7_context (notmuch_crypto_t *crypto)\r
++{\r
++ notmuch_crypto_context_t *pkcs7ctx;\r
++\r
++ if (crypto->pkcs7ctx)\r
++ return crypto->pkcs7ctx;\r
++\r
++ /* TODO: GMimePasswordRequestFunc */\r
++ pkcs7ctx = g_mime_pkcs7_context_new (NULL);\r
++ if (! pkcs7ctx) {\r
++ fprintf (stderr, "Failed to construct pkcs7 context.\n");\r
++ return NULL;\r
++ }\r
++ crypto->pkcs7ctx = pkcs7ctx;\r
++\r
++ g_mime_pkcs7_context_set_always_trust ((GMimePkcs7Context *) pkcs7ctx,\r
++ FALSE);\r
++\r
++ return crypto->pkcs7ctx;\r
++}\r
++static const struct {\r
++ const char *protocol;\r
++ GMimeCryptoContext *(*get_context) (_notmuch_crypto_t *crypto);\r
++} protocols[] = {\r
++ {\r
++ .protocol = "application/pgp-signature",\r
++ .get_context = create_gpg_context,\r
++ },\r
++ {\r
++ .protocol = "application/pgp-encrypted",\r
++ .get_context = create_gpg_context,\r
++ },\r
++ {\r
++ .protocol = "application/pkcs7-signature",\r
++ .get_context = create_pkcs7_context,\r
++ },\r
++ {\r
++ .protocol = "application/x-pkcs7-signature",\r
++ .get_context = create_pkcs7_context,\r
++ },\r
++};\r
++\r
++/* for the specified protocol return the context pointer (initializing\r
++ * if needed) */\r
++GMimeCryptoContext *\r
++_notmuch_crypto_get_gmime_context (_notmuch_crypto_t *crypto, const char *protocol)\r
++{\r
++ GMimeCryptoContext *cryptoctx = NULL;\r
++ size_t i;\r
++\r
++ if (! protocol) {\r
++ fprintf (stderr, "Cryptographic protocol is empty.\n");\r
++ return cryptoctx;\r
++ }\r
++\r
++ /* As per RFC 1847 section 2.1: "the [protocol] value token is\r
++ * comprised of the type and sub-type tokens of the Content-Type".\r
++ * As per RFC 1521 section 2: "Content-Type values, subtypes, and\r
++ * parameter names as defined in this document are\r
++ * case-insensitive." Thus, we use strcasecmp for the protocol.\r
++ */\r
++ for (i = 0; i < ARRAY_SIZE (protocols); i++) {\r
++ if (strcasecmp (protocol, protocols[i].protocol) == 0)\r
++ return protocols[i].get_context (crypto);\r
++ }\r
++\r
++ fprintf (stderr, "Unknown or unsupported cryptographic protocol %s.\n",\r
++ protocol);\r
++\r
++ return NULL;\r
++}\r
++\r
++void\r
++_notmuch_crypto_cleanup (_notmuch_crypto_t *crypto)\r
++{\r
++ if (crypto->gpgctx) {\r
++ g_object_unref (crypto->gpgctx);\r
++ crypto->gpgctx = NULL;\r
++ }\r
++\r
++ if (crypto->pkcs7ctx) {\r
++ g_object_unref (crypto->pkcs7ctx);\r
++ crypto->pkcs7ctx = NULL;\r
++ }\r
++}\r
+diff --git a/util/crypto.h b/util/crypto.h\r
+new file mode 100644\r
+index 0000000..d4a51e8\r
+--- /dev/null\r
++++ b/util/crypto.h\r
+@@ -0,0 +1,25 @@\r
++#ifndef _CRYPTO_H\r
++#define _CRYPTO_H\r
++\r
++#include "notmuch.h"\r
++#include <gmime/gmime.h>\r
++/* This is automatically included only since gmime 2.6.10 */\r
++#include <gmime/gmime-pkcs7-context.h>\r
++\r
++typedef struct _notmuch_crypto {\r
++ GMimeCryptoContext* gpgctx;\r
++ GMimeCryptoContext* pkcs7ctx;\r
++ notmuch_bool_t verify;\r
++ notmuch_bool_t decrypt;\r
++ const char *gpgpath;\r
++} _notmuch_crypto_t;\r
++\r
++\r
++GMimeCryptoContext *\r
++_notmuch_crypto_get_gmime_context (_notmuch_crypto_t *crypto, const char *protocol);\r
++\r
++void\r
++_notmuch_crypto_cleanup (_notmuch_crypto_t *crypto);\r
++\r
++\r
++#endif\r
+-- \r
+2.8.1\r
+\r