Commit 85ef6f6a authored by Thomas Roessler's avatar Thomas Roessler

S/MIME support. From Oliver Ehli <elmy@acm.org> and Mike Schiraldi

<raldi@research.netsol.com>.
parent c6d96bc1
...@@ -15,7 +15,7 @@ bin_SCRIPTS = muttbug flea ...@@ -15,7 +15,7 @@ bin_SCRIPTS = muttbug flea
BUILT_SOURCES = keymap_defs.h patchlist.c BUILT_SOURCES = keymap_defs.h patchlist.c
bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@ bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@ @SMIMEAUX_TARGET@
mutt_SOURCES = $(BUILT_SOURCES) \ mutt_SOURCES = $(BUILT_SOURCES) \
addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \ addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \ commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
...@@ -56,20 +56,14 @@ INCLUDES=-I. -I$(top_srcdir) $(IMAP_INCLUDES) -Iintl ...@@ -56,20 +56,14 @@ INCLUDES=-I. -I$(top_srcdir) $(IMAP_INCLUDES) -Iintl
CPPFLAGS=@CPPFLAGS@ -I$(includedir) CPPFLAGS=@CPPFLAGS@ -I$(includedir)
non_us_sources = pgp.c pgpinvoke.c pgpkey.c pgplib.c sha1.c \
pgpmicalg.c gnupgparse.c sha1.h \
doc/language.txt doc/language50.txt OPS.PGP doc/PGP-Notes.txt \
OPS.MIX remailer.c remailer.h pgpewrap.c \
contrib/pgp2.rc contrib/pgp5.rc contrib/gpg.rc \
mutt_ssl.c mutt_ssl.h README.SSL mutt_ssl_nss.c \
pgppacket.c pgppacket.h
EXTRA_mutt_SOURCES = account.c md5c.c mutt_sasl.c mutt_socket.c mutt_ssl.c \ EXTRA_mutt_SOURCES = account.c md5c.c mutt_sasl.c mutt_socket.c mutt_ssl.c \
mutt_tunnel.c pop.c pop_auth.c pop_lib.c pgp.c pgpinvoke.c pgpkey.c \ mutt_tunnel.c pop.c pop_auth.c pop_lib.c crypt.c smime.c pgp.c pgpinvoke.c pgpkey.c \
pgplib.c sha1.c pgpmicalg.c gnupgparse.c resize.c dotlock.c remailer.c \ pgplib.c sha1.c pgpmicalg.c gnupgparse.c resize.c dotlock.c remailer.c \
browser.h mbyte.h remailer.h url.h mutt_ssl_nss.c pgppacket.c browser.h mbyte.h remailer.h url.h mutt_ssl_nss.c pgppacket.c
EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP TODO configure acconfig.h account.h \ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO \
configure acconfig.h account.h \
attach.h buffy.h charset.h copy.h dotlock.h functions.h gen_defs \ attach.h buffy.h charset.h copy.h dotlock.h functions.h gen_defs \
globals.h hash.h history.h init.h keymap.h \ globals.h hash.h history.h init.h keymap.h \
mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \ mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
...@@ -77,8 +71,8 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP TODO configure acconfig.h account.h \ ...@@ -77,8 +71,8 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP TODO configure acconfig.h account.h \
mx.h pager.h pgp.h pop.h protos.h reldate.h rfc1524.h rfc2047.h \ mx.h pager.h pgp.h pop.h protos.h reldate.h rfc1524.h rfc2047.h \
rfc2231.h rfc822.h sha1.h sort.h mime.types VERSION prepare \ rfc2231.h rfc822.h sha1.h sort.h mime.types VERSION prepare \
_regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \ _regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
mbyte.h lib.h extlib.c pgpewrap.c pgplib.h Muttrc.head Muttrc \ mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h Muttrc.head Muttrc \
makedoc.c stamp-doc-rc README.SSL \ makedoc.c stamp-doc-rc README.SSL crypt.h \
muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh
mutt_dotlock_SOURCES = mutt_dotlock.c mutt_dotlock_SOURCES = mutt_dotlock.c
...@@ -105,6 +99,10 @@ flea: muttbug.sh ...@@ -105,6 +99,10 @@ flea: muttbug.sh
cp muttbug.sh flea cp muttbug.sh flea
chmod +x flea chmod +x flea
smime_keys: smime_keys.pl
cp smime_keys.pl smime_keys
chmod +x smime_keys
Makefile: $(BUILT_SOURCES) Makefile: $(BUILT_SOURCES)
keymap_defs.h: $(OPS) $(srcdir)/gen_defs keymap_defs.h: $(OPS) $(srcdir)/gen_defs
...@@ -156,27 +154,6 @@ changelog: ...@@ -156,27 +154,6 @@ changelog:
dist-hook: dist-hook:
-for file in $(BUILT_SOURCES) ; do rm -f $(distdir)/$$file ; done -for file in $(BUILT_SOURCES) ; do rm -f $(distdir)/$$file ; done
us-distdir: distdir dist-hook
mv $(distdir) $(distdir)-us
find $(distdir)-us -type f -print | while read f ; do \
cp $$f `dirname $$f`/_`basename $$f`.$$$$ && \
rm $$f && mv `dirname $$f`/_`basename $$f`.$$$$ $$f ; \
done
us-dist: us-distdir
for file in $(distdir)-us/*.c $(distdir)-us/*.h ; do \
$(srcdir)/reap.pl HAVE_PGP < $$file | $(srcdir)/reap.pl MIXMASTER | $(srcdir)/reap.pl USE_SSL > $$file.n && rm $$file && mv $$file.n $$file ; \
done
for file in $(non_us_sources) ; do \
echo "/* This file is only available in the international mutt version */" \
> $(distdir)-us/$$file ; \
done
echo "This version of mutt may be exported from the US."> $(distdir)-us/EXPORTABLE
-chmod -R a+r $(distdir)-us
GZIP=$(GZIP) $(TAR) chozf $(distdir)-us.tar.gz $(distdir)-us
-rm -rf $(distdir)-us
mutt-dist: mutt-dist:
(cd $(srcdir) && ./build-release ) (cd $(srcdir) && ./build-release )
......
OP_DECRYPT_SAVE "make decrypted copy and delete"
OP_DECRYPT_COPY "make decrypted copy"
OP_FORGET_PASSPHRASE "wipe passphrase(s) from memory"
OP_EXTRACT_KEYS "extract supported public keys"
OP_COMPOSE_ATTACH_KEY "attach a PGP public key" OP_COMPOSE_ATTACH_KEY "attach a PGP public key"
OP_COMPOSE_PGP_MENU "show PGP options" OP_COMPOSE_PGP_MENU "show PGP options"
OP_EXTRACT_KEYS "extract PGP public keys"
OP_FORGET_PASSPHRASE "wipe PGP passphrase from memory"
OP_MAIL_KEY "mail a PGP public key" OP_MAIL_KEY "mail a PGP public key"
OP_VERIFY_KEY "verify a PGP public key" OP_VERIFY_KEY "verify a PGP public key"
OP_VIEW_ID "view the key's user id" OP_VIEW_ID "view the key's user id"
OP_DECRYPT_SAVE "make decrypted copy and delete"
OP_DECRYPT_COPY "make decrypted copy"
OP_CHECK_TRADITIONAL "check for classic pgp" OP_CHECK_TRADITIONAL "check for classic pgp"
OP_COMPOSE_SMIME_MENU "show S/MIME options"
...@@ -32,6 +32,10 @@ ...@@ -32,6 +32,10 @@
#include "pgp.h" #include "pgp.h"
#endif #endif
#ifdef HAVE_SMIME
#include "smime.h"
#endif
#include <ctype.h> #include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
...@@ -413,10 +417,11 @@ int mutt_view_attachment (FILE *fp, BODY *a, int flag, HEADER *hdr, ...@@ -413,10 +417,11 @@ int mutt_view_attachment (FILE *fp, BODY *a, int flag, HEADER *hdr,
int unlink_tempfile = 0; int unlink_tempfile = 0;
is_message = mutt_is_message_type(a->type, a->subtype); is_message = mutt_is_message_type(a->type, a->subtype);
#ifdef HAVE_PGP #if defined(HAVE_PGP) || defined(HAVE_SMIME)
if (is_message && a->hdr && (a->hdr->pgp & PGPENCRYPT) && !pgp_valid_passphrase()) if (is_message && a->hdr && (a->hdr->security & ENCRYPT) &&
!crypt_valid_passphrase(a->hdr->security))
return (rc); return (rc);
#endif /* HAVE_PGP */ #endif /* HAVE_PGP || HAVE_SMIME */
use_mailcap = (flag == M_MAILCAP || use_mailcap = (flag == M_MAILCAP ||
(flag == M_REGULAR && mutt_needs_mailcap (a))); (flag == M_REGULAR && mutt_needs_mailcap (a)));
snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype); snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype);
......
...@@ -45,6 +45,11 @@ ...@@ -45,6 +45,11 @@
#endif #endif
#ifdef HAVE_SMIME
#include "smime.h"
#endif
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
...@@ -76,18 +81,22 @@ int mutt_display_message (HEADER *cur) ...@@ -76,18 +81,22 @@ int mutt_display_message (HEADER *cur)
mutt_parse_mime_message (Context, cur); mutt_parse_mime_message (Context, cur);
mutt_message_hook (Context, cur, M_MESSAGEHOOK); mutt_message_hook (Context, cur, M_MESSAGEHOOK);
#ifdef HAVE_PGP #if defined (HAVE_PGP) || defined (HAVE_SMIME)
/* see if PGP is needed for this message. if so, we should exit curses */ /* see if PGP is needed for this message. if so, we should exit curses */
if (cur->pgp) if (cur->security)
{ {
if (cur->pgp & PGPENCRYPT) if (cur->security & ENCRYPT)
{ {
if (!pgp_valid_passphrase ()) #ifdef HAVE_SMIME
if (cur->env->to && cur->security & APPLICATION_SMIME)
smime_getkeys (cur->env->to->mailbox);
#endif
if(!crypt_valid_passphrase(cur->security))
return 0; return 0;
cmflags |= M_CM_VERIFY; cmflags |= M_CM_VERIFY;
} }
else if (cur->pgp & PGPSIGN) else if (cur->security & SIGN)
{ {
/* find out whether or not the verify signature */ /* find out whether or not the verify signature */
if (query_quadoption (OPT_VERIFYSIG, _("Verify PGP signature?")) == M_YES) if (query_quadoption (OPT_VERIFYSIG, _("Verify PGP signature?")) == M_YES)
...@@ -97,15 +106,25 @@ int mutt_display_message (HEADER *cur) ...@@ -97,15 +106,25 @@ int mutt_display_message (HEADER *cur)
} }
} }
if ((cmflags & M_CM_VERIFY) || (cur->pgp & PGPENCRYPT)) if (cmflags & M_CM_VERIFY || cur->security & ENCRYPT)
{ {
if (cur->env->from) #ifdef HAVE_PGP
pgp_invoke_getkeys (cur->env->from); if (cur->security & APPLICATION_PGP)
{
if (cur->env->from)
pgp_invoke_getkeys (cur->env->from);
mutt_message _("Invoking PGP..."); mutt_message _("Invoking PGP...");
} }
#endif
#ifdef HAVE_SMIME
if (cur->security & APPLICATION_SMIME)
mutt_message _("Invoking OpenSSL...");
#endif #endif
}
#endif /* defined (HAVE_PGP) || defined (HAVE_SMIME) */
mutt_mktemp (tempfile); mutt_mktemp (tempfile);
if ((fpout = safe_fopen (tempfile, "w")) == NULL) if ((fpout = safe_fopen (tempfile, "w")) == NULL)
...@@ -153,18 +172,35 @@ int mutt_display_message (HEADER *cur) ...@@ -153,18 +172,35 @@ int mutt_display_message (HEADER *cur)
if (fpfilterout != NULL && mutt_wait_filter (filterpid) != 0) if (fpfilterout != NULL && mutt_wait_filter (filterpid) != 0)
mutt_any_key_to_continue (NULL); mutt_any_key_to_continue (NULL);
#ifdef HAVE_PGP #if defined(HAVE_PGP) || defined(HAVE_SMIME)
/* update PGP information for this message */ /* update PGP information for this message */
cur->pgp |= pgp_query (cur->content); cur->security |= crypt_query (cur->content);
#endif #endif
if (builtin) if (builtin)
{ {
pager_t info; pager_t info;
#ifdef HAVE_SMIME
char *smime_signer;
if (cur->security & APPLICATION_SMIME && (cmflags & M_CM_VERIFY))
{
if (cur->security & GOODSIGN)
{
if (!(smime_signer = smime_verify_sender(cur)))
mutt_message ( _("S/MIME signature successfully verified."));
else
mutt_error ( _("S/MIME certificate owner does not match sender."));
}
else if (cur->security & SIGN || cur->security & BADSIGN)
mutt_error ( _("S/MIME signature could NOT be verified."));
}
#endif
#ifdef HAVE_PGP #ifdef HAVE_PGP
if (cmflags & M_CM_VERIFY) if (cur->security & APPLICATION_PGP && (cmflags & M_CM_VERIFY))
mutt_message ((cur->pgp & PGPGOODSIGN) ? mutt_message ((cur->security & GOODSIGN) ?
_("PGP signature successfully verified.") : _("PGP signature successfully verified.") :
_("PGP signature could NOT be verified.")); _("PGP signature could NOT be verified."));
#endif #endif
...@@ -282,17 +318,16 @@ void pipe_msg (HEADER *h, FILE *fp, int decode, int print) ...@@ -282,17 +318,16 @@ void pipe_msg (HEADER *h, FILE *fp, int decode, int print)
pipe_set_flags (decode, print, &cmflags, &chflags); pipe_set_flags (decode, print, &cmflags, &chflags);
#ifdef HAVE_PGP #if defined(HAVE_PGP) || defined(HAVE_SMIME)
if (decode && h->security & ENCRYPT)
if (decode && (h->pgp & PGPENCRYPT)) {
{ if(!crypt_valid_passphrase(h->security))
if (!pgp_valid_passphrase()) return;
return; endwin ();
endwin(); }
}
#endif #endif
if (decode) if (decode)
mutt_parse_mime_message (Context, h); mutt_parse_mime_message (Context, h);
...@@ -313,17 +348,22 @@ static int _mutt_pipe_message (HEADER *h, char *cmd, ...@@ -313,17 +348,22 @@ static int _mutt_pipe_message (HEADER *h, char *cmd,
pid_t thepid; pid_t thepid;
FILE *fpout; FILE *fpout;
mutt_endwin (NULL); /* mutt_endwin (NULL);
is this really needed here ?
it makes the screen flicker on pgp and s/mime messages,
before asking for a passphrase...
Oliver Ehli */
if (h) if (h)
{ {
mutt_message_hook (Context, h, M_MESSAGEHOOK); mutt_message_hook (Context, h, M_MESSAGEHOOK);
#ifdef HAVE_PGP #if defined(HAVE_PGP) || defined(HAVE_SMIME)
if (decode) if (decode)
{ {
mutt_parse_mime_message (Context, h); mutt_parse_mime_message (Context, h);
if(h->pgp & PGPENCRYPT && !pgp_valid_passphrase()) if(h->security & ENCRYPT && !crypt_valid_passphrase(h->security))
return 1; return 1;
} }
mutt_endwin (NULL); mutt_endwin (NULL);
...@@ -336,7 +376,7 @@ static int _mutt_pipe_message (HEADER *h, char *cmd, ...@@ -336,7 +376,7 @@ static int _mutt_pipe_message (HEADER *h, char *cmd,
} }
pipe_msg (h, fpout, decode, print); pipe_msg (h, fpout, decode, print);
safe_fclose (&fpout); fclose (fpout);
rc = mutt_wait_filter (thepid); rc = mutt_wait_filter (thepid);
} }
else else
...@@ -344,7 +384,7 @@ static int _mutt_pipe_message (HEADER *h, char *cmd, ...@@ -344,7 +384,7 @@ static int _mutt_pipe_message (HEADER *h, char *cmd,
#ifdef HAVE_PGP #if defined(HAVE_PGP) || defined(HAVE_SMIME)
if (decode) if (decode)
{ {
...@@ -353,8 +393,8 @@ static int _mutt_pipe_message (HEADER *h, char *cmd, ...@@ -353,8 +393,8 @@ static int _mutt_pipe_message (HEADER *h, char *cmd,
{ {
mutt_message_hook (Context, Context->hdrs[Context->v2r[i]], M_MESSAGEHOOK); mutt_message_hook (Context, Context->hdrs[Context->v2r[i]], M_MESSAGEHOOK);
mutt_parse_mime_message(Context, Context->hdrs[Context->v2r[i]]); mutt_parse_mime_message(Context, Context->hdrs[Context->v2r[i]]);
if (Context->hdrs[Context->v2r[i]]->pgp & PGPENCRYPT && if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT &&
!pgp_valid_passphrase()) !crypt_valid_passphrase(Context->hdrs[Context->v2r[i]]->security))
return 1; return 1;
} }
} }
...@@ -576,18 +616,30 @@ static void set_copy_flags (HEADER *hdr, int decode, int decrypt, int *cmflags, ...@@ -576,18 +616,30 @@ static void set_copy_flags (HEADER *hdr, int decode, int decrypt, int *cmflags,
*cmflags = 0; *cmflags = 0;
*chflags = CH_UPDATE_LEN; *chflags = CH_UPDATE_LEN;
#ifdef HAVE_PGP #if defined(HAVE_PGP) || defined(HAVE_SMIME)
if (!decode && decrypt && (hdr->pgp & PGPENCRYPT)) if (!decode && decrypt && (hdr->security & ENCRYPT))
{ {
#ifdef HAVE_PGP
if (mutt_is_multipart_encrypted(hdr->content)) if (mutt_is_multipart_encrypted(hdr->content))
{ {
*chflags = CH_NONEWLINE | CH_XMIT | CH_MIME; *chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
*cmflags = M_CM_DECODE_PGP; *cmflags = M_CM_DECODE_PGP;
} }
else if (mutt_is_application_pgp(hdr->content) & PGPENCRYPT) else if (mutt_is_application_pgp(hdr->content) & ENCRYPT)
decode = 1; decode = 1;
}
#endif #endif
#if defined(HAVE_PGP) && defined(HAVE_SMIME)
else
#endif
#ifdef HAVE_SMIME
if (mutt_is_application_smime(hdr->content) & ENCRYPT)
{
*chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
*cmflags = M_CM_DECODE_SMIME;
}
#endif
}
#endif /* defined(HAVE_PGP) || defined(HAVE_SMIME) */
if (decode) if (decode)
{ {
...@@ -628,8 +680,8 @@ int mutt_save_message (HEADER *h, int delete, ...@@ -628,8 +680,8 @@ int mutt_save_message (HEADER *h, int delete,
int decode, int decrypt, int *redraw) int decode, int decrypt, int *redraw)
{ {
int i, need_buffy_cleanup; int i, need_buffy_cleanup;
#ifdef HAVE_PGP #if defined(HAVE_PGP) || defined(HAVE_SMIME)
int need_passphrase = 0; int need_passphrase = 0, app=0;
#endif #endif
char prompt[SHORT_STRING], buf[_POSIX_PATH_MAX]; char prompt[SHORT_STRING], buf[_POSIX_PATH_MAX];
CONTEXT ctx; CONTEXT ctx;
...@@ -651,10 +703,12 @@ int mutt_save_message (HEADER *h, int delete, ...@@ -651,10 +703,12 @@ int mutt_save_message (HEADER *h, int delete,
(delete ? _("Save%s to mailbox") : _("Copy%s to mailbox"))), (delete ? _("Save%s to mailbox") : _("Copy%s to mailbox"))),
h ? "" : _(" tagged")); h ? "" : _(" tagged"));
if (h) if (h)
{ {
#ifdef HAVE_PGP #if defined(HAVE_PGP) || defined(HAVE_SMIME)
need_passphrase = h->pgp & PGPENCRYPT; need_passphrase = h->security & ENCRYPT;
app = h->security;
#endif #endif
mutt_message_hook (Context, h, M_MESSAGEHOOK); mutt_message_hook (Context, h, M_MESSAGEHOOK);
mutt_default_save (buf, sizeof (buf), h); mutt_default_save (buf, sizeof (buf), h);
...@@ -672,12 +726,14 @@ int mutt_save_message (HEADER *h, int delete, ...@@ -672,12 +726,14 @@ int mutt_save_message (HEADER *h, int delete,
} }
} }
if (h) if (h)
{ {
mutt_message_hook (Context, h, M_MESSAGEHOOK); mutt_message_hook (Context, h, M_MESSAGEHOOK);
mutt_default_save (buf, sizeof (buf), h); mutt_default_save (buf, sizeof (buf), h);
#ifdef HAVE_PGP #if defined(HAVE_PGP) || defined(HAVE_SMIME)
need_passphrase |= h->pgp & PGPENCRYPT; need_passphrase = h->security & ENCRYPT;
app = h->security;
#endif #endif
h = NULL; h = NULL;
} }
...@@ -712,10 +768,8 @@ int mutt_save_message (HEADER *h, int delete, ...@@ -712,10 +768,8 @@ int mutt_save_message (HEADER *h, int delete,
if (!mutt_save_confirm (buf, &st)) if (!mutt_save_confirm (buf, &st))
return -1; return -1;
#ifdef HAVE_PGP if (need_passphrase && (decode || decrypt) && !crypt_valid_passphrase(app))
if(need_passphrase && (decode || decrypt) && !pgp_valid_passphrase())
return -1; return -1;
#endif
mutt_message (_("Copying to %s..."), buf); mutt_message (_("Copying to %s..."), buf);
...@@ -865,20 +919,19 @@ void mutt_edit_content_type (HEADER *h, BODY *b, FILE *fp) ...@@ -865,20 +919,19 @@ void mutt_edit_content_type (HEADER *h, BODY *b, FILE *fp)
if (fp && (is_multipart (b) || mutt_is_message_type (b->type, b->subtype))) if (fp && (is_multipart (b) || mutt_is_message_type (b->type, b->subtype)))
mutt_parse_part (fp, b); mutt_parse_part (fp, b);
#ifdef HAVE_PGP #if defined(HAVE_PGP) || defined(HAVE_SMIME)
if (h) if (h)
{ {
if (h->content == b) if (h->content == b)
h->pgp = 0; h->security = 0;
h->pgp |= pgp_query (b);
}
#endif /* HAVE_PGP */
h->security |= crypt_query (b);
#endif
}
} }
#ifdef HAVE_PGP #ifdef HAVE_PGP
static int _mutt_check_traditional_pgp (HEADER *h, int *redraw) static int _mutt_check_traditional_pgp (HEADER *h, int *redraw)
{ {
MESSAGE *msg; MESSAGE *msg;
...@@ -889,7 +942,7 @@ static int _mutt_check_traditional_pgp (HEADER *h, int *redraw) ...@@ -889,7 +942,7 @@ static int _mutt_check_traditional_pgp (HEADER *h, int *redraw)
return 0; return 0;
if (pgp_check_traditional (msg->fp, h->content, 0)) if (pgp_check_traditional (msg->fp, h->content, 0))
{ {
h->pgp = pgp_query (h->content); h->security = crypt_query (h->content);
*redraw |= REDRAW_FULL; *redraw |= REDRAW_FULL;
rv = 1; rv = 1;
} }
......
...@@ -58,11 +58,10 @@ enum ...@@ -58,11 +58,10 @@ enum
HDR_MIX, HDR_MIX,
#endif #endif
#ifdef HAVE_PGP #if defined(HAVE_PGP) || defined(HAVE_SMIME)
HDR_PGP, HDR_CRYPT,
HDR_PGPSIGINFO, HDR_CRYPTINFO,
#endif #endif
HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */ HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
}; };
...@@ -103,80 +102,204 @@ static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num) ...@@ -103,80 +102,204 @@ static void snd_entry (char *b, size_t blen, MUTTMENU *menu, int num)
#ifdef HAVE_SMIME
#include "smime.h"
#endif
#ifdef HAVE_PGP #ifdef HAVE_PGP
#include "pgp.h" #include "pgp.h"
#endif
#if defined(HAVE_PGP) || defined(HAVE_SMIME)
static void redraw_pgp_lines (int pgp) static void redraw_crypt_lines (HEADER *msg)
{ {
mvaddstr (HDR_PGP, 0, " PGP: "); #ifdef HAVE_SMIME
if ((pgp & (PGPENCRYPT | PGPSIGN)) == (PGPENCRYPT | PGPSIGN)) int off = 0;
#endif
#if defined(HAVE_PGP) && defined(HAVE_SMIME)
if (!msg->security)
mvaddstr (HDR_CRYPT, 0, "Security: ");
else if (msg->security & APPLICATION_SMIME)
mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
else if (msg->security & APPLICATION_PGP)
mvaddstr (HDR_CRYPT, 0, " PGP: ");
#else
#ifdef HAVE_SMIME
mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
#endif
#ifdef HAVE_PGP
mvaddstr (HDR_CRYPT, 0, " PGP: ");
#endif
#endif
if ((msg->security & (ENCRYPT | SIGN)) == (ENCRYPT | SIGN))
addstr (_("Sign, Encrypt")); addstr (_("Sign, Encrypt"));
else if (pgp & PGPENCRYPT) else if (msg->security & ENCRYPT)
addstr (_("Encrypt")); addstr (_("Encrypt"));
else if (pgp & PGPSIGN) else if (msg->security & SIGN)
addstr (_("Sign")); addstr (_("Sign"));
else else
addstr (_("Clear")); addstr (_("Clear"));
clrtoeol (); clrtoeol ();
move (HDR_PGPSIGINFO, 0); move (HDR_CRYPTINFO, 0);
clrtoeol (); clrtoeol ();
if (pgp & PGPSIGN) #ifdef HAVE_PGP
if (msg->security & APPLICATION_PGP && msg->security & SIGN)
printw ("%s%s", _(" sign as: "), PgpSignAs ? PgpSignAs : _("<default>")); printw ("%s%s", _(" sign as: "), PgpSignAs ? PgpSignAs : _("<default>"));
#endif
#ifdef HAVE_SMIME
if (msg->security & APPLICATION_SMIME && msg->security & SIGN) {
printw ("%s%s", _(" sign as: "), SmimeSignAs ? SmimeSignAs : _("<default>"));
}
if (msg->security & APPLICATION_SMIME && (msg->security & ENCRYPT)) {
mvprintw (HDR_CRYPTINFO, 40, "%s%s", _("Encrypt with: "),
NONULL(SmimeCryptAlg));
off = 20;
}
#endif
} }
#endif /* defined(HAVE_PGP) || defined(HAVE_SMIME) */
static int pgp_send_menu (int bits, int *redraw) #ifdef HAVE_PGP
static int pgp_send_menu (HEADER *msg, int *redraw)
{ {
pgp_key_t *p; pgp_key_t *p;
char input_signas[SHORT_STRING]; char input_signas[SHORT_STRING];
switch (mutt_multi_choice (_("(e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "), switch (mutt_multi_choice (_("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "),
_("esabf"))) _("esabf")))
{ {
case 1: /* (e)ncrypt */ case 1: /* (e)ncrypt */
bits |= PGPENCRYPT; msg->security |= PGPENCRYPT;
break; break;
case 2: /* (s)ign */ case 2: /* (s)ign */
bits |= PGPSIGN; msg->security |= PGPSIGN;
break; break;
case 3: /* sign (a)s */ case 3: /* sign (a)s */
unset_option(OPTPGPCHECKTRUST); unset_option(OPTPGPCHECKTRUST);
if ((p = pgp_ask_for_key (_("Sign as: "), NULL, KEYFLAG_CANSIGN, PGP_SECRING))) if ((p = pgp_ask_for_key (_("Sign as: "), NULL, KEYFLAG_CANSIGN, PGP_PUBRING)))
{ {
snprintf (input_signas, sizeof (input_signas), "0x%s", pgp_keyid (p)); snprintf (input_signas, sizeof (input_signas), "0x%s", pgp_keyid (p));
mutt_str_replace (&PgpSignAs, input_signas); mutt_str_replace (&PgpSignAs, input_signas);
pgp_free_key (&p); pgp_free_key (&p);
bits |= PGPSIGN; msg->security |= PGPSIGN;