]> granicus.if.org Git - mutt/commitdiff
Add retainable signatures. This should work nicely with encrypted
authorThomas Roessler <roessler@does-not-exist.org>
Thu, 18 Feb 1999 23:14:34 +0000 (23:14 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Thu, 18 Feb 1999 23:14:34 +0000 (23:14 +0000)
mailing lists.

init.h
mutt.h
pgp.c

diff --git a/init.h b/init.h
index 8858b5f146dcbf60d410732dd088e479230eec35..e4c60dca77bc73e6befe1027b35b271188ce9caf 100644 (file)
--- a/init.h
+++ b/init.h
@@ -185,6 +185,7 @@ struct option_t MuttVars[] = {
   { "pgp_long_ids",    DT_BOOL, R_NONE, OPTPGPLONGIDS, 0 },
   { "pgp_replyencrypt",        DT_BOOL, R_NONE, OPTPGPREPLYENCRYPT, 0 },
   { "pgp_replysign",   DT_BOOL, R_NONE, OPTPGPREPLYSIGN, 0 },
+  { "pgp_retainable_sigs", DT_BOOL, R_NONE, OPTPGPRETAINABLESIG, 0 },
   { "pgp_show_unusable", DT_BOOL, R_NONE, OPTPGPSHOWUNUSABLE, 1 },
   { "pgp_sign_as",     DT_STR,  R_NONE, UL &PgpSignAs, 0 },
   { "pgp_sign_micalg", DT_STR,  R_NONE, UL &PgpSignMicalg, UL "pgp-md5" },
diff --git a/mutt.h b/mutt.h
index 0ca5ff5d269f448ad821d7bb936ce3cc3e188c0c..6e0e220e5f7b231c6a35a21fd9c283bdf922d65c 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -359,6 +359,7 @@ enum
   OPTPGPREPLYENCRYPT,
   OPTPGPREPLYSIGN,
   OPTPGPENCRYPTSELF,
+  OPTPGPRETAINABLESIG,
   OPTPGPSTRICTENC,
   OPTFORWDECRYPT,
   OPTPGPSHOWUNUSABLE,
diff --git a/pgp.c b/pgp.c
index 781eb2a2251ef01903590e402e558f835c9e2c83..e476c29dc5eb89995faefc6ebfbdda4ba8da4d41 100644 (file)
--- a/pgp.c
+++ b/pgp.c
@@ -1447,20 +1447,43 @@ int pgp_get_keys (HEADER *msg, char **pgpkeylist)
 int pgp_protect (HEADER *msg, char *pgpkeylist)
 {
   BODY *pbody = NULL;
+  int flags = msg->pgp;
 
   if ((msg->pgp & PGPSIGN) && !pgp_valid_passphrase ())
     return (-1);
 
   if (!isendwin ())
     endwin ();
-  if (msg->pgp & PGPENCRYPT)
-    pbody = pgp_encrypt_message (msg->content, pgpkeylist, msg->pgp & PGPSIGN);
-  else if (msg->pgp & PGPSIGN)
-    pbody = pgp_sign_message (msg->content);
 
-  if (!pbody)
-    return (-1);
-  msg->content = pbody;
+  if ((flags & PGPSIGN) && (!(flags & PGPENCRYPT) || option (OPTPGPRETAINABLESIG)))
+  {
+    if (!(pbody = pgp_sign_message (msg->content)))
+      return -1;
+
+    msg->content = pbody;
+    flags &= ~PGPSIGN;
+  }
+
+  if (flags & PGPENCRYPT)
+  {
+    if (!(pbody = pgp_encrypt_message (msg->content, pgpkeylist, flags & PGPSIGN)))
+    {
+
+      /* did we perform a retainable signature? */
+      if (flags != msg->pgp)
+      {
+       /* remove the outer multipart layer */
+       msg->content = mutt_remove_multipart (msg->content);
+       /* get rid of the signature */
+       mutt_free_body (&msg->content->next);
+      }
+
+      return (-1);
+    }
+
+    msg->content = pbody;
+  }
+
   return (0);
 }