From: Thomas Roessler Date: Thu, 18 Feb 1999 23:14:34 +0000 (+0000) Subject: Add retainable signatures. This should work nicely with encrypted X-Git-Tag: mutt-0-96-1-rel~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0b025e274afbb7d067ab771698d0d32d34daadda;p=mutt Add retainable signatures. This should work nicely with encrypted mailing lists. --- diff --git a/init.h b/init.h index 8858b5f1..e4c60dca 100644 --- 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 0ca5ff5d..6e0e220e 100644 --- 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 781eb2a2..e476c29d 100644 --- 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); }