NeoMutt  2019-12-07
Teaching an old dog new tricks
DOXYGEN
crypt.c
Go to the documentation of this file.
1 
35 #include "config.h"
36 #include <locale.h>
37 #include <stdbool.h>
38 #include <stdio.h>
39 #include <string.h>
40 #include "mutt/mutt.h"
41 #include "address/lib.h"
42 #include "config/lib.h"
43 #include "email/lib.h"
44 #include "mutt.h"
45 #include "crypt.h"
46 #include "alias.h"
47 #include "copy.h"
48 #include "cryptglue.h"
49 #include "curs_lib.h"
50 #include "globals.h"
51 #include "handler.h"
52 #include "mutt_curses.h"
53 #include "mutt_parse.h"
54 #include "mutt_window.h"
55 #include "muttlib.h"
56 #include "ncrypt.h"
57 #include "options.h"
58 #include "send.h"
59 #include "sendlib.h"
60 #include "state.h"
61 #ifdef USE_AUTOCRYPT
62 #include "autocrypt/autocrypt.h"
63 #endif
64 
65 struct Mailbox;
66 
67 /* These Config Variables are only used in ncrypt/crypt.c */
68 bool C_CryptTimestamp;
69 unsigned char C_PgpEncryptSelf;
70 unsigned char C_PgpMimeAuto;
74 unsigned char C_SmimeEncryptSelf;
76 
84 void crypt_current_time(struct State *s, const char *app_name)
85 {
86  char p[256], tmp[256];
87 
88  if (!WithCrypto)
89  return;
90 
91  if (C_CryptTimestamp)
92  {
93  mutt_date_localtime_format(p, sizeof(p), _(" (current time: %c)"), MUTT_DATE_NOW);
94  }
95  else
96  *p = '\0';
97 
98  snprintf(tmp, sizeof(tmp), _("[-- %s output follows%s --]\n"), NONULL(app_name), p);
99  state_attach_puts(s, tmp);
100 }
101 
106 {
109 
112 
113  if (WithCrypto)
114  {
115  /* L10N: Due to the implementation details (e.g. some passwords are managed
116  by gpg-agent) we can't know whether we forgot zero, 1, 12, ...
117  passwords. So in English we use "Passphrases". Your language might
118  have other means to express this. */
119  mutt_message(_("Passphrases forgotten"));
120  }
121 }
122 
123 #ifndef DEBUG
124 #include <sys/resource.h>
128 static void disable_coredumps(void)
129 {
130  struct rlimit rl = { 0, 0 };
131  static bool done = false;
132 
133  if (!done)
134  {
135  setrlimit(RLIMIT_CORE, &rl);
136  done = true;
137  }
138 }
139 #endif
140 
148 {
149  bool rc = false;
150 
151 #ifndef DEBUG
152  disable_coredumps();
153 #endif
154 
155  if (((WithCrypto & APPLICATION_PGP) != 0) && (flags & APPLICATION_PGP))
157 
158  if (((WithCrypto & APPLICATION_SMIME) != 0) && (flags & APPLICATION_SMIME))
160 
161  return rc;
162 }
163 
172 int mutt_protect(struct Email *e, char *keylist, bool postpone)
173 {
174  struct Body *pbody = NULL, *tmp_pbody = NULL;
175  struct Body *tmp_smime_pbody = NULL;
176  struct Body *tmp_pgp_pbody = NULL;
177  bool has_retainable_sig = false;
178 
179  if (!WithCrypto)
180  return -1;
181 
182  int security = e->security;
183  int sign = security & (SEC_AUTOCRYPT | SEC_SIGN);
184  if (postpone)
185  {
186  sign = SEC_NO_FLAGS;
187  security &= ~SEC_SIGN;
188  }
189 
190  if (!(security & (SEC_ENCRYPT | SEC_AUTOCRYPT)) && !sign)
191  return 0;
192 
193  if (sign && !(security & SEC_AUTOCRYPT) && !crypt_valid_passphrase(security))
194  return -1;
195 
196  if (((WithCrypto & APPLICATION_PGP) != 0) && !(security & SEC_AUTOCRYPT) &&
197  ((security & PGP_INLINE) == PGP_INLINE))
198  {
199  if ((e->content->type != TYPE_TEXT) ||
200  (mutt_str_strcasecmp(e->content->subtype, "plain") != 0))
201  {
203  _("Inline PGP can't be used with attachments. "
204  "Revert to PGP/MIME?")) != MUTT_YES)
205  {
206  mutt_error(
207  _("Mail not sent: inline PGP can't be used with attachments"));
208  return -1;
209  }
210  }
211  else if (mutt_str_strcasecmp("flowed", mutt_param_get(&e->content->parameter, "format")) == 0)
212  {
214  _("Inline PGP can't be used with format=flowed. "
215  "Revert to PGP/MIME?"))) != MUTT_YES)
216  {
217  mutt_error(
218  _("Mail not sent: inline PGP can't be used with format=flowed"));
219  return -1;
220  }
221  }
222  else
223  {
224  /* they really want to send it inline... go for it */
225  if (!isendwin())
226  {
227  mutt_endwin();
228  puts(_("Invoking PGP..."));
229  }
230  pbody = crypt_pgp_traditional_encryptsign(e->content, security, keylist);
231  if (pbody)
232  {
233  e->content = pbody;
234  return 0;
235  }
236 
237  /* otherwise inline won't work...ask for revert */
238  if (query_quadoption(
240  _("Message can't be sent inline. Revert to using PGP/MIME?")) != MUTT_YES)
241  {
242  mutt_error(_("Mail not sent"));
243  return -1;
244  }
245  }
246 
247  /* go ahead with PGP/MIME */
248  }
249 
250  if (!isendwin())
251  mutt_endwin();
252 
254  tmp_smime_pbody = e->content;
255  if (WithCrypto & APPLICATION_PGP)
256  tmp_pgp_pbody = e->content;
257 
258  if (C_CryptUsePka && sign)
259  {
260  /* Set sender (necessary for e.g. PKA). */
261  const char *mailbox = NULL;
262  struct Address *from = TAILQ_FIRST(&e->env->from);
263  bool free_from = false;
264 
265  if (!from)
266  {
267  free_from = true;
268  from = mutt_default_from();
269  }
270 
271  mailbox = from->mailbox;
272  if (!mailbox && C_EnvelopeFromAddress)
273  mailbox = C_EnvelopeFromAddress->mailbox;
274 
275  if (((WithCrypto & APPLICATION_SMIME) != 0) && (security & APPLICATION_SMIME))
276  crypt_smime_set_sender(mailbox);
277  else if (((WithCrypto & APPLICATION_PGP) != 0) && (security & APPLICATION_PGP))
278  crypt_pgp_set_sender(mailbox);
279 
280  if (free_from)
281  mutt_addr_free(&from);
282  }
283 
285  {
286  struct Envelope *protected_headers = mutt_env_new();
287  mutt_str_replace(&protected_headers->subject, e->env->subject);
288  /* Note: if other headers get added, such as to, cc, then a call to
289  * mutt_env_to_intl() will need to be added here too. */
290  mutt_prepare_envelope(protected_headers, 0);
291 
293  e->content->mime_headers = protected_headers;
294  }
295 
296  /* A note about e->content->mime_headers. If postpone or send
297  * fails, the mime_headers is cleared out before returning to the
298  * compose menu. So despite the "robustness" code above and in the
299  * gen_gossip_list function below, mime_headers will not be set when
300  * entering mutt_protect().
301  *
302  * This is important to note because the user could toggle
303  * $crypt_protected_headers_write or $autocrypt off back in the
304  * compose menu. We don't want mutt_write_rfc822_header() to write
305  * stale data from one option if the other is set.
306  */
307 #ifdef USE_AUTOCRYPT
308  if (C_Autocrypt && !postpone && (security & SEC_AUTOCRYPT))
309  {
311  }
312 #endif
313 
314  if (sign)
315  {
316  if (((WithCrypto & APPLICATION_SMIME) != 0) && (security & APPLICATION_SMIME))
317  {
318  tmp_pbody = crypt_smime_sign_message(e->content);
319  if (!tmp_pbody)
320  goto bail;
321  pbody = tmp_pbody;
322  tmp_smime_pbody = tmp_pbody;
323  }
324 
325  if (((WithCrypto & APPLICATION_PGP) != 0) && (security & APPLICATION_PGP) &&
326  (!(security & (SEC_ENCRYPT | SEC_AUTOCRYPT)) || C_PgpRetainableSigs))
327  {
328  tmp_pbody = crypt_pgp_sign_message(e->content);
329  if (!tmp_pbody)
330  goto bail;
331 
332  has_retainable_sig = true;
333  sign = SEC_NO_FLAGS;
334  pbody = tmp_pbody;
335  tmp_pgp_pbody = tmp_pbody;
336  }
337 
338  if ((WithCrypto != 0) && (security & APPLICATION_SMIME) && (security & APPLICATION_PGP))
339  {
340  /* here comes the draft ;-) */
341  }
342  }
343 
344  if (security & (SEC_ENCRYPT | SEC_AUTOCRYPT))
345  {
346  if (((WithCrypto & APPLICATION_SMIME) != 0) && (security & APPLICATION_SMIME))
347  {
348  tmp_pbody = crypt_smime_build_smime_entity(tmp_smime_pbody, keylist);
349  if (!tmp_pbody)
350  {
351  /* signed ? free it! */
352  goto bail;
353  }
354  /* free tmp_body if messages was signed AND encrypted ... */
355  if ((tmp_smime_pbody != e->content) && (tmp_smime_pbody != tmp_pbody))
356  {
357  /* detach and don't delete e->content,
358  * which tmp_smime_pbody->parts after signing. */
359  tmp_smime_pbody->parts = tmp_smime_pbody->parts->next;
360  e->content->next = NULL;
361  mutt_body_free(&tmp_smime_pbody);
362  }
363  pbody = tmp_pbody;
364  }
365 
366  if (((WithCrypto & APPLICATION_PGP) != 0) && (security & APPLICATION_PGP))
367  {
368  pbody = crypt_pgp_encrypt_message(e, tmp_pgp_pbody, keylist, sign);
369  if (!pbody)
370  {
371  /* did we perform a retainable signature? */
372  if (has_retainable_sig)
373  {
374  /* remove the outer multipart layer */
375  tmp_pgp_pbody = mutt_remove_multipart(tmp_pgp_pbody);
376  /* get rid of the signature */
377  mutt_body_free(&tmp_pgp_pbody->next);
378  }
379 
380  goto bail;
381  }
382 
383  /* destroy temporary signature envelope when doing retainable
384  * signatures.
385 
386  */
387  if (has_retainable_sig)
388  {
389  tmp_pgp_pbody = mutt_remove_multipart(tmp_pgp_pbody);
390  mutt_body_free(&tmp_pgp_pbody->next);
391  }
392  }
393  }
394 
395  if (pbody)
396  {
397  e->content = pbody;
398  return 0;
399  }
400 
401 bail:
403  return -1;
404 }
405 
413 {
414  if (!b || (b->type != TYPE_MULTIPART) || !b->subtype ||
415  (mutt_str_strcasecmp(b->subtype, "signed") != 0))
416  {
417  return SEC_NO_FLAGS;
418  }
419 
420  char *p = mutt_param_get(&b->parameter, "protocol");
421  if (!p)
422  return SEC_NO_FLAGS;
423 
424  if (!(mutt_str_strcasecmp(p, "multipart/mixed") != 0))
425  return SEC_SIGN;
426 
427  if (((WithCrypto & APPLICATION_PGP) != 0) &&
428  !(mutt_str_strcasecmp(p, "application/pgp-signature") != 0))
429  {
430  return PGP_SIGN;
431  }
432 
433  if (((WithCrypto & APPLICATION_SMIME) != 0) &&
434  !(mutt_str_strcasecmp(p, "application/x-pkcs7-signature") != 0))
435  {
436  return SMIME_SIGN;
437  }
438  if (((WithCrypto & APPLICATION_SMIME) != 0) &&
439  !(mutt_str_strcasecmp(p, "application/pkcs7-signature") != 0))
440  {
441  return SMIME_SIGN;
442  }
443 
444  return SEC_NO_FLAGS;
445 }
446 
454 {
455  if ((WithCrypto & APPLICATION_PGP) == 0)
456  return SEC_NO_FLAGS;
457 
458  char *p = NULL;
459 
460  if (!b || (b->type != TYPE_MULTIPART) || !b->subtype ||
461  (mutt_str_strcasecmp(b->subtype, "encrypted") != 0) ||
462  !(p = mutt_param_get(&b->parameter, "protocol")) ||
463  (mutt_str_strcasecmp(p, "application/pgp-encrypted") != 0))
464  {
465  return SEC_NO_FLAGS;
466  }
467 
468  return PGP_ENCRYPT;
469 }
470 
478 {
480  return 0;
481 
482  b = b->parts;
483  if (!b || (b->type != TYPE_APPLICATION) || !b->subtype ||
484  (mutt_str_strcasecmp(b->subtype, "pgp-encrypted") != 0))
485  {
486  return 0;
487  }
488 
489  b = b->next;
490  if (!b || (b->type != TYPE_APPLICATION) || !b->subtype ||
491  (mutt_str_strcasecmp(b->subtype, "octet-stream") != 0))
492  {
493  return 0;
494  }
495 
496  return PGP_ENCRYPT;
497 }
498 
515 {
516  if (!(WithCrypto & APPLICATION_PGP))
517  return SEC_NO_FLAGS;
518 
519  if (!b || (b->type != TYPE_MULTIPART) || !b->subtype ||
520  (mutt_str_strcasecmp(b->subtype, "mixed") != 0))
521  {
522  return SEC_NO_FLAGS;
523  }
524 
525  b = b->parts;
526  if (!b || (b->type != TYPE_TEXT) || !b->subtype ||
527  (mutt_str_strcasecmp(b->subtype, "plain") != 0) || (b->length != 0))
528  {
529  return SEC_NO_FLAGS;
530  }
531 
532  b = b->next;
533  if (!b || (b->type != TYPE_APPLICATION) || !b->subtype ||
534  (mutt_str_strcasecmp(b->subtype, "pgp-encrypted") != 0))
535  {
536  return SEC_NO_FLAGS;
537  }
538 
539  b = b->next;
540  if (!b || (b->type != TYPE_APPLICATION) || !b->subtype ||
541  (mutt_str_strcasecmp(b->subtype, "octet-stream") != 0))
542  {
543  return SEC_NO_FLAGS;
544  }
545 
546  b = b->next;
547  if (b)
548  return SEC_NO_FLAGS;
549 
550  return PGP_ENCRYPT;
551 }
552 
560 {
562  char *p = NULL;
563 
564  if (m->type == TYPE_APPLICATION)
565  {
566  if ((mutt_str_strcasecmp(m->subtype, "pgp") == 0) ||
567  (mutt_str_strcasecmp(m->subtype, "x-pgp-message") == 0))
568  {
569  p = mutt_param_get(&m->parameter, "x-action");
570  if (p && ((mutt_str_strcasecmp(p, "sign") == 0) ||
571  (mutt_str_strcasecmp(p, "signclear") == 0)))
572  {
573  t |= PGP_SIGN;
574  }
575 
576  p = mutt_param_get(&m->parameter, "format");
577  if (p && (mutt_str_strcasecmp(p, "keys-only") == 0))
578  {
579  t |= PGP_KEY;
580  }
581 
582  if (t == SEC_NO_FLAGS)
583  t |= PGP_ENCRYPT; /* not necessarily correct, but... */
584  }
585 
586  if (mutt_str_strcasecmp(m->subtype, "pgp-signed") == 0)
587  t |= PGP_SIGN;
588 
589  if (mutt_str_strcasecmp(m->subtype, "pgp-keys") == 0)
590  t |= PGP_KEY;
591  }
592  else if ((m->type == TYPE_TEXT) && (mutt_str_strcasecmp("plain", m->subtype) == 0))
593  {
594  if (((p = mutt_param_get(&m->parameter, "x-mutt-action")) ||
595  (p = mutt_param_get(&m->parameter, "x-action")) ||
596  (p = mutt_param_get(&m->parameter, "action"))) &&
597  mutt_str_startswith(p, "pgp-sign", CASE_IGNORE))
598  {
599  t |= PGP_SIGN;
600  }
601  else if (p && mutt_str_startswith(p, "pgp-encrypt", CASE_IGNORE))
602  t |= PGP_ENCRYPT;
603  else if (p && mutt_str_startswith(p, "pgp-keys", CASE_IGNORE))
604  t |= PGP_KEY;
605  }
606  if (t)
607  t |= PGP_INLINE;
608 
609  return t;
610 }
611 
619 {
620  if (!m)
621  return SEC_NO_FLAGS;
622 
623  if (((m->type & TYPE_APPLICATION) == 0) || !m->subtype)
624  return SEC_NO_FLAGS;
625 
626  char *t = NULL;
627  bool complain = false;
628  /* S/MIME MIME types don't need x- anymore, see RFC2311 */
629  if ((mutt_str_strcasecmp(m->subtype, "x-pkcs7-mime") == 0) ||
630  (mutt_str_strcasecmp(m->subtype, "pkcs7-mime") == 0))
631  {
632  t = mutt_param_get(&m->parameter, "smime-type");
633  if (t)
634  {
635  if (mutt_str_strcasecmp(t, "enveloped-data") == 0)
636  return SMIME_ENCRYPT;
637  if (mutt_str_strcasecmp(t, "signed-data") == 0)
638  return SMIME_SIGN | SMIME_OPAQUE;
639  return SEC_NO_FLAGS;
640  }
641  /* Netscape 4.7 uses
642  * Content-Description: S/MIME Encrypted Message
643  * instead of Content-Type parameter */
644  if (mutt_str_strcasecmp(m->description, "S/MIME Encrypted Message") == 0)
645  return SMIME_ENCRYPT;
646  complain = true;
647  }
648  else if (mutt_str_strcasecmp(m->subtype, "octet-stream") != 0)
649  return SEC_NO_FLAGS;
650 
651  t = mutt_param_get(&m->parameter, "name");
652 
653  if (!t)
654  t = m->d_filename;
655  if (!t)
656  t = m->filename;
657  if (!t)
658  {
659  if (complain)
660  {
661  mutt_message(
662  _("S/MIME messages with no hints on content are unsupported"));
663  }
664  return SEC_NO_FLAGS;
665  }
666 
667  /* no .p7c, .p10 support yet. */
668 
669  int len = mutt_str_strlen(t) - 4;
670  if ((len > 0) && (*(t + len) == '.'))
671  {
672  len++;
673  if (mutt_str_strcasecmp((t + len), "p7m") == 0)
674  {
675  /* Not sure if this is the correct thing to do, but
676  * it's required for compatibility with Outlook */
677  return SMIME_SIGN | SMIME_OPAQUE;
678  }
679  else if (mutt_str_strcasecmp((t + len), "p7s") == 0)
680  return SMIME_SIGN | SMIME_OPAQUE;
681  }
682 
683  return SEC_NO_FLAGS;
684 }
685 
695 {
696  if (!WithCrypto || !m)
697  return SEC_NO_FLAGS;
698 
700 
701  if (m->type == TYPE_APPLICATION)
702  {
704  rc |= mutt_is_application_pgp(m);
705 
707  {
708  rc |= mutt_is_application_smime(m);
709  if (rc && m->goodsig)
710  rc |= SEC_GOODSIGN;
711  if (rc && m->badsig)
712  rc |= SEC_BADSIGN;
713  }
714  }
715  else if (((WithCrypto & APPLICATION_PGP) != 0) && (m->type == TYPE_TEXT))
716  {
717  rc |= mutt_is_application_pgp(m);
718  if (rc && m->goodsig)
719  rc |= SEC_GOODSIGN;
720  }
721 
722  if (m->type == TYPE_MULTIPART)
723  {
725  rc |= mutt_is_multipart_signed(m);
727 
728  if (rc && m->goodsig)
729  rc |= SEC_GOODSIGN;
730 #ifdef USE_AUTOCRYPT
731  if (rc && m->is_autocrypt)
732  rc |= SEC_AUTOCRYPT;
733 #endif
734  }
735 
736  if ((m->type == TYPE_MULTIPART) || (m->type == TYPE_MESSAGE))
737  {
738  SecurityFlags u = m->parts ? SEC_ALL_FLAGS : SEC_NO_FLAGS; /* Bits set in all parts */
739  SecurityFlags w = SEC_NO_FLAGS; /* Bits set in any part */
740 
741  for (struct Body *b = m->parts; b; b = b->next)
742  {
743  const SecurityFlags v = crypt_query(b);
744  u &= v;
745  w |= v;
746  }
747  rc |= u | (w & ~SEC_GOODSIGN);
748 
749  if ((w & SEC_GOODSIGN) && !(u & SEC_GOODSIGN))
750  rc |= SEC_PARTSIGN;
751  }
752 
753  return rc;
754 }
755 
766 int crypt_write_signed(struct Body *a, struct State *s, const char *tempfile)
767 {
768  if (!WithCrypto)
769  return -1;
770 
771  FILE *fp = mutt_file_fopen(tempfile, "w");
772  if (!fp)
773  {
774  mutt_perror(tempfile);
775  return -1;
776  }
777 
778  fseeko(s->fp_in, a->hdr_offset, SEEK_SET);
779  size_t bytes = a->length + a->offset - a->hdr_offset;
780  bool hadcr = false;
781  while (bytes > 0)
782  {
783  const int c = fgetc(s->fp_in);
784  if (c == EOF)
785  break;
786 
787  bytes--;
788 
789  if (c == '\r')
790  hadcr = true;
791  else
792  {
793  if ((c == '\n') && !hadcr)
794  fputc('\r', fp);
795 
796  hadcr = false;
797  }
798 
799  fputc(c, fp);
800  }
801  mutt_file_fclose(&fp);
802 
803  return 0;
804 }
805 
811 {
812  if (!WithCrypto)
813  return;
814 
815  while (a)
816  {
817  if (a->type == TYPE_MULTIPART)
818  {
819  if (a->encoding != ENC_7BIT)
820  {
821  a->encoding = ENC_7BIT;
823  }
824  else if (((WithCrypto & APPLICATION_PGP) != 0) && C_PgpStrictEnc)
826  }
827  else if ((a->type == TYPE_MESSAGE) &&
828  (mutt_str_strcasecmp(a->subtype, "delivery-status") != 0))
829  {
830  if (a->encoding != ENC_7BIT)
831  mutt_message_to_7bit(a, NULL);
832  }
833  else if (a->encoding == ENC_8BIT)
835  else if (a->encoding == ENC_BINARY)
836  a->encoding = ENC_BASE64;
837  else if (a->content && (a->encoding != ENC_BASE64) &&
838  (a->content->from || (a->content->space && C_PgpStrictEnc)))
839  {
841  }
842  a = a->next;
843  }
844 }
845 
853 void crypt_extract_keys_from_messages(struct Mailbox *m, struct EmailList *el)
854 {
855  if (!WithCrypto)
856  return;
857 
858  struct Buffer *tempfname = mutt_buffer_pool_get();
859  mutt_buffer_mktemp(tempfname);
860  FILE *fp_out = mutt_file_fopen(mutt_b2s(tempfname), "w");
861  if (!fp_out)
862  {
863  mutt_perror(mutt_b2s(tempfname));
864  goto cleanup;
865  }
866 
868  OptDontHandlePgpKeys = true;
869 
870  struct EmailNode *en = NULL;
871  STAILQ_FOREACH(en, el, entries)
872  {
873  struct Email *e = en->email;
874 
877  {
878  mutt_file_fclose(&fp_out);
879  break;
880  }
881 
882  if (((WithCrypto & APPLICATION_PGP) != 0) && (e->security & APPLICATION_PGP))
883  {
885  fflush(fp_out);
886 
887  mutt_endwin();
888  puts(_("Trying to extract PGP keys...\n"));
889  crypt_pgp_invoke_import(mutt_b2s(tempfname));
890  }
891 
892  if (((WithCrypto & APPLICATION_SMIME) != 0) && (e->security & APPLICATION_SMIME))
893  {
894  if (e->security & SEC_ENCRYPT)
895  {
897  CH_NO_FLAGS, 0);
898  }
899  else
901  fflush(fp_out);
902 
903  char *mbox = NULL;
904  if (!TAILQ_EMPTY(&e->env->from))
905  {
907  mbox = TAILQ_FIRST(&e->env->from)->mailbox;
908  }
909  else if (!TAILQ_EMPTY(&e->env->sender))
910  {
912  mbox = TAILQ_FIRST(&e->env->sender)->mailbox;
913  }
914  if (mbox)
915  {
916  mutt_endwin();
917  puts(_("Trying to extract S/MIME certificates..."));
918  crypt_smime_invoke_import(mutt_b2s(tempfname), mbox);
919  }
920  }
921 
922  rewind(fp_out);
923  }
924 
925  mutt_file_fclose(&fp_out);
926  if (isendwin())
928 
929  mutt_file_unlink(mutt_b2s(tempfname));
930 
931  if (WithCrypto & APPLICATION_PGP)
932  OptDontHandlePgpKeys = false;
933 
934 cleanup:
935  mutt_buffer_pool_release(&tempfname);
936 }
937 
952 int crypt_get_keys(struct Email *e, char **keylist, bool oppenc_mode)
953 {
954  if (!WithCrypto)
955  return 0;
956 
957  struct AddressList addrlist = TAILQ_HEAD_INITIALIZER(addrlist);
958  const char *fqdn = mutt_fqdn(true);
959  char *self_encrypt = NULL;
960 
961  /* Do a quick check to make sure that we can find all of the encryption
962  * keys if the user has requested this service. */
963 
964  *keylist = NULL;
965 
966 #ifdef USE_AUTOCRYPT
967  if (!oppenc_mode && (e->security & SEC_AUTOCRYPT))
968  {
970  return -1;
971  return 0;
972  }
973 #endif
974 
976  OptPgpCheckTrust = true;
977 
978  mutt_addrlist_copy(&addrlist, &e->env->to, false);
979  mutt_addrlist_copy(&addrlist, &e->env->cc, false);
980  mutt_addrlist_copy(&addrlist, &e->env->bcc, false);
981  mutt_addrlist_qualify(&addrlist, fqdn);
982  mutt_addrlist_dedupe(&addrlist);
983 
984  if (oppenc_mode || (e->security & SEC_ENCRYPT))
985  {
986  if (((WithCrypto & APPLICATION_PGP) != 0) && (e->security & APPLICATION_PGP))
987  {
988  *keylist = crypt_pgp_find_keys(&addrlist, oppenc_mode);
989  if (!*keylist)
990  {
991  mutt_addrlist_clear(&addrlist);
992  return -1;
993  }
994  OptPgpCheckTrust = false;
996  self_encrypt = C_PgpDefaultKey;
997  }
998  if (((WithCrypto & APPLICATION_SMIME) != 0) && (e->security & APPLICATION_SMIME))
999  {
1000  *keylist = crypt_smime_find_keys(&addrlist, oppenc_mode);
1001  if (!*keylist)
1002  {
1003  mutt_addrlist_clear(&addrlist);
1004  return -1;
1005  }
1007  self_encrypt = C_SmimeDefaultKey;
1008  }
1009  }
1010 
1011  if (!oppenc_mode && self_encrypt)
1012  {
1013  const size_t keylist_size = mutt_str_strlen(*keylist);
1014  mutt_mem_realloc(keylist, keylist_size + mutt_str_strlen(self_encrypt) + 2);
1015  sprintf(*keylist + keylist_size, " %s", self_encrypt);
1016  }
1017 
1018  mutt_addrlist_clear(&addrlist);
1019 
1020  return 0;
1021 }
1022 
1031 {
1032  if (!WithCrypto)
1033  return;
1034 
1036  return;
1037 
1038  char *pgpkeylist = NULL;
1039 
1040  crypt_get_keys(e, &pgpkeylist, 1);
1041  if (pgpkeylist)
1042  {
1043  e->security |= SEC_ENCRYPT;
1044  FREE(&pgpkeylist);
1045  }
1046  else
1047  {
1048  e->security &= ~SEC_ENCRYPT;
1049  }
1050 }
1051 
1058 static void crypt_fetch_signatures(struct Body ***signatures, struct Body *a, int *n)
1059 {
1060  if (!WithCrypto)
1061  return;
1062 
1063  for (; a; a = a->next)
1064  {
1065  if (a->type == TYPE_MULTIPART)
1066  crypt_fetch_signatures(signatures, a->parts, n);
1067  else
1068  {
1069  if ((*n % 5) == 0)
1070  mutt_mem_realloc(signatures, (*n + 6) * sizeof(struct Body **));
1071 
1072  (*signatures)[(*n)++] = a;
1073  }
1074  }
1075 }
1076 
1083 {
1086  {
1087  return true;
1088  }
1089 
1090  return false;
1091 }
1092 
1096 int mutt_protected_headers_handler(struct Body *a, struct State *s)
1097 {
1099  {
1100  if (a->mime_headers->subject)
1101  {
1102  const bool display = (s->flags & MUTT_DISPLAY);
1103 
1104  if (display && C_Weed && mutt_matches_ignore("subject"))
1105  return 0;
1106 
1108  int wraplen = display ? mutt_window_wrap_cols(s->wraplen, C_Wrap) : 0;
1109 
1110  mutt_write_one_header(s->fp_out, "Subject", a->mime_headers->subject,
1111  s->prefix, wraplen, display ? CH_DISPLAY : CH_NO_FLAGS);
1112  state_puts(s, "\n");
1113  }
1114  }
1115 
1116  return 0;
1117 }
1118 
1122 int mutt_signed_handler(struct Body *a, struct State *s)
1123 {
1124  if (!WithCrypto)
1125  return -1;
1126 
1127  bool inconsistent = false;
1128  struct Body *b = a;
1129  struct Body **signatures = NULL;
1130  int sigcnt = 0;
1131  int rc = 0;
1132  struct Buffer *tempfile = NULL;
1133 
1134  a = a->parts;
1135  SecurityFlags signed_type = mutt_is_multipart_signed(b);
1136  if (signed_type == SEC_NO_FLAGS)
1137  {
1138  /* A null protocol value is already checked for in mutt_body_handler() */
1139  state_printf(s,
1140  _("[-- Error: "
1141  "Unknown multipart/signed protocol %s --]\n\n"),
1142  mutt_param_get(&b->parameter, "protocol"));
1143  return mutt_body_handler(a, s);
1144  }
1145 
1146  if (!(a && a->next))
1147  inconsistent = true;
1148  else
1149  {
1150  switch (signed_type)
1151  {
1152  case SEC_SIGN:
1153  if ((a->next->type != TYPE_MULTIPART) ||
1154  (mutt_str_strcasecmp(a->next->subtype, "mixed") != 0))
1155  {
1156  inconsistent = true;
1157  }
1158  break;
1159  case PGP_SIGN:
1160  if ((a->next->type != TYPE_APPLICATION) ||
1161  (mutt_str_strcasecmp(a->next->subtype, "pgp-signature") != 0))
1162  {
1163  inconsistent = true;
1164  }
1165  break;
1166  case SMIME_SIGN:
1167  if ((a->next->type != TYPE_APPLICATION) ||
1168  ((mutt_str_strcasecmp(a->next->subtype, "x-pkcs7-signature") != 0) &&
1169  (mutt_str_strcasecmp(a->next->subtype, "pkcs7-signature") != 0)))
1170  {
1171  inconsistent = true;
1172  }
1173  break;
1174  default:
1175  inconsistent = true;
1176  }
1177  }
1178  if (inconsistent)
1179  {
1180  state_attach_puts(s, _("[-- Error: Missing or bad-format multipart/signed "
1181  "signature --]\n\n"));
1182  return mutt_body_handler(a, s);
1183  }
1184 
1185  if (s->flags & MUTT_DISPLAY)
1186  {
1187  crypt_fetch_signatures(&signatures, a->next, &sigcnt);
1188 
1189  if (sigcnt != 0)
1190  {
1191  tempfile = mutt_buffer_pool_get();
1192  mutt_buffer_mktemp(tempfile);
1193  bool goodsig = true;
1194  if (crypt_write_signed(a, s, mutt_b2s(tempfile)) == 0)
1195  {
1196  for (int i = 0; i < sigcnt; i++)
1197  {
1198  if (((WithCrypto & APPLICATION_PGP) != 0) &&
1199  (signatures[i]->type == TYPE_APPLICATION) &&
1200  (mutt_str_strcasecmp(signatures[i]->subtype, "pgp-signature") == 0))
1201  {
1202  if (crypt_pgp_verify_one(signatures[i], s, mutt_b2s(tempfile)) != 0)
1203  goodsig = false;
1204 
1205  continue;
1206  }
1207 
1208  if (((WithCrypto & APPLICATION_SMIME) != 0) &&
1209  (signatures[i]->type == TYPE_APPLICATION) &&
1210  ((mutt_str_strcasecmp(signatures[i]->subtype,
1211  "x-pkcs7-signature") == 0) ||
1212  (mutt_str_strcasecmp(signatures[i]->subtype,
1213  "pkcs7-signature") == 0)))
1214  {
1215  if (crypt_smime_verify_one(signatures[i], s, mutt_b2s(tempfile)) != 0)
1216  goodsig = false;
1217 
1218  continue;
1219  }
1220 
1221  state_printf(s,
1222  _("[-- Warning: "
1223  "We can't verify %s/%s signatures. --]\n\n"),
1224  TYPE(signatures[i]), signatures[i]->subtype);
1225  }
1226  }
1227 
1228  mutt_file_unlink(mutt_b2s(tempfile));
1229  mutt_buffer_pool_release(&tempfile);
1230 
1231  b->goodsig = goodsig;
1232  b->badsig = !goodsig;
1233 
1234  /* Now display the signed body */
1235  state_attach_puts(s, _("[-- The following data is signed --]\n\n"));
1236 
1238 
1239  FREE(&signatures);
1240  }
1241  else
1243  _("[-- Warning: Can't find any signatures. --]\n\n"));
1244  }
1245 
1246  rc = mutt_body_handler(a, s);
1247 
1248  if ((s->flags & MUTT_DISPLAY) && (sigcnt != 0))
1249  state_attach_puts(s, _("\n[-- End of signed data --]\n"));
1250 
1251  return rc;
1252 }
1253 
1268 const char *crypt_get_fingerprint_or_id(const char *p, const char **pphint,
1269  const char **ppl, const char **pps)
1270 {
1271  const char *ps = NULL, *pl = NULL, *phint = NULL;
1272  char *pfcopy = NULL, *s1 = NULL, *s2 = NULL;
1273  char c;
1274  int isid;
1275  size_t hexdigits;
1276 
1277  /* User input may be partial name, fingerprint or short or long key ID,
1278  * independent of C_PgpLongIds.
1279  * Fingerprint without spaces is 40 hex digits (SHA-1) or 32 hex digits (MD5).
1280  * Strip leading "0x" for key ID detection and prepare pl and ps to indicate
1281  * if an ID was found and to simplify logic in the key loop's inner
1282  * condition of the caller. */
1283 
1284  char *pf = mutt_str_skip_whitespace(p);
1285  if (mutt_str_startswith(pf, "0x", CASE_IGNORE))
1286  pf += 2;
1287 
1288  /* Check if a fingerprint is given, must be hex digits only, blanks
1289  * separating groups of 4 hex digits are allowed. Also pre-check for ID. */
1290  isid = 2; /* unknown */
1291  hexdigits = 0;
1292  s1 = pf;
1293  do
1294  {
1295  c = *(s1++);
1296  if ((('0' <= c) && (c <= '9')) || (('A' <= c) && (c <= 'F')) ||
1297  (('a' <= c) && (c <= 'f')))
1298  {
1299  hexdigits++;
1300  if (isid == 2)
1301  isid = 1; /* it is an ID so far */
1302  }
1303  else if (c)
1304  {
1305  isid = 0; /* not an ID */
1306  if ((c == ' ') && ((hexdigits % 4) == 0))
1307  ; /* skip blank before or after 4 hex digits */
1308  else
1309  break; /* any other character or position */
1310  }
1311  } while (c);
1312 
1313  /* If at end of input, check for correct fingerprint length and copy if. */
1314  pfcopy = (!c && ((hexdigits == 40) || (hexdigits == 32)) ? mutt_str_strdup(pf) : NULL);
1315 
1316  if (pfcopy)
1317  {
1318  /* Use pfcopy to strip all spaces from fingerprint and as hint. */
1319  s1 = pfcopy;
1320  s2 = pfcopy;
1321  do
1322  {
1323  *(s1++) = *(s2 = mutt_str_skip_whitespace(s2));
1324  } while (*(s2++));
1325 
1326  phint = pfcopy;
1327  ps = NULL;
1328  pl = NULL;
1329  }
1330  else
1331  {
1332  phint = p;
1333  ps = NULL;
1334  pl = NULL;
1335  if (isid == 1)
1336  {
1337  if (mutt_str_strlen(pf) == 16)
1338  pl = pf; /* long key ID */
1339  else if (mutt_str_strlen(pf) == 8)
1340  ps = pf; /* short key ID */
1341  }
1342  }
1343 
1344  *pphint = phint;
1345  *ppl = pl;
1346  *pps = ps;
1347  return pfcopy;
1348 }
1349 
1357 bool crypt_is_numerical_keyid(const char *s)
1358 {
1359  /* or should we require the "0x"? */
1360  if (strncmp(s, "0x", 2) == 0)
1361  s += 2;
1362  if (strlen(s) % 8)
1363  return false;
1364  while (*s)
1365  if (!strchr("0123456789ABCDEFabcdef", *s++))
1366  return false;
1367 
1368  return true;
1369 }
#define MUTT_CM_DECODE_CRYPT
Definition: copy.h:47
int mutt_protected_headers_handler(struct Body *a, struct State *s)
Process a protected header - Implements handler_t.
Definition: crypt.c:1096
bool mutt_matches_ignore(const char *s)
Does the string match the ignore list.
Definition: parse.c:309
const char * crypt_get_fingerprint_or_id(const char *p, const char **pphint, const char **ppl, const char **pps)
Get the fingerprint or long key ID.
Definition: crypt.c:1268
int state_printf(struct State *s, const char *fmt,...)
Write a formatted string to the State.
Definition: state.c:153
char * mutt_str_skip_whitespace(const char *p)
Find the first non-whitespace character in a string.
Definition: string.c:720
#define mutt_buffer_mktemp(buf)
Definition: muttlib.h:78
#define MUTT_DISPLAY
Output is displayed to the user.
Definition: state.h:32
void mutt_message_to_7bit(struct Body *a, FILE *fp)
Convert an email&#39;s MIME parts to 7-bit.
Definition: sendlib.c:1303
char * filename
when sending a message, this is the file to which this structure refers
Definition: body.h:46
#define NONULL(x)
Definition: string2.h:37
#define SEC_AUTOCRYPT
Message will be, or was Autocrypt encrypt+signed.
Definition: ncrypt.h:131
WHERE bool C_Autocrypt
Config: Enables the Autocrypt feature.
Definition: globals.h:202
struct Envelope * mime_headers
Memory hole protected headers.
Definition: body.h:63
Define wrapper functions around Curses/Slang.
Miscellaneous email parsing routines.
struct Body * mutt_remove_multipart(struct Body *b)
Extract the multipart body if it exists.
Definition: sendlib.c:1772
void mutt_expand_aliases(struct AddressList *al)
Expand aliases in a List of Addresses.
Definition: alias.c:303
#define PGP_INLINE
Definition: ncrypt.h:144
size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t)
Format localtime.
Definition: date.c:774
The envelope/body of an email.
Definition: email.h:37
#define state_puts(STATE, STR)
Definition: state.h:55
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:101
char * crypt_smime_find_keys(struct AddressList *addrlist, bool oppenc_mode)
Wrapper for CryptModuleSpecs::find_keys()
Definition: cryptglue.c:470
#define TAILQ_FIRST(head)
Definition: queue.h:717
#define mutt_perror(...)
Definition: logging.h:85
struct Content * content
Detailed info about the content of the attachment.
Definition: body.h:51
Window management.
GUI miscellaneous curses (window drawing) routines.
Structs that make up an email.
enum QuadOption query_quadoption(enum QuadOption opt, const char *prompt)
Ask the user a quad-question.
Definition: init.c:3359
7-bit text
Definition: mime.h:49
#define mutt_message(...)
Definition: logging.h:83
int mutt_signed_handler(struct Body *a, struct State *s)
Verify a "multipart/signed" body - Implements handler_t.
Definition: crypt.c:1122
WHERE char * C_SmimeDefaultKey
Config: Default key for SMIME operations.
Definition: globals.h:167
User answered &#39;Yes&#39;, or assume &#39;Yes&#39;.
Definition: quad.h:39
struct AddressList bcc
Email&#39;s &#39;Bcc&#39; list.
Definition: envelope.h:60
void mutt_addrlist_clear(struct AddressList *al)
Unlink and free all Address in an AddressList.
Definition: address.c:1381
WHERE char * C_CryptProtectedHeadersSubject
Config: Use this as the subject for encrypted emails.
Definition: globals.h:106
Wrapper around crypto functions.
void crypt_pgp_void_passphrase(void)
Wrapper for CryptModuleSpecs::void_passphrase()
Definition: cryptglue.c:183
void crypt_convert_to_7bit(struct Body *a)
Convert an email to 7bit encoding.
Definition: crypt.c:810
bool crypt_smime_valid_passphrase(void)
Wrapper for CryptModuleSpecs::valid_passphrase()
Definition: cryptglue.c:415
#define SEC_NO_FLAGS
No flags are set.
Definition: ncrypt.h:121
bool mutt_should_hide_protected_subject(struct Email *e)
Should NeoMutt hide the protected subject?
Definition: crypt.c:1082
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
Definition: pool.c:112
void mutt_addrlist_copy(struct AddressList *dst, const struct AddressList *src, bool prune)
Copy a list of addresses into another list.
Definition: address.c:727
bool crypt_is_numerical_keyid(const char *s)
Is this a numerical keyid.
Definition: crypt.c:1357
struct Body * content
List of MIME parts.
Definition: email.h:90
void crypt_forget_passphrase(void)
Forget a passphrase and display a message.
Definition: crypt.c:105
void mutt_file_unlink(const char *s)
Delete a file, carefully.
Definition: file.c:194
String manipulation buffer.
Definition: buffer.h:33
WHERE bool C_CryptUsePka
Config: Use GPGME to use PKA (lookup PGP keys using DNS)
Definition: globals.h:272
char * prefix
String to add to the beginning of each output line.
Definition: state.h:48
void mutt_parse_mime_message(struct Mailbox *m, struct Email *e)
Parse a MIME email.
Definition: mutt_parse.c:49
int mutt_is_valid_multipart_pgp_encrypted(struct Body *b)
Is this a valid multi-part encrypted message?
Definition: crypt.c:477
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:810
LOFF_T offset
offset where the actual data begins
Definition: body.h:44
WHERE bool C_CryptProtectedHeadersWrite
Config: Generate protected header (Memory Hole) for signed and encrypted emails.
Definition: globals.h:280
void crypt_pgp_set_sender(const char *sender)
Wrapper for CryptModuleSpecs::set_sender()
Definition: cryptglue.c:397
#define _(a)
Definition: message.h:28
bool is_autocrypt
Flag autocrypt-decrypted messages for replying.
Definition: body.h:79
WHERE short C_Wrap
Config: Width to wrap text in the pager.
Definition: globals.h:153
struct Body * next
next attachment in the list
Definition: body.h:53
An email address.
Definition: address.h:34
8-bit text
Definition: mime.h:50
#define MUTT_DATE_NOW
Constant representing the &#39;current time&#39;, see: mutt_date_gmtime(), mutt_date_localtime() ...
Definition: date.h:37
FILE * fp_out
File to write to.
Definition: state.h:47
char * mailbox
Mailbox and host address.
Definition: address.h:37
#define SEC_INLINE
Email has an inline signature.
Definition: ncrypt.h:129
#define SMIME_SIGN
Definition: ncrypt.h:147
size_t mutt_str_strlen(const char *a)
Calculate the length of a string, safely.
Definition: string.c:666
int crypt_get_keys(struct Email *e, char **keylist, bool oppenc_mode)
Check we have all the keys we need.
Definition: crypt.c:952
bool C_PgpStrictEnc
Config: Encode PGP signed messages with quoted-printable (don&#39;t unset)
Definition: crypt.c:73
int crypt_write_signed(struct Body *a, struct State *s, const char *tempfile)
Write the message body/part.
Definition: crypt.c:766
#define SEC_ENCRYPT
Email is encrypted.
Definition: ncrypt.h:122
#define MUTT_CM_NO_FLAGS
No flags are set.
Definition: copy.h:34
void mutt_addr_free(struct Address **ptr)
Free a single Address.
Definition: address.c:439
FILE * fp_in
File to read from.
Definition: state.h:46
#define SEC_PARTSIGN
Not all parts of the email is signed.
Definition: ncrypt.h:126
bool C_PgpSelfEncrypt
Config: Encrypted messages will also be encrypted to C_PgpDefaultKey too.
Definition: crypt.c:72
Representation of a single alias to an email address.
The body of an email.
Definition: body.h:34
void mutt_prepare_envelope(struct Envelope *env, bool final)
Prepare an email header.
Definition: sendlib.c:3009
Convenience wrapper for the config headers.
#define SEC_BADSIGN
Email has a bad signature.
Definition: ncrypt.h:125
Prepare and send an email.
Hundreds of global variables to back the user variables.
struct Body * crypt_smime_sign_message(struct Body *a)
Wrapper for CryptModuleSpecs::sign_message()
Definition: cryptglue.c:481
Email Address Handling.
void crypt_smime_set_sender(const char *sender)
Wrapper for CryptModuleSpecs::set_sender()
Definition: cryptglue.c:534
Some miscellaneous functions.
StateFlags flags
Flags, e.g. MUTT_DISPLAY.
Definition: state.h:49
#define SEC_ALL_FLAGS
Definition: ncrypt.h:138
bool crypt_valid_passphrase(SecurityFlags flags)
Check that we have a usable passphrase, ask if not.
Definition: crypt.c:147
void mutt_addrlist_dedupe(struct AddressList *al)
Remove duplicate addresses.
Definition: address.c:1318
SecurityFlags mutt_is_multipart_encrypted(struct Body *b)
Does the message have encrypted parts?
Definition: crypt.c:453
#define SEC_GOODSIGN
Email has a valid signature.
Definition: ncrypt.h:124
struct AddressList from
Email&#39;s &#39;From&#39; list.
Definition: envelope.h:57
unsigned char C_PgpEncryptSelf
Deprecated, see C_PgpSelfEncrypt.
Definition: crypt.c:69
#define SMIME_OPAQUE
Definition: ncrypt.h:150
int mutt_file_fclose(FILE **fp)
Close a FILE handle (and NULL the pointer)
Definition: file.c:152
bool C_PgpRetainableSigs
Config: Create nested multipart/signed or encrypted messages.
Definition: crypt.c:71
struct Envelope * env
Envelope information.
Definition: email.h:89
void crypt_current_time(struct State *s, const char *app_name)
Print the current time.
Definition: crypt.c:84
bool badsig
Bad cryptographic signature (needed to check encrypted s/mime-signatures)
Definition: body.h:77
struct AddressList cc
Email&#39;s &#39;Cc&#39; list.
Definition: envelope.h:59
WHERE bool OptDontHandlePgpKeys
(pseudo) used to extract PGP keys
Definition: options.h:34
SecurityFlags mutt_is_multipart_signed(struct Body *b)
Is a message signed?
Definition: crypt.c:412
int wraplen
Width to wrap lines to (when flags & MUTT_DISPLAY)
Definition: state.h:50
unsigned int encoding
content-transfer-encoding
Definition: body.h:66
Base-64 encoded text.
Definition: mime.h:52
struct Envelope * mutt_env_new(void)
Create a new Envelope.
Definition: envelope.c:42
void crypt_smime_void_passphrase(void)
Wrapper for CryptModuleSpecs::void_passphrase()
Definition: cryptglue.c:406
#define PGP_SIGN
Definition: ncrypt.h:141
void mutt_mem_realloc(void *ptr, size_t size)
Resize a block of memory on the heap.
Definition: memory.c:114
char * subtype
content-type subtype
Definition: body.h:37
bool C_SmimeSelfEncrypt
Config: Encrypted messages will also be encrypt to C_SmimeDefaultKey too.
Definition: crypt.c:75
#define mutt_b2s(buf)
Definition: buffer.h:41
bool goodsig
Good cryptographic signature.
Definition: body.h:75
SecurityFlags mutt_is_application_pgp(struct Body *m)
Does the message use PGP?
Definition: crypt.c:559
#define SEC_SIGN
Email is signed.
Definition: ncrypt.h:123
struct Address * mutt_default_from(void)
Get a default &#39;from&#39; Address.
Definition: send.c:1335
WHERE bool C_CryptOpportunisticEncrypt
Config: Enable encryption when the recipient&#39;s key is available.
Definition: globals.h:277
Signing/encryption multiplexor.
void mutt_endwin(void)
Shutdown curses/slang.
Definition: curs_lib.c:544
LOFF_T length
length (in bytes) of attachment
Definition: body.h:45
void crypt_pgp_invoke_import(const char *fname)
Wrapper for CryptModuleSpecs::pgp_invoke_import()
Definition: cryptglue.c:357
A mailbox.
Definition: mailbox.h:92
#define CH_NO_FLAGS
No flags are set.
Definition: copy.h:50
#define MUTT_CM_DECODE
Decode the message body into text/plain.
Definition: copy.h:37
#define PGP_KEY
Definition: ncrypt.h:143
Type: &#39;text/*&#39;.
Definition: mime.h:38
void mutt_env_free(struct Envelope **ptr)
Free an Envelope.
Definition: envelope.c:96
#define MUTT_CM_CHARCONV
Perform character set conversions.
Definition: copy.h:41
int mutt_protect(struct Email *e, char *keylist, bool postpone)
Encrypt and/or sign a message.
Definition: crypt.c:172
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:54
#define CH_DISPLAY
Display result to user.
Definition: copy.h:69
struct Body * crypt_pgp_traditional_encryptsign(struct Body *a, int flags, char *keylist)
Wrapper for CryptModuleSpecs::pgp_traditional_encryptsign()
Definition: cryptglue.c:288
Do no use Autocrypt.
Definition: autocrypt.h:104
int mutt_window_wrap_cols(int width, short wrap)
Calculate the wrap column for a given screen width.
Definition: mutt_window.c:351
SecurityFlags mutt_is_malformed_multipart_pgp_encrypted(struct Body *b)
Check for malformed layout.
Definition: crypt.c:514
Ignore case when comparing strings.
Definition: string2.h:68
void state_mark_protected_header(struct State *s)
Write a unique marker around protected headers.
Definition: state.c:56
unsigned char C_SmimeEncryptSelf
Deprecated, see C_SmimeSelfEncrypt.
Definition: crypt.c:74
struct Body * crypt_pgp_sign_message(struct Body *a)
Wrapper for CryptModuleSpecs::sign_message()
Definition: cryptglue.c:321
WHERE bool OptPgpCheckTrust
(pseudo) used by pgp_select_key()
Definition: options.h:47
SecurityFlags mutt_is_application_smime(struct Body *m)
Does the message use S/MIME?
Definition: crypt.c:618
static void crypt_fetch_signatures(struct Body ***signatures, struct Body *a, int *n)
Create an array of an emails parts.
Definition: crypt.c:1058
API for encryption/signing of emails.
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:350
char * description
content-description
Definition: body.h:40
SecurityFlags security
bit 0-10: flags, bit 11,12: application, bit 13: traditional pgp See: ncrypt/ncrypt.h pgplib.h, smime.h
Definition: email.h:39
WHERE bool C_CryptProtectedHeadersRead
Config: Display protected headers (Memory Hole) in the pager.
Definition: globals.h:278
void mutt_str_replace(char **p, const char *s)
Replace one string with another.
Definition: string.c:453
const char * mutt_fqdn(bool may_hide_host)
Get the Fully-Qualified Domain Name.
Definition: sendlib.c:2539
unsigned int type
content-type primary type
Definition: body.h:65
#define SEC_OPPENCRYPT
Opportunistic encrypt mode.
Definition: ncrypt.h:130
bool from
Has a line beginning with "From "?
Definition: content.h:43
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: ncrypt.h:134
size_t mutt_str_startswith(const char *str, const char *prefix, enum CaseSensitivity cs)
Check whether a string starts with a prefix.
Definition: string.c:168
bool C_CryptTimestamp
Config: Add a timestamp to PGP or SMIME output to prevent spoofing.
Definition: crypt.c:65
Type: &#39;message/*&#39;.
Definition: mime.h:35
unsigned char C_PgpMimeAuto
Config: Prompt the user to use MIME if inline PGP fails.
Definition: crypt.c:70
#define MUTT_CM_DECODE_SMIME
Used for decoding S/MIME messages.
Definition: copy.h:45
int mutt_any_key_to_continue(const char *s)
Prompt the user to &#39;press any key&#39; and wait.
Definition: curs_lib.c:577
void state_attach_puts(struct State *s, const char *t)
Write a string to the state.
Definition: state.c:70
Keep track when processing files.
#define TYPE(body)
Definition: mime.h:83
void crypt_opportunistic_encrypt(struct Email *e)
Can all recipients be determined.
Definition: crypt.c:1030
struct Body * crypt_smime_build_smime_entity(struct Body *a, char *certlist)
Wrapper for CryptModuleSpecs::smime_build_smime_entity()
Definition: cryptglue.c:492
void mutt_addrlist_qualify(struct AddressList *al, const char *host)
Expand local names in an Address list using a hostname.
Definition: address.c:640
char * crypt_pgp_find_keys(struct AddressList *addrlist, bool oppenc_mode)
Wrapper for CryptModuleSpecs::find_keys()
Definition: cryptglue.c:310
void crypt_smime_invoke_import(const char *infile, const char *mailbox)
Wrapper for CryptModuleSpecs::smime_invoke_import()
Definition: cryptglue.c:503
char * subject
Email&#39;s subject.
Definition: envelope.h:66
Type: &#39;multipart/*&#39;.
Definition: mime.h:37
enum AutocryptRec mutt_autocrypt_ui_recommendation(struct Email *e, char **keylist)
Get the recommended action for an Email.
Definition: autocrypt.c:561
Duplicate the structure of an entire email.
int mutt_autocrypt_generate_gossip_list(struct Email *e)
Create the gossip list headers.
Definition: autocrypt.c:797
char * mutt_str_strdup(const char *str)
Copy a string, safely.
Definition: string.c:380
Autocrypt end-to-end encryption.
struct Email * email
Email in the list.
Definition: email.h:116
#define SMIME_ENCRYPT
Definition: ncrypt.h:146
#define mutt_error(...)
Definition: logging.h:84
WHERE struct Address * C_EnvelopeFromAddress
Config: Manually set the sender for outgoing messages.
Definition: globals.h:94
Binary.
Definition: mime.h:53
int mutt_str_strcasecmp(const char *a, const char *b)
Compare two strings ignoring case, safely.
Definition: string.c:628
Quoted-printable text.
Definition: mime.h:51
WHERE char * C_PgpDefaultKey
Config: Default key to use for PGP operations.
Definition: globals.h:163
#define FREE(x)
Definition: memory.h:40
char * mutt_param_get(const struct ParameterList *pl, const char *s)
Find a matching Parameter.
Definition: parameter.c:84
int crypt_smime_verify_one(struct Body *sigbdy, struct State *s, const char *tempf)
Wrapper for CryptModuleSpecs::verify_one()
Definition: cryptglue.c:512
bool space
Whitespace at the end of lines?
Definition: content.h:41
void crypt_extract_keys_from_messages(struct Mailbox *m, struct EmailList *el)
Extract keys from a message.
Definition: crypt.c:853
Keep track when processing files.
Definition: state.h:44
struct AddressList to
Email&#39;s &#39;To&#39; list.
Definition: envelope.h:58
struct AddressList sender
Email&#39;s sender.
Definition: envelope.h:61
int mutt_body_handler(struct Body *b, struct State *s)
Handler for the Body of an email.
Definition: handler.c:1550
List of Emails.
Definition: email.h:114
char * d_filename
filename to be used for the content-disposition header.
Definition: body.h:47
struct Body * crypt_pgp_encrypt_message(struct Email *e, struct Body *a, char *keylist, int sign)
Wrapper for CryptModuleSpecs::pgp_encrypt_message()
Definition: cryptglue.c:332
Handling of global boolean variables.
Miscellaneous functions for sending an email.
long hdr_offset
Offset in stream where the headers begin.
Definition: body.h:42
void mutt_body_free(struct Body **ptr)
Free a Body.
Definition: body.c:57
#define TAILQ_EMPTY(head)
Definition: queue.h:715
uint16_t SecurityFlags
Flags, e.g. SEC_ENCRYPT.
Definition: ncrypt.h:120
#define MUTT_CM_NOHEADER
Don&#39;t copy the message header.
Definition: copy.h:35
FILE * mutt_file_fopen(const char *path, const char *mode)
Call fopen() safely.
Definition: file.c:585
#define TAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:631
Decide how to display email content.
struct ParameterList parameter
parameters of the content-type
Definition: body.h:39
#define WithCrypto
Definition: ncrypt.h:160
SecurityFlags crypt_query(struct Body *m)
Check out the type of encryption used.
Definition: crypt.c:694
int mutt_write_one_header(FILE *fp, const char *tag, const char *value, const char *pfx, int wraplen, CopyHeaderFlags chflags)
Write one header line to a file.
Definition: sendlib.c:2163
Type: &#39;application/*&#39;.
Definition: mime.h:33
#define PGP_ENCRYPT
Definition: ncrypt.h:140
bool crypt_pgp_valid_passphrase(void)
Wrapper for CryptModuleSpecs::valid_passphrase()
Definition: cryptglue.c:192
The header of an Email.
Definition: envelope.h:54
bool C_Weed
Config: Filter headers when displaying/forwarding/printing/replying.
Definition: email_globals.c:40
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: ncrypt.h:135
int crypt_pgp_verify_one(struct Body *sigbdy, struct State *s, const char *tempf)
Wrapper for CryptModuleSpecs::verify_one()
Definition: cryptglue.c:366