Find a PGP key by address.
375{
376 if (!a)
377 return NULL;
378
380
381 bool multi = false;
382
383 struct PgpKeyInfo *keys = NULL, *k = NULL, *kn = NULL;
384 struct PgpKeyInfo *the_strong_valid_key = NULL;
385 struct PgpKeyInfo *a_valid_addrmatch_key = NULL;
389
394
395 if (!oppenc_mode)
398
400
401 if (!keys)
402 return NULL;
403
406
407 for (k = keys; k; k = kn)
408 {
409 kn = k->next;
410
412
413 if (abilities && !(k->flags & abilities))
414 {
416 continue;
417 }
418
419 bool match = false;
420
421 for (q = k->address; q; q = q->
next)
422 {
427 {
429
431 match = true;
432
434 {
436 {
437 if (the_strong_valid_key && (the_strong_valid_key != k))
438 multi = true;
439 the_strong_valid_key = k;
440 }
441 else
442 {
443 a_valid_addrmatch_key = k;
444 }
445 }
446 }
447
449 }
450
451 if (match)
452 {
456 }
457 }
458
460
461 if (matches)
462 {
463 if (oppenc_mode || !isatty(STDIN_FILENO))
464 {
465 const bool c_crypt_opportunistic_encrypt_strong_keys =
467 if (the_strong_valid_key)
468 {
470 k = the_strong_valid_key;
471 }
472 else if (a_valid_addrmatch_key && !c_crypt_opportunistic_encrypt_strong_keys)
473 {
475 k = a_valid_addrmatch_key;
476 }
477 else
478 {
479 k = NULL;
480 }
481 }
482 else if (the_strong_valid_key && !multi)
483 {
484
485
487 k = the_strong_valid_key;
488 }
489 else
490 {
491
493 if (k)
495 }
496
498
499 return k;
500 }
501
502 return NULL;
503}
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,...)
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
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.
#define PGP_KV_STRONGID
PGP Key is strong.
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.
#define PGP_KV_VALID
PGP Key ID is valid.
#define PGP_KV_ADDR
PGP Key address is valid.
static struct PgpKeyInfo ** pgp_get_lastp(struct PgpKeyInfo *p)
Get the last PGP key in a list.
uint8_t PgpKeyValidFlags
Flags for valid Pgp Key fields, e.g. PGP_KV_VALID.
struct PgpKeyInfo * pgp_principal_key(struct PgpKeyInfo *key)
Get the main (parent) PGP key.
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)
struct Buffer * personal
Real name of address.
struct Buffer * mailbox
Mailbox and host address.
struct ConfigSubset * sub
Inherited config items.
char * addr
Email address.
struct PgpUid * next
Linked list.