64#ifdef CRYPT_BACKEND_CLASSIC_SMIME
116 *keylist = (*keylist)->
next;
177 const int rc =
mw_get_field(
_(
"Enter S/MIME passphrase:"), buf,
240 struct stat st = { 0 };
246 if ((stat(
buf_string(path), &st) != 0) || !S_ISDIR(st.st_mode))
286 const char *s = cctx->
fname;
314 const char *s = cctx->
key;
368static pid_t
smime_invoke(FILE **fp_smime_in, FILE **fp_smime_out, FILE **fp_smime_err,
369 int fp_smime_infd,
int fp_smime_outfd,
int fp_smime_errfd,
391 fp_smime_infd, fp_smime_outfd, fp_smime_errfd,
EnvList);
404 char *pend = NULL, *p = NULL;
409 for (p = buf; p; p = pend)
414 if ((pend = strchr(p,
' ')) || (pend = strchr(p,
'\t')) || (pend = strchr(p,
'\n')))
487 char buf[1024] = { 0 };
488 struct SmimeKey *key = NULL, *results = NULL;
489 struct SmimeKey **results_end = &results;
495 only_public_key ?
NONULL(c_smime_certificates) :
NONULL(c_smime_keys));
506 while (fgets(buf,
sizeof(buf), fp))
514 results_end = &key->
next;
537 for (
struct SmimeKey *result = results; result; result = result->
next)
560 bool only_public_key,
bool oppenc_mode)
565 struct SmimeKey *results = NULL, *result = NULL;
567 struct SmimeKey **matches_end = &matches;
569 struct SmimeKey *trusted_match = NULL;
570 struct SmimeKey *valid_match = NULL;
572 bool multi_trusted_matches =
false;
575 for (result = results; result; result = result->
next)
577 if (abilities && !(result->flags & abilities))
585 *matches_end = match;
586 matches_end = &match->
next;
588 if (match->
trust ==
't')
592 multi_trusted_matches =
true;
594 trusted_match = match;
596 else if ((match->
trust ==
'u') || (match->
trust ==
'v'))
607 if (oppenc_mode || !isatty(STDIN_FILENO))
609 const bool c_crypt_opportunistic_encrypt_strong_keys =
613 else if (valid_match && !c_crypt_opportunistic_encrypt_strong_keys)
618 else if (trusted_match && !multi_trusted_matches)
645 struct SmimeKey *results = NULL, *result = NULL;
647 struct SmimeKey **matches_end = &matches;
652 for (result = results; result; result = result->
next)
654 if (abilities && !(result->flags & abilities))
663 *matches_end = match;
664 matches_end = &match->
next;
725 const char *k = NULL;
732 buf_printf(prompt,
_(
"Enter keyID for %s: "), mailbox);
741 k = key ? key->
hash :
NONULL(c_smime_default_key);
763 if (c_smime_decrypt_use_default_key && c_smime_default_key)
802 char *keyid = NULL, *keylist = NULL;
803 size_t keylist_size = 0;
804 size_t keylist_used = 0;
810 if (!key && !oppenc_mode && isatty(STDIN_FILENO))
828 sprintf(keylist + keylist_used,
"%s%s", keylist_used ?
" " :
"", keyid);
848 bool copy,
char ***buffer,
int *num)
850 char email[256] = { 0 };
851 int rc = -1, count = 0;
869 const struct Expando *c_smime_get_cert_email_command =
871 pid =
smime_invoke(NULL, NULL, NULL, -1, fileno(fp_out), fileno(fp_err), certificate,
872 NULL, NULL, NULL, NULL, NULL, NULL, c_smime_get_cert_email_command);
875 mutt_message(
_(
"Error: unable to create OpenSSL subprocess"));
888 while ((fgets(email,
sizeof(email), fp_out)))
891 if (len && (email[len - 1] ==
'\n'))
892 email[len - 1] =
'\0';
896 rc = (rc < 0) ? 0 : rc;
916 if (copy && buffer && num)
923 while ((fgets(email,
sizeof(email), fp_out)))
926 if (len && (email[len - 1] ==
'\n'))
927 email[len - 1] =
'\0';
953 FILE *fp_cert = NULL;
979 pid =
smime_invoke(NULL, NULL, NULL, -1, fileno(fp_out), fileno(fp_err), infile,
980 NULL, NULL, NULL, NULL, NULL, NULL, c_smime_pk7out_command);
993 empty = (fgetc(fp_out) == EOF);
1013 pid =
smime_invoke(NULL, NULL, NULL, -1, fileno(fp_cert), fileno(fp_err),
1014 buf_string(pk7out), NULL, NULL, NULL, NULL, NULL, NULL,
1015 c_smime_get_cert_command);
1031 empty = (fgetc(fp_cert) == EOF);
1067 struct Buffer *certfile = NULL;
1090 const struct Expando *c_smime_get_signer_cert_command =
1092 pid =
smime_invoke(NULL, NULL, NULL, -1, -1, fileno(fp_err), infile, NULL, NULL, NULL,
1093 NULL,
buf_string(certfile), NULL, c_smime_get_signer_cert_command);
1106 empty = (fgetc(fp_out) == EOF);
1134 char *certfile = NULL;
1135 struct Buffer *buf = NULL;
1137 FILE *fp_out = NULL;
1154 if (c_smime_ask_cert_label)
1170 const struct Expando *c_smime_import_cert_command =
1172 FILE *fp_smime_in = NULL;
1173 pid_t pid =
smime_invoke(&fp_smime_in, NULL, NULL, -1, fileno(fp_out),
1174 fileno(fp_err), certfile, NULL, NULL, NULL, NULL,
1175 NULL, NULL, c_smime_import_cert_command);
1178 mutt_message(
_(
"Error: unable to create OpenSSL subprocess"));
1182 fputc(
'\n', fp_smime_in);
1210 const char *mbox = NULL, *certfile = NULL;
1293 FILE **fp_smime_err,
int fp_smime_infd,
1294 int fp_smime_outfd,
int fp_smime_errfd,
1295 const char *fname,
const char *uids)
1299 return smime_invoke(fp_smime_in, fp_smime_out, fp_smime_err, fp_smime_infd,
1300 fp_smime_outfd, fp_smime_errfd, fname, NULL, c_smime_encrypt_with,
1301 NULL, NULL, uids, NULL, c_smime_encrypt_command);
1320 FILE **fp_smime_err,
int fp_smime_infd,
int fp_smime_outfd,
1321 int fp_smime_errfd,
const char *fname)
1325 return smime_invoke(fp_smime_in, fp_smime_out, fp_smime_err, fp_smime_infd, fp_smime_outfd,
1326 fp_smime_errfd, fname, NULL, NULL, c_smime_sign_digest_alg,
1336 char buf[1024] = { 0 };
1338 char *cert_end = NULL;
1339 FILE *fp_smime_in = NULL, *fp_smime_err = NULL, *fp_out = NULL, *fp_tmp = NULL;
1340 struct Body *b_enc = NULL;
1372 for (
char *cert_start = certlist; cert_start; cert_start = cert_end)
1374 cert_end = strchr(cert_start,
' ');
1381 snprintf(certfile + off,
sizeof(certfile) - off,
"%s%s/%s",
1382 (off != 0) ?
" " :
"",
NONULL(c_smime_certificates), cert_start);
1390 fputc(
'\n', fp_tmp);
1395 fileno(fp_smime_err),
buf_string(smime_infile), certfile);
1409 empty = (fgetc(fp_out) == EOF);
1412 fflush(fp_smime_err);
1413 rewind(fp_smime_err);
1414 while (fgets(buf,
sizeof(buf) - 1, fp_smime_err))
1445 b_enc->
parts = NULL;
1483 char *micalg = NULL;
1501 struct Body *b_sign = NULL;
1502 struct Body *rc = NULL;
1503 char buf[1024] = { 0 };
1504 struct Buffer *filetosign = NULL, *signedfile = NULL;
1505 FILE *fp_smime_in = NULL, *fp_smime_out = NULL, *fp_smime_err = NULL, *fp_sign = NULL;
1509 const char *intermediates = NULL;
1513 const char *signas = c_smime_sign_as ? c_smime_sign_as : c_smime_default_key;
1514 if (!signas || (*signas ==
'\0'))
1516 mutt_error(
_(
"Can't sign: No key specified. Use Sign As."));
1542 fputc(
'\n', fp_sign);
1553 intermediates = signas;
1555 intermediates = signas_key->
issuer;
1562 fileno(fp_smime_out), -1,
buf_string(filetosign));
1570 fputc(
'\n', fp_smime_in);
1577 fflush(fp_smime_err);
1578 rewind(fp_smime_err);
1579 while (fgets(buf,
sizeof(buf) - 1, fp_smime_err))
1586 fflush(fp_smime_out);
1587 rewind(fp_smime_out);
1588 empty = (fgetc(fp_smime_out) == EOF);
1667 FILE **fp_smime_err,
int fp_smime_infd,
1668 int fp_smime_outfd,
int fp_smime_errfd,
1669 const char *fname,
const char *sig_fname,
int opaque)
1671 const struct Expando *c_smime_verify_opaque_command =
1674 return smime_invoke(fp_smime_in, fp_smime_out, fp_smime_err, fp_smime_infd, fp_smime_outfd,
1675 fp_smime_errfd, fname, sig_fname, NULL, NULL, NULL, NULL, NULL,
1676 (opaque ? c_smime_verify_opaque_command : c_smime_verify_command));
1695 FILE **fp_smime_err,
int fp_smime_infd,
int fp_smime_outfd,
1696 int fp_smime_errfd,
const char *fname)
1699 return smime_invoke(fp_smime_in, fp_smime_out, fp_smime_err, fp_smime_infd,
1700 fp_smime_outfd, fp_smime_errfd, fname, NULL, NULL, NULL,
1702 NULL, c_smime_decrypt_command);
1710 FILE *fp = NULL, *fp_smime_out = NULL, *fp_smime_err = NULL;
1714 LOFF_T tmpoffset = 0;
1715 size_t tmplength = 0;
1716 int orig_type = b->
type;
1737 const char *save_prefix = state->
prefix;
1752 state->
prefix = save_prefix;
1754 b->
type = orig_type;
1769 fflush(fp_smime_out);
1781 fflush(fp_smime_err);
1782 rewind(fp_smime_err);
1792 fflush(fp_smime_err);
1793 rewind(fp_smime_err);
1825 FILE *fp_smime_out = NULL, *fp_smime_in = NULL, *fp_smime_err = NULL;
1826 FILE *fp_tmp = NULL, *fp_out = NULL;
1827 struct Body *p = NULL;
1869 fileno(fp_smime_err),
buf_string(tmpfname))) == -1))
1880 fileno(fp_smime_out), fileno(fp_smime_err), NULL,
1896 fputc(
'\n', fp_smime_in);
1906 fflush(fp_smime_err);
1907 rewind(fp_smime_err);
1909 const int c = fgetc(fp_smime_err);
1912 ungetc(c, fp_smime_err);
1929 fflush(fp_smime_out);
1930 rewind(fp_smime_out);
1935 if (fgetc(fp_smime_out) == EOF)
1940 rewind(fp_smime_out);
1945 fp_out = fp_out_file;
1956 char buf[8192] = { 0 };
1957 while (fgets(buf,
sizeof(buf) - 1, fp_smime_out))
1960 if ((len > 1) && (buf[len - 2] ==
'\r'))
1962 buf[len - 2] =
'\n';
1963 buf[len - 1] =
'\0';
1996 FILE *fp_tmp_buffer = state->
fp_in;
1997 state->
fp_in = fp_out;
1999 state->
fp_in = fp_tmp_buffer;
2035 rewind(fp_smime_err);
2062 struct State state = { 0 };
2063 LOFF_T tmpoffset = b->
offset;
2064 size_t tmplength = b->
length;
2092 state.
fp_in = fp_tmp;
2106 (*b_dec)->goodsig = b->
goodsig;
2107 (*b_dec)->badsig = b->
badsig;
2145 const char *prompt = NULL;
2146 const char *letters = NULL;
2147 const char *choices = NULL;
2162 prompt =
_(
"S/MIME (s)ign, encrypt (w)ith, sign (a)s, (c)lear, or (o)ppenc mode off?");
2164 letters =
_(
"swaco");
2167 else if (c_crypt_opportunistic_encrypt)
2172 prompt =
_(
"S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, (c)lear, or (o)ppenc mode?");
2174 letters =
_(
"eswabco");
2175 choices =
"eswabcO";
2181 prompt =
_(
"S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, or (c)lear?");
2183 letters =
_(
"eswabc");
2190 switch (choices[choice - 1])
2249 switch (
mw_multi_choice(
_(
"Choose algorithm family: (1) DES, (2) RC2, (3) AES, or (c)lear?"),
2270 switch (choice =
mw_multi_choice(
_(
"(1) RC2-40, (2) RC2-64, (3) RC2-128?"),
2323 }
while (choice == -1);
2347 { -1, -1, NULL, NULL },
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?
size_t buf_strcpy(struct Buffer *buf, const char *s)
Copy a string into a Buffer.
size_t buf_copy(struct Buffer *dst, const struct Buffer *src)
Copy a Buffer's contents to another 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.
const struct Expando * cs_subset_expando(const struct ConfigSubset *sub, const char *name)
Get an Expando 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.
@ ED_SMIME_CMD
Smime Command ED_SMI_ ExpandoDataSmimeCmd.
@ ED_GLOBAL
Global ED_GLO_ ExpandoDataGlobal.
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 expando_render(const struct Expando *exp, const struct ExpandoRenderData *rdata, void *data, MuttFormatFlags flags, int max_cols, struct Buffer *buf)
Render an Expando + data into a string.
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.
int mutt_file_copy_bytes(FILE *fp_in, FILE *fp_out, size_t size)
Copy some content from one file to another.
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_file_fclose(FP)
#define mutt_file_fopen(PATH, MODE)
#define MUTT_RL_NO_FLAGS
No flags are set.
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() -.
void smime_command_a(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Smime Command: algorithm - Implements ExpandoRenderData::get_string() -.
void smime_command_C(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Smime Command: CA location - Implements ExpandoRenderData::get_string() -.
void smime_command_k(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Smime Command: Key-pair - Implements ExpandoRenderData::get_string() -.
void smime_command_i(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Smime Command: Intermediate certificates - Implements ExpandoRenderData::get_string() -.
void smime_command_f(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Smime Command: Filename of message - Implements ExpandoRenderData::get_string() -.
void smime_command_s(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Smime Command: Filename of signature - Implements ExpandoRenderData::get_string() -.
void smime_command_d(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Smime Command: Message digest algorithm - Implements ExpandoRenderData::get_string() -.
void smime_command_c(const struct ExpandoNode *node, void *data, MuttFormatFlags flags, struct Buffer *buf)
Smime Command: certificate IDs - Implements ExpandoRenderData::get_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(const 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.
#define MUTT_MEM_CALLOC(n, type)
#define MUTT_MEM_REALLOC(pptr, n, type)
@ 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.
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)
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)
#define MUTT_FORMAT_NO_FLAGS
No flags are set.
uint8_t MuttFormatFlags
Flags for expando_render(), e.g. MUTT_FORMAT_FORCESUBJ.
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.
const struct ExpandoRenderData SmimeCommandRenderData[]
Callbacks for Smime Command Expandos.
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 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 struct Expando *exp)
Run an SMIME command.
static struct Buffer SmimeCertToUse
Smime certificate to use.
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 void smime_command(struct Buffer *buf, struct SmimeCommandContext *cctx, const struct Expando *exp)
Format an SMIME command string.
static struct SmimeKey * smime_ask_for_key(const char *prompt, KeyFlags abilities, bool only_public_key)
Ask the user to select a key.
@ ED_SMI_MESSAGE_FILE
SmimeCommandContext.fname.
@ ED_SMI_ALGORITHM
SmimeCommandContext.cryptalg.
@ ED_SMI_SIGNATURE_FILE
SmimeCommandContext.sig_fname.
@ ED_SMI_DIGEST_ALGORITHM
SmimeCommandContext.digestalg.
@ ED_SMI_CERTIFICATE_IDS
SmimeCommandContext.certificates.
@ ED_SMI_KEY
SmimeCommandContext.key.
@ ED_SMI_INTERMEDIATE_IDS
SmimeCommandContext.intermediates.
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.
size_t dsize
Length of data.
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.
FILE * fp_in
File to read from.
const char * prefix
String to add to the beginning of each output line.
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()
@ ED_GLO_CERTIFICATE_PATH
Path of Smime certificates.