NeoMutt  2021-02-05-89-gabe350
Teaching an old dog new tricks
DOXYGEN
smime.h File Reference
#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include "lib.h"
+ Include dependency graph for smime.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SmimeKey
 An SIME key. More...
 

Functions

void smime_init (void)
 Initialise smime globals. More...
 
void smime_cleanup (void)
 Clean up smime globals. More...
 
int smime_class_application_handler (struct Body *m, struct State *s)
 Implements CryptModuleSpecs::application_handler() More...
 
struct Bodysmime_class_build_smime_entity (struct Body *a, char *certlist)
 Implements CryptModuleSpecs::smime_build_smime_entity() More...
 
int smime_class_decrypt_mime (FILE *fp_in, FILE **fp_out, struct Body *b, struct Body **cur)
 Implements CryptModuleSpecs::decrypt_mime() More...
 
char * smime_class_find_keys (struct AddressList *addrlist, bool oppenc_mode)
 Implements CryptModuleSpecs::find_keys() More...
 
void smime_class_getkeys (struct Envelope *env)
 Implements CryptModuleSpecs::smime_getkeys() More...
 
void smime_class_invoke_import (const char *infile, const char *mailbox)
 Implements CryptModuleSpecs::smime_invoke_import() More...
 
SecurityFlags smime_class_send_menu (struct Email *e)
 Implements CryptModuleSpecs::send_menu() More...
 
struct Bodysmime_class_sign_message (struct Body *a, const struct AddressList *from)
 Implements CryptModuleSpecs::sign_message() More...
 
bool smime_class_valid_passphrase (void)
 Implements CryptModuleSpecs::valid_passphrase() More...
 
int smime_class_verify_one (struct Body *sigbdy, struct State *s, const char *tempfile)
 Implements CryptModuleSpecs::verify_one() More...
 
int smime_class_verify_sender (struct Mailbox *m, struct Email *e)
 Implements CryptModuleSpecs::smime_verify_sender() More...
 
void smime_class_void_passphrase (void)
 Implements CryptModuleSpecs::void_passphrase() More...
 

Detailed Description

SMIME helper routines

Authors
  • Oliver Ehli
  • g10 Code GmbH
  • Pietro Cerutti

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file smime.h.

Function Documentation

◆ smime_init()

void smime_init ( void  )

Initialise smime globals.

Definition at line 87 of file smime.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ smime_cleanup()

void smime_cleanup ( void  )

Clean up smime globals.

Definition at line 97 of file smime.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ smime_class_application_handler()

int smime_class_application_handler ( struct Body m,
struct State s 
)

Implements CryptModuleSpecs::application_handler()

Definition at line 2089 of file smime.c.

2090 {
2091  int rc = -1;
2092 
2093  /* clear out any mime headers before the handler, so they can't be spoofed. */
2095 
2096  struct Body *tattach = smime_handle_entity(m, s, NULL);
2097  if (tattach)
2098  {
2099  rc = 0;
2100  mutt_body_free(&tattach);
2101  }
2102  return rc;
2103 }
+ Here is the call graph for this function:

◆ smime_class_build_smime_entity()

struct Body* smime_class_build_smime_entity ( struct Body a,
char *  certlist 
)

Implements CryptModuleSpecs::smime_build_smime_entity()

Definition at line 1317 of file smime.c.

1318 {
1319  char buf[1024], certfile[PATH_MAX];
1320  char *cert_end = NULL;
1321  FILE *fp_smime_in = NULL, *fp_smime_err = NULL, *fp_out = NULL, *fp_tmp = NULL;
1322  struct Body *t = NULL;
1323  int err = 0, empty, off;
1324  pid_t pid;
1325 
1326  struct Buffer *tempfile = mutt_buffer_pool_get();
1327  struct Buffer *smime_infile = mutt_buffer_pool_get();
1328 
1329  mutt_buffer_mktemp(tempfile);
1330  fp_out = mutt_file_fopen(mutt_buffer_string(tempfile), "w+");
1331  if (!fp_out)
1332  {
1333  mutt_perror(mutt_buffer_string(tempfile));
1334  goto cleanup;
1335  }
1336 
1337  fp_smime_err = mutt_file_mkstemp();
1338  if (!fp_smime_err)
1339  {
1340  mutt_perror(_("Can't create temporary file"));
1341  goto cleanup;
1342  }
1343 
1344  mutt_buffer_mktemp(smime_infile);
1345  fp_tmp = mutt_file_fopen(mutt_buffer_string(smime_infile), "w+");
1346  if (!fp_tmp)
1347  {
1348  mutt_perror(mutt_buffer_string(smime_infile));
1349  goto cleanup;
1350  }
1351 
1352  *certfile = '\0';
1353  for (char *cert_start = certlist; cert_start; cert_start = cert_end)
1354  {
1355  cert_end = strchr(cert_start, ' ');
1356  if (cert_end)
1357  *cert_end = '\0';
1358  if (*cert_start)
1359  {
1360  off = mutt_str_len(certfile);
1361  snprintf(certfile + off, sizeof(certfile) - off, "%s%s/%s",
1362  (off != 0) ? " " : "", NONULL(C_SmimeCertificates), cert_start);
1363  }
1364  if (cert_end)
1365  *cert_end++ = ' ';
1366  }
1367 
1368  /* write a MIME entity */
1369  mutt_write_mime_header(a, fp_tmp, NeoMutt->sub);
1370  fputc('\n', fp_tmp);
1371  mutt_write_mime_body(a, fp_tmp, NeoMutt->sub);
1372  mutt_file_fclose(&fp_tmp);
1373 
1374  pid = smime_invoke_encrypt(&fp_smime_in, NULL, NULL, -1, fileno(fp_out),
1375  fileno(fp_smime_err),
1376  mutt_buffer_string(smime_infile), certfile);
1377  if (pid == -1)
1378  {
1379  mutt_file_unlink(mutt_buffer_string(smime_infile));
1380  goto cleanup;
1381  }
1382 
1383  mutt_file_fclose(&fp_smime_in);
1384 
1385  filter_wait(pid);
1386  mutt_file_unlink(mutt_buffer_string(smime_infile));
1387 
1388  fflush(fp_out);
1389  rewind(fp_out);
1390  empty = (fgetc(fp_out) == EOF);
1391  mutt_file_fclose(&fp_out);
1392 
1393  fflush(fp_smime_err);
1394  rewind(fp_smime_err);
1395  while (fgets(buf, sizeof(buf) - 1, fp_smime_err))
1396  {
1397  err = 1;
1398  fputs(buf, stdout);
1399  }
1400  mutt_file_fclose(&fp_smime_err);
1401 
1402  /* pause if there is any error output from SMIME */
1403  if (err)
1405 
1406  if (empty)
1407  {
1408  /* fatal error while trying to encrypt message */
1409  if (err == 0)
1410  mutt_any_key_to_continue(_("No output from OpenSSL..."));
1412  goto cleanup;
1413  }
1414 
1415  t = mutt_body_new();
1416  t->type = TYPE_APPLICATION;
1417  t->subtype = mutt_str_dup("x-pkcs7-mime");
1418  mutt_param_set(&t->parameter, "name", "smime.p7m");
1419  mutt_param_set(&t->parameter, "smime-type", "enveloped-data");
1420  t->encoding = ENC_BASE64; /* The output of OpenSSL SHOULD be binary */
1421  t->use_disp = true;
1422  t->disposition = DISP_ATTACH;
1423  t->d_filename = mutt_str_dup("smime.p7m");
1424  t->filename = mutt_buffer_strdup(tempfile);
1425  t->unlink = true; /* delete after sending the message */
1426  t->parts = NULL;
1427  t->next = NULL;
1428 
1429 cleanup:
1430  if (fp_out)
1431  {
1432  mutt_file_fclose(&fp_out);
1434  }
1435  mutt_file_fclose(&fp_smime_err);
1436  if (fp_tmp)
1437  {
1438  mutt_file_fclose(&fp_tmp);
1439  mutt_file_unlink(mutt_buffer_string(smime_infile));
1440  }
1441  mutt_buffer_pool_release(&tempfile);
1442  mutt_buffer_pool_release(&smime_infile);
1443 
1444  return t;
1445 }
+ Here is the call graph for this function:

◆ smime_class_decrypt_mime()

int smime_class_decrypt_mime ( FILE *  fp_in,
FILE **  fp_out,
struct Body b,
struct Body **  cur 
)

Implements CryptModuleSpecs::decrypt_mime()

Definition at line 2027 of file smime.c.

2028 {
2029  struct State s = { 0 };
2030  LOFF_T tmpoffset = b->offset;
2031  size_t tmplength = b->length;
2032  int orig_type = b->type;
2033  int rc = -1;
2034 
2035  if (!mutt_is_application_smime(b))
2036  return -1;
2037 
2038  if (b->parts)
2039  return -1;
2040 
2041  s.fp_in = fp_in;
2042  fseeko(s.fp_in, b->offset, SEEK_SET);
2043 
2044  FILE *fp_tmp = mutt_file_mkstemp();
2045  if (!fp_tmp)
2046  {
2047  mutt_perror(_("Can't create temporary file"));
2048  return -1;
2049  }
2050 
2051  s.fp_out = fp_tmp;
2052  mutt_decode_attachment(b, &s);
2053  fflush(fp_tmp);
2054  b->length = ftello(s.fp_out);
2055  b->offset = 0;
2056  rewind(fp_tmp);
2057  s.fp_in = fp_tmp;
2058  s.fp_out = 0;
2059 
2061  if (!*fp_out)
2062  {
2063  mutt_perror(_("Can't create temporary file"));
2064  goto bail;
2065  }
2066 
2067  *cur = smime_handle_entity(b, &s, *fp_out);
2068  if (!*cur)
2069  goto bail;
2070 
2071  (*cur)->goodsig = b->goodsig;
2072  (*cur)->badsig = b->badsig;
2073  rc = 0;
2074 
2075 bail:
2076  b->type = orig_type;
2077  b->length = tmplength;
2078  b->offset = tmpoffset;
2079  mutt_file_fclose(&fp_tmp);
2080  if (*fp_out)
2081  rewind(*fp_out);
2082 
2083  return rc;
2084 }
+ Here is the call graph for this function:

◆ smime_class_find_keys()

char* smime_class_find_keys ( struct AddressList *  addrlist,
bool  oppenc_mode 
)

Implements CryptModuleSpecs::find_keys()

Definition at line 803 of file smime.c.

804 {
805  struct SmimeKey *key = NULL;
806  char *keyid = NULL, *keylist = NULL;
807  size_t keylist_size = 0;
808  size_t keylist_used = 0;
809 
810  struct Address *a = NULL;
811  TAILQ_FOREACH(a, al, entries)
812  {
813  key = smime_get_key_by_addr(a->mailbox, KEYFLAG_CANENCRYPT, true, oppenc_mode);
814  if (!key && !oppenc_mode)
815  {
816  char buf[1024];
817  snprintf(buf, sizeof(buf), _("Enter keyID for %s: "), a->mailbox);
818  key = smime_ask_for_key(buf, KEYFLAG_CANENCRYPT, true);
819  }
820  if (!key)
821  {
822  if (!oppenc_mode)
823  mutt_message(_("No (valid) certificate found for %s"), a->mailbox);
824  FREE(&keylist);
825  return NULL;
826  }
827 
828  keyid = key->hash;
829  keylist_size += mutt_str_len(keyid) + 2;
830  mutt_mem_realloc(&keylist, keylist_size);
831  sprintf(keylist + keylist_used, "%s%s", keylist_used ? " " : "", keyid);
832  keylist_used = mutt_str_len(keylist);
833 
834  smime_key_free(&key);
835  }
836  return keylist;
837 }
+ Here is the call graph for this function:

◆ smime_class_getkeys()

void smime_class_getkeys ( struct Envelope env)

Implements CryptModuleSpecs::smime_getkeys()

Definition at line 767 of file smime.c.

768 {
770  {
773  return;
774  }
775 
776  struct Address *a = NULL;
777  TAILQ_FOREACH(a, &env->to, entries)
778  {
779  if (mutt_addr_is_user(a))
780  {
781  getkeys(a->mailbox);
782  return;
783  }
784  }
785 
786  TAILQ_FOREACH(a, &env->cc, entries)
787  {
788  if (mutt_addr_is_user(a))
789  {
790  getkeys(a->mailbox);
791  return;
792  }
793  }
794 
795  struct Address *f = mutt_default_from(NeoMutt->sub);
796  getkeys(f->mailbox);
797  mutt_addr_free(&f);
798 }
+ Here is the call graph for this function:

◆ smime_class_invoke_import()

void smime_class_invoke_import ( const char *  infile,
const char *  mailbox 
)

Implements CryptModuleSpecs::smime_invoke_import()

Definition at line 1124 of file smime.c.

1125 {
1126  char *certfile = NULL;
1127  char buf[256];
1128  FILE *fp_smime_in = NULL;
1129 
1130  FILE *fp_err = mutt_file_mkstemp();
1131  if (!fp_err)
1132  {
1133  mutt_perror(_("Can't create temporary file"));
1134  return;
1135  }
1136 
1137  FILE *fp_out = mutt_file_mkstemp();
1138  if (!fp_out)
1139  {
1140  mutt_file_fclose(&fp_err);
1141  mutt_perror(_("Can't create temporary file"));
1142  return;
1143  }
1144 
1145  buf[0] = '\0';
1146  if (C_SmimeAskCertLabel)
1147  {
1148  if ((mutt_get_field(_("Label for certificate: "), buf, sizeof(buf),
1149  MUTT_COMP_NO_FLAGS, false, NULL, NULL) != 0) ||
1150  (buf[0] == '\0'))
1151  {
1152  mutt_file_fclose(&fp_out);
1153  mutt_file_fclose(&fp_err);
1154  return;
1155  }
1156  }
1157 
1158  mutt_endwin();
1159  certfile = smime_extract_certificate(infile);
1160  if (certfile)
1161  {
1162  mutt_endwin();
1163 
1164  pid_t pid = smime_invoke(&fp_smime_in, NULL, NULL, -1, fileno(fp_out),
1165  fileno(fp_err), certfile, NULL, NULL, NULL, NULL,
1166  NULL, NULL, C_SmimeImportCertCommand);
1167  if (pid == -1)
1168  {
1169  mutt_message(_("Error: unable to create OpenSSL subprocess"));
1170  return;
1171  }
1172  fputs(buf, fp_smime_in);
1173  fputc('\n', fp_smime_in);
1174  mutt_file_fclose(&fp_smime_in);
1175 
1176  filter_wait(pid);
1177 
1178  mutt_file_unlink(certfile);
1179  FREE(&certfile);
1180  }
1181 
1182  fflush(fp_out);
1183  rewind(fp_out);
1184  fflush(fp_err);
1185  rewind(fp_err);
1186 
1187  mutt_file_copy_stream(fp_out, stdout);
1188  mutt_file_copy_stream(fp_err, stdout);
1189 
1190  mutt_file_fclose(&fp_out);
1191  mutt_file_fclose(&fp_err);
1192 }
+ Here is the call graph for this function:

◆ smime_class_send_menu()

SecurityFlags smime_class_send_menu ( struct Email e)

Implements CryptModuleSpecs::send_menu()

Definition at line 2108 of file smime.c.

2109 {
2110  struct SmimeKey *key = NULL;
2111  const char *prompt = NULL;
2112  const char *letters = NULL;
2113  const char *choices = NULL;
2114  int choice;
2115 
2116  if (!(WithCrypto & APPLICATION_SMIME))
2117  return e->security;
2118 
2120 
2121  /* Opportunistic encrypt is controlling encryption.
2122  * NOTE: "Signing" and "Clearing" only adjust the sign bit, so we have different
2123  * letter choices for those. */
2125  {
2126  /* L10N: S/MIME options (opportunistic encryption is on) */
2127  prompt = _("S/MIME (s)ign, encrypt (w)ith, sign (a)s, (c)lear, or (o)ppenc "
2128  "mode off?");
2129  /* L10N: S/MIME options (opportunistic encryption is on) */
2130  letters = _("swaco");
2131  choices = "SwaCo";
2132  }
2133  /* Opportunistic encryption option is set, but is toggled off
2134  * for this message. */
2135  else if (C_CryptOpportunisticEncrypt)
2136  {
2137  /* L10N: S/MIME options (opportunistic encryption is off) */
2138  prompt = _("S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, "
2139  "(c)lear, or (o)ppenc mode?");
2140  /* L10N: S/MIME options (opportunistic encryption is off) */
2141  letters = _("eswabco");
2142  choices = "eswabcO";
2143  }
2144  /* Opportunistic encryption is unset */
2145  else
2146  {
2147  /* L10N: S/MIME options */
2148  prompt = _("S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, "
2149  "or (c)lear?");
2150  /* L10N: S/MIME options */
2151  letters = _("eswabc");
2152  choices = "eswabc";
2153  }
2154 
2155  choice = mutt_multi_choice(prompt, letters);
2156  if (choice > 0)
2157  {
2158  switch (choices[choice - 1])
2159  {
2160  case 'a': /* sign (a)s */
2161  key = smime_ask_for_key(_("Sign as: "), KEYFLAG_CANSIGN, false);
2162  if (key)
2163  {
2165  smime_key_free(&key);
2166 
2167  e->security |= SEC_SIGN;
2168 
2169  /* probably need a different passphrase */
2171  }
2172 
2173  break;
2174 
2175  case 'b': /* (b)oth */
2176  e->security |= (SEC_ENCRYPT | SEC_SIGN);
2177  break;
2178 
2179  case 'c': /* (c)lear */
2180  e->security &= ~(SEC_ENCRYPT | SEC_SIGN);
2181  break;
2182 
2183  case 'C':
2184  e->security &= ~SEC_SIGN;
2185  break;
2186 
2187  case 'e': /* (e)ncrypt */
2188  e->security |= SEC_ENCRYPT;
2189  e->security &= ~SEC_SIGN;
2190  break;
2191 
2192  case 'O': /* oppenc mode on */
2193  e->security |= SEC_OPPENCRYPT;
2195  break;
2196 
2197  case 'o': /* oppenc mode off */
2198  e->security &= ~SEC_OPPENCRYPT;
2199  break;
2200 
2201  case 'S': /* (s)ign in oppenc mode */
2202  e->security |= SEC_SIGN;
2203  break;
2204 
2205  case 's': /* (s)ign */
2206  e->security &= ~SEC_ENCRYPT;
2207  e->security |= SEC_SIGN;
2208  break;
2209 
2210  case 'w': /* encrypt (w)ith */
2211  {
2212  e->security |= SEC_ENCRYPT;
2213  do
2214  {
2215  struct Buffer errmsg = mutt_buffer_make(0);
2216  int rc = CSR_SUCCESS;
2217  switch (mutt_multi_choice(_("Choose algorithm family: (1) DES, (2) "
2218  "RC2, (3) AES, or (c)lear?"),
2219  // L10N: Options for: Choose algorithm family: (1) DES, (2) RC2, (3) AES, or (c)lear?
2220  _("123c")))
2221  {
2222  case 1:
2223  switch (choice = mutt_multi_choice(_("(1) DES, (2) Triple-DES?"),
2224  // L10N: Options for: (1) DES, (2) Triple-DES
2225  _("12")))
2226  {
2227  case 1:
2228  rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2229  "des", &errmsg);
2230  break;
2231  case 2:
2232  rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2233  "des3", &errmsg);
2234  break;
2235  }
2236  break;
2237 
2238  case 2:
2239  switch (choice = mutt_multi_choice(
2240  _("(1) RC2-40, (2) RC2-64, (3) RC2-128?"),
2241  // L10N: Options for: (1) RC2-40, (2) RC2-64, (3) RC2-128
2242  _("123")))
2243  {
2244  case 1:
2245  rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2246  "rc2-40", &errmsg);
2247  break;
2248  case 2:
2249  rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2250  "rc2-64", &errmsg);
2251  break;
2252  case 3:
2253  rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2254  "rc2-128", &errmsg);
2255  break;
2256  }
2257  break;
2258 
2259  case 3:
2260  switch (choice = mutt_multi_choice(
2261  _("(1) AES128, (2) AES192, (3) AES256?"),
2262  // L10N: Options for: (1) AES128, (2) AES192, (3) AES256
2263  _("123")))
2264  {
2265  case 1:
2266  rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2267  "aes128", &errmsg);
2268  break;
2269  case 2:
2270  rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2271  "aes192", &errmsg);
2272  break;
2273  case 3:
2274  rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2275  "aes256", &errmsg);
2276  break;
2277  }
2278  break;
2279 
2280  case 4:
2281  rc = cs_subset_str_string_set(NeoMutt->sub, "smime_encrypt_with",
2282  NULL, &errmsg);
2283  /* (c)lear */
2284  /* fallthrough */
2285  case -1: /* Ctrl-G or Enter */
2286  choice = 0;
2287  break;
2288  }
2289 
2290  if ((CSR_RESULT(rc) != CSR_SUCCESS) && !mutt_buffer_is_empty(&errmsg))
2291  mutt_error("%s", mutt_buffer_string(&errmsg));
2292 
2293  mutt_buffer_dealloc(&errmsg);
2294  } while (choice == -1);
2295  break;
2296  }
2297  }
2298  }
2299 
2300  return e->security;
2301 }
+ Here is the call graph for this function:

◆ smime_class_sign_message()

struct Body* smime_class_sign_message ( struct Body a,
const struct AddressList *  from 
)

Implements CryptModuleSpecs::sign_message()

Definition at line 1482 of file smime.c.

1483 {
1484  struct Body *t = NULL;
1485  struct Body *retval = NULL;
1486  char buf[1024];
1487  struct Buffer *filetosign = NULL, *signedfile = NULL;
1488  FILE *fp_smime_in = NULL, *fp_smime_out = NULL, *fp_smime_err = NULL, *fp_sign = NULL;
1489  int err = 0;
1490  int empty = 0;
1491  pid_t pid;
1492  char *intermediates = NULL;
1493 
1494  char *signas = C_SmimeSignAs ? C_SmimeSignAs : C_SmimeDefaultKey;
1495  if (!signas || (*signas == '\0'))
1496  {
1497  mutt_error(_("Can't sign: No key specified. Use Sign As."));
1498  return NULL;
1499  }
1500 
1501  crypt_convert_to_7bit(a); /* Signed data _must_ be in 7-bit format. */
1502 
1503  filetosign = mutt_buffer_pool_get();
1504  signedfile = mutt_buffer_pool_get();
1505 
1506  mutt_buffer_mktemp(filetosign);
1507  fp_sign = mutt_file_fopen(mutt_buffer_string(filetosign), "w+");
1508  if (!fp_sign)
1509  {
1510  mutt_perror(mutt_buffer_string(filetosign));
1511  goto cleanup;
1512  }
1513 
1514  mutt_buffer_mktemp(signedfile);
1515  fp_smime_out = mutt_file_fopen(mutt_buffer_string(signedfile), "w+");
1516  if (!fp_smime_out)
1517  {
1518  mutt_perror(mutt_buffer_string(signedfile));
1519  goto cleanup;
1520  }
1521 
1522  mutt_write_mime_header(a, fp_sign, NeoMutt->sub);
1523  fputc('\n', fp_sign);
1524  mutt_write_mime_body(a, fp_sign, NeoMutt->sub);
1525  mutt_file_fclose(&fp_sign);
1526 
1527  mutt_buffer_printf(&SmimeKeyToUse, "%s/%s", NONULL(C_SmimeKeys), signas);
1529 
1530  struct SmimeKey *signas_key = smime_get_key_by_hash(signas, 1);
1531  if (!signas_key || mutt_str_equal("?", signas_key->issuer))
1532  intermediates = signas; /* so openssl won't complain in any case */
1533  else
1534  intermediates = signas_key->issuer;
1535 
1537  NONULL(C_SmimeCertificates), intermediates);
1538 
1539  smime_key_free(&signas_key);
1540 
1541  pid = smime_invoke_sign(&fp_smime_in, NULL, &fp_smime_err, -1,
1542  fileno(fp_smime_out), -1, mutt_buffer_string(filetosign));
1543  if (pid == -1)
1544  {
1545  mutt_perror(_("Can't open OpenSSL subprocess"));
1546  mutt_file_unlink(mutt_buffer_string(filetosign));
1547  goto cleanup;
1548  }
1549  fputs(SmimePass, fp_smime_in);
1550  fputc('\n', fp_smime_in);
1551  mutt_file_fclose(&fp_smime_in);
1552 
1553  filter_wait(pid);
1554 
1555  /* check for errors from OpenSSL */
1556  err = 0;
1557  fflush(fp_smime_err);
1558  rewind(fp_smime_err);
1559  while (fgets(buf, sizeof(buf) - 1, fp_smime_err))
1560  {
1561  err = 1;
1562  fputs(buf, stdout);
1563  }
1564  mutt_file_fclose(&fp_smime_err);
1565 
1566  fflush(fp_smime_out);
1567  rewind(fp_smime_out);
1568  empty = (fgetc(fp_smime_out) == EOF);
1569  mutt_file_fclose(&fp_smime_out);
1570 
1571  mutt_file_unlink(mutt_buffer_string(filetosign));
1572 
1573  if (err)
1575 
1576  if (empty)
1577  {
1578  mutt_any_key_to_continue(_("No output from OpenSSL..."));
1579  mutt_file_unlink(mutt_buffer_string(signedfile));
1580  goto cleanup; /* fatal error while signing */
1581  }
1582 
1583  t = mutt_body_new();
1584  t->type = TYPE_MULTIPART;
1585  t->subtype = mutt_str_dup("signed");
1586  t->encoding = ENC_7BIT;
1587  t->use_disp = false;
1588  t->disposition = DISP_INLINE;
1589 
1591 
1593  mutt_param_set(&t->parameter, "micalg", micalg);
1594  FREE(&micalg);
1595 
1596  mutt_param_set(&t->parameter, "protocol", "application/x-pkcs7-signature");
1597 
1598  t->parts = a;
1599  retval = t;
1600 
1601  t->parts->next = mutt_body_new();
1602  t = t->parts->next;
1603  t->type = TYPE_APPLICATION;
1604  t->subtype = mutt_str_dup("x-pkcs7-signature");
1605  t->filename = mutt_buffer_strdup(signedfile);
1606  t->d_filename = mutt_str_dup("smime.p7s");
1607  t->use_disp = true;
1608  t->disposition = DISP_ATTACH;
1609  t->encoding = ENC_BASE64;
1610  t->unlink = true; /* ok to remove this file after sending. */
1611 
1612 cleanup:
1613  if (fp_sign)
1614  {
1615  mutt_file_fclose(&fp_sign);
1616  mutt_file_unlink(mutt_buffer_string(filetosign));
1617  }
1618  if (fp_smime_out)
1619  {
1620  mutt_file_fclose(&fp_smime_out);
1621  mutt_file_unlink(mutt_buffer_string(signedfile));
1622  }
1623  mutt_buffer_pool_release(&filetosign);
1624  mutt_buffer_pool_release(&signedfile);
1625  return retval;
1626 }
+ Here is the call graph for this function:

◆ smime_class_valid_passphrase()

bool smime_class_valid_passphrase ( void  )

Implements CryptModuleSpecs::valid_passphrase()

Definition at line 167 of file smime.c.

168 {
169  const time_t now = mutt_date_epoch();
170  if (now < SmimeExpTime)
171  {
172  /* Use cached copy. */
173  return true;
174  }
175 
177 
178  if (mutt_get_field_unbuffered(_("Enter S/MIME passphrase:"), SmimePass,
179  sizeof(SmimePass), MUTT_PASS) == 0)
180  {
182  return true;
183  }
184  else
185  SmimeExpTime = 0;
186 
187  return false;
188 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ smime_class_verify_one()

int smime_class_verify_one ( struct Body sigbdy,
struct State s,
const char *  tempfile 
)

Implements CryptModuleSpecs::verify_one()

Definition at line 1683 of file smime.c.

1684 {
1685  FILE *fp = NULL, *fp_smime_out = NULL, *fp_smime_err = NULL;
1686  pid_t pid;
1687  int badsig = -1;
1688 
1689  LOFF_T tmpoffset = 0;
1690  size_t tmplength = 0;
1691  int orig_type = sigbdy->type;
1692 
1693  struct Buffer *signedfile = mutt_buffer_pool_get();
1694 
1695  mutt_buffer_printf(signedfile, "%s.sig", tempfile);
1696 
1697  /* decode to a tempfile, saving the original destination */
1698  fp = s->fp_out;
1699  s->fp_out = mutt_file_fopen(mutt_buffer_string(signedfile), "w");
1700  if (!s->fp_out)
1701  {
1702  mutt_perror(mutt_buffer_string(signedfile));
1703  goto cleanup;
1704  }
1705  /* decoding the attachment changes the size and offset, so save a copy
1706  * of the "real" values now, and restore them after processing */
1707  tmplength = sigbdy->length;
1708  tmpoffset = sigbdy->offset;
1709 
1710  /* if we are decoding binary bodies, we don't want to prefix each
1711  * line with the prefix or else the data will get corrupted. */
1712  char *save_prefix = s->prefix;
1713  s->prefix = NULL;
1714 
1715  mutt_decode_attachment(sigbdy, s);
1716 
1717  sigbdy->length = ftello(s->fp_out);
1718  sigbdy->offset = 0;
1719  mutt_file_fclose(&s->fp_out);
1720 
1721  /* restore final destination and substitute the tempfile for input */
1722  s->fp_out = fp;
1723  fp = s->fp_in;
1724  s->fp_in = fopen(mutt_buffer_string(signedfile), "r");
1725 
1726  /* restore the prefix */
1727  s->prefix = save_prefix;
1728 
1729  sigbdy->type = orig_type;
1730 
1731  fp_smime_err = mutt_file_mkstemp();
1732  if (!fp_smime_err)
1733  {
1734  mutt_perror(_("Can't create temporary file"));
1735  goto cleanup;
1736  }
1737 
1738  crypt_current_time(s, "OpenSSL");
1739 
1740  pid = smime_invoke_verify(NULL, &fp_smime_out, NULL, -1, -1, fileno(fp_smime_err),
1741  tempfile, mutt_buffer_string(signedfile), 0);
1742  if (pid != -1)
1743  {
1744  fflush(fp_smime_out);
1745  mutt_file_fclose(&fp_smime_out);
1746 
1747  if (filter_wait(pid))
1748  badsig = -1;
1749  else
1750  {
1751  char *line = NULL;
1752  size_t linelen;
1753 
1754  fflush(fp_smime_err);
1755  rewind(fp_smime_err);
1756 
1757  line = mutt_file_read_line(line, &linelen, fp_smime_err, NULL, MUTT_RL_NO_FLAGS);
1758  if (linelen && mutt_istr_equal(line, "verification successful"))
1759  badsig = 0;
1760 
1761  FREE(&line);
1762  }
1763  }
1764 
1765  fflush(fp_smime_err);
1766  rewind(fp_smime_err);
1767  mutt_file_copy_stream(fp_smime_err, s->fp_out);
1768  mutt_file_fclose(&fp_smime_err);
1769 
1770  state_attach_puts(s, _("[-- End of OpenSSL output --]\n\n"));
1771 
1772  mutt_file_unlink(mutt_buffer_string(signedfile));
1773 
1774  sigbdy->length = tmplength;
1775  sigbdy->offset = tmpoffset;
1776 
1777  /* restore the original source stream */
1778  mutt_file_fclose(&s->fp_in);
1779  s->fp_in = fp;
1780 
1781 cleanup:
1782  mutt_buffer_pool_release(&signedfile);
1783  return badsig;
1784 }
+ Here is the call graph for this function:

◆ smime_class_verify_sender()

int smime_class_verify_sender ( struct Mailbox m,
struct Email e 
)

Implements CryptModuleSpecs::smime_verify_sender()

Definition at line 1197 of file smime.c.

1198 {
1199  char *mbox = NULL, *certfile = NULL;
1200  int rc = 1;
1201 
1202  struct Buffer *tempfname = mutt_buffer_pool_get();
1203  mutt_buffer_mktemp(tempfname);
1204  FILE *fp_out = mutt_file_fopen(mutt_buffer_string(tempfname), "w");
1205  if (!fp_out)
1206  {
1207  mutt_perror(mutt_buffer_string(tempfname));
1208  goto cleanup;
1209  }
1210 
1211  if (e->security & SEC_ENCRYPT)
1212  {
1214  CH_MIME | CH_WEED | CH_NONEWLINE, 0);
1215  }
1216  else
1217  mutt_copy_message(fp_out, m, e, MUTT_CM_NO_FLAGS, CH_NO_FLAGS, 0);
1218 
1219  fflush(fp_out);
1220  mutt_file_fclose(&fp_out);
1221 
1222  if (!TAILQ_EMPTY(&e->env->from))
1223  {
1225  mbox = TAILQ_FIRST(&e->env->from)->mailbox;
1226  }
1227  else if (!TAILQ_EMPTY(&e->env->sender))
1228  {
1230  mbox = TAILQ_FIRST(&e->env->sender)->mailbox;
1231  }
1232 
1233  if (mbox)
1234  {
1236  if (certfile)
1237  {
1239  if (smime_handle_cert_email(certfile, mbox, false, NULL, NULL))
1240  {
1241  if (isendwin())
1243  }
1244  else
1245  rc = 0;
1246  mutt_file_unlink(certfile);
1247  FREE(&certfile);
1248  }
1249  else
1250  mutt_any_key_to_continue(_("no certfile"));
1251  }
1252  else
1253  mutt_any_key_to_continue(_("no mbox"));
1254 
1256 
1257 cleanup:
1258  mutt_buffer_pool_release(&tempfname);
1259  return rc;
1260 }
+ Here is the call graph for this function:

◆ smime_class_void_passphrase()

void smime_class_void_passphrase ( void  )

Implements CryptModuleSpecs::void_passphrase()

Definition at line 158 of file smime.c.

159 {
160  memset(SmimePass, 0, sizeof(SmimePass));
161  SmimeExpTime = 0;
162 }
+ Here is the caller graph for this function:
mutt_endwin
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:572
C_SmimeImportCertCommand
char * C_SmimeImportCertCommand
Config: (smime) External command to import a certificate.
Definition: config.c:112
mutt_generate_boundary
void mutt_generate_boundary(struct ParameterList *pl)
Create a unique boundary id for a MIME part.
Definition: multipart.c:86
SmimeCertToUse
static struct Buffer SmimeCertToUse
Definition: smime.c:81
State::fp_in
FILE * fp_in
File to read from.
Definition: state.h:46
C_SmimeKeys
char * C_SmimeKeys
Config: File containing user's private certificates.
Definition: config.c:113
_
#define _(a)
Definition: message.h:28
NONULL
#define NONULL(x)
Definition: string2.h:37
SmimeKeyToUse
static struct Buffer SmimeKeyToUse
Definition: smime.c:80
APPLICATION_SMIME
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: lib.h:98
CH_NONEWLINE
#define CH_NONEWLINE
Don't output terminating newline after the header.
Definition: copy.h:59
Buffer
String manipulation buffer.
Definition: buffer.h:33
Body::offset
LOFF_T offset
offset where the actual data begins
Definition: body.h:44
SEC_OPPENCRYPT
#define SEC_OPPENCRYPT
Opportunistic encrypt mode.
Definition: lib.h:93
crypt_smime_void_passphrase
void crypt_smime_void_passphrase(void)
Wrapper for CryptModuleSpecs::void_passphrase()
Definition: cryptglue.c:414
smime_invoke_encrypt
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.
Definition: smime.c:1278
mutt_file_fclose
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:153
Body::next
struct Body * next
next attachment in the list
Definition: body.h:53
mutt_buffer_is_empty
bool mutt_buffer_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:252
mutt_buffer_dealloc
void mutt_buffer_dealloc(struct Buffer *buf)
Release the memory allocated by a buffer.
Definition: buffer.c:294
MUTT_CM_DECODE_CRYPT
#define MUTT_CM_DECODE_CRYPT
Definition: copy.h:47
Body
The body of an email.
Definition: body.h:34
SEC_ENCRYPT
#define SEC_ENCRYPT
Email is encrypted.
Definition: lib.h:85
CSR_SUCCESS
#define CSR_SUCCESS
Action completed successfully.
Definition: set.h:35
SEC_SIGN
#define SEC_SIGN
Email is signed.
Definition: lib.h:86
SmimeKey
An SIME key.
Definition: smime.h:43
CSR_RESULT
#define CSR_RESULT(x)
Definition: set.h:52
C_SmimeTimeout
long C_SmimeTimeout
Config: Time in seconds to cache a passphrase.
Definition: config.c:117
mutt_buffer_mktemp
#define mutt_buffer_mktemp(buf)
Definition: muttlib.h:77
mutt_multi_choice
int mutt_multi_choice(const char *prompt, const char *letters)
Offer the user a multiple choice question.
Definition: curs_lib.c:937
smime_get_key_by_hash
static struct SmimeKey * smime_get_key_by_hash(char *hash, bool only_public_key)
Find a key by its hash.
Definition: smime.c:551
TAILQ_EMPTY
#define TAILQ_EMPTY(head)
Definition: queue.h:714
CH_WEED
#define CH_WEED
Weed the headers?
Definition: copy.h:52
TAILQ_FOREACH
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:718
mutt_expand_aliases
void mutt_expand_aliases(struct AddressList *al)
Expand aliases in a List of Addresses.
Definition: alias.c:294
mutt_str_dup
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:370
SmimeKey::issuer
char * issuer
Definition: smime.h:48
mutt_file_fopen
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:589
mutt_file_unlink
void mutt_file_unlink(const char *s)
Delete a file, carefully.
Definition: file.c:195
crypt_convert_to_7bit
void crypt_convert_to_7bit(struct Body *a)
Convert an email to 7bit encoding.
Definition: crypt.c:803
C_SmimeCertificates
char * C_SmimeCertificates
Config: File containing user's public certificates.
Definition: config.c:105
smime_class_void_passphrase
void smime_class_void_passphrase(void)
Implements CryptModuleSpecs::void_passphrase()
Definition: smime.c:158
FREE
#define FREE(x)
Definition: memory.h:40
Body::disposition
unsigned int disposition
content-disposition, ContentDisposition
Definition: body.h:67
mutt_perror
#define mutt_perror(...)
Definition: logging.h:85
smime_invoke_sign
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.
Definition: smime.c:1303
Body::encoding
unsigned int encoding
content-transfer-encoding, ContentEncoding
Definition: body.h:66
DISP_ATTACH
@ DISP_ATTACH
Content is attached.
Definition: mime.h:63
KEYFLAG_CANENCRYPT
#define KEYFLAG_CANENCRYPT
Key is suitable for encryption.
Definition: lib.h:135
PATH_MAX
#define PATH_MAX
Definition: mutt.h:44
smime_handle_cert_email
static int smime_handle_cert_email(char *certificate, char *mailbox, bool copy, char ***buffer, int *num)
Process an email containing certificates.
Definition: smime.c:850
mutt_buffer_pool_release
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
mutt_body_free
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition: body.c:57
Body::subtype
char * subtype
content-type subtype
Definition: body.h:37
mutt_buffer_alloc
void mutt_buffer_alloc(struct Buffer *buf, size_t new_size)
Make sure a buffer can store at least new_size bytes.
Definition: buffer.c:265
State::fp_out
FILE * fp_out
File to write to.
Definition: state.h:47
state_attach_puts
void state_attach_puts(struct State *s, const char *t)
Write a string to the state.
Definition: state.c:70
State::prefix
char * prefix
String to add to the beginning of each output line.
Definition: state.h:48
mutt_istr_equal
bool mutt_istr_equal(const char *a, const char *b)
Compare two strings, ignoring case.
Definition: string.c:883
MUTT_CM_DECODE_SMIME
#define MUTT_CM_DECODE_SMIME
Used for decoding S/MIME messages.
Definition: copy.h:45
Body::badsig
bool badsig
Bad cryptographic signature (needed to check encrypted s/mime-signatures)
Definition: body.h:77
mutt_str_equal
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:871
C_SmimeSignAs
char * C_SmimeSignAs
Config: Use this alternative key for signing messages.
Definition: config.c:68
MUTT_RL_NO_FLAGS
#define MUTT_RL_NO_FLAGS
No flags are set.
Definition: file.h:39
TAILQ_FIRST
#define TAILQ_FIRST(head)
Definition: queue.h:716
mutt_any_key_to_continue
int mutt_any_key_to_continue(const char *s)
Prompt the user to 'press any key' and wait.
Definition: curs_lib.c:605
Envelope::cc
struct AddressList cc
Email's 'Cc' list.
Definition: envelope.h:59
mutt_body_new
struct Body * mutt_body_new(void)
Create a new Body.
Definition: body.c:43
mutt_env_free
void mutt_env_free(struct Envelope **ptr)
Free an Envelope.
Definition: envelope.c:96
mutt_buffer_pool_get
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
smime_extract_signer_certificate
static char * smime_extract_signer_certificate(const char *infile)
Extract the signer's certificate.
Definition: smime.c:1057
C_SmimeAskCertLabel
bool C_SmimeAskCertLabel
Config: Prompt the user for a label for SMIME certificates.
Definition: config.c:103
Body::goodsig
bool goodsig
Good cryptographic signature.
Definition: body.h:75
mutt_file_copy_stream
int mutt_file_copy_stream(FILE *fp_in, FILE *fp_out)
Copy the contents of one file into another.
Definition: file.c:271
mutt_write_mime_body
int mutt_write_mime_body(struct Body *a, FILE *fp, struct ConfigSubset *sub)
Write a MIME part.
Definition: body.c:314
Body::length
LOFF_T length
length (in bytes) of attachment
Definition: body.h:45
KEYFLAG_CANSIGN
#define KEYFLAG_CANSIGN
Key is suitable for signing.
Definition: lib.h:134
MUTT_CM_NO_FLAGS
#define MUTT_CM_NO_FLAGS
No flags are set.
Definition: copy.h:34
C_CryptOpportunisticEncrypt
bool C_CryptOpportunisticEncrypt
Config: Enable encryption when the recipient's key is available.
Definition: config.c:54
openssl_md_to_smime_micalg
static char * openssl_md_to_smime_micalg(char *md)
Change the algorithm names.
Definition: smime.c:1459
CH_NO_FLAGS
#define CH_NO_FLAGS
No flags are set.
Definition: copy.h:50
cs_subset_str_string_set
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.
Definition: subset.c:395
smime_key_free
static void smime_key_free(struct SmimeKey **keylist)
Free a list of SMIME keys.
Definition: smime.c:108
mutt_param_set
void mutt_param_set(struct ParameterList *pl, const char *attribute, const char *value)
Set a Parameter.
Definition: parameter.c:110
Envelope::to
struct AddressList to
Email's 'To' list.
Definition: envelope.h:58
Body::parts
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:54
getkeys
static void getkeys(char *mailbox)
Get the keys for a mailbox.
Definition: smime.c:735
mutt_mem_realloc
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:114
Email::env
struct Envelope * env
Envelope information.
Definition: email.h:90
SmimeExpTime
time_t SmimeExpTime
Definition: smime.c:78
smime_handle_entity
static struct Body * smime_handle_entity(struct Body *m, struct State *s, FILE *fp_out_file)
Handle type application/pkcs7-mime.
Definition: smime.c:1795
smime_ask_for_key
static struct SmimeKey * smime_ask_for_key(char *prompt, KeyFlags abilities, bool only_public_key)
Ask the user to select a key.
Definition: smime.c:702
mutt_addr_free
void mutt_addr_free(struct Address **ptr)
Free a single Address.
Definition: address.c:440
mutt_str_len
size_t mutt_str_len(const char *a)
Calculate the length of a string, safely.
Definition: string.c:631
mutt_buffer_string
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:77
Email::security
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/lib.h pgplib....
Definition: email.h:39
mutt_date_epoch
time_t mutt_date_epoch(void)
Return the number of seconds since the Unix epoch.
Definition: date.c:416
crypt_current_time
void crypt_current_time(struct State *s, const char *app_name)
Print the current time.
Definition: crypt.c:72
mutt_str_replace
char * mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:446
filter_wait
int filter_wait(pid_t pid)
Wait for the exit of a process and return its status.
Definition: filter.c:217
WithCrypto
#define WithCrypto
Definition: lib.h:123
Address::mailbox
char * mailbox
Mailbox and host address.
Definition: address.h:37
C_SmimeDecryptUseDefaultKey
bool C_SmimeDecryptUseDefaultKey
Config: Use the default key for decryption.
Definition: config.c:107
MUTT_PASS
#define MUTT_PASS
Password mode (no echo)
Definition: mutt.h:61
C_SmimeSignDigestAlg
char * C_SmimeSignDigestAlg
Config: Digest algorithm.
Definition: config.c:116
Envelope::from
struct AddressList from
Email's 'From' list.
Definition: envelope.h:57
State
Keep track when processing files.
Definition: state.h:44
TYPE_APPLICATION
@ TYPE_APPLICATION
Type: 'application/*'.
Definition: mime.h:33
Body::d_filename
char * d_filename
filename to be used for the content-disposition header.
Definition: body.h:47
ENC_BASE64
@ ENC_BASE64
Base-64 encoded text.
Definition: mime.h:52
SmimeIntermediateToUse
static struct Buffer SmimeIntermediateToUse
Definition: smime.c:82
SmimePass
char SmimePass[256]
Definition: smime.c:77
NeoMutt
Container for Accounts, Notifications.
Definition: neomutt.h:36
DISP_INLINE
@ DISP_INLINE
Content is inline.
Definition: mime.h:62
crypt_opportunistic_encrypt
void crypt_opportunistic_encrypt(struct Email *e)
Can all recipients be determined.
Definition: crypt.c:1024
Body::type
unsigned int type
content-type primary type, ContentType
Definition: body.h:65
SmimeKey::hash
char * hash
Definition: smime.h:46
C_SmimeDefaultKey
char * C_SmimeDefaultKey
Config: Default key for SMIME operations.
Definition: config.c:67
smime_invoke
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.
Definition: smime.c:390
smime_invoke_verify
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.
Definition: smime.c:1645
mutt_write_mime_header
int mutt_write_mime_header(struct Body *a, FILE *fp, struct ConfigSubset *sub)
Create a MIME header.
Definition: header.c:764
mutt_default_from
struct Address * mutt_default_from(struct ConfigSubset *sub)
Get a default 'from' Address.
Definition: send.c:1338
NeoMutt::sub
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:39
smime_get_key_by_addr
static struct SmimeKey * smime_get_key_by_addr(char *mailbox, KeyFlags abilities, bool only_public_key, bool oppenc_mode)
Find an SIME key by address.
Definition: smime.c:577
Body::use_disp
bool use_disp
Content-Disposition uses filename= ?
Definition: body.h:68
CH_MIME
#define CH_MIME
Ignore MIME fields.
Definition: copy.h:60
mutt_get_field
int mutt_get_field(const char *field, char *buf, size_t buflen, CompletionFlags complete, bool multiple, char ***files, int *numfiles)
Ask the user for a string.
Definition: curs_lib.c:311
mutt_buffer_strdup
char * mutt_buffer_strdup(const struct Buffer *buf)
Copy a Buffer's string.
Definition: buffer.c:432
Body::unlink
bool unlink
If true, filename should be unlink()ed before free()ing this structure.
Definition: body.h:69
mutt_date_add_timeout
time_t mutt_date_add_timeout(time_t now, time_t timeout)
Safely add a timeout to a given time_t value.
Definition: date.c:625
Body::parameter
struct ParameterList parameter
parameters of the content-type
Definition: body.h:39
mutt_decode_attachment
void mutt_decode_attachment(struct Body *b, struct State *s)
Decode an email's attachment.
Definition: handler.c:1845
TYPE_MULTIPART
@ TYPE_MULTIPART
Type: 'multipart/*'.
Definition: mime.h:37
mutt_message
#define mutt_message(...)
Definition: logging.h:83
mutt_buffer_printf
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:160
mutt_file_mkstemp
#define mutt_file_mkstemp()
Definition: file.h:109
mutt_copy_message
int mutt_copy_message(FILE *fp_out, struct Mailbox *m, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags, int wraplen)
Copy a message from a Mailbox.
Definition: copy.c:835
mutt_buffer_make
struct Buffer mutt_buffer_make(size_t size)
Make a new buffer on the stack.
Definition: buffer.c:61
Envelope::sender
struct AddressList sender
Email's sender.
Definition: envelope.h:61
mutt_is_application_smime
SecurityFlags mutt_is_application_smime(struct Body *m)
Does the message use S/MIME?
Definition: crypt.c:612
ENC_7BIT
@ ENC_7BIT
7-bit text
Definition: mime.h:49
mutt_addr_is_user
bool mutt_addr_is_user(const struct Address *addr)
Does the address belong to the user.
Definition: alias.c:556
Address
An email address.
Definition: address.h:34
Body::mime_headers
struct Envelope * mime_headers
Memory hole protected headers.
Definition: body.h:63
Body::filename
char * filename
when sending a message, this is the file to which this structure refers
Definition: body.h:46
smime_extract_certificate
static char * smime_extract_certificate(const char *infile)
Extract an SMIME certificate from a file.
Definition: smime.c:944
mutt_error
#define mutt_error(...)
Definition: logging.h:84
mutt_file_read_line
char * mutt_file_read_line(char *line, size_t *size, FILE *fp, int *line_num, ReadLineFlags flags)
Read a line from a file.
Definition: file.c:667
mutt_get_field_unbuffered
int mutt_get_field_unbuffered(const char *msg, char *buf, size_t buflen, CompletionFlags flags)
Ask the user for a string (ignoring macro buffer)
Definition: curs_lib.c:335
MUTT_COMP_NO_FLAGS
#define MUTT_COMP_NO_FLAGS
No flags are set.
Definition: mutt.h:56