55#ifdef CRYPT_BACKEND_CLASSIC_PGP
74#define PGP_KV_NO_FLAGS 0
75#define PGP_KV_VALID (1 << 0)
76#define PGP_KV_ADDR (1 << 1)
77#define PGP_KV_STRING (1 << 2)
78#define PGP_KV_STRONGID (1 << 3)
81#define PGP_KV_MATCH (PGP_KV_ADDR | PGP_KV_STRING)
118 if ((uid->
trust & 3) < 3)
239 struct Body *att = NULL;
240 char buf[1024] = { 0 };
241 char tmp[256] = { 0 };
242 struct stat st = { 0 };
245 struct Buffer *tempf = NULL;
265 FILE *fp_null = fopen(
"/dev/null",
"w");
276 pid =
pgp_invoke_export(NULL, NULL, NULL, -1, fileno(fp_tmp), fileno(fp_null), tmp);
297 snprintf(buf,
sizeof(buf),
_(
"PGP Key %s"), tmp);
323 for (
char *t = strtok(scratch,
" ,.:\"()<>\n"); t; t = strtok(NULL,
" ,.:\"()<>\n"))
339 for (; p; p = p->
next)
355 enum PgpRing keyring,
bool oppenc_mode)
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;
387 for (k = keys; k; k = kn)
393 if (abilities && !(k->flags & abilities))
401 for (q = k->address; q; q = q->
next)
417 if (the_strong_valid_key && (the_strong_valid_key != k))
419 the_strong_valid_key = k;
423 a_valid_addrmatch_key = k;
445 const bool c_crypt_opportunistic_encrypt_strong_keys =
447 if (the_strong_valid_key)
450 k = the_strong_valid_key;
452 else if (a_valid_addrmatch_key && !c_crypt_opportunistic_encrypt_strong_keys)
455 k = a_valid_addrmatch_key;
460 else if (the_strong_valid_key && !multi)
465 k = the_strong_valid_key;
499 const char *ps = NULL, *pl = NULL, *pfcopy = NULL, *phint = NULL;
501 char *p = strdup(cp);
503 if ((l > 0) && (p[l - 1] ==
'!'))
513 for (k = keys; k; k = kn)
516 if (abilities && !(k->
flags & abilities))
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.
size_t mutt_buffer_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
void mutt_buffer_reset(struct Buffer *buf)
Reset an existing Buffer.
char * mutt_buffer_strdup(const struct Buffer *buf)
Copy a Buffer's string.
static const char * mutt_buffer_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 PgpKeyInfo * dlg_select_pgp_key(struct PgpKeyInfo *keys, struct Address *p, const char *s)
Let the user select a key to use.
struct Body * mutt_body_new(void)
Create a new Body.
Structs that make up an email.
int mutt_buffer_get_field(const char *field, struct Buffer *buf, CompletionFlags complete, bool multiple, struct Mailbox *m, char ***files, int *numfiles)
Ask the user for a string.
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
bool OptPgpCheckTrust
(pseudo) used by dlg_select_pgp_key()
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)
Implements CryptModuleSpecs::pgp_make_key_attachment() -.
#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.
void * mutt_mem_malloc(size_t size)
Allocate memory on the heap.
@ TYPE_APPLICATION
Type: 'application/*'.
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)
Some miscellaneous functions.
#define mutt_buffer_mktemp(buf)
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.
struct PgpKeyInfo * pgp_ask_for_key(char *tag, char *whatfor, KeyFlags abilities, enum PgpRing keyring)
Ask the user for a PGP 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.
static struct PgpCache * id_defaults
#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.
static struct PgpKeyInfo ** pgp_get_lastp(struct PgpKeyInfo *p)
Get the last PGP key in a list.
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.
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from 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 *a, struct ConfigSubset *sub)
Update the encoding type.
char * mailbox
Mailbox and host address.
char * personal
Real name of 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.