From: Richard Russon Date: Thu, 18 Jul 2019 13:02:48 +0000 (+0100) Subject: smime: factor out context X-Git-Tag: 2019-10-25~123 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0a7bb5c2245df6bc585814500127b6f30cbec59e;p=neomutt smime: factor out context --- diff --git a/commands.c b/commands.c index 4b238d74b..3f5f79e05 100644 --- a/commands.c +++ b/commands.c @@ -311,7 +311,7 @@ int mutt_display_message(struct Email *e) { if (e->security & SEC_GOODSIGN) { - if (crypt_smime_verify_sender(e) == 0) + if (crypt_smime_verify_sender(Context->mailbox, e) == 0) mutt_message(_("S/MIME signature successfully verified")); else mutt_error(_("S/MIME certificate owner does not match sender")); diff --git a/ncrypt/crypt.c b/ncrypt/crypt.c index 89f7a4aa6..96df17fe8 100644 --- a/ncrypt/crypt.c +++ b/ncrypt/crypt.c @@ -44,7 +44,6 @@ #include "email/lib.h" #include "mutt.h" #include "alias.h" -#include "context.h" #include "copy.h" #include "cryptglue.h" #include "curs_lib.h" @@ -60,6 +59,8 @@ #include "sendlib.h" #include "state.h" +struct Mailbox; + /* These Config Variables are only used in ncrypt/crypt.c */ bool C_CryptTimestamp; ///< Config: Add a timestamp to PGP or SMIME output to prevent spoofing unsigned char C_PgpEncryptSelf; diff --git a/ncrypt/crypt_gpgme.c b/ncrypt/crypt_gpgme.c index 6f4e6eef9..af7e9f163 100644 --- a/ncrypt/crypt_gpgme.c +++ b/ncrypt/crypt_gpgme.c @@ -5654,7 +5654,7 @@ static bool verify_sender(struct Email *e) /** * smime_gpgme_verify_sender - Implements CryptModuleSpecs::smime_verify_sender() */ -int smime_gpgme_verify_sender(struct Email *e) +int smime_gpgme_verify_sender(struct Mailbox *m, struct Email *e) { return verify_sender(e); } diff --git a/ncrypt/crypt_gpgme.h b/ncrypt/crypt_gpgme.h index 843c46aab..3d3306238 100644 --- a/ncrypt/crypt_gpgme.h +++ b/ncrypt/crypt_gpgme.h @@ -30,6 +30,7 @@ struct AddressList; struct Body; struct Email; +struct Mailbox; struct State; void pgp_gpgme_set_sender(const char *sender); @@ -55,7 +56,7 @@ void smime_gpgme_init(void); int smime_gpgme_send_menu(struct Email *e); struct Body *smime_gpgme_sign_message(struct Body *a); int smime_gpgme_verify_one(struct Body *sigbdy, struct State *s, const char *tempfile); -int smime_gpgme_verify_sender(struct Email *e); +int smime_gpgme_verify_sender(struct Mailbox *m, struct Email *e); const char *mutt_gpgme_print_version(void); diff --git a/ncrypt/crypt_mod.h b/ncrypt/crypt_mod.h index e6aada2a1..11fc34f0b 100644 --- a/ncrypt/crypt_mod.h +++ b/ncrypt/crypt_mod.h @@ -185,11 +185,12 @@ struct CryptModuleSpecs void (*smime_getkeys)(struct Envelope *env); /** * smime_verify_sender - Does the sender match the certificate? + * @param m Mailbox * @param e Email * @retval 0 Success * @retval 1 Failure */ - int (*smime_verify_sender)(struct Email *e); + int (*smime_verify_sender)(struct Mailbox *m, struct Email *e); /** * smime_build_smime_entity - Encrypt the email body to all recipients * @param a Body of email diff --git a/ncrypt/cryptglue.c b/ncrypt/cryptglue.c index b0e12ab02..09d0da2e6 100644 --- a/ncrypt/cryptglue.c +++ b/ncrypt/cryptglue.c @@ -413,10 +413,10 @@ void crypt_smime_getkeys(struct Envelope *env) /** * crypt_smime_verify_sender - Wrapper for CryptModuleSpecs::smime_verify_sender() */ -int crypt_smime_verify_sender(struct Email *e) +int crypt_smime_verify_sender(struct Mailbox *m, struct Email *e) { if (CRYPT_MOD_CALL_CHECK(SMIME, smime_verify_sender)) - return CRYPT_MOD_CALL(SMIME, smime_verify_sender)(e); + return CRYPT_MOD_CALL(SMIME, smime_verify_sender)(m, e); return 1; } diff --git a/ncrypt/ncrypt.h b/ncrypt/ncrypt.h index 354efcd37..1f37eae4a 100644 --- a/ncrypt/ncrypt.h +++ b/ncrypt/ncrypt.h @@ -216,7 +216,7 @@ int crypt_smime_application_handler(struct Body *m, struct State *s); int crypt_smime_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur); void crypt_smime_getkeys(struct Envelope *env); int crypt_smime_send_menu(struct Email *e); -int crypt_smime_verify_sender(struct Email *e); +int crypt_smime_verify_sender(struct Mailbox *m, struct Email *e); /* crypt_mod.c */ void crypto_module_free(void); diff --git a/ncrypt/smime.c b/ncrypt/smime.c index f5179f198..59004dcfe 100644 --- a/ncrypt/smime.c +++ b/ncrypt/smime.c @@ -42,7 +42,6 @@ #include "email/lib.h" #include "mutt.h" #include "alias.h" -#include "context.h" #include "copy.h" #include "crypt.h" #include "cryptglue.h" @@ -1414,7 +1413,7 @@ void smime_class_invoke_import(char *infile, char *mailbox) /** * smime_class_verify_sender - Implements CryptModuleSpecs::smime_verify_sender() */ -int smime_class_verify_sender(struct Email *e) +int smime_class_verify_sender(struct Mailbox *m, struct Email *e) { char *mbox = NULL, *certfile = NULL; char tempfname[PATH_MAX]; @@ -1430,11 +1429,11 @@ int smime_class_verify_sender(struct Email *e) if (e->security & SEC_ENCRYPT) { - mutt_copy_message(fp_out, Context->mailbox, e, MUTT_CM_DECODE_CRYPT & MUTT_CM_DECODE_SMIME, + mutt_copy_message(fp_out, m, e, MUTT_CM_DECODE_CRYPT & MUTT_CM_DECODE_SMIME, CH_MIME | CH_WEED | CH_NONEWLINE); } else - mutt_copy_message(fp_out, Context->mailbox, e, MUTT_CM_NO_FLAGS, CH_NO_FLAGS); + mutt_copy_message(fp_out, m, e, MUTT_CM_NO_FLAGS, CH_NO_FLAGS); fflush(fp_out); mutt_file_fclose(&fp_out); diff --git a/ncrypt/smime.h b/ncrypt/smime.h index fa1af9b5e..24eab8a9b 100644 --- a/ncrypt/smime.h +++ b/ncrypt/smime.h @@ -31,8 +31,9 @@ struct AddressList; struct Body; -struct Envelope; struct Email; +struct Envelope; +struct Mailbox; struct State; /** @@ -59,7 +60,7 @@ int smime_class_send_menu(struct Email *e); struct Body *smime_class_sign_message(struct Body *a); bool smime_class_valid_passphrase(void); int smime_class_verify_one(struct Body *sigbdy, struct State *s, const char *tempfile); -int smime_class_verify_sender(struct Email *e); +int smime_class_verify_sender(struct Mailbox *m, struct Email *e); void smime_class_void_passphrase(void); #endif /* MUTT_NCRYPT_SMIME_H */