Find a PGP key by address.
356{
357 if (!a)
358 return NULL;
359
361
362 bool multi = false;
363
364 struct PgpKeyInfo *keys = NULL, *k = NULL, *kn = NULL;
365 struct PgpKeyInfo *the_strong_valid_key = NULL;
366 struct PgpKeyInfo *a_valid_addrmatch_key = NULL;
370
375
376 if (!oppenc_mode)
379
381
382 if (!keys)
383 return NULL;
384
386
387 for (k = keys; k; k = kn)
388 {
389 kn = k->next;
390
392
393 if (abilities && !(k->flags & abilities))
394 {
396 continue;
397 }
398
399 bool match = false;
400
401 for (q = k->address; q; q = q->
next)
402 {
407 {
409
411 match = true;
412
414 {
416 {
417 if (the_strong_valid_key && (the_strong_valid_key != k))
418 multi = true;
419 the_strong_valid_key = k;
420 }
421 else
422 {
423 a_valid_addrmatch_key = k;
424 }
425 }
426 }
427
429 }
430
431 if (match)
432 {
436 }
437 }
438
440
441 if (matches)
442 {
443 if (oppenc_mode)
444 {
445 const bool c_crypt_opportunistic_encrypt_strong_keys =
447 if (the_strong_valid_key)
448 {
450 k = the_strong_valid_key;
451 }
452 else if (a_valid_addrmatch_key && !c_crypt_opportunistic_encrypt_strong_keys)
453 {
455 k = a_valid_addrmatch_key;
456 }
457 else
458 k = NULL;
459 }
460 else if (the_strong_valid_key && !multi)
461 {
462
463
465 k = the_strong_valid_key;
466 }
467 else
468 {
469
471 if (k)
473 }
474
476
477 return k;
478 }
479
480 return NULL;
481}
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 * dlg_select_pgp_key(struct PgpKeyInfo *keys, struct Address *p, const char *s)
Let the user select a key to use.
struct PgpKeyInfo * pgp_get_candidates(enum PgpRing keyring, struct ListHead *hints)
Find PGP keys matching a list of hints.
#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)
char * mailbox
Mailbox and host address.
char * personal
Real name of address.
Container for Accounts, Notifications.
struct ConfigSubset * sub
Inherited config items.
struct PgpUid * next
Linked list.