mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 04:18:08 +01:00
a990585408
When doing any decryption, if the notmuch database knows of any session keys associated with the message in question, try them before defaulting to using default symmetric crypto. This changeset does the primary work in _notmuch_crypto_decrypt, which grows some new parameters to handle it. The primary advantage this patch offers is a significant speedup when rendering large encrypted threads ("notmuch show") if session keys happen to be cached. Additionally, it permits message composition without access to asymmetric secret keys ("notmuch reply"); and it permits recovering a cleartext index when reindexing after a "notmuch restore" for those messages that already have a session key stored. Note that we may try multiple decryptions here (e.g. if there are multiple session keys in the database), but we will ignore and throw away all the GMime errors except for those that come from last decryption attempt. Since we don't necessarily know at the time of the decryption that this *is* the last decryption attempt, we'll ask for the errors each time anyway. This does nothing if no session keys are stashed in the database, which is fine. Actually stashing session keys in the database will come as a subsequent patch.
35 lines
781 B
C
35 lines
781 B
C
#ifndef _CRYPTO_H
|
|
#define _CRYPTO_H
|
|
|
|
#include <stdbool.h>
|
|
#include "gmime-extra.h"
|
|
#include "notmuch.h"
|
|
|
|
typedef struct _notmuch_crypto {
|
|
bool verify;
|
|
bool decrypt;
|
|
#if (GMIME_MAJOR_VERSION < 3)
|
|
GMimeCryptoContext* gpgctx;
|
|
GMimeCryptoContext* pkcs7ctx;
|
|
const char *gpgpath;
|
|
#endif
|
|
} _notmuch_crypto_t;
|
|
|
|
GMimeObject *
|
|
_notmuch_crypto_decrypt (notmuch_message_t *message,
|
|
GMimeCryptoContext* crypto_ctx,
|
|
GMimeMultipartEncrypted *part,
|
|
GMimeDecryptResult **decrypt_result,
|
|
GError **err);
|
|
|
|
#if (GMIME_MAJOR_VERSION < 3)
|
|
notmuch_status_t
|
|
_notmuch_crypto_get_gmime_ctx_for_protocol (_notmuch_crypto_t *crypto,
|
|
const char *protocol,
|
|
GMimeCryptoContext **ctx);
|
|
#endif
|
|
|
|
void
|
|
_notmuch_crypto_cleanup (_notmuch_crypto_t *crypto);
|
|
|
|
#endif
|