Find a PGP key by address.
378{
379 if (!a)
380 return NULL;
381
383
384 bool multi = false;
385
386 struct PgpKeyInfo *keys = NULL, *k = NULL, *kn = NULL;
387 struct PgpKeyInfo *the_strong_valid_key = NULL;
388 struct PgpKeyInfo *a_valid_addrmatch_key = NULL;
392
397
398 if (!oppenc_mode)
401
403
404 if (!keys)
405 return NULL;
406
409
410 for (k = keys; k; k = kn)
411 {
412 kn = k->next;
413
415
416 if (abilities && !(k->flags & abilities))
417 {
419 continue;
420 }
421
422 bool match = false;
423
424 for (q = k->address; q; q = q->
next)
425 {
430 {
432
434 match = true;
435
437 {
439 {
440 if (the_strong_valid_key && (the_strong_valid_key != k))
441 multi = true;
442 the_strong_valid_key = k;
443 }
444 else
445 {
446 a_valid_addrmatch_key = k;
447 }
448 }
449 }
450
452 }
453
454 if (match)
455 {
459 }
460 }
461
463
464 if (matches)
465 {
466 if (oppenc_mode || !isatty(STDIN_FILENO))
467 {
468 const bool c_crypt_opportunistic_encrypt_strong_keys =
470 if (the_strong_valid_key)
471 {
473 k = the_strong_valid_key;
474 }
475 else if (a_valid_addrmatch_key && !c_crypt_opportunistic_encrypt_strong_keys)
476 {
478 k = a_valid_addrmatch_key;
479 }
480 else
481 {
482 k = NULL;
483 }
484 }
485 else if (the_strong_valid_key && !multi)
486 {
487
488
490 k = the_strong_valid_key;
491 }
492 else
493 {
494
496 if (k)
498 }
499
501
502 return k;
503 }
504
505 return NULL;
506}
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
int mutt_addrlist_parse(struct AddressList *al, const char *s)
Parse a list of email addresses.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
struct PgpKeyInfo * pgp_get_candidates(enum PgpRing keyring, struct ListHead *hints)
Find PGP keys matching a list of hints.
struct PgpKeyInfo * dlg_pgp(struct PgpKeyInfo *keys, struct Address *p, const char *s)
Let the user select a key to use -.
#define mutt_message(...)
#define mutt_debug(LEVEL,...)
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
@ LL_DEBUG3
Log at debug level 3.
@ LL_DEBUG5
Log at debug level 5.
char * pgp_keyid(struct PgpKeyInfo *k)
Get the ID of the main (parent) key.
static void pgp_add_string_to_hints(const char *str, struct ListHead *hints)
Split a string and add the parts to a List.
static PgpKeyValidFlags pgp_id_matches_addr(struct Address *addr, struct Address *u_addr, struct PgpUid *uid)
Does the key ID match the address.
static struct PgpKeyInfo ** pgp_get_lastp(struct PgpKeyInfo *p)
Get the last PGP key in a list.
void pgp_key_free(struct PgpKeyInfo **kpp)
Free a PGP key info.
struct PgpKeyInfo * pgp_remove_key(struct PgpKeyInfo **klist, struct PgpKeyInfo *key)
Remove a PGP key from a list.
#define TAILQ_FOREACH(var, head, field)
#define STAILQ_HEAD_INITIALIZER(head)
#define TAILQ_HEAD_INITIALIZER(head)
Container for Accounts, Notifications.
struct ConfigSubset * sub
Inherited config items.
struct PgpUid * next
Linked list.