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;
692 prompt =
_(
"Enter keyID: ");
725 const char *k = NULL;
731 char buf[256] = { 0 };
732 snprintf(buf,
sizeof(buf),
_(
"Enter keyID for %s: "), mailbox);
740 k = key ? key->
hash :
NONULL(c_smime_default_key);
762 if (c_smime_decrypt_use_default_key && c_smime_default_key)
801 char *keyid = NULL, *keylist = NULL;
802 size_t keylist_size = 0;
803 size_t keylist_used = 0;
809 if (!key && !oppenc_mode && isatty(STDIN_FILENO))
811 char buf[1024] = { 0 };
826 sprintf(keylist + keylist_used,
"%s%s", keylist_used ?
" " :
"", keyid);
846 bool copy,
char ***buffer,
int *num)
848 char email[256] = { 0 };
849 int rc = -1, count = 0;
867 const struct Expando *c_smime_get_cert_email_command =
869 pid =
smime_invoke(NULL, NULL, NULL, -1, fileno(fp_out), fileno(fp_err), certificate,
870 NULL, NULL, NULL, NULL, NULL, NULL, c_smime_get_cert_email_command);
873 mutt_message(
_(
"Error: unable to create OpenSSL subprocess"));
886 while ((fgets(email,
sizeof(email), fp_out)))
889 if (len && (email[len - 1] ==
'\n'))
890 email[len - 1] =
'\0';
894 rc = (rc < 0) ? 0 : rc;
914 if (copy && buffer && num)
921 while ((fgets(email,
sizeof(email), fp_out)))
924 if (len && (email[len - 1] ==
'\n'))
925 email[len - 1] =
'\0';
951 FILE *fp_cert = NULL;
977 pid =
smime_invoke(NULL, NULL, NULL, -1, fileno(fp_out), fileno(fp_err), infile,
978 NULL, NULL, NULL, NULL, NULL, NULL, c_smime_pk7out_command);
991 empty = (fgetc(fp_out) == EOF);
1011 pid =
smime_invoke(NULL, NULL, NULL, -1, fileno(fp_cert), fileno(fp_err),
1012 buf_string(pk7out), NULL, NULL, NULL, NULL, NULL, NULL,
1013 c_smime_get_cert_command);
1029 empty = (fgetc(fp_cert) == EOF);
1065 struct Buffer *certfile = NULL;
1088 const struct Expando *c_smime_get_signer_cert_command =
1090 pid =
smime_invoke(NULL, NULL, NULL, -1, -1, fileno(fp_err), infile, NULL, NULL, NULL,
1091 NULL,
buf_string(certfile), NULL, c_smime_get_signer_cert_command);
1104 empty = (fgetc(fp_out) == EOF);
1132 char *certfile = NULL;
1133 struct Buffer *buf = NULL;
1135 FILE *fp_out = NULL;
1152 if (c_smime_ask_cert_label)
1168 const struct Expando *c_smime_import_cert_command =
1170 FILE *fp_smime_in = NULL;
1171 pid_t pid =
smime_invoke(&fp_smime_in, NULL, NULL, -1, fileno(fp_out),
1172 fileno(fp_err), certfile, NULL, NULL, NULL, NULL,
1173 NULL, NULL, c_smime_import_cert_command);
1176 mutt_message(
_(
"Error: unable to create OpenSSL subprocess"));
1180 fputc(
'\n', fp_smime_in);
1208 const char *mbox = NULL, *certfile = NULL;
1291 FILE **fp_smime_err,
int fp_smime_infd,
1292 int fp_smime_outfd,
int fp_smime_errfd,
1293 const char *fname,
const char *uids)
1297 return smime_invoke(fp_smime_in, fp_smime_out, fp_smime_err, fp_smime_infd,
1298 fp_smime_outfd, fp_smime_errfd, fname, NULL, c_smime_encrypt_with,
1299 NULL, NULL, uids, NULL, c_smime_encrypt_command);
1318 FILE **fp_smime_err,
int fp_smime_infd,
int fp_smime_outfd,
1319 int fp_smime_errfd,
const char *fname)
1323 return smime_invoke(fp_smime_in, fp_smime_out, fp_smime_err, fp_smime_infd, fp_smime_outfd,
1324 fp_smime_errfd, fname, NULL, NULL, c_smime_sign_digest_alg,
1334 char buf[1024] = { 0 };
1336 char *cert_end = NULL;
1337 FILE *fp_smime_in = NULL, *fp_smime_err = NULL, *fp_out = NULL, *fp_tmp = NULL;
1338 struct Body *b_enc = NULL;
1370 for (
char *cert_start = certlist; cert_start; cert_start = cert_end)
1372 cert_end = strchr(cert_start,
' ');
1379 snprintf(certfile + off,
sizeof(certfile) - off,
"%s%s/%s",
1380 (off != 0) ?
" " :
"",
NONULL(c_smime_certificates), cert_start);
1388 fputc(
'\n', fp_tmp);
1393 fileno(fp_smime_err),
buf_string(smime_infile), certfile);
1407 empty = (fgetc(fp_out) == EOF);
1410 fflush(fp_smime_err);
1411 rewind(fp_smime_err);
1412 while (fgets(buf,
sizeof(buf) - 1, fp_smime_err))
1443 b_enc->
parts = NULL;
1481 char *micalg = NULL;
1499 struct Body *b_sign = NULL;
1500 struct Body *rc = NULL;
1501 char buf[1024] = { 0 };
1502 struct Buffer *filetosign = NULL, *signedfile = NULL;
1503 FILE *fp_smime_in = NULL, *fp_smime_out = NULL, *fp_smime_err = NULL, *fp_sign = NULL;
1507 const char *intermediates = NULL;
1511 const char *signas = c_smime_sign_as ? c_smime_sign_as : c_smime_default_key;
1512 if (!signas || (*signas ==
'\0'))
1514 mutt_error(
_(
"Can't sign: No key specified. Use Sign As."));
1540 fputc(
'\n', fp_sign);
1551 intermediates = signas;
1553 intermediates = signas_key->
issuer;
1560 fileno(fp_smime_out), -1,
buf_string(filetosign));
1568 fputc(
'\n', fp_smime_in);
1575 fflush(fp_smime_err);
1576 rewind(fp_smime_err);
1577 while (fgets(buf,
sizeof(buf) - 1, fp_smime_err))
1584 fflush(fp_smime_out);
1585 rewind(fp_smime_out);
1586 empty = (fgetc(fp_smime_out) == EOF);
1665 FILE **fp_smime_err,
int fp_smime_infd,
1666 int fp_smime_outfd,
int fp_smime_errfd,
1667 const char *fname,
const char *sig_fname,
int opaque)
1669 const struct Expando *c_smime_verify_opaque_command =
1672 return smime_invoke(fp_smime_in, fp_smime_out, fp_smime_err, fp_smime_infd, fp_smime_outfd,
1673 fp_smime_errfd, fname, sig_fname, NULL, NULL, NULL, NULL, NULL,
1674 (opaque ? c_smime_verify_opaque_command : c_smime_verify_command));
1693 FILE **fp_smime_err,
int fp_smime_infd,
int fp_smime_outfd,
1694 int fp_smime_errfd,
const char *fname)
1697 return smime_invoke(fp_smime_in, fp_smime_out, fp_smime_err, fp_smime_infd,
1698 fp_smime_outfd, fp_smime_errfd, fname, NULL, NULL, NULL,
1700 NULL, c_smime_decrypt_command);
1708 FILE *fp = NULL, *fp_smime_out = NULL, *fp_smime_err = NULL;
1712 LOFF_T tmpoffset = 0;
1713 size_t tmplength = 0;
1714 int orig_type = b->
type;
1735 const char *save_prefix = state->
prefix;
1750 state->
prefix = save_prefix;
1752 b->
type = orig_type;
1767 fflush(fp_smime_out);
1779 fflush(fp_smime_err);
1780 rewind(fp_smime_err);
1790 fflush(fp_smime_err);
1791 rewind(fp_smime_err);
1823 FILE *fp_smime_out = NULL, *fp_smime_in = NULL, *fp_smime_err = NULL;
1824 FILE *fp_tmp = NULL, *fp_out = NULL;
1825 struct Body *p = NULL;
1867 fileno(fp_smime_err),
buf_string(tmpfname))) == -1))
1878 fileno(fp_smime_out), fileno(fp_smime_err), NULL,
1894 fputc(
'\n', fp_smime_in);
1904 fflush(fp_smime_err);
1905 rewind(fp_smime_err);
1907 const int c = fgetc(fp_smime_err);
1910 ungetc(c, fp_smime_err);
1927 fflush(fp_smime_out);
1928 rewind(fp_smime_out);
1933 if (fgetc(fp_smime_out) == EOF)
1938 rewind(fp_smime_out);
1943 fp_out = fp_out_file;
1954 char buf[8192] = { 0 };
1955 while (fgets(buf,
sizeof(buf) - 1, fp_smime_out))
1958 if ((len > 1) && (buf[len - 2] ==
'\r'))
1960 buf[len - 2] =
'\n';
1961 buf[len - 1] =
'\0';
1994 FILE *fp_tmp_buffer = state->
fp_in;
1995 state->
fp_in = fp_out;
1997 state->
fp_in = fp_tmp_buffer;
2033 rewind(fp_smime_err);
2060 struct State state = { 0 };
2061 LOFF_T tmpoffset = b->
offset;
2062 size_t tmplength = b->
length;
2090 state.
fp_in = fp_tmp;
2104 (*b_dec)->goodsig = b->
goodsig;
2105 (*b_dec)->badsig = b->
badsig;
2143 const char *prompt = NULL;
2144 const char *letters = NULL;
2145 const char *choices = NULL;
2160 prompt =
_(
"S/MIME (s)ign, encrypt (w)ith, sign (a)s, (c)lear, or (o)ppenc mode off?");
2162 letters =
_(
"swaco");
2165 else if (c_crypt_opportunistic_encrypt)
2170 prompt =
_(
"S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, (c)lear, or (o)ppenc mode?");
2172 letters =
_(
"eswabco");
2173 choices =
"eswabcO";
2179 prompt =
_(
"S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, or (c)lear?");
2181 letters =
_(
"eswabc");
2188 switch (choices[choice - 1])
2247 switch (
mw_multi_choice(
_(
"Choose algorithm family: (1) DES, (2) RC2, (3) AES, or (c)lear?"),
2268 switch (choice =
mw_multi_choice(
_(
"(1) RC2-40, (2) RC2-64, (3) RC2-128?"),
2321 }
while (choice == -1);
2345 { -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.
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.
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 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 void smime_command(struct Buffer *buf, struct SmimeCommandContext *cctx, const struct Expando *exp)
Format an SMIME command string.
@ 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.