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