summaryrefslogtreecommitdiffstats
path: root/crypt.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2015-03-30 15:45:47 -0700
committerKevin McCarthy <kevin@8t8.us>2015-03-30 15:45:47 -0700
commitecbba07c51d92c7af5b97ff49b50267ef00074d6 (patch)
tree3b3d1d9536f55158ee843b6442ae59ca655fad5c /crypt.c
parent2539e02de66b8a47d976b420eb46f5212f09419a (diff)
Refactor the address list generation out of the find_keys routines.
All four find_keys routines have a similar set up code for generating a single address list out of the to, cc, bcc lists. This patch pulls all the code into crypt_get_keys. This is done to simplify the functions before later patches make them more complicated (with the oppenc_mode parameter).
Diffstat (limited to 'crypt.c')
-rw-r--r--crypt.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/crypt.c b/crypt.c
index 83471859..30a97201 100644
--- a/crypt.c
+++ b/crypt.c
@@ -709,6 +709,9 @@ void crypt_extract_keys_from_messages (HEADER * h)
int crypt_get_keys (HEADER *msg, char **keylist)
{
+ ADDRESS *adrlist = NULL, *last = NULL;
+ const char *fqdn = mutt_fqdn (1);
+
/* Do a quick check to make sure that we can find all of the encryption
* keys if the user has requested this service.
*/
@@ -719,6 +722,14 @@ int crypt_get_keys (HEADER *msg, char **keylist)
if ((WithCrypto & APPLICATION_PGP))
set_option (OPTPGPCHECKTRUST);
+ last = rfc822_append (&adrlist, msg->env->to, 0);
+ last = rfc822_append (last ? &last : &adrlist, msg->env->cc, 0);
+ rfc822_append (last ? &last : &adrlist, msg->env->bcc, 0);
+
+ if (fqdn)
+ rfc822_qualify (adrlist, fqdn);
+ adrlist = mutt_remove_duplicates (adrlist);
+
*keylist = NULL;
if (msg->security & ENCRYPT)
@@ -726,19 +737,25 @@ int crypt_get_keys (HEADER *msg, char **keylist)
if ((WithCrypto & APPLICATION_PGP)
&& (msg->security & APPLICATION_PGP))
{
- if ((*keylist = crypt_pgp_findkeys (msg->env->to, msg->env->cc,
- msg->env->bcc)) == NULL)
+ if ((*keylist = crypt_pgp_findkeys (adrlist)) == NULL)
+ {
+ rfc822_free_address (&adrlist);
return (-1);
+ }
unset_option (OPTPGPCHECKTRUST);
}
if ((WithCrypto & APPLICATION_SMIME)
&& (msg->security & APPLICATION_SMIME))
{
- if ((*keylist = crypt_smime_findkeys (msg->env->to, msg->env->cc,
- msg->env->bcc)) == NULL)
+ if ((*keylist = crypt_smime_findkeys (adrlist)) == NULL)
+ {
+ rfc822_free_address (&adrlist);
return (-1);
+ }
}
}
+
+ rfc822_free_address (&adrlist);
return (0);
}