From: Kevin McCarthy Date: Mon, 30 Mar 2015 22:45:49 +0000 (-0700) Subject: Introduce an oppenc_mode parameter X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4615a829c7dd4a2ba64683bae4c058b098f5d30a;p=mutt Introduce an oppenc_mode parameter It's added to the parameter lists through the call stack down to the find_keys calls. No functionality is implemented yet. This patch is separated just to keep other patches more readable. --- diff --git a/crypt-gpgme.c b/crypt-gpgme.c index 43ccd278..1aa96d4a 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -4305,8 +4305,10 @@ static crypt_key_t *crypt_ask_for_key (char *tag, } /* This routine attempts to find the keyids of the recipients of a - message. It returns NULL if any of the keys can not be found. */ -static char *find_keys (ADDRESS *adrlist, unsigned int app) + message. It returns NULL if any of the keys can not be found. + If oppenc_mode is true, only keys that can be determined without + prompting will be used. */ +static char *find_keys (ADDRESS *adrlist, unsigned int app, int oppenc_mode) { char *keyID, *keylist = NULL, *t; size_t keylist_size = 0; @@ -4409,14 +4411,14 @@ static char *find_keys (ADDRESS *adrlist, unsigned int app) return (keylist); } -char *pgp_gpgme_findkeys (ADDRESS *adrlist) +char *pgp_gpgme_findkeys (ADDRESS *adrlist, int oppenc_mode) { - return find_keys (adrlist, APPLICATION_PGP); + return find_keys (adrlist, APPLICATION_PGP, oppenc_mode); } -char *smime_gpgme_findkeys (ADDRESS *adrlist) +char *smime_gpgme_findkeys (ADDRESS *adrlist, int oppenc_mode) { - return find_keys (adrlist, APPLICATION_SMIME); + return find_keys (adrlist, APPLICATION_SMIME, oppenc_mode); } #ifdef HAVE_GPGME_OP_EXPORT_KEYS diff --git a/crypt-gpgme.h b/crypt-gpgme.h index 25867065..11ca6a60 100644 --- a/crypt-gpgme.h +++ b/crypt-gpgme.h @@ -24,8 +24,8 @@ void pgp_gpgme_init (void); void smime_gpgme_init (void); -char *pgp_gpgme_findkeys (ADDRESS *adrlist); -char *smime_gpgme_findkeys (ADDRESS *adrlist); +char *pgp_gpgme_findkeys (ADDRESS *adrlist, int oppenc_mode); +char *smime_gpgme_findkeys (ADDRESS *adrlist, int oppenc_mode); BODY *pgp_gpgme_encrypt_message (BODY *a, char *keylist, int sign); BODY *smime_gpgme_build_smime_entity (BODY *a, char *keylist); diff --git a/crypt-mod-pgp-classic.c b/crypt-mod-pgp-classic.c index 1a221e5d..2f69dcdc 100644 --- a/crypt-mod-pgp-classic.c +++ b/crypt-mod-pgp-classic.c @@ -46,9 +46,9 @@ static int crypt_mod_pgp_application_handler (BODY *m, STATE *s) return pgp_application_pgp_handler (m, s); } -static char *crypt_mod_pgp_findkeys (ADDRESS *adrlist) +static char *crypt_mod_pgp_findkeys (ADDRESS *adrlist, int oppenc_mode) { - return pgp_findKeys (adrlist); + return pgp_findKeys (adrlist, oppenc_mode); } static BODY *crypt_mod_pgp_sign_message (BODY *a) diff --git a/crypt-mod-pgp-gpgme.c b/crypt-mod-pgp-gpgme.c index a2b799f5..948585c4 100644 --- a/crypt-mod-pgp-gpgme.c +++ b/crypt-mod-pgp-gpgme.c @@ -70,9 +70,9 @@ static void crypt_mod_pgp_invoke_import (const char *fname) pgp_gpgme_invoke_import (fname); } -static char *crypt_mod_pgp_findkeys (ADDRESS *adrlist) +static char *crypt_mod_pgp_findkeys (ADDRESS *adrlist, int oppenc_mode) { - return pgp_gpgme_findkeys (adrlist); + return pgp_gpgme_findkeys (adrlist, oppenc_mode); } static BODY *crypt_mod_pgp_sign_message (BODY *a) diff --git a/crypt-mod-smime-classic.c b/crypt-mod-smime-classic.c index c4ae79a2..c09db9c7 100644 --- a/crypt-mod-smime-classic.c +++ b/crypt-mod-smime-classic.c @@ -46,9 +46,9 @@ static int crypt_mod_smime_application_handler (BODY *m, STATE *s) return smime_application_smime_handler (m, s); } -static char *crypt_mod_smime_findkeys (ADDRESS *adrlist) +static char *crypt_mod_smime_findkeys (ADDRESS *adrlist, int oppenc_mode) { - return smime_findKeys (adrlist); + return smime_findKeys (adrlist, oppenc_mode); } static BODY *crypt_mod_smime_sign_message (BODY *a) diff --git a/crypt-mod-smime-gpgme.c b/crypt-mod-smime-gpgme.c index c7ade57d..ec1b2ba6 100644 --- a/crypt-mod-smime-gpgme.c +++ b/crypt-mod-smime-gpgme.c @@ -55,9 +55,9 @@ static int crypt_mod_smime_application_handler (BODY *m, STATE *s) return smime_gpgme_application_handler (m, s); } -static char *crypt_mod_smime_findkeys (ADDRESS *adrlist) +static char *crypt_mod_smime_findkeys (ADDRESS *adrlist, int oppenc_mode) { - return smime_gpgme_findkeys (adrlist); + return smime_gpgme_findkeys (adrlist, oppenc_mode); } static BODY *crypt_mod_smime_sign_message (BODY *a) diff --git a/crypt-mod.h b/crypt-mod.h index 2489a613..70910eee 100644 --- a/crypt-mod.h +++ b/crypt-mod.h @@ -43,7 +43,7 @@ typedef int (*crypt_func_pgp_check_traditional_t) (FILE *fp, BODY *b, typedef BODY *(*crypt_func_pgp_traditional_encryptsign_t) (BODY *a, int flags, char *keylist); typedef BODY *(*crypt_func_pgp_make_key_attachment_t) (char *tempf); -typedef char *(*crypt_func_findkeys_t) (ADDRESS *adrlist); +typedef char *(*crypt_func_findkeys_t) (ADDRESS *adrlist, int oppenc_mode); typedef BODY *(*crypt_func_sign_message_t) (BODY *a); typedef BODY *(*crypt_func_pgp_encrypt_message_t) (BODY *a, char *keylist, int sign); diff --git a/crypt.c b/crypt.c index 30a97201..446352b0 100644 --- a/crypt.c +++ b/crypt.c @@ -737,7 +737,7 @@ int crypt_get_keys (HEADER *msg, char **keylist) if ((WithCrypto & APPLICATION_PGP) && (msg->security & APPLICATION_PGP)) { - if ((*keylist = crypt_pgp_findkeys (adrlist)) == NULL) + if ((*keylist = crypt_pgp_findkeys (adrlist, 0)) == NULL) { rfc822_free_address (&adrlist); return (-1); @@ -747,7 +747,7 @@ int crypt_get_keys (HEADER *msg, char **keylist) if ((WithCrypto & APPLICATION_SMIME) && (msg->security & APPLICATION_SMIME)) { - if ((*keylist = crypt_smime_findkeys (adrlist)) == NULL) + if ((*keylist = crypt_smime_findkeys (adrlist, 0)) == NULL) { rfc822_free_address (&adrlist); return (-1); diff --git a/cryptglue.c b/cryptglue.c index fd1c296e..a54ea076 100644 --- a/cryptglue.c +++ b/cryptglue.c @@ -199,11 +199,13 @@ BODY *crypt_pgp_make_key_attachment (char *tempf) } /* This routine attempts to find the keyids of the recipients of a - message. It returns NULL if any of the keys can not be found. */ -char *crypt_pgp_findkeys (ADDRESS *adrlist) + message. It returns NULL if any of the keys can not be found. + If oppenc_mode is true, only keys that can be determined without + prompting will be used. */ +char *crypt_pgp_findkeys (ADDRESS *adrlist, int oppenc_mode) { if (CRYPT_MOD_CALL_CHECK (PGP, findkeys)) - return (CRYPT_MOD_CALL (PGP, findkeys)) (adrlist); + return (CRYPT_MOD_CALL (PGP, findkeys)) (adrlist, oppenc_mode); return NULL; } @@ -333,11 +335,13 @@ int crypt_smime_verify_sender(HEADER *h) } /* This routine attempts to find the keyids of the recipients of a - message. It returns NULL if any of the keys can not be found. */ -char *crypt_smime_findkeys (ADDRESS *adrlist) + message. It returns NULL if any of the keys can not be found. + If oppenc_mode is true, only keys that can be determined without + prompting will be used. */ +char *crypt_smime_findkeys (ADDRESS *adrlist, int oppenc_mode) { if (CRYPT_MOD_CALL_CHECK (SMIME, findkeys)) - return (CRYPT_MOD_CALL (SMIME, findkeys)) (adrlist); + return (CRYPT_MOD_CALL (SMIME, findkeys)) (adrlist, oppenc_mode); return NULL; } diff --git a/mutt_crypt.h b/mutt_crypt.h index cdb43524..8619c5c5 100644 --- a/mutt_crypt.h +++ b/mutt_crypt.h @@ -210,8 +210,10 @@ void crypt_pgp_free_key (pgp_key_t *kpp); BODY *crypt_pgp_make_key_attachment (char *tempf); /* This routine attempts to find the keyids of the recipients of a - message. It returns NULL if any of the keys can not be found. */ -char *crypt_pgp_findkeys (ADDRESS *adrlist); + message. It returns NULL if any of the keys can not be found. + If oppenc_mode is true, only keys that can be determined without + prompting will be used. */ +char *crypt_pgp_findkeys (ADDRESS *adrlist, int oppenc_mode); /* Create a new body with a PGP signed message from A. */ BODY *crypt_pgp_sign_message (BODY *a); @@ -259,8 +261,10 @@ int crypt_smime_verify_sender(HEADER *h); char *crypt_smime_ask_for_key (char *prompt, char *mailbox, short public); /* This routine attempts to find the keyids of the recipients of a - message. It returns NULL if any of the keys can not be found. */ -char *crypt_smime_findkeys (ADDRESS *adrlist); + message. It returns NULL if any of the keys can not be found. + If oppenc_mode is true, only keys that can be determined without + prompting will be used. */ +char *crypt_smime_findkeys (ADDRESS *adrlist, int oppenc_mode); /* fixme: Needs documentation. */ BODY *crypt_smime_sign_message (BODY *a); diff --git a/pgp.c b/pgp.c index b5c9d69c..7d041c8b 100644 --- a/pgp.c +++ b/pgp.c @@ -1182,8 +1182,10 @@ static short is_numerical_keyid (const char *s) /* This routine attempts to find the keyids of the recipients of a message. * It returns NULL if any of the keys can not be found. + * If oppenc_mode is true, only keys that can be determined without + * prompting will be used. */ -char *pgp_findKeys (ADDRESS *adrlist) +char *pgp_findKeys (ADDRESS *adrlist, int oppenc_mode) { char *keyID, *keylist = NULL; size_t keylist_size = 0; diff --git a/pgp.h b/pgp.h index 542d14f3..ab874045 100644 --- a/pgp.h +++ b/pgp.h @@ -51,7 +51,7 @@ pgp_key_t pgp_get_candidates (pgp_ring_t, LIST *); pgp_key_t pgp_getkeybyaddr (ADDRESS *, short, pgp_ring_t); pgp_key_t pgp_getkeybystr (char *, short, pgp_ring_t); -char *pgp_findKeys (ADDRESS *adrlist); +char *pgp_findKeys (ADDRESS *adrlist, int oppenc_mode); void pgp_forget_passphrase (void); int pgp_application_pgp_handler (BODY *, STATE *); diff --git a/smime.c b/smime.c index 0d3416b1..00099459 100644 --- a/smime.c +++ b/smime.c @@ -729,9 +729,11 @@ void smime_getkeys (ENVELOPE *env) /* This routine attempts to find the keyids of the recipients of a message. * It returns NULL if any of the keys can not be found. + * If oppenc_mode is true, only keys that can be determined without + * prompting will be used. */ -char *smime_findKeys (ADDRESS *adrlist) +char *smime_findKeys (ADDRESS *adrlist, int oppenc_mode) { char *keyID, *keylist = NULL; size_t keylist_size = 0; diff --git a/smime.h b/smime.h index 4a91dc86..ce8f0d05 100644 --- a/smime.h +++ b/smime.h @@ -50,7 +50,7 @@ void smime_getkeys (ENVELOPE *); char* smime_ask_for_key (char *, char *, short); -char *smime_findKeys (ADDRESS *adrlist); +char *smime_findKeys (ADDRESS *adrlist, int oppenc_mode); void smime_invoke_import (char *, char *);