58#ifdef CRYPT_BACKEND_CLASSIC_PGP
78#define PGP_KV_NO_FLAGS 0
79#define PGP_KV_VALID (1 << 0)
80#define PGP_KV_ADDR (1 << 1)
81#define PGP_KV_STRING (1 << 2)
82#define PGP_KV_STRONGID (1 << 3)
85#define PGP_KV_MATCH (PGP_KV_ADDR | PGP_KV_STRING)
138 if ((uid->
trust & 3) < 3)
261 struct Body *att = NULL;
262 char buf[1024] = { 0 };
263 char tmp[256] = { 0 };
264 struct stat st = { 0 };
267 struct Buffer *tempf = NULL;
298 pid =
pgp_invoke_export(NULL, NULL, NULL, -1, fileno(fp_tmp), fileno(fp_null), tmp);
319 snprintf(buf,
sizeof(buf),
_(
"PGP Key %s"), tmp);
345 for (
char *t = strtok(scratch,
" ,.:\"()<>\n"); t; t = strtok(NULL,
" ,.:\"()<>\n"))
361 for (; p; p = p->
next)
377 enum PgpRing keyring,
bool oppenc_mode)
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;
410 for (k = keys; k; k = kn)
416 if (abilities && !(k->flags & abilities))
424 for (q = k->address; q; q = q->
next)
440 if (the_strong_valid_key && (the_strong_valid_key != k))
442 the_strong_valid_key = k;
446 a_valid_addrmatch_key = k;
466 if (oppenc_mode || !isatty(STDIN_FILENO))
468 const bool c_crypt_opportunistic_encrypt_strong_keys =
470 if (the_strong_valid_key)
473 k = the_strong_valid_key;
475 else if (a_valid_addrmatch_key && !c_crypt_opportunistic_encrypt_strong_keys)
478 k = a_valid_addrmatch_key;
485 else if (the_strong_valid_key && !multi)
490 k = the_strong_valid_key;
524 const char *ps = NULL, *pl = NULL, *pfcopy = NULL, *phint = NULL;
526 char *p = strdup(cp);
528 if ((l > 0) && (p[l - 1] ==
'!'))
538 for (k = keys; k; k = kn)
541 if (abilities && !(k->
flags & abilities))
588 if (isatty(STDIN_FILENO))
601 mutt_error(
_(
"A key can't be used: expired/disabled/revoked"));
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 buf_istr_equal(const struct Buffer *a, const struct Buffer *b)
Return if two buffers are equal, case insensitive.
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Convenience wrapper for the config headers.
Convenience wrapper for the core headers.
const char * crypt_get_fingerprint_or_id(const char *p, const char **pphint, const char **ppl, const char **pps)
Get the fingerprint or long key ID.
Signing/encryption multiplexor.
struct Body * mutt_body_new(void)
Create a new Body.
Structs that make up an email.
#define mutt_file_fclose(FP)
#define mutt_file_fopen(PATH, MODE)
bool OptPgpCheckTrust
(pseudo) used by dlg_pgp()
struct PgpKeyInfo * pgp_get_candidates(enum PgpRing keyring, struct ListHead *hints)
Find PGP keys matching a list of hints.
Parse the output of CLI PGP programinclude "pgpkey.h".
struct Body * pgp_class_make_key_attachment(void)
Generate a public key attachment - Implements CryptModuleSpecs::pgp_make_key_attachment() -.
struct PgpKeyInfo * dlg_pgp(struct PgpKeyInfo *keys, struct Address *p, const char *s)
Let the user select a key to use -.
int mw_get_field(const char *prompt, struct Buffer *buf, CompletionFlags complete, enum HistoryClass hclass, const struct CompleteOps *comp_api, void *cdata)
Ask the user for a string -.
#define mutt_message(...)
#define mutt_debug(LEVEL,...)
Read/write command history from/to a file.
@ HC_OTHER
Miscellaneous strings.
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.
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
@ TYPE_APPLICATION
Type: 'application/*'.
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
Convenience wrapper for the library headers.
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
char * mutt_str_dup(const char *str)
Copy a string, safely.
const char * mutt_istr_find(const char *haystack, const char *needle)
Find first occurrence of string (ignoring case)
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Many unsorted constants and some structs.
#define MUTT_COMP_NO_FLAGS
No flags are set.
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
uint16_t KeyFlags
Flags describing PGP/SMIME keys, e.g. KEYFLAG_CANSIGN.
#define KEYFLAG_SUBKEY
Key is a subkey.
#define KEYFLAG_NO_FLAGS
No flags are set.
char * pgp_long_keyid(struct PgpKeyInfo *k)
Get a key's long id.
char * pgp_keyid(struct PgpKeyInfo *k)
Get the ID of the main (parent) key.
char * pgp_fpr_or_lkeyid(struct PgpKeyInfo *k)
Get the fingerprint or long keyid.
char * pgp_short_keyid(struct PgpKeyInfo *k)
Get a key's short id.
PGP sign, encrypt, check routines.
pid_t pgp_invoke_export(FILE **fp_pgp_in, FILE **fp_pgp_out, FILE **fp_pgp_err, int fd_pgp_in, int fd_pgp_out, int fd_pgp_err, const char *uids)
Use PGP to export a key from the user's keyring.
Wrapper around calls to external PGP program.
bool pgp_id_is_valid(struct PgpUid *uid)
Is a PGP key valid.
#define PGP_KV_NO_FLAGS
No flags are set.
#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.
struct PgpKeyInfo * pgp_ask_for_key(char *tag, const char *whatfor, KeyFlags abilities, enum PgpRing keyring)
Ask the user for a PGP key.
#define PGP_KV_VALID
PGP Key ID is valid.
#define PGP_KV_STRING
PGP Key name string is valid.
#define PGP_KV_ADDR
PGP Key address is valid.
bool pgp_keys_are_valid(struct PgpKeyInfo *keys)
Are all these PGP keys valid?
static struct PgpKeyInfo ** pgp_get_lastp(struct PgpKeyInfo *p)
Get the last PGP key in a list.
static struct PgpCache * IdDefaults
Cache of GPGME keys.
bool pgp_id_is_strong(struct PgpUid *uid)
Is a PGP key strong?
struct PgpKeyInfo * pgp_getkeybyaddr(struct Address *a, KeyFlags abilities, enum PgpRing keyring, bool oppenc_mode)
Find a PGP key by address.
bool pgp_key_is_valid(struct PgpKeyInfo *k)
Is a PGP key valid?
struct PgpKeyInfo * pgp_getkeybystr(const char *cp, KeyFlags abilities, enum PgpRing keyring)
Find a PGP key by string.
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.
PGP key management routines.
@ PGP_PUBRING
Public keys.
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.
Misc PGP helper routines.
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
#define TAILQ_FOREACH(var, head, field)
#define STAILQ_HEAD_INITIALIZER(head)
#define TAILQ_HEAD_INITIALIZER(head)
Convenience wrapper for the send headers.
void mutt_update_encoding(struct Body *b, struct ConfigSubset *sub)
Update the encoding type.
struct Buffer * personal
Real name of address.
struct Buffer * mailbox
Mailbox and host address.
bool unlink
If true, filename should be unlink()ed before free()ing this structure.
LOFF_T length
length (in bytes) of attachment
bool use_disp
Content-Disposition uses filename= ?
char * description
content-description
char * subtype
content-type subtype
unsigned int type
content-type primary type, ContentType
char * filename
When sending a message, this is the file to which this structure refers.
String manipulation buffer.
Container for Accounts, Notifications.
struct ConfigSubset * sub
Inherited config items.
struct PgpCache * next
Linked list.
Information about a PGP key.
struct PgpKeyInfo * parent
struct PgpKeyInfo * parent
Parent key.
struct PgpUid * next
Linked list.