diff options
author | Daniel Kahn Gillmor <dkg@fifthhorseman.net> | 2017-12-08 01:23:53 -0500 |
---|---|---|
committer | David Bremner <david@tethera.net> | 2017-12-08 08:07:53 -0400 |
commit | e4890b5bf9e2260b36bcc36ddb77d8e97e2abe7d (patch) | |
tree | 83c71b87a02c656aee698a5e10700a4ff6e12419 /util | |
parent | 798aa789b5d117cf11697bc97dd982bd5a2c2ac8 (diff) |
crypto: new decryption policy "auto"
This new automatic decryption policy should make it possible to
decrypt messages that we have stashed session keys for, without
incurring a call to the user's asymmetric keys.
Diffstat (limited to 'util')
-rw-r--r-- | util/crypto.c | 9 | ||||
-rw-r--r-- | util/crypto.h | 3 |
2 files changed, 10 insertions, 2 deletions
diff --git a/util/crypto.c b/util/crypto.c index 476f1879..bb587571 100644 --- a/util/crypto.c +++ b/util/crypto.c @@ -140,13 +140,16 @@ void _notmuch_crypto_cleanup (unused(_notmuch_crypto_t *crypto)) #endif GMimeObject * -_notmuch_crypto_decrypt (notmuch_message_t *message, +_notmuch_crypto_decrypt (notmuch_decryption_policy_t decrypt, + notmuch_message_t *message, g_mime_3_unused(GMimeCryptoContext* crypto_ctx), GMimeMultipartEncrypted *part, GMimeDecryptResult **decrypt_result, GError **err) { GMimeObject *ret = NULL; + if (decrypt == NOTMUCH_DECRYPT_FALSE) + return NULL; /* the versions of notmuch that can support session key decryption */ #if HAVE_GMIME_SESSION_KEYS @@ -184,6 +187,10 @@ _notmuch_crypto_decrypt (notmuch_message_t *message, g_error_free (*err); *err = NULL; } + + if (decrypt == NOTMUCH_DECRYPT_AUTO) + return ret; + #if (GMIME_MAJOR_VERSION < 3) ret = g_mime_multipart_encrypted_decrypt(part, crypto_ctx, decrypt_result, err); diff --git a/util/crypto.h b/util/crypto.h index b23ca747..dc95b4ca 100644 --- a/util/crypto.h +++ b/util/crypto.h @@ -16,7 +16,8 @@ typedef struct _notmuch_crypto { } _notmuch_crypto_t; GMimeObject * -_notmuch_crypto_decrypt (notmuch_message_t *message, +_notmuch_crypto_decrypt (notmuch_decryption_policy_t decrypt, + notmuch_message_t *message, GMimeCryptoContext* crypto_ctx, GMimeMultipartEncrypted *part, GMimeDecryptResult **decrypt_result, |