rework includes a bit
[apps/madmutt.git] / lib-crypt / crypt.c
1 /*
2  * Copyright notice from original mutt:
3  * Copyright (C) 1996,1997 Michael R. Elkins <me@mutt.org>
4  * Copyright (C) 1999-2000 Thomas Roessler <roessler@does-not-exist.org>
5  * Copyright (C) 2001  Thomas Roessler <roessler@does-not-exist.org>
6  *                     Oliver Ehli <elmy@acm.org>
7  * Copyright (C) 2003  Werner Koch <wk@gnupg.org>
8  * Copyright (C) 2004 g10code GmbH
9  *
10  * This file is part of mutt-ng, see http://www.muttng.org/.
11  * It's licensed under the GNU General Public License,
12  * please see the file GPL in the top level source directory.
13  */
14
15 #if HAVE_CONFIG_H
16 # include "config.h"
17 #endif
18
19 #include <sys/wait.h>
20 #include <string.h>
21 #include <stdlib.h>
22 #include <unistd.h>
23 #include <sys/stat.h>
24 #include <errno.h>
25 #include <ctype.h>
26
27 #ifdef HAVE_LOCALE_H
28 #  include <locale.h>
29 #endif
30 #ifdef HAVE_SYS_TIME_H
31 #  include <sys/time.h>
32 #endif
33 #ifdef HAVE_SYS_RESOURCE_H
34 #  include <sys/resource.h>
35 #endif
36
37 #include <lib-lib/str.h>
38 #include <lib-lib/file.h>
39 #include <lib-lib/ascii.h>
40 #include <lib-lib/mem.h>
41 #include <lib-lib/macros.h>
42
43 #include <lib-mime/mime.h>
44
45 #include <lib-ui/curses.h>
46
47 #include "mutt.h"
48 #include "alias.h"
49 #include "handler.h"
50 #include "copy.h"
51 #include "crypt.h"
52 #include "pgp.h"
53
54 /* print the current time to avoid spoofing of the signature output */
55 void crypt_current_time (STATE * s, const char *app_name)
56 {
57   time_t t;
58   char p[STRING], tmp[STRING];
59
60   if (option (OPTCRYPTTIMESTAMP)) {
61     t = time (NULL);
62     setlocale (LC_TIME, "");
63     strftime (p, sizeof (p), _(" (current time: %c)"), localtime (&t));
64     setlocale (LC_TIME, "C");
65   }
66   else
67     *p = '\0';
68
69   snprintf (tmp, sizeof (tmp), _("[-- %s output follows%s --]\n"),
70             NONULL (app_name), p);
71   state_attach_puts (tmp, s);
72 }
73
74
75
76 void crypt_forget_passphrase (void)
77 {
78     crypt_pgp_void_passphrase ();
79     crypt_smime_void_passphrase ();
80     mutt_message _("Passphrase(s) forgotten.");
81 }
82
83
84 #if defined(HAVE_SETRLIMIT) && (!defined(DEBUG))
85
86 static void disable_coredumps (void)
87 {
88   struct rlimit rl = { 0, 0 };
89   static short done = 0;
90
91   if (!done) {
92     setrlimit (RLIMIT_CORE, &rl);
93     done = 1;
94   }
95 }
96
97 #endif /* HAVE_SETRLIMIT */
98
99
100 int crypt_valid_passphrase (int flags)
101 {
102   int ret = 0;
103
104 # if defined(HAVE_SETRLIMIT) &&(!defined(DEBUG))
105   disable_coredumps ();
106 # endif
107
108   if (flags & APPLICATION_PGP)
109     ret = crypt_pgp_valid_passphrase ();
110
111   if (flags & APPLICATION_SMIME)
112     ret = crypt_smime_valid_passphrase ();
113
114   return ret;
115 }
116
117
118
119 int mutt_protect (HEADER * msg, char *keylist)
120 {
121   BODY *pbody = NULL, *tmp_pbody = NULL;
122   BODY *tmp_smime_pbody = NULL;
123   BODY *tmp_pgp_pbody = NULL;
124   int flags = msg->security;
125   int i;
126
127   if ((msg->security & SIGN) && !crypt_valid_passphrase (msg->security))
128     return (-1);
129
130   if ((msg->security & PGPINLINE) == PGPINLINE) {
131     /* they really want to send it inline... go for it */
132     if (!isendwin ())
133       mutt_endwin _("Invoking PGP...");
134
135     pbody = crypt_pgp_traditional_encryptsign (msg->content, flags, keylist);
136     if (pbody) {
137       msg->content = pbody;
138       return 0;
139     }
140
141     /* otherwise inline won't work...ask for revert */
142     if ((i =
143          query_quadoption (OPT_PGPMIMEAUTO,
144                            _
145                            ("Message can't be sent inline.  Revert to using PGP/MIME?")))
146         != M_YES) {
147       mutt_error _("Mail not sent.");
148
149       return -1;
150     }
151
152     /* go ahead with PGP/MIME */
153   }
154
155   if (!isendwin ())
156     mutt_endwin (NULL);
157
158   tmp_smime_pbody = msg->content;
159   tmp_pgp_pbody = msg->content;
160
161   if (msg->security & SIGN) {
162     if (msg->security & APPLICATION_SMIME) {
163       if (!(tmp_pbody = crypt_smime_sign_message (msg->content)))
164         return -1;
165       pbody = tmp_smime_pbody = tmp_pbody;
166     }
167
168     if ((msg->security & APPLICATION_PGP)
169         && (!(flags & ENCRYPT) || option (OPTPGPRETAINABLESIG))) {
170       if (!(tmp_pbody = crypt_pgp_sign_message (msg->content)))
171         return -1;
172
173       flags &= ~SIGN;
174       pbody = tmp_pgp_pbody = tmp_pbody;
175     }
176
177     if ((msg->security & APPLICATION_SMIME)
178         && (msg->security & APPLICATION_PGP)) {
179       /* here comes the draft ;-) */
180     }
181   }
182
183
184   if (msg->security & ENCRYPT) {
185     if ((msg->security & APPLICATION_SMIME)) {
186       if (!(tmp_pbody = crypt_smime_build_smime_entity (tmp_smime_pbody,
187                                                         keylist))) {
188         /* signed ? free it! */
189         return (-1);
190       }
191       /* free tmp_body if messages was signed AND encrypted ... */
192       if (tmp_smime_pbody != msg->content && tmp_smime_pbody != tmp_pbody) {
193         /* detatch and dont't delete msg->content,
194            which tmp_smime_pbody->parts after signing. */
195         tmp_smime_pbody->parts = tmp_smime_pbody->parts->next;
196         msg->content->next = NULL;
197         mutt_free_body (&tmp_smime_pbody);
198       }
199       pbody = tmp_pbody;
200     }
201
202     if ((msg->security & APPLICATION_PGP)) {
203       if (!(pbody = crypt_pgp_encrypt_message (tmp_pgp_pbody, keylist,
204                                                flags & SIGN))) {
205
206         /* did we perform a retainable signature? */
207         if (flags != msg->security) {
208           /* remove the outer multipart layer */
209           tmp_pgp_pbody = mutt_remove_multipart (tmp_pgp_pbody);
210           /* get rid of the signature */
211           mutt_free_body (&tmp_pgp_pbody->next);
212         }
213
214         return (-1);
215       }
216
217       /* destroy temporary signature envelope when doing retainable 
218        * signatures.
219
220        */
221       if (flags != msg->security) {
222         tmp_pgp_pbody = mutt_remove_multipart (tmp_pgp_pbody);
223         mutt_free_body (&tmp_pgp_pbody->next);
224       }
225     }
226   }
227
228   if (pbody)
229     msg->content = pbody;
230
231   return 0;
232 }
233
234
235
236
237 int mutt_is_multipart_signed (BODY * b)
238 {
239   char *p;
240
241   if (!b || !(b->type == TYPEMULTIPART) ||
242       !b->subtype || ascii_strcasecmp (b->subtype, "signed"))
243     return 0;
244
245   if (!(p = mutt_get_parameter ("protocol", b->parameter)))
246     return 0;
247
248   if (!(ascii_strcasecmp (p, "multipart/mixed")))
249     return SIGN;
250
251   if (!(ascii_strcasecmp (p, "application/pgp-signature")))
252     return PGPSIGN;
253
254   if (!(ascii_strcasecmp (p, "application/x-pkcs7-signature")))
255     return SMIMESIGN;
256   if (!(ascii_strcasecmp (p, "application/pkcs7-signature")))
257     return SMIMESIGN;
258
259   return 0;
260 }
261
262
263 int mutt_is_multipart_encrypted (BODY * b)
264 {
265   char *p;
266
267   if (!b || b->type != TYPEMULTIPART ||
268       !b->subtype || ascii_strcasecmp (b->subtype, "encrypted") ||
269       !(p = mutt_get_parameter ("protocol", b->parameter)) ||
270       ascii_strcasecmp (p, "application/pgp-encrypted"))
271     return 0;
272
273   return PGPENCRYPT;
274 }
275
276
277 int mutt_is_application_pgp (BODY * m)
278 {
279   int t = 0;
280   char *p;
281
282   if (m->type == TYPEAPPLICATION) {
283     if (!ascii_strcasecmp (m->subtype, "pgp")
284         || !ascii_strcasecmp (m->subtype, "x-pgp-message")) {
285       if ((p = mutt_get_parameter ("x-action", m->parameter))
286           && (!ascii_strcasecmp (p, "sign")
287               || !ascii_strcasecmp (p, "signclear")))
288         t |= PGPSIGN;
289
290       if ((p = mutt_get_parameter ("format", m->parameter)) &&
291           !ascii_strcasecmp (p, "keys-only"))
292         t |= PGPKEY;
293
294       if (!t)
295         t |= PGPENCRYPT;        /* not necessarily correct, but... */
296     }
297
298     if (!ascii_strcasecmp (m->subtype, "pgp-signed"))
299       t |= PGPSIGN;
300
301     if (!ascii_strcasecmp (m->subtype, "pgp-keys"))
302       t |= PGPKEY;
303   }
304   else if (m->type == TYPETEXT && ascii_strcasecmp ("plain", m->subtype) == 0) {
305     if (((p = mutt_get_parameter ("x-mutt-action", m->parameter))
306          || (p = mutt_get_parameter ("x-action", m->parameter))
307          || (p = mutt_get_parameter ("action", m->parameter)))
308         && !ascii_strncasecmp ("pgp-sign", p, 8))
309       t |= PGPSIGN;
310     else if (p && !ascii_strncasecmp ("pgp-encrypt", p, 11))
311       t |= PGPENCRYPT;
312     else if (p && !ascii_strncasecmp ("pgp-keys", p, 7))
313       t |= PGPKEY;
314   }
315   if (t)
316     t |= PGPINLINE;
317
318   return t;
319 }
320
321 int mutt_is_application_smime (BODY * m)
322 {
323   char *t = NULL;
324   int len, complain = 0;
325
326   if (!m)
327     return 0;
328
329   if ((m->type & TYPEAPPLICATION) && m->subtype) {
330     /* S/MIME MIME types don't need x- anymore, see RFC2311 */
331     if (!ascii_strcasecmp (m->subtype, "x-pkcs7-mime") ||
332         !ascii_strcasecmp (m->subtype, "pkcs7-mime")) {
333       if ((t = mutt_get_parameter ("smime-type", m->parameter))) {
334         if (!ascii_strcasecmp (t, "enveloped-data"))
335           return SMIMEENCRYPT;
336         else if (!ascii_strcasecmp (t, "signed-data"))
337           return (SMIMESIGN | SMIMEOPAQUE);
338         else
339           return 0;
340       }
341       /* Netscape 4.7 uses 
342        * Content-Description: S/MIME Encrypted Message
343        * instead of Content-Type parameter
344        */
345       if (!ascii_strcasecmp (m->description, "S/MIME Encrypted Message"))
346         return SMIMEENCRYPT;
347       complain = 1;
348     }
349     else if (ascii_strcasecmp (m->subtype, "octet-stream"))
350       return 0;
351
352     t = mutt_get_parameter ("name", m->parameter);
353
354     if (!t)
355       t = m->d_filename;
356     if (!t)
357       t = m->filename;
358     if (!t) {
359       if (complain)
360         mutt_message (_
361                       ("S/MIME messages with no hints on content are unsupported."));
362       return 0;
363     }
364
365     /* no .p7c, .p10 support yet. */
366
367     len = m_strlen(t) - 4;
368     if (len > 0 && *(t + len) == '.') {
369       len++;
370       if (!ascii_strcasecmp ((t + len), "p7m"))
371 #if 0
372         return SMIMEENCRYPT;
373 #else
374         /* Not sure if this is the correct thing to do, but 
375            it's required for compatibility with Outlook */
376         return (SMIMESIGN | SMIMEOPAQUE);
377 #endif
378       else if (!ascii_strcasecmp ((t + len), "p7s"))
379         return (SMIMESIGN | SMIMEOPAQUE);
380     }
381   }
382
383   return 0;
384 }
385
386
387
388
389
390
391 int crypt_query (BODY * m)
392 {
393   int t = 0;
394
395   if (!m)
396     return 0;
397
398   if (m->type == TYPEAPPLICATION) {
399     t |= mutt_is_application_pgp (m);
400
401     t |= mutt_is_application_smime (m);
402     if (t && m->goodsig)
403       t |= GOODSIGN;
404     if (t && m->badsig)
405       t |= BADSIGN;
406   }
407   else if (m->type == TYPETEXT) {
408     t |= mutt_is_application_pgp (m);
409     if (t && m->goodsig)
410       t |= GOODSIGN;
411   }
412
413   if (m->type == TYPEMULTIPART) {
414     t |= mutt_is_multipart_encrypted (m);
415     t |= mutt_is_multipart_signed (m);
416
417     if (t && m->goodsig)
418       t |= GOODSIGN;
419   }
420
421   if (m->type == TYPEMULTIPART || m->type == TYPEMESSAGE) {
422     BODY *p;
423     int u, v, w;
424
425     u = m->parts ? 0xffffffff : 0;      /* Bits set in all parts */
426     w = 0;                      /* Bits set in any part  */
427
428     for (p = m->parts; p; p = p->next) {
429       v = crypt_query (p);
430       u &= v;
431       w |= v;
432     }
433     t |= u | (w & ~GOODSIGN);
434
435     if ((w & GOODSIGN) && !(u & GOODSIGN))
436       t |= PARTSIGN;
437   }
438
439   return t;
440 }
441
442
443
444
445 int crypt_write_signed (BODY * a, STATE * s, const char *tempfile)
446 {
447   FILE *fp;
448   int c;
449   short hadcr;
450   size_t bytes;
451
452   if (!(fp = safe_fopen (tempfile, "w"))) {
453     mutt_perror (tempfile);
454     return -1;
455   }
456
457   fseeko (s->fpin, a->hdr_offset, 0);
458   bytes = a->length + a->offset - a->hdr_offset;
459   hadcr = 0;
460   while (bytes > 0) {
461     if ((c = fgetc (s->fpin)) == EOF)
462       break;
463
464     bytes--;
465
466     if (c == '\r')
467       hadcr = 1;
468     else {
469       if (c == '\n' && !hadcr)
470         fputc ('\r', fp);
471
472       hadcr = 0;
473     }
474
475     fputc (c, fp);
476
477   }
478   fclose (fp);
479
480   return 0;
481 }
482
483
484
485 void convert_to_7bit (BODY * a)
486 {
487   while (a) {
488     if (a->type == TYPEMULTIPART) {
489       if (a->encoding != ENC7BIT) {
490         a->encoding = ENC7BIT;
491         convert_to_7bit (a->parts);
492       }
493       else if (option (OPTPGPSTRICTENC))
494         convert_to_7bit (a->parts);
495     }
496     else if (a->type == TYPEMESSAGE &&
497              m_strcasecmp(a->subtype, "delivery-status")) {
498       if (a->encoding != ENC7BIT)
499         mutt_message_to_7bit (a, NULL);
500     }
501     else if (a->encoding == ENC8BIT)
502       a->encoding = ENCQUOTEDPRINTABLE;
503     else if (a->encoding == ENCBINARY)
504       a->encoding = ENCBASE64;
505     else if (a->content && a->encoding != ENCBASE64 &&
506              (a->content->from || (a->content->space &&
507                                    option (OPTPGPSTRICTENC))))
508       a->encoding = ENCQUOTEDPRINTABLE;
509     a = a->next;
510   }
511 }
512
513
514
515
516 void crypt_extract_keys_from_messages (HEADER * h)
517 {
518   int i;
519   char tempfname[_POSIX_PATH_MAX], *mbox;
520   address_t *tmp = NULL;
521   FILE *fpout;
522
523   mutt_mktemp (tempfname);
524   if (!(fpout = safe_fopen (tempfname, "w"))) {
525     mutt_perror (tempfname);
526     return;
527   }
528
529   set_option (OPTDONTHANDLEPGPKEYS);
530
531   if (!h) {
532     for (i = 0; i < Context->vcount; i++) {
533       if (Context->hdrs[Context->v2r[i]]->tagged) {
534         mutt_parse_mime_message (Context, Context->hdrs[Context->v2r[i]]);
535         if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT &&
536             !crypt_valid_passphrase (Context->hdrs[Context->v2r[i]]->
537                                      security)) {
538           fclose (fpout);
539           break;
540         }
541
542         if (Context->hdrs[Context->v2r[i]]->security & APPLICATION_PGP) {
543           mutt_copy_message (fpout, Context, Context->hdrs[Context->v2r[i]],
544                              M_CM_DECODE | M_CM_CHARCONV, 0);
545           fflush (fpout);
546
547           mutt_endwin (_("Trying to extract PGP keys...\n"));
548           crypt_pgp_invoke_import (tempfname);
549         }
550
551         if (Context->hdrs[Context->v2r[i]]->security & APPLICATION_SMIME) {
552           if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT)
553             mutt_copy_message (fpout, Context, Context->hdrs[Context->v2r[i]],
554                                M_CM_NOHEADER | M_CM_DECODE_CRYPT
555                                | M_CM_DECODE_SMIME, 0);
556           else
557             mutt_copy_message (fpout, Context,
558                                Context->hdrs[Context->v2r[i]], 0, 0);
559           fflush (fpout);
560
561           if (Context->hdrs[Context->v2r[i]]->env->from)
562             tmp = mutt_expand_aliases (h->env->from);
563           else if (Context->hdrs[Context->v2r[i]]->env->sender)
564             tmp = mutt_expand_aliases (Context->hdrs[Context->v2r[i]]
565                                        ->env->sender);
566           mbox = tmp ? tmp->mailbox : NULL;
567           if (mbox) {
568             mutt_endwin (_("Trying to extract S/MIME certificates...\n"));
569             crypt_smime_invoke_import (tempfname, mbox);
570             tmp = NULL;
571           }
572         }
573
574         rewind (fpout);
575       }
576     }
577   }
578   else {
579     mutt_parse_mime_message (Context, h);
580     if (!(h->security & ENCRYPT && !crypt_valid_passphrase (h->security))) {
581       if (h->security & APPLICATION_PGP) {
582         mutt_copy_message (fpout, Context, h, M_CM_DECODE | M_CM_CHARCONV, 0);
583         fflush (fpout);
584         mutt_endwin (_("Trying to extract PGP keys...\n"));
585         crypt_pgp_invoke_import (tempfname);
586       }
587
588       if (h->security & APPLICATION_SMIME) {
589         if (h->security & ENCRYPT)
590           mutt_copy_message (fpout, Context, h, M_CM_NOHEADER
591                              | M_CM_DECODE_CRYPT | M_CM_DECODE_SMIME, 0);
592         else
593           mutt_copy_message (fpout, Context, h, 0, 0);
594
595         fflush (fpout);
596         if (h->env->from)
597           tmp = mutt_expand_aliases (h->env->from);
598         else if (h->env->sender)
599           tmp = mutt_expand_aliases (h->env->sender);
600         mbox = tmp ? tmp->mailbox : NULL;
601         if (mbox) {             /* else ? */
602           mutt_message (_("Trying to extract S/MIME certificates...\n"));
603           crypt_smime_invoke_import (tempfname, mbox);
604         }
605       }
606     }
607   }
608
609   fclose (fpout);
610   if (isendwin ())
611     mutt_any_key_to_continue (NULL);
612
613   mutt_unlink (tempfname);
614
615   unset_option (OPTDONTHANDLEPGPKEYS);
616 }
617
618
619
620 int crypt_get_keys (HEADER * msg, char **keylist)
621 {
622   /* Do a quick check to make sure that we can find all of the encryption
623    * keys if the user has requested this service.
624    */
625
626   set_option (OPTPGPCHECKTRUST);
627
628   *keylist = NULL;
629
630   if (msg->security & ENCRYPT) {
631     if (msg->security & APPLICATION_PGP) {
632       if ((*keylist = crypt_pgp_findkeys (msg->env->to, msg->env->cc,
633                                           msg->env->bcc)) == NULL)
634         return (-1);
635       unset_option (OPTPGPCHECKTRUST);
636     }
637     if (msg->security & APPLICATION_SMIME) {
638       if ((*keylist = crypt_smime_findkeys (msg->env->to, msg->env->cc,
639                                             msg->env->bcc)) == NULL)
640         return (-1);
641     }
642   }
643
644   return (0);
645 }
646
647
648
649 static void crypt_fetch_signatures (BODY ***signatures, BODY * a, int *n)
650 {
651   for (; a; a = a->next) {
652     if (a->type == TYPEMULTIPART)
653       crypt_fetch_signatures (signatures, a->parts, n);
654     else {
655       if ((*n % 5) == 0)
656         p_realloc(signatures, *n + 6);
657
658       (*signatures)[(*n)++] = a;
659     }
660   }
661 }
662
663
664 /*
665  * This routine verifies a  "multipart/signed"  body.
666  */
667
668 int mutt_signed_handler (BODY * a, STATE * s)
669 {
670   char tempfile[_POSIX_PATH_MAX];
671   char *protocol;
672   int protocol_major = TYPEOTHER;
673   char *protocol_minor = NULL;
674
675   BODY *b = a;
676   BODY **signatures = NULL;
677   int sigcnt = 0;
678   int i;
679   short goodsig = 1;
680   int rc = 0;
681
682   protocol = mutt_get_parameter ("protocol", a->parameter);
683   a = a->parts;
684
685   /* extract the protocol information */
686
687   if (protocol) {
688     char major[STRING];
689     char *t;
690
691     if ((protocol_minor = strchr (protocol, '/')))
692       protocol_minor++;
693
694     m_strcpy(major, sizeof(major), protocol);
695     if ((t = strchr (major, '/')))
696       *t = '\0';
697
698     protocol_major = mutt_check_mime_type (major);
699   }
700
701   /* consistency check */
702
703   if (!(a && a->next && a->next->type == protocol_major &&
704         !m_strcasecmp(a->next->subtype, protocol_minor))) {
705     state_attach_puts (_("[-- Error: "
706                          "Inconsistent multipart/signed structure! --]\n\n"),
707                        s);
708     return mutt_body_handler (a, s);
709   }
710
711
712   if (protocol_major == TYPEAPPLICATION
713       && !m_strcasecmp(protocol_minor, "pgp-signature"));
714   else if (protocol_major == TYPEAPPLICATION
715            && !(m_strcasecmp(protocol_minor, "x-pkcs7-signature")
716                 && m_strcasecmp(protocol_minor, "pkcs7-signature")));
717   else if (protocol_major == TYPEMULTIPART
718            && !m_strcasecmp(protocol_minor, "mixed"));
719   else {
720     state_printf (s, _("[-- Error: "
721                        "Unknown multipart/signed protocol %s! --]\n\n"),
722                   protocol);
723     return mutt_body_handler (a, s);
724   }
725
726   if (s->flags & M_DISPLAY) {
727
728     crypt_fetch_signatures (&signatures, a->next, &sigcnt);
729
730     if (sigcnt) {
731       mutt_mktemp (tempfile);
732       if (crypt_write_signed (a, s, tempfile) == 0) {
733         for (i = 0; i < sigcnt; i++) {
734           if (signatures[i]->type == TYPEAPPLICATION
735               && !m_strcasecmp(signatures[i]->subtype, "pgp-signature")) {
736             if (crypt_pgp_verify_one (signatures[i], s, tempfile) != 0)
737               goodsig = 0;
738
739             continue;
740           }
741
742           if (signatures[i]->type == TYPEAPPLICATION
743           && (!m_strcasecmp(signatures[i]->subtype, "x-pkcs7-signature")
744                || !m_strcasecmp(signatures[i]->subtype, "pkcs7-signature")))
745           {
746             if (crypt_smime_verify_one (signatures[i], s, tempfile) != 0)
747               goodsig = 0;
748
749             continue;
750           }
751
752           state_printf (s, _("[-- Warning: "
753                              "We can't verify %s/%s signatures. --]\n\n"),
754                         TYPE (signatures[i]), signatures[i]->subtype);
755         }
756       }
757
758       mutt_unlink (tempfile);
759
760       b->goodsig = goodsig;
761       b->badsig = !goodsig;
762
763       /* Now display the signed body */
764       state_attach_puts (_("[-- The following data is signed --]\n\n"), s);
765
766
767       p_delete(&signatures);
768     }
769     else
770       state_attach_puts (_("[-- Warning: Can't find any signatures. --]\n\n"),
771                          s);
772   }
773
774   rc = mutt_body_handler (a, s);
775
776   if (s->flags & M_DISPLAY && sigcnt)
777     state_attach_puts (_("\n[-- End of signed data --]\n"), s);
778
779   return (rc);
780 }