From: Thomas Roessler Date: Tue, 30 Dec 2003 13:04:20 +0000 (+0000) Subject: Handle partially signed messages more reasonably. See #1743. X-Git-Tag: mutt-1-5-6-rel~52 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=73871654dc1015ef2bae3c0bac364020c61ca320;p=mutt Handle partially signed messages more reasonably. See #1743. --- diff --git a/commands.c b/commands.c index f2381d2a..a4859aeb 100644 --- a/commands.c +++ b/commands.c @@ -183,15 +183,22 @@ int mutt_display_message (HEADER *cur) else mutt_error ( _("S/MIME certificate owner does not match sender.")); } + else if (cur->security & PARTSIGN) + mutt_message (_("Warning: Part of this message has not been signed.")); else if (cur->security & SIGN || cur->security & BADSIGN) mutt_error ( _("S/MIME signature could NOT be verified.")); } if (WithCrypto && (cur->security & APPLICATION_PGP) && (cmflags & M_CM_VERIFY)) - mutt_message ((cur->security & GOODSIGN) ? - _("PGP signature successfully verified.") : - _("PGP signature could NOT be verified.")); + { + if (cur->security & GOODSIGN) + mutt_message (_("PGP signature successfully verified.")); + else if (cur->security & PARTSIGN) + mutt_message (_("Warning: Part of this message has not been signed.")); + else + mutt_message (_("PGP signature could NOT be verified.")); + } /* Invoke the builtin pager */ memset (&info, 0, sizeof (pager_t)); diff --git a/crypt.c b/crypt.c index c5529398..c63458d6 100644 --- a/crypt.c +++ b/crypt.c @@ -466,6 +466,9 @@ int crypt_query (BODY *m) if (!WithCrypto) return 0; + + if (!m) + return 0; if (m->type == TYPEAPPLICATION) { @@ -491,15 +494,27 @@ int crypt_query (BODY *m) t |= mutt_is_multipart_encrypted(m); t |= mutt_is_multipart_signed (m); - if (t && m->goodsig) t |= GOODSIGN; + if (t && m->goodsig) + t |= GOODSIGN; } if (m->type == TYPEMULTIPART || m->type == TYPEMESSAGE) { BODY *p; + int u, v, w; + + u = m->parts ? 0xffffffff : 0; /* Bits set in all parts */ + w = 0; /* Bits set in any part */ for (p = m->parts; p; p = p->next) - t |= crypt_query (p) & ~GOODSIGN; + { + v = crypt_query (p); + u &= v; w |= v; + } + t |= u | (w & ~GOODSIGN); + + if ((w & GOODSIGN) && !(u & GOODSIGN)) + t |= PARTSIGN; } return t; @@ -889,7 +904,7 @@ void mutt_signed_handler (BODY *a, STATE *s) mutt_unlink (tempfile); b->goodsig = goodsig; - b->badsig = goodsig; /* XXX - WHAT!?!?!? */ + b->badsig = !goodsig; /* Now display the signed body */ state_attach_puts (_("[-- The following data is signed --]\n\n"), s); diff --git a/mutt.h b/mutt.h index cc0d1b19..eeed5dfc 100644 --- a/mutt.h +++ b/mutt.h @@ -622,7 +622,7 @@ typedef struct body */ unsigned int goodsig : 1; /* good cryptographic signature */ - unsigned int badsig : 1; /* bad cryptographic signature (needed to check encrypted s/mime-signatures */ + unsigned int badsig : 1; /* bad cryptographic signature (needed to check encrypted s/mime-signatures) */ unsigned int collapsed : 1; /* used by recvattach */ @@ -630,7 +630,7 @@ typedef struct body typedef struct header { - unsigned int security : 7; /* bit 0-4: flags, bit 5,6: application. + unsigned int security : 9; /* bit 0-6: flags, bit 7,8: application. see: crypt.h pgplib.h, smime.h */ unsigned int mime : 1; /* has a Mime-Version header? */ diff --git a/mutt_crypt.h b/mutt_crypt.h index 04c6e654..bd3c8c5e 100644 --- a/mutt_crypt.h +++ b/mutt_crypt.h @@ -24,7 +24,7 @@ #ifndef MUTT_CRYPT_H #define MUTT_CRYPT_H -#include "mutt.h" /* Need this to declarer BODY, ADDTESS. STATE etc. */ +#include "mutt.h" /* Need this to declare BODY, ADDRESS. STATE etc. */ /* FIXME: They should be pointer to anonymous structures for better information hiding. */ @@ -33,16 +33,18 @@ #define ENCRYPT (1 << 0) #define SIGN (1 << 1) #define GOODSIGN (1 << 2) -#define BADSIGN (1 << 3) /* FIXME: value also used below for PGPKEY */ -#define SIGNOPAQUE (1 << 4) +#define BADSIGN (1 << 3) +#define PARTSIGN (1 << 4) +#define SIGNOPAQUE (1 << 5) +/* (1 << 6) is used by PGPKEY below. */ -#define APPLICATION_PGP (1 << 5) -#define APPLICATION_SMIME (1 << 6) +#define APPLICATION_PGP (1 << 7) +#define APPLICATION_SMIME (1 << 8) #define PGPENCRYPT (APPLICATION_PGP | ENCRYPT) #define PGPSIGN (APPLICATION_PGP | SIGN) #define PGPGOODSIGN (APPLICATION_PGP | GOODSIGN) -#define PGPKEY (APPLICATION_PGP | (1 << 3)) +#define PGPKEY (APPLICATION_PGP | (1 << 6)) #define SMIMEENCRYPT (APPLICATION_SMIME | ENCRYPT) #define SMIMESIGN (APPLICATION_SMIME | SIGN) diff --git a/smime.c b/smime.c index a2da21f2..87a1a2b7 100644 --- a/smime.c +++ b/smime.c @@ -1837,9 +1837,10 @@ static BODY *smime_handle_entity (BODY *m, STATE *s, FILE *outFile) m->goodsig = 1; FREE (&line); } - else { + else + { m->goodsig = p->goodsig; - m->badsig = p->badsig; + m->badsig = p->badsig; } fclose (smimeerr);