]> granicus.if.org Git - mutt/commitdiff
Handle partially signed messages more reasonably. See #1743.
authorThomas Roessler <roessler@does-not-exist.org>
Tue, 30 Dec 2003 13:04:20 +0000 (13:04 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Tue, 30 Dec 2003 13:04:20 +0000 (13:04 +0000)
commands.c
crypt.c
mutt.h
mutt_crypt.h
smime.c

index f2381d2a53b4d5d0862f7c0356021b4cd42d0401..a4859aebcec86e54253fa0f0c288e69025c6f0d6 100644 (file)
@@ -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 c5529398f01cdf000ee59becea7ffd49d55847ea..c63458d64e31e5be935fa400b2aa09771825b20d 100644 (file)
--- 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 cc0d1b192b05d933e7acd4851484f619a065590c..eeed5dfc7432fd7a182c62f61ab39925121879db 100644 (file)
--- 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? */
index 04c6e654e5eb761a88b2ba8f75da36f19a2fa5ae..bd3c8c5e5db37d5baff904fe06eb183f60001a5c 100644 (file)
@@ -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. */
 
 #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 a2da21f2bf2b6c2603a65999a938ca45740e3e35..87a1a2b76f67cda86e4aa82b17cbfefadd778872 100644 (file)
--- 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);