62#ifdef CRYPT_BACKEND_CLASSIC_SMIME
112 *keylist = (*keylist)->
next;
173 const int rc =
mw_get_field(
_(
"Enter S/MIME passphrase:"), buf,
211 int cols,
char op,
const char *src,
212 const char *prec,
const char *if_str,
213 const char *else_str, intptr_t
data,
216 char fmt[128] = { 0 };
230 struct stat st = { 0 };
236 if ((stat(
buf_string(path), &st) != 0) || !S_ISDIR(st.st_mode))
241 snprintf(fmt,
sizeof(fmt),
"%%%ss", prec);
248 else if (!c_smime_ca_location)
259 snprintf(fmt,
sizeof(fmt),
"%%%ss", prec);
273 snprintf(fmt,
sizeof(fmt),
"%%%ss", prec);
287 snprintf(fmt,
sizeof(fmt),
"%%%ss", prec);
301 snprintf(fmt,
sizeof(fmt),
"%%%ss", prec);
302 snprintf(buf, buflen, fmt,
NONULL(cctx->
key));
315 snprintf(fmt,
sizeof(fmt),
"%%%ss", prec);
329 snprintf(fmt,
sizeof(fmt),
"%%%ss", prec);
332 else if (!cctx->
fname)
343 snprintf(fmt,
sizeof(fmt),
"%%%ss", prec);
412static pid_t
smime_invoke(FILE **fp_smime_in, FILE **fp_smime_out, FILE **fp_smime_err,
413 int fp_smime_infd,
int fp_smime_outfd,
int fp_smime_errfd,
414 const char *fname,
const char *sig_fname,
const char *cryptalg,
415 const char *digestalg,
const char *key,
const char *certificates,
416 const char *intermediates,
const char *format)
421 if (!format || (*format ==
'\0'))
435 fp_smime_infd, fp_smime_outfd, fp_smime_errfd,
EnvList);
446 char *pend = NULL, *p = NULL;
451 for (p = buf; p; p = pend)
456 if ((pend = strchr(p,
' ')) || (pend = strchr(p,
'\t')) || (pend = strchr(p,
'\n')))
529 char buf[1024] = { 0 };
530 struct SmimeKey *key = NULL, *results = NULL;
531 struct SmimeKey **results_end = &results;
537 only_public_key ?
NONULL(c_smime_certificates) :
NONULL(c_smime_keys));
548 while (fgets(buf,
sizeof(buf), fp))
556 results_end = &key->
next;
579 for (
struct SmimeKey *result = results; result; result = result->
next)
602 bool only_public_key,
bool oppenc_mode)
607 struct SmimeKey *results = NULL, *result = NULL;
609 struct SmimeKey **matches_end = &matches;
611 struct SmimeKey *trusted_match = NULL;
612 struct SmimeKey *valid_match = NULL;
614 bool multi_trusted_matches =
false;
617 for (result = results; result; result = result->
next)
619 if (abilities && !(result->flags & abilities))
627 *matches_end = match;
628 matches_end = &match->
next;
630 if (match->
trust ==
't')
634 multi_trusted_matches =
true;
636 trusted_match = match;
638 else if ((match->
trust ==
'u') || (match->
trust ==
'v'))
651 const bool c_crypt_opportunistic_encrypt_strong_keys =
655 else if (valid_match && !c_crypt_opportunistic_encrypt_strong_keys)
660 else if (trusted_match && !multi_trusted_matches)
687 struct SmimeKey *results = NULL, *result = NULL;
689 struct SmimeKey **matches_end = &matches;
694 for (result = results; result; result = result->
next)
696 if (abilities && !(result->flags & abilities))
705 *matches_end = match;
706 matches_end = &match->
next;
734 prompt =
_(
"Enter keyID: ");
767 const char *k = NULL;
773 char buf[256] = { 0 };
774 snprintf(buf,
sizeof(buf),
_(
"Enter keyID for %s: "), mailbox);
782 k = key ? key->
hash :
NONULL(c_smime_default_key);
804 if (c_smime_decrypt_use_default_key && c_smime_default_key)
843 char *keyid = NULL, *keylist = NULL;
844 size_t keylist_size = 0;
845 size_t keylist_used = 0;
851 if (!key && !oppenc_mode)
853 char buf[1024] = { 0 };
868 sprintf(keylist + keylist_used,
"%s%s", keylist_used ?
" " :
"", keyid);
888 bool copy,
char ***buffer,
int *num)
890 char email[256] = { 0 };
891 int rc = -1, count = 0;
910 pid =
smime_invoke(NULL, NULL, NULL, -1, fileno(fp_out), fileno(fp_err), certificate,
911 NULL, NULL, NULL, NULL, NULL, NULL, c_smime_get_cert_email_command);
914 mutt_message(
_(
"Error: unable to create OpenSSL subprocess"));
927 while ((fgets(email,
sizeof(email), fp_out)))
930 if (len && (email[len - 1] ==
'\n'))
931 email[len - 1] =
'\0';
935 rc = (rc < 0) ? 0 : rc;
955 if (copy && buffer && num)
962 while ((fgets(email,
sizeof(email), fp_out)))
965 if (len && (email[len - 1] ==
'\n'))
966 email[len - 1] =
'\0';
992 FILE *fp_cert = NULL;
1018 pid =
smime_invoke(NULL, NULL, NULL, -1, fileno(fp_out), fileno(fp_err), infile,
1019 NULL, NULL, NULL, NULL, NULL, NULL, c_smime_pk7out_command);
1032 empty = (fgetc(fp_out) == EOF);
1052 pid =
smime_invoke(NULL, NULL, NULL, -1, fileno(fp_cert), fileno(fp_err),
1053 buf_string(pk7out), NULL, NULL, NULL, NULL, NULL, NULL,
1054 c_smime_get_cert_command);
1070 empty = (fgetc(fp_cert) == EOF);
1106 struct Buffer *certfile = NULL;
1130 pid =
smime_invoke(NULL, NULL, NULL, -1, -1, fileno(fp_err), infile, NULL, NULL, NULL,
1131 NULL,
buf_string(certfile), NULL, c_smime_get_signer_cert_command);
1144 empty = (fgetc(fp_out) == EOF);
1172 char *certfile = NULL;
1173 struct Buffer *buf = NULL;
1175 FILE *fp_out = NULL;
1192 if (c_smime_ask_cert_label)
1209 FILE *fp_smime_in = NULL;
1210 pid_t pid =
smime_invoke(&fp_smime_in, NULL, NULL, -1, fileno(fp_out),
1211 fileno(fp_err), certfile, NULL, NULL, NULL, NULL,
1212 NULL, NULL, c_smime_import_cert_command);
1215 mutt_message(
_(
"Error: unable to create OpenSSL subprocess"));
1219 fputc(
'\n', fp_smime_in);
1247 const char *mbox = NULL, *certfile = NULL;
1330 FILE **fp_smime_err,
int fp_smime_infd,
1331 int fp_smime_outfd,
int fp_smime_errfd,
1332 const char *fname,
const char *uids)
1336 return smime_invoke(fp_smime_in, fp_smime_out, fp_smime_err, fp_smime_infd,
1337 fp_smime_outfd, fp_smime_errfd, fname, NULL, c_smime_encrypt_with,
1338 NULL, NULL, uids, NULL, c_smime_encrypt_command);
1357 FILE **fp_smime_err,
int fp_smime_infd,
int fp_smime_outfd,
1358 int fp_smime_errfd,
const char *fname)
1362 return smime_invoke(fp_smime_in, fp_smime_out, fp_smime_err, fp_smime_infd, fp_smime_outfd,
1363 fp_smime_errfd, fname, NULL, NULL, c_smime_sign_digest_alg,
1373 char buf[1024], certfile[
PATH_MAX];
1374 char *cert_end = NULL;
1375 FILE *fp_smime_in = NULL, *fp_smime_err = NULL, *fp_out = NULL, *fp_tmp = NULL;
1376 struct Body *b_enc = NULL;
1377 int err = 0, empty, off;
1407 for (
char *cert_start = certlist; cert_start; cert_start = cert_end)
1409 cert_end = strchr(cert_start,
' ');
1416 snprintf(certfile + off,
sizeof(certfile) - off,
"%s%s/%s",
1417 (off != 0) ?
" " :
"",
NONULL(c_smime_certificates), cert_start);
1425 fputc(
'\n', fp_tmp);
1430 fileno(fp_smime_err),
buf_string(smime_infile), certfile);
1444 empty = (fgetc(fp_out) == EOF);
1447 fflush(fp_smime_err);
1448 rewind(fp_smime_err);
1449 while (fgets(buf,
sizeof(buf) - 1, fp_smime_err))
1480 b_enc->
parts = NULL;
1518 char *micalg = NULL;
1536 struct Body *b_sign = NULL;
1537 struct Body *rc = NULL;
1538 char buf[1024] = { 0 };
1539 struct Buffer *filetosign = NULL, *signedfile = NULL;
1540 FILE *fp_smime_in = NULL, *fp_smime_out = NULL, *fp_smime_err = NULL, *fp_sign = NULL;
1544 const char *intermediates = NULL;
1548 const char *signas = c_smime_sign_as ? c_smime_sign_as : c_smime_default_key;
1549 if (!signas || (*signas ==
'\0'))
1551 mutt_error(
_(
"Can't sign: No key specified. Use Sign As."));
1577 fputc(
'\n', fp_sign);
1588 intermediates = signas;
1590 intermediates = signas_key->
issuer;
1597 fileno(fp_smime_out), -1,
buf_string(filetosign));
1605 fputc(
'\n', fp_smime_in);
1612 fflush(fp_smime_err);
1613 rewind(fp_smime_err);
1614 while (fgets(buf,
sizeof(buf) - 1, fp_smime_err))
1621 fflush(fp_smime_out);
1622 rewind(fp_smime_out);
1623 empty = (fgetc(fp_smime_out) == EOF);
1702 FILE **fp_smime_err,
int fp_smime_infd,
1703 int fp_smime_outfd,
int fp_smime_errfd,
1704 const char *fname,
const char *sig_fname,
int opaque)
1708 return smime_invoke(fp_smime_in, fp_smime_out, fp_smime_err, fp_smime_infd, fp_smime_outfd,
1709 fp_smime_errfd, fname, sig_fname, NULL, NULL, NULL, NULL, NULL,
1710 (opaque ? c_smime_verify_opaque_command : c_smime_verify_command));
1729 FILE **fp_smime_err,
int fp_smime_infd,
int fp_smime_outfd,
1730 int fp_smime_errfd,
const char *fname)
1733 return smime_invoke(fp_smime_in, fp_smime_out, fp_smime_err, fp_smime_infd,
1734 fp_smime_outfd, fp_smime_errfd, fname, NULL, NULL, NULL,
1736 NULL, c_smime_decrypt_command);
1744 FILE *fp = NULL, *fp_smime_out = NULL, *fp_smime_err = NULL;
1748 LOFF_T tmpoffset = 0;
1749 size_t tmplength = 0;
1750 int orig_type = b->
type;
1771 char *save_prefix = state->
prefix;
1786 state->
prefix = save_prefix;
1788 b->
type = orig_type;
1803 fflush(fp_smime_out);
1815 fflush(fp_smime_err);
1816 rewind(fp_smime_err);
1826 fflush(fp_smime_err);
1827 rewind(fp_smime_err);
1859 FILE *fp_smime_out = NULL, *fp_smime_in = NULL, *fp_smime_err = NULL;
1860 FILE *fp_tmp = NULL, *fp_out = NULL;
1861 struct Body *p = NULL;
1903 fileno(fp_smime_err),
buf_string(&tmpfname))) == -1))
1914 fileno(fp_smime_out), fileno(fp_smime_err), NULL,
1930 fputc(
'\n', fp_smime_in);
1940 fflush(fp_smime_err);
1941 rewind(fp_smime_err);
1943 const int c = fgetc(fp_smime_err);
1946 ungetc(c, fp_smime_err);
1963 fflush(fp_smime_out);
1964 rewind(fp_smime_out);
1969 if (fgetc(fp_smime_out) == EOF)
1974 rewind(fp_smime_out);
1979 fp_out = fp_out_file;
1990 char buf[8192] = { 0 };
1991 while (fgets(buf,
sizeof(buf) - 1, fp_smime_out))
1994 if ((len > 1) && (buf[len - 2] ==
'\r'))
1996 buf[len - 2] =
'\n';
1997 buf[len - 1] =
'\0';
2030 FILE *fp_tmp_buffer = state->
fp_in;
2031 state->
fp_in = fp_out;
2033 state->
fp_in = fp_tmp_buffer;
2069 rewind(fp_smime_err);
2096 struct State state = { 0 };
2097 LOFF_T tmpoffset = b->
offset;
2098 size_t tmplength = b->
length;
2126 state.
fp_in = fp_tmp;
2140 (*b_dec)->goodsig = b->
goodsig;
2141 (*b_dec)->badsig = b->
badsig;
2179 const char *prompt = NULL;
2180 const char *letters = NULL;
2181 const char *choices = NULL;
2196 prompt =
_(
"S/MIME (s)ign, encrypt (w)ith, sign (a)s, (c)lear, or (o)ppenc mode off?");
2198 letters =
_(
"swaco");
2201 else if (c_crypt_opportunistic_encrypt)
2206 prompt =
_(
"S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, (c)lear, or (o)ppenc mode?");
2208 letters =
_(
"eswabco");
2209 choices =
"eswabcO";
2215 prompt =
_(
"S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, or (c)lear?");
2217 letters =
_(
"eswabc");
2224 switch (choices[choice - 1])
2283 switch (
mw_multi_choice(
_(
"Choose algorithm family: (1) DES, (2) RC2, (3) AES, or (c)lear?"),
2304 switch (choice =
mw_multi_choice(
_(
"(1) RC2-40, (2) RC2-64, (3) RC2-128?"),
2318 "rc2-128", &errmsg);
2358 }
while (choice == -1);
void mutt_addr_free(struct Address **ptr)
Free a single Address.
void mutt_expand_aliases(struct AddressList *al)
Expand aliases in a List of Addresses.
bool mutt_addr_is_user(const struct Address *addr)
Does the address belong to the user.
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
size_t buf_len(const struct Buffer *buf)
Calculate the length of a Buffer.
void buf_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
struct Buffer buf_make(size_t size)
Make a new buffer on the stack.
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.
void buf_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
short cs_subset_number(const struct ConfigSubset *sub, const char *name)
Get a number config item by name.
const char * cs_subset_path(const struct ConfigSubset *sub, const char *name)
Get a path config item by name.
bool cs_subset_bool(const struct ConfigSubset *sub, const char *name)
Get a boolean config item by name.
Convenience wrapper for the config headers.
#define CSR_SUCCESS
Action completed successfully.
int mutt_copy_message(FILE *fp_out, struct Email *e, struct Message *msg, CopyMessageFlags cmflags, CopyHeaderFlags chflags, int wraplen)
Copy a message from a Mailbox.
Duplicate the structure of an entire email.
#define CH_NONEWLINE
Don't output terminating newline after the header.
#define CH_WEED
Weed the headers?
#define MUTT_CM_DECODE_SMIME
Used for decoding S/MIME messages.
#define CH_MIME
Ignore MIME fields.
#define MUTT_CM_NO_FLAGS
No flags are set.
#define MUTT_CM_DECODE_CRYPT
#define CH_NO_FLAGS
No flags are set.
Convenience wrapper for the core headers.
void crypt_opportunistic_encrypt(struct Email *e)
Can all recipients be determined.
SecurityFlags mutt_is_multipart_signed(struct Body *b)
Is a message signed?
SecurityFlags mutt_is_application_smime(struct Body *b)
Does the message use S/MIME?
void crypt_current_time(struct State *state, const char *app_name)
Print the current time.
void crypt_convert_to_7bit(struct Body *b)
Convert an email to 7bit encoding.
Signing/encryption multiplexor.
void crypt_smime_void_passphrase(void)
Wrapper for CryptModuleSpecs::void_passphrase()
Wrapper around crypto functions.
int mutt_any_key_to_continue(const char *s)
Prompt the user to 'press any key' and wait.
void mutt_endwin(void)
Shutdown curses.
void mutt_body_free(struct Body **ptr)
Free a Body.
struct Body * mutt_body_new(void)
Create a new Body.
Structs that make up an email.
void mutt_parse_part(FILE *fp, struct Body *b)
Parse a MIME part.
struct Body * mutt_read_mime_header(FILE *fp, bool digest)
Parse a MIME header.
void mutt_env_free(struct Envelope **ptr)
Free an Envelope.
int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
Copy the contents of one file into another.
void buf_quote_filename(struct Buffer *buf, const char *filename, bool add_outer)
Quote a filename to survive the shell's quoting rules.
char * mutt_file_read_line(char *line, size_t *size, FILE *fp, int *line_num, ReadLineFlags flags)
Read a line from a file.
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
int mutt_file_copy_bytes(FILE *fp_in, FILE *fp_out, size_t size)
Copy some content from one file to another.
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
long mutt_file_get_size_fp(FILE *fp)
Get the size of a file.
bool mutt_file_seek(FILE *fp, LOFF_T offset, int whence)
Wrapper for fseeko with error handling.
void mutt_file_unlink(const char *s)
Delete a file, carefully.
#define MUTT_RL_NO_FLAGS
No flags are set.
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
pid_t filter_create_fd(const char *cmd, FILE **fp_in, FILE **fp_out, FILE **fp_err, int fdin, int fdout, int fderr, char **envlist)
Run a command on a pipe (optionally connect stdin/stdout)
char ** EnvList
Private copy of the environment variables.
int smime_class_application_handler(struct Body *b, struct State *state)
Manage the MIME type "application/pgp" or "application/smime" - Implements CryptModuleSpecs::applicat...
int smime_class_decrypt_mime(FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **b_dec)
Decrypt an encrypted MIME part - Implements CryptModuleSpecs::decrypt_mime() -.
char * smime_class_find_keys(const struct AddressList *al, bool oppenc_mode)
Find the keyids of the recipients of a message - Implements CryptModuleSpecs::find_keys() -.
struct Body * smime_class_sign_message(struct Body *b, const struct AddressList *from)
Cryptographically sign the Body of a message - Implements CryptModuleSpecs::sign_message() -.
struct Body * smime_class_build_smime_entity(struct Body *b, char *certlist)
Encrypt the email body to all recipients - Implements CryptModuleSpecs::smime_build_smime_entity() -.
void smime_class_getkeys(struct Envelope *env)
Get the S/MIME keys required to encrypt this email - Implements CryptModuleSpecs::smime_getkeys() -.
void smime_class_invoke_import(const char *infile, const char *mailbox)
Add a certificate and update index file (externally) - Implements CryptModuleSpecs::smime_invoke_impo...
int smime_class_verify_sender(struct Email *e, struct Message *msg)
Does the sender match the certificate? - Implements CryptModuleSpecs::smime_verify_sender() -.
bool smime_class_valid_passphrase(void)
Ensure we have a valid passphrase - Implements CryptModuleSpecs::valid_passphrase() -.
int smime_class_verify_one(struct Body *b, struct State *state, const char *tempfile)
Check a signed MIME part against a signature - Implements CryptModuleSpecs::verify_one() -.
void smime_class_void_passphrase(void)
Forget the cached passphrase - Implements CryptModuleSpecs::void_passphrase() -.
static const char * smime_command_format_str(char *buf, size_t buflen, size_t col, int cols, char op, const char *src, const char *prec, const char *if_str, const char *else_str, intptr_t data, MuttFormatFlags flags)
Format an SMIME command - Implements format_t -.
void mutt_expando_format(char *buf, size_t buflen, size_t col, int cols, const char *src, format_t callback, intptr_t data, MuttFormatFlags flags)
Expand expandos (x) in a string -.
struct SmimeKey * dlg_smime(struct SmimeKey *keys, const char *query)
Get the user to select a key -.
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 -.
int mw_multi_choice(const char *prompt, const char *letters)
Offer the user a multiple choice question -.
int mutt_protected_headers_handler(struct Body *b_email, struct State *state)
Handler for protected headers - Implements handler_t -.
#define mutt_message(...)
#define mutt_debug(LEVEL,...)
Convenience wrapper for the gui headers.
int mutt_body_handler(struct Body *b, struct State *state)
Handler for the Body of an email.
void mutt_decode_attachment(struct Body *b, struct State *state)
Decode an email's attachment.
Decide how to display email content.
Read/write command history from/to a file.
@ HC_OTHER
Miscellaneous strings.
@ LL_DEBUG2
Log at debug level 2.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
@ ENC_BASE64
Base-64 encoded text.
@ TYPE_MULTIPART
Type: 'multipart/*'.
@ TYPE_APPLICATION
Type: 'application/*'.
@ DISP_ATTACH
Content is attached.
@ DISP_INLINE
Content is inline.
void mutt_generate_boundary(struct ParameterList *pl)
Create a unique boundary id for a MIME part.
time_t mutt_date_add_timeout(time_t now, time_t timeout)
Safely add a timeout to a given time_t value.
time_t mutt_date_now(void)
Return the number of seconds since the Unix epoch.
Convenience wrapper for the library headers.
void state_attach_puts(struct State *state, const char *t)
Write a string to the state.
#define STATE_DISPLAY
Output is displayed to the user.
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.
int mutt_str_asprintf(char **strp, const char *fmt,...)
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
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.
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
size_t mutt_istr_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix, ignoring case.
Many unsorted constants and some structs.
#define MUTT_COMP_PASS
Password mode (no echo)
#define MUTT_COMP_UNBUFFERED
Ignore macro buffer.
#define MUTT_COMP_NO_FLAGS
No flags are set.
void mutt_clear_error(void)
Clear the message line (bottom line of screen)
void buf_expand_path(struct Buffer *buf)
Create the canonical path.
Some miscellaneous functions.
uint16_t SecurityFlags
Flags, e.g. SEC_ENCRYPT.
#define SEC_OPPENCRYPT
Opportunistic encrypt mode.
uint16_t KeyFlags
Flags describing PGP/SMIME keys, e.g. KEYFLAG_CANSIGN.
#define SEC_SIGNOPAQUE
Email has an opaque signature (encrypted)
#define KEYFLAG_CANENCRYPT
Key is suitable for encryption.
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
#define SEC_ENCRYPT
Email is encrypted.
#define SEC_SIGN
Email is signed.
#define KEYFLAG_CANSIGN
Key is suitable for signing.
void mutt_param_set(struct ParameterList *pl, const char *attribute, const char *value)
Set a Parameter.
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 TAILQ_FIRST(head)
#define TAILQ_EMPTY(head)
int mutt_write_mime_body(struct Body *b, FILE *fp, struct ConfigSubset *sub)
Write a MIME part.
Convenience wrapper for the send headers.
struct Address * mutt_default_from(struct ConfigSubset *sub)
Get a default 'from' Address.
static struct Buffer SmimeIntermediateToUse
Smime intermediate certificate to use.
static struct SmimeKey * smime_get_key_by_hash(const char *hash, bool only_public_key)
Find a key by its hash.
static pid_t smime_invoke_sign(FILE **fp_smime_in, FILE **fp_smime_out, FILE **fp_smime_err, int fp_smime_infd, int fp_smime_outfd, int fp_smime_errfd, const char *fname)
Use SMIME to sign a file.
static char SmimePass[256]
Cached Smime Passphrase.
static time_t SmimeExpTime
Unix time when SmimePass expires.
static void getkeys(const char *mailbox)
Get the keys for a mailbox.
static struct SmimeKey * smime_copy_key(struct SmimeKey *key)
Copy an SMIME key.
static void smime_command(char *buf, size_t buflen, struct SmimeCommandContext *cctx, const char *fmt)
Format an SMIME command string.
static struct SmimeKey * smime_get_key_by_str(const char *str, KeyFlags abilities, bool only_public_key)
Find an SMIME key by string.
void smime_init(void)
Initialise smime globals.
static pid_t smime_invoke_verify(FILE **fp_smime_in, FILE **fp_smime_out, FILE **fp_smime_err, int fp_smime_infd, int fp_smime_outfd, int fp_smime_errfd, const char *fname, const char *sig_fname, int opaque)
Use SMIME to verify a file.
void smime_cleanup(void)
Clean up smime globals.
static char * smime_extract_signer_certificate(const char *infile)
Extract the signer's certificate.
static struct Body * smime_handle_entity(struct Body *b, struct State *state, FILE *fp_out_file)
Handle type application/pkcs7-mime.
static struct SmimeKey * smime_parse_key(char *buf)
Parse an SMIME key block.
static pid_t smime_invoke_decrypt(FILE **fp_smime_in, FILE **fp_smime_out, FILE **fp_smime_err, int fp_smime_infd, int fp_smime_outfd, int fp_smime_errfd, const char *fname)
Use SMIME to decrypt a file.
static struct SmimeKey * smime_get_candidates(const char *search, bool only_public_key)
Find keys matching a string.
static struct Buffer SmimeKeyToUse
Smime key to use.
static char * smime_extract_certificate(const char *infile)
Extract an SMIME certificate from a file.
static int smime_handle_cert_email(const char *certificate, const char *mailbox, bool copy, char ***buffer, int *num)
Process an email containing certificates.
static struct SmimeKey * smime_get_key_by_addr(const char *mailbox, KeyFlags abilities, bool only_public_key, bool oppenc_mode)
Find an SIME key by address.
static struct Buffer SmimeCertToUse
Smime certificate to use.
static struct SmimeKey * smime_ask_for_key(char *prompt, KeyFlags abilities, bool only_public_key)
Ask the user to select a key.
static pid_t smime_invoke_encrypt(FILE **fp_smime_in, FILE **fp_smime_out, FILE **fp_smime_err, int fp_smime_infd, int fp_smime_outfd, int fp_smime_errfd, const char *fname, const char *uids)
Use SMIME to encrypt a file.
static void smime_key_free(struct SmimeKey **keylist)
Free a list of SMIME keys.
static char * openssl_md_to_smime_micalg(const char *md)
Change the algorithm names.
static pid_t smime_invoke(FILE **fp_smime_in, FILE **fp_smime_out, FILE **fp_smime_err, int fp_smime_infd, int fp_smime_outfd, int fp_smime_errfd, const char *fname, const char *sig_fname, const char *cryptalg, const char *digestalg, const char *key, const char *certificates, const char *intermediates, const char *format)
Run an SMIME command.
#define STR_COMMAND
Enough space for a long command line.
struct Buffer * mailbox
Mailbox and host address.
char * d_filename
filename to be used for the content-disposition header If NULL, filename is used instead.
struct Body * parts
parts of a multipart or message/rfc822
LOFF_T offset
offset where the actual data begins
bool unlink
If true, filename should be unlink()ed before free()ing this structure.
bool badsig
Bad cryptographic signature (needed to check encrypted s/mime-signatures)
struct Envelope * mime_headers
Memory hole protected headers.
LOFF_T length
length (in bytes) of attachment
struct ParameterList parameter
Parameters of the content-type.
bool use_disp
Content-Disposition uses filename= ?
unsigned int disposition
content-disposition, ContentDisposition
struct Body * next
next attachment in the list
char * subtype
content-type subtype
unsigned int encoding
content-transfer-encoding, ContentEncoding
bool goodsig
Good cryptographic signature.
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.
char * data
Pointer to data.
The envelope/body of an email.
struct Envelope * env
Envelope information.
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib....
struct AddressList to
Email's 'To' list.
struct AddressList cc
Email's 'Cc' list.
struct AddressList sender
Email's sender.
struct AddressList from
Email's 'From' list.
A local copy of an email.
Container for Accounts, Notifications.
struct ConfigSubset * sub
Inherited config items.
const char * intermediates
i
const char * certificates
c
char trust
i=Invalid r=revoked e=expired u=unverified v=verified t=trusted
Keep track when processing files.
StateFlags flags
Flags, e.g. STATE_DISPLAY.
FILE * fp_out
File to write to.
char * prefix
String to add to the beginning of each output line.
FILE * fp_in
File to read from.
int cs_subset_str_string_set(const struct ConfigSubset *sub, const char *name, const char *value, struct Buffer *err)
Set a config item by string.
#define mutt_file_mkstemp()