bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@ @SMIMEAUX_TARGET@
mutt_SOURCES = $(BUILT_SOURCES) \
addrbook.c alias.c attach.c base64.c browser.c buffy.c color.c \
+ crypt.c cryptglue.c \
commands.c complete.c compose.c copy.c curs_lib.c curs_main.c date.c \
edit.c enter.c flags.c init.c filter.c from.c getdomain.c \
handler.c hash.c hdrline.c headers.c help.c hook.c keymap.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 crypt.c smime.c pgp.c pgpinvoke.c pgpkey.c \
+ mutt_tunnel.c pop.c pop_auth.c pop_lib.c smime.c pgp.c pgpinvoke.c pgpkey.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
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 \
- globals.h hash.h history.h init.h keymap.h \
+ globals.h hash.h history.h init.h keymap.h crypt.h \
mailbox.h mapping.h md5.h mime.h mutt.h mutt_curses.h mutt_menu.h \
mutt_regex.h mutt_sasl.h mutt_socket.h mutt_ssl.h mutt_tunnel.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 \
_regex.h OPS.MIX README.SECURITY remailer.c remailer.h browser.h \
mbyte.h lib.h extlib.c pgpewrap.c smime_keys.pl pgplib.h Muttrc.head Muttrc \
- makedoc.c stamp-doc-rc README.SSL crypt.h smime.h\
+ makedoc.c stamp-doc-rc README.SSL smime.h\
muttbug pgppacket.h depcomp ascii.h BEWARE PATCHES patchlist.sh \
ChangeLog.old mkchangelog.sh cvslog2changelog.pl
-/*
- * Define if you have problems with mutt not detecting new/old mailboxes
- * over NFS. Some NFS implementations incorrectly cache the attributes
- * of small files.
- */
-#undef NFS_ATTRIBUTE_HACK
-
-/*
- * Is mail spooled to the user's home directory? If defined, MAILPATH should
- * be set to the filename of the spool mailbox relative the the home
- * directory.
- * use: configure --with-homespool=FILE
- */
-#undef HOMESPOOL
-
/* program to use for shell commands */
#define EXECSHELL "/bin/sh"
-/* Enable exact regeneration of email addresses as parsed? NOTE: this requires
- significant more memory when defined. */
-#undef EXACT_ADDRESS
-
/* Define to `int' if <signal.h> doesn't define. */
#undef sig_atomic_t
#include "mailbox.h"
#include "copy.h"
#include "mx.h"
-
-#ifdef HAVE_PGP
-#include "pgp.h"
-#endif
-
-#ifdef HAVE_SMIME
-#include "smime.h"
-#endif
+#include "mutt_crypt.h"
#include <ctype.h>
#include <stdlib.h>
int unlink_tempfile = 0;
is_message = mutt_is_message_type(a->type, a->subtype);
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- if (is_message && a->hdr && (a->hdr->security & ENCRYPT) &&
+ if (WithCrypto && is_message && a->hdr && (a->hdr->security & ENCRYPT) &&
!crypt_valid_passphrase(a->hdr->security))
return (rc);
-#endif /* HAVE_PGP || HAVE_SMIME */
use_mailcap = (flag == M_MAILCAP ||
(flag == M_REGULAR && mutt_needs_mailcap (a)));
snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype);
#include "copy.h"
#include "mx.h"
#include "pager.h"
+#include "mutt_crypt.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "buffy.h"
#endif
-
-
-#ifdef HAVE_PGP
-#include "pgp.h"
-#endif
-
-
-#ifdef HAVE_SMIME
-#include "smime.h"
-#endif
-
-
-
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
mutt_parse_mime_message (Context, cur);
mutt_message_hook (Context, cur, M_MESSAGEHOOK);
-#if defined (HAVE_PGP) || defined (HAVE_SMIME)
- /* see if PGP is needed for this message. if so, we should exit curses */
- if (cur->security)
+ /* see if crytpo is needed for this message. if so, we should exit curses */
+ if (WithCrypto && cur->security)
{
if (cur->security & ENCRYPT)
{
-#ifdef HAVE_SMIME
if (cur->security & APPLICATION_SMIME)
- smime_getkeys (cur->env);
-#endif
+ crypt_smime_getkeys (cur->env);
if(!crypt_valid_passphrase(cur->security))
return 0;
if (cmflags & M_CM_VERIFY || cur->security & ENCRYPT)
{
-#ifdef HAVE_PGP
if (cur->security & APPLICATION_PGP)
{
if (cur->env->from)
- pgp_invoke_getkeys (cur->env->from);
-
- mutt_message _("Invoking PGP...");
+ crypt_pgp_invoke_getkeys (cur->env->from);
+
+ crypt_invoke_message (APPLICATION_PGP);
}
-#endif
-#ifdef HAVE_SMIME
if (cur->security & APPLICATION_SMIME)
- mutt_message _("Invoking OpenSSL...");
-#endif
+ crypt_invoke_message (APPLICATION_SMIME);
}
-#endif /* defined (HAVE_PGP) || defined (HAVE_SMIME) */
mutt_mktemp (tempfile);
safe_fclose (&fpfilterout); /* XXX - check result? */
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- /* update crypto information for this message */
- cur->security |= crypt_query (cur->content);
+ if (WithCrypto)
+ {
+ /* update crypto information for this message */
+ cur->security |= crypt_query (cur->content);
- /* Remove color cache for this message, in case there
- are color patterns for both ~g and ~V */
- cur->pair = 0;
-#endif
+ /* Remove color cache for this message, in case there
+ are color patterns for both ~g and ~V */
+ cur->pair = 0;
+ }
if (builtin)
{
pager_t info;
-#ifdef HAVE_SMIME
- if (cur->security & APPLICATION_SMIME && (cmflags & M_CM_VERIFY))
+ if (WithCrypto
+ && (cur->security & APPLICATION_SMIME) && (cmflags & M_CM_VERIFY))
{
if (cur->security & GOODSIGN)
{
- if (!smime_verify_sender(cur))
+ if (!crypt_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
- if ((cur->security & APPLICATION_PGP) && (cmflags & M_CM_VERIFY))
+ 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."));
-#endif
/* Invoke the builtin pager */
memset (&info, 0, sizeof (pager_t));
pipe_set_flags (decode, print, &cmflags, &chflags);
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- if (decode && h->security & ENCRYPT)
- {
- if(!crypt_valid_passphrase(h->security))
- return;
- endwin ();
- }
-#endif
-
+ if (WithCrypto && decode && h->security & ENCRYPT)
+ {
+ if(!crypt_valid_passphrase(h->security))
+ return;
+ endwin ();
+ }
if (decode)
mutt_parse_mime_message (Context, h);
mutt_message_hook (Context, h, M_MESSAGEHOOK);
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- if (decode)
+ if (WithCrypto && decode)
{
mutt_parse_mime_message (Context, h);
if(h->security & ENCRYPT && !crypt_valid_passphrase(h->security))
return 1;
}
mutt_endwin (NULL);
-#endif
if ((thepid = mutt_create_filter (cmd, &fpout, NULL, NULL)) < 0)
{
else
{ /* handle tagged messages */
-
-
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
-
- if (decode)
+ if (WithCrypto && decode)
{
for (i = 0; i < Context->vcount; i++)
if(Context->hdrs[Context->v2r[i]]->tagged)
return 1;
}
}
-#endif
if (split)
{
*cmflags = 0;
*chflags = CH_UPDATE_LEN;
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- if (!decode && decrypt && (hdr->security & ENCRYPT))
+ if (WithCrypto && !decode && decrypt && (hdr->security & ENCRYPT))
{
-#ifdef HAVE_PGP
- if (mutt_is_multipart_encrypted(hdr->content))
+ if ((WithCrypto & APPLICATION_PGP)
+ && mutt_is_multipart_encrypted(hdr->content))
{
*chflags = CH_NONEWLINE | CH_XMIT | CH_MIME;
*cmflags = M_CM_DECODE_PGP;
}
- else if (mutt_is_application_pgp (hdr->content) & ENCRYPT)
+ else if ((WithCrypto & APPLICATION_PGP)
+ && mutt_is_application_pgp (hdr->content) & ENCRYPT)
decode = 1;
-#endif
-#if defined(HAVE_PGP) && defined(HAVE_SMIME)
- else
-#endif
-#ifdef HAVE_SMIME
- if (mutt_is_application_smime(hdr->content) & ENCRYPT)
+ else if ((WithCrypto & APPLICATION_SMIME)
+ && 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)
{
int decode, int decrypt, int *redraw)
{
int i, need_buffy_cleanup;
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
int need_passphrase = 0, app=0;
-#endif
char prompt[SHORT_STRING], buf[_POSIX_PATH_MAX];
CONTEXT ctx;
struct stat st;
if (h)
{
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
+ if (WithCrypto)
+ {
need_passphrase = h->security & ENCRYPT;
app = h->security;
-#endif
+ }
mutt_message_hook (Context, h, M_MESSAGEHOOK);
mutt_default_save (buf, sizeof (buf), h);
}
{
mutt_message_hook (Context, h, M_MESSAGEHOOK);
mutt_default_save (buf, sizeof (buf), h);
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- need_passphrase = h->security & ENCRYPT;
- app = h->security;
-#endif
+ if (WithCrypto)
+ {
+ need_passphrase = h->security & ENCRYPT;
+ app = h->security;
+ }
h = NULL;
}
}
if (!mutt_save_confirm (buf, &st))
return -1;
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- if (need_passphrase && (decode || decrypt) && !crypt_valid_passphrase(app))
+ if (WithCrypto && need_passphrase && (decode || decrypt)
+ && !crypt_valid_passphrase(app))
return -1;
-#endif
mutt_message (_("Copying to %s..."), buf);
if (fp && (is_multipart (b) || mutt_is_message_type (b->type, b->subtype)))
mutt_parse_part (fp, b);
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- if (h)
+ if (WithCrypto && h)
{
if (h->content == b)
h->security = 0;
h->security |= crypt_query (b);
}
-#endif
}
-#ifdef HAVE_PGP
static int _mutt_check_traditional_pgp (HEADER *h, int *redraw)
{
MESSAGE *msg;
mutt_parse_mime_message (Context, h);
if ((msg = mx_open_message (Context, h->msgno)) == NULL)
return 0;
- if (pgp_check_traditional (msg->fp, h->content, 0))
+ if (crypt_pgp_check_traditional (msg->fp, h->content, 0))
{
h->security = crypt_query (h->content);
*redraw |= REDRAW_FULL;
return rv;
}
-#endif
+
HDR_MIX,
#endif
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
HDR_CRYPT,
HDR_CRYPTINFO,
-#endif
HDR_ATTACH = (HDR_FCC + 5) /* where to start printing the attachments */
};
-#ifdef HAVE_SMIME
-#include "smime.h"
-#endif
-
-#ifdef HAVE_PGP
-#include "pgp.h"
-#endif
-
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
+#include "mutt_crypt.h"
static void redraw_crypt_lines (HEADER *msg)
{
-#ifdef HAVE_SMIME
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)
+ if ((WithCrypto & APPLICATION_PGP) && (WithCrypto & APPLICATION_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 if ((WithCrypto & APPLICATION_SMIME))
mvaddstr (HDR_CRYPT, 0, " S/MIME: ");
- else if (msg->security & APPLICATION_PGP)
+ else if ((WithCrypto & 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
-
+ else
+ return;
if ((msg->security & (ENCRYPT | SIGN)) == (ENCRYPT | SIGN))
addstr (_("Sign, Encrypt"));
move (HDR_CRYPTINFO, 0);
clrtoeol ();
-#ifdef HAVE_PGP
- if (msg->security & APPLICATION_PGP && msg->security & SIGN)
+ if ((WithCrypto & APPLICATION_PGP)
+ && msg->security & APPLICATION_PGP && msg->security & SIGN)
printw ("%s%s", _(" sign as: "), PgpSignAs ? PgpSignAs : _("<default>"));
-#endif
-#ifdef HAVE_SMIME
- if (msg->security & APPLICATION_SMIME && msg->security & SIGN) {
+
+ if ((WithCrypto & APPLICATION_SMIME)
+ && msg->security & APPLICATION_SMIME && msg->security & SIGN) {
printw ("%s%s", _(" sign as: "), SmimeDefaultKey ? SmimeDefaultKey : _("<default>"));
}
- if (msg->security & APPLICATION_SMIME && (msg->security & ENCRYPT)) {
+
+ if ((WithCrypto & APPLICATION_SMIME)
+ && 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) */
-#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];
+ if (!(WithCrypto & APPLICATION_PGP))
+ return msg->security;
+
switch (mutt_multi_choice (_("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, or (f)orget it? "),
_("esabf")))
{
break;
case 3: /* sign (a)s */
-
unset_option(OPTPGPCHECKTRUST);
- if ((p = pgp_ask_for_key (_("Sign as: "), NULL, KEYFLAG_CANSIGN, PGP_PUBRING)))
+ if ((p = crypt_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",
+ crypt_pgp_keyid (p));
mutt_str_replace (&PgpSignAs, input_signas);
- pgp_free_key (&p);
+ crypt_pgp_free_key (&p);
msg->security |= PGPSIGN;
- pgp_void_passphrase (); /* probably need a different passphrase */
+ crypt_pgp_void_passphrase (); /* probably need a different passphrase */
}
else
{
redraw_crypt_lines (msg);
return (msg->security);
}
-#endif /* HAVE_PGP */
-
-#ifdef HAVE_SMIME
static int smime_send_menu (HEADER *msg, int *redraw)
{
- char *p;
+ char *p;
+
+ if (!(WithCrypto & APPLICATION_SMIME))
+ return msg->security;
switch (mutt_multi_choice (_("S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, or (f)orget it? "),
_("eswabf")))
case 4: /* sign (a)s */
- if ((p = smime_ask_for_key (_("Sign as: "), NULL, 0))) {
+ if ((p = crypt_smime_ask_for_key (_("Sign as: "), NULL, 0))) {
p[mutt_strlen (p)-1] = '\0';
mutt_str_replace (&SmimeDefaultKey, p);
msg->security |= SMIMESIGN;
/* probably need a different passphrase */
- smime_void_passphrase ();
+ crypt_smime_void_passphrase ();
}
else
msg->security &= ~SMIMESIGN;
redraw_crypt_lines (msg);
return (msg->security);
}
-#endif /* HAVE_SMIME */
+
#ifdef MIXMASTER
c += mutt_strlen (t) + 2;
}
}
-#endif
+#endif /* MIXMASTER */
static int
check_attachments(ATTACHPTR **idx, short idxlen)
mvprintw (HDR_FCC, 0, TITLE_FMT, Prompts[HDR_FCC - 1]);
mutt_paddstr (W, fcc);
-
-
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- redraw_crypt_lines (msg);
-#endif /* HAVE_PGP || HAVE_SMIE */
-
+ if (WithCrypto)
+ redraw_crypt_lines (msg);
#ifdef MIXMASTER
redraw_mix_line (msg->chain);
-#ifdef HAVE_PGP
case OP_COMPOSE_ATTACH_KEY:
-
+ if (!(WithCrypto & APPLICATION_PGP))
+ break;
if (idxlen == idxmax)
{
safe_realloc ((void **) &idx, sizeof (ATTACHPTR *) * (idxmax += 5));
}
idx[idxlen] = (ATTACHPTR *) safe_calloc (1, sizeof (ATTACHPTR));
- if ((idx[idxlen]->content = pgp_make_key_attachment(NULL)) != NULL)
+ if ((idx[idxlen]->content = crypt_pgp_make_key_attachment(NULL)) != NULL)
{
idx[idxlen]->level = (idxlen > 0) ? idx[idxlen-1]->level : 0;
}
break;
-#endif
-
case OP_COMPOSE_ATTACH_FILE:
-#ifdef HAVE_PGP
case OP_COMPOSE_PGP_MENU:
-
-#ifdef HAVE_SMIME
- if (msg->security & APPLICATION_SMIME)
+ if (!(WithCrypto & APPLICATION_PGP))
+ break;
+ if ((WithCrypto & APPLICATION_SMIME)
+ && msg->security & APPLICATION_SMIME)
{
if (mutt_yesorno (_("S/MIME already selected. Clear & continue ? "),
M_YES) == M_NO)
}
msg->security = 0;
}
-#endif /* HAVE_SMIME */
msg->security = pgp_send_menu (msg, &menu->redraw);
redraw_crypt_lines (msg);
break;
-#endif /* HAVE_PGP */
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
case OP_FORGET_PASSPHRASE:
-
crypt_forget_passphrase ();
break;
-#endif /* HAVE_(PGP||SMIME) */
-
-#ifdef HAVE_SMIME
case OP_COMPOSE_SMIME_MENU:
+ if (!(WithCrypto & APPLICATION_SMIME))
+ break;
-#ifdef HAVE_PGP
- if (msg->security & APPLICATION_PGP)
+ if ((WithCrypto & APPLICATION_PGP)
+ && msg->security & APPLICATION_PGP)
{
if (mutt_yesorno (_("PGP already selected. Clear & continue ? "),
M_YES) == M_NO)
}
msg->security = 0;
}
-#endif /* HAVE_pgp */
msg->security = smime_send_menu(msg, &menu->redraw);
redraw_crypt_lines (msg);
break;
-#endif /* HAVE_SMIME */
-
#ifdef MIXMASTER
case OP_COMPOSE_MIX:
return (r);
}
+
AC_SUBST(DEBUGGER)
+# The following templates should be used with newer automakes
+# instead of acconfig.h
+#
+#AH_TEMPLATE([sig_atomic_t],
+# [/* Define to `int' if <signal.h> doesn't define.])
+#AH_TEMPLATE([HAVE_START_COLOR],
+# [Define if you have start_color, as a function or macro.])
+#AH_TEMPLATE([HAVE_TYPEAHEAD],
+# [Define if you have typeahead, as a function or macro.])
+#AH_TEMPLATE([HAVE_BKGDSET],
+# [Define if you have bkgdset, as a function or macro.])
+#AH_TEMPLATE([HAVE_CURS_SET],
+# [Define if you have curs_set, as a function or macro.])
+#AH_TEMPLATE([HAVE_META],
+# [Define if you have meta, as a function or macro.])
+#AH_TEMPLATE([HAVE_USE_DEFAULT_COLORS],
+# [Define if you have use_default_colors, as a function or macro.])
+#AH_TEMPLATE([HAVE_RESIZETERM],
+# [Define if you have resizeterm, as a function or macro.])
+#AH_TEMPLATE([SIG_ATOMIC_VOLATILE_T],
+# [Some systems declare sig_atomic_t as volatile, some others -- no.
+# This define will have value `sig_atomic_t' or
+# `volatile sig_atomic_t' accordingly.])
+#AH_TEMPLATE([ICONV_NONTRANS],
+# [Define as 1 if iconv() only converts exactly and we should treat
+# all return values other than (size_t)(-1) as equivalent.])
+
+
ac_aux_path_sendmail=/usr/sbin:/usr/lib
AC_PATH_PROG(SENDMAIL, sendmail, /usr/sbin/sendmail, $PATH:$ac_aux_path_sendmail)
AC_DEFINE_UNQUOTED(SENDMAIL,"$ac_cv_path_SENDMAIL",[ Where to find sendmail on your system. ])
])
if test x$have_pgp != xno ; then
- AC_DEFINE(HAVE_PGP,1,[ Define if you want PGP support. ])
+ AC_DEFINE(CRYPT_BACKEND_CLASSIC_PGP,1,
+ [ Define if you want classic PGP support. ])
PGPAUX_TARGET="pgpring pgpewrap"
MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS pgp.o pgpinvoke.o pgpkey.o pgplib.o gnupgparse.o pgpmicalg.o pgppacket.o"
- OPS="$OPS \$(srcdir)/OPS.PGP"
fi
AC_ARG_ENABLE(smime, [ --disable-smime Disable SMIME support],
])
if test x$have_smime != xno ; then
- AC_DEFINE(HAVE_SMIME,1,[ Define if you want S/MIME support. ])
+ AC_DEFINE(CRYPT_BACKEND_CLASSIC_SMIME,1,
+ [ Define if you want clasic S/MIME support. ])
MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS smime.o "
- OPS="$OPS \$(srcdir)/OPS.SMIME"
SMIMEAUX_TARGET="smime_keys"
fi
- if test x$HAVE_SMIME != xno -o x$HAVE_PGP != xno ; then
- MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS crypt.o "
- OPS="$OPS \$(srcdir)/OPS.CRYPT"
- fi
-
AC_ARG_WITH(mixmaster, [ --with-mixmaster[=PATH] Include Mixmaster support],
[if test -x "$withval" ; then
MIXMASTER="$withval"
])
fi
+# We now require all OPS
+OPS="$OPS \$(srcdir)/OPS.PGP \$(srcdir)/OPS.SMIME \$(srcdir)/OPS.CRYPT "
AC_SUBST(OPS)
+
AC_SUBST(PGPAUX_TARGET)
AC_SUBST(SMIMEAUX_TARGET)
old_LIBS="$LIBS"
LIBS="$LIBS $MUTTLIBS"
- CF_CHECK_FUNCDECLS([#include <${cf_cv_ncurses_header-curses.h}>], start_color typeahead bkgdset curs_set meta use_default_colors resizeterm)
+ CF_CHECK_FUNCDECLS([#include <${cf_cv_ncurses_header-curses.h}>],
+ [start_color typeahead bkgdset curs_set meta use_default_colors resizeterm])
if test "$ac_cv_func_decl_start_color" = yes; then
AC_DEFINE(HAVE_COLOR,1,[ Define if your curses library supports color. ])
fi
AC_CHECK_FUNCS(snprintf, , [mutt_cv_snprintf=yes])
AC_CHECK_FUNCS(vsnprintf, , [mutt_cv_snprintf=yes])
if test $mutt_cv_snprintf = yes; then
+# AC_LIBOBJ(snprintf)
LIBOBJS="$LIBOBJS snprintf.o"
fi
if test $mutt_cv_regex = yes; then
AC_DEFINE(USE_GNU_REGEX,1,[ Define if you want to use the included regex.c. ])
+### AC_LIBOBJ(regex)
LIBOBJS="$LIBOBJS regex.o"
fi
with_homespool=mailbox
fi
AC_DEFINE_UNQUOTED(MAILPATH,"$with_homespool",[ Where new mail is spooled. ])
- AC_DEFINE(HOMESPOOL)
+ AC_DEFINE(HOMESPOOL,1,
+ [Is mail spooled to the user's home directory? If defined,
+ MAILPATH should be set to the filename of the spool mailbox
+ relative the the home directory.
+ use: configure --with-homespool=FILE])
AC_DEFINE(USE_DOTLOCK,1,[ Define to use dotlocking for mailboxes. ])
mutt_cv_setgid=no
else
AC_ARG_ENABLE(nfs-fix, [ --enable-nfs-fix Work around an NFS with broken attributes caching ],
[if test x$enableval = xyes; then
- AC_DEFINE(NFS_ATTRIBUTE_HACK)
+ AC_DEFINE(NFS_ATTRIBUTE_HACK,1,
+ [Define if you have problems with mutt not detecting
+ new/old mailboxes over NFS. Some NFS implementations
+ incorrectly cache the attributes of small files.])
fi])
AC_ARG_ENABLE(buffy-size, [ --enable-buffy-size Use file size attribute instead of access time ],
AC_ARG_WITH(exec-shell, [ --with-exec-shell=SHELL Specify alternate shell (ONLY if /bin/sh is broken)],
[if test $withval != yes; then
- AC_DEFINE_UNQUOTED(EXECSHELL, "$withval")
- fi])
+ AC_DEFINE_UNQUOTED(EXECSHELL, "$withval",
+ [program to use for shell commands])
+ else
+ AC_DEFINE_UNQUOTED(EXECSHELL, "/bin/sh")
+ fi],
+ [AC_DEFINE_UNQUOTED(EXECSHELL, "/bin/sh")])
AC_ARG_ENABLE(exact-address, [ --enable-exact-address Enable regeneration of email addresses],
[if test $enableval = yes; then
- AC_DEFINE(EXACT_ADDRESS)
+ AC_DEFINE(EXACT_ADDRESS,1,
+ [Enable exact regeneration of email addresses as parsed?
+ NOTE: this requires significant more memory when defined.])
+
fi])
AC_SUBST(MUTTLIBS)
#include "copy.h"
#include "rfc2047.h"
#include "mime.h"
-
-#ifdef HAVE_PGP
-#include "pgp.h"
-#endif
-
-#ifdef HAVE_SMIME
-#include "smime.h"
-#endif
+#include "mutt_crypt.h"
#include <string.h>
#include <stdlib.h>
if (flags & M_CM_CHARCONV)
s.flags |= M_CHARCONV;
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- if (flags & M_CM_VERIFY)
+ if (WithCrypto && flags & M_CM_VERIFY)
s.flags |= M_VERIFY;
-#endif
mutt_body_handler (body, &s);
}
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- else if ((flags & M_CM_DECODE_CRYPT) && (hdr->security & ENCRYPT))
+ else if (WithCrypto
+ && (flags & M_CM_DECODE_CRYPT) && (hdr->security & ENCRYPT))
{
BODY *cur;
FILE *fp;
-#ifdef HAVE_PGP
- if ((flags & M_CM_DECODE_PGP) && (hdr->security & APPLICATION_PGP) &&
+ if ((WithCrypto & APPLICATION_PGP)
+ && (flags & M_CM_DECODE_PGP) && (hdr->security & APPLICATION_PGP) &&
hdr->content->type == TYPEMULTIPART)
{
- if (pgp_decrypt_mime (fpin, &fp, hdr->content, &cur))
+ if (crypt_pgp_decrypt_mime (fpin, &fp, hdr->content, &cur))
return (-1);
fputs ("Mime-Version: 1.0\n", fpout);
}
-#endif
-#ifdef HAVE_SMIME
- if ((flags & M_CM_DECODE_SMIME) && (hdr->security & APPLICATION_SMIME)
+
+ if ((WithCrypto & APPLICATION_SMIME)
+ && (flags & M_CM_DECODE_SMIME) && (hdr->security & APPLICATION_SMIME)
&& hdr->content->type == TYPEAPPLICATION)
{
- if (smime_decrypt_mime (fpin, &fp, hdr->content, &cur))
+ if (crypt_smime_decrypt_mime (fpin, &fp, hdr->content, &cur))
return (-1);
}
-#endif
+
mutt_write_mime_header (cur, fpout);
fputc ('\n', fpout);
mutt_free_body (&cur);
fclose (fp);
}
-#endif
else
{
fseek (fpin, body->offset, 0);
#define M_CM_PRINTING (1<<7) /* printing the message - display light */
-#ifdef HAVE_PGP
-#define M_CM_DECODE_PGP (1<<8) /* used for decoding PGP messages */
-#define M_CM_DECODE_CRYPT (1<<8)
-#endif
-
-
-#ifdef HAVE_SMIME
-#ifdef M_CM_DECODE_CRYPT
-#undef M_CM_DECODE_CRYPT
-#endif
-#define M_CM_DECODE_SMIME (1<<9) /* used for decoding S/MIME messages */
-#ifdef HAVE_PGP
-#undef M_CM_DECODE_CRYPT
+#define M_CM_DECODE_PGP (1<<8) /* used for decoding PGP messages */
+#define M_CM_DECODE_SMIME (1<<9) /* used for decoding S/MIME messages */
#define M_CM_DECODE_CRYPT (M_CM_DECODE_PGP | M_CM_DECODE_SMIME)
-#else
-#define M_CM_DECODE_CRYPT (1<<9) /* used for decoding S/MIME messages */
-#endif
-#endif
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
#define M_CM_VERIFY (1<<10) /* do signature verification */
-#endif
-
* Copyright (C) 1999-2000 Thomas Roessler <roessler@does-not-exist.org>
* Copyright (C) 2001 Thomas Roessler <roessler@does-not-exist.org>
* Oliver Ehli <elmy@acm.org>
+ * Copyright (C) 2003 Werner Koch <wk@gnupg.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include "mutt.h"
#include "mutt_curses.h"
-#include "mutt_crypt.h"
#include "mime.h"
#include "copy.h"
+#include "mutt_crypt.h"
#include <sys/wait.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
-#ifdef HAVE_PGP
-#include "pgp.h"
-#endif
-
-#ifdef HAVE_SMIME
-#include "smime.h"
-#endif
-
#ifdef HAVE_LOCALE_H
#include <locale.h>
#endif
# include <sys/resource.h>
#endif
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
-
/* print the current time to avoid spoofing of the signature output */
void crypt_current_time(STATE *s, char *app_name)
time_t t;
char p[STRING], tmp[STRING];
+ if (!WithCrypto)
+ return;
+
if (option (OPTCRYPTTIMESTAMP))
{
t = time(NULL);
void crypt_forget_passphrase (void)
{
-
-#ifdef HAVE_PGP
- pgp_void_passphrase ();
-#endif
+ if ((WithCrypto & APPLICATION_PGP))
+ crypt_pgp_void_passphrase ();
-#ifdef HAVE_SMIME
- smime_void_passphrase ();
-#endif
+ if ((WithCrypto & APPLICATION_SMIME))
+ crypt_smime_void_passphrase ();
- mutt_message _("Passphrase(s) forgotten.");
+ if (WithCrypto)
+ mutt_message _("Passphrase(s) forgotten.");
}
-# if defined(HAVE_SETRLIMIT) && (!defined(DEBUG))
+#if defined(HAVE_SETRLIMIT) && (!defined(DEBUG))
static void disable_coredumps (void)
{
}
}
-# endif /* HAVE_SETRLIMIT */
+#endif /* HAVE_SETRLIMIT */
int crypt_valid_passphrase(int flags)
disable_coredumps ();
# endif
-
-#ifdef HAVE_PGP
- if (flags & APPLICATION_PGP)
+ if ((WithCrypto & APPLICATION_PGP) && (flags & APPLICATION_PGP))
{
extern char PgpPass[STRING];
extern time_t PgpExptime;
+ if (pgp_use_gpg_agent())
+ {
+ *PgpPass = 0;
+ return 0; /* handled by gpg-agent */
+ }
+
if (now < PgpExptime) return 1; /* just use the cached copy. */
- pgp_void_passphrase ();
+ crypt_pgp_void_passphrase ();
- if (mutt_get_password (_("Enter PGP passphrase:"), PgpPass, sizeof (PgpPass)) == 0)
+ if (mutt_get_password (_("Enter PGP passphrase:"),
+ PgpPass, sizeof (PgpPass)) == 0)
{
PgpExptime = time (NULL) + PgpTimeout;
return (1);
else
PgpExptime = 0;
}
-#endif
-#ifdef HAVE_SMIME
- if (flags & APPLICATION_SMIME)
+
+ if ((WithCrypto & APPLICATION_SMIME) && (flags & APPLICATION_SMIME))
{
extern char SmimePass[STRING];
extern time_t SmimeExptime;
if (now < SmimeExptime) return (1);
- smime_void_passphrase ();
+ crypt_smime_void_passphrase ();
if (mutt_get_password (_("Enter SMIME passphrase:"), SmimePass,
sizeof (SmimePass)) == 0)
else
SmimeExptime = 0;
}
-#endif
+
return (0);
}
int mutt_protect (HEADER *msg, char *keylist)
{
BODY *pbody = NULL, *tmp_pbody = NULL;
-#ifdef HAVE_SMIME
BODY *tmp_smime_pbody = NULL;
-#endif
-#ifdef HAVE_PGP
BODY *tmp_pgp_pbody = NULL;
int traditional = 0;
- int flags = msg->security, i;
-#endif
+ int flags = (WithCrypto & APPLICATION_PGP)? msg->security: 0;
+ int i;
+
+ if (!WithCrypto)
+ return -1;
+
if ((msg->security & SIGN) && !crypt_valid_passphrase (msg->security))
return (-1);
-#ifdef HAVE_PGP
- if (msg->security & APPLICATION_PGP)
+ if ((WithCrypto & APPLICATION_PGP) && (msg->security & APPLICATION_PGP))
{
if ((msg->content->type == TYPETEXT) &&
!ascii_strcasecmp (msg->content->subtype, "plain"))
if (traditional)
{
if (!isendwin ()) mutt_endwin _("Invoking PGP...");
- if (!(pbody = pgp_traditional_encryptsign (msg->content, flags, keylist)))
+ if (!(pbody = crypt_pgp_traditional_encryptsign (msg->content, flags, keylist)))
return -1;
msg->content = pbody;
return 0;
}
}
-#endif
if (!isendwin ()) mutt_endwin (NULL);
-#ifdef HAVE_SMIME
- tmp_smime_pbody = msg->content;
-#endif
-
+ if ((WithCrypto & APPLICATION_SMIME))
+ tmp_smime_pbody = msg->content;
if (msg->security & SIGN)
{
-#ifdef HAVE_SMIME
- if (msg->security & APPLICATION_SMIME)
+ if ((WithCrypto & APPLICATION_SMIME)
+ && (msg->security & APPLICATION_SMIME))
{
- if (!(tmp_pbody = smime_sign_message (msg->content)))
+ if (!(tmp_pbody = crypt_smime_sign_message (msg->content)))
return -1;
pbody = tmp_smime_pbody = tmp_pbody;
}
-#endif
-#ifdef HAVE_PGP
- if ((msg->security & APPLICATION_PGP) &&
- (!(flags & ENCRYPT) || option (OPTPGPRETAINABLESIG)))
+
+ if ((WithCrypto & APPLICATION_PGP)
+ && (msg->security & APPLICATION_PGP)
+ && (!(flags & ENCRYPT) || option (OPTPGPRETAINABLESIG)))
{
- if (!(tmp_pbody = pgp_sign_message (msg->content)))
+ if (!(tmp_pbody = crypt_pgp_sign_message (msg->content)))
return -1;
flags &= ~SIGN;
pbody = tmp_pgp_pbody = tmp_pbody;
}
-#endif
-#if defined(HAVE_SMIME) && defined(HAVE_PGP)
- if ((msg->security & APPLICATION_SMIME) &&
- (msg->security & APPLICATION_PGP))
+ if (WithCrypto
+ && (msg->security & APPLICATION_SMIME)
+ && (msg->security & APPLICATION_PGP))
{
/* here comes the draft ;-) */
}
-#endif
}
if (msg->security & ENCRYPT)
{
-#ifdef HAVE_SMIME
- if (msg->security & APPLICATION_SMIME)
+ if ((WithCrypto & APPLICATION_SMIME)
+ && (msg->security & APPLICATION_SMIME))
{
- if (!(tmp_pbody = smime_build_smime_entity (tmp_smime_pbody, keylist)))
+ if (!(tmp_pbody = crypt_smime_build_smime_entity (tmp_smime_pbody,
+ keylist)))
{
/* signed ? free it! */
return (-1);
}
pbody = tmp_pbody;
}
-#endif
-#ifdef HAVE_PGP
- if (msg->security & APPLICATION_PGP)
+ if ((WithCrypto & APPLICATION_PGP)
+ && (msg->security & APPLICATION_PGP))
{
- if (!(pbody = pgp_encrypt_message (msg->content, keylist, flags & SIGN)))
+ if (!(pbody = crypt_pgp_encrypt_message (msg->content, keylist,
+ flags & SIGN)))
{
/* did we perform a retainable signature? */
mutt_free_body (&msg->content->next);
}
}
-#endif
}
if(pbody)
if (!(ascii_strcasecmp (p, "multipart/mixed")))
return SIGN;
-#ifdef HAVE_PGP
- if (!(ascii_strcasecmp (p, "application/pgp-signature")))
+ if ((WithCrypto & APPLICATION_PGP)
+ && !(ascii_strcasecmp (p, "application/pgp-signature")))
return PGPSIGN;
-#endif
-#ifdef HAVE_SMIME
- if (!(ascii_strcasecmp (p, "application/x-pkcs7-signature")))
+ if ((WithCrypto & APPLICATION_SMIME)
+ && !(ascii_strcasecmp (p, "application/x-pkcs7-signature")))
return SMIMESIGN;
- if (!(ascii_strcasecmp (p, "application/pkcs7-signature")))
+ if ((WithCrypto & APPLICATION_SMIME)
+ && !(ascii_strcasecmp (p, "application/pkcs7-signature")))
return SMIMESIGN;
-#endif
return 0;
}
int mutt_is_multipart_encrypted (BODY *b)
{
- int ret=0;
-#ifdef HAVE_PGP
- ret = pgp_is_multipart_encrypted (b);
-#endif
+ if ((WithCrypto & APPLICATION_PGP))
+ {
+ char *p;
+
+ if (!b || b->type != TYPEMULTIPART ||
+ !b->subtype || ascii_strcasecmp (b->subtype, "encrypted") ||
+ !(p = mutt_get_parameter ("protocol", b->parameter)) ||
+ ascii_strcasecmp (p, "application/pgp-encrypted"))
+ return 0;
+
+ return PGPENCRYPT;
+ }
+
+ return 0;
+}
+
+
+int mutt_is_application_pgp (BODY *m)
+{
+ int t = 0;
+ char *p;
+
+ if (m->type == TYPEAPPLICATION)
+ {
+ if (!ascii_strcasecmp (m->subtype, "pgp") || !ascii_strcasecmp (m->subtype, "x-pgp-message"))
+ {
+ if ((p = mutt_get_parameter ("x-action", m->parameter))
+ && (!ascii_strcasecmp (p, "sign") || !ascii_strcasecmp (p, "signclear")))
+ t |= PGPSIGN;
+
+ if ((p = mutt_get_parameter ("format", m->parameter)) &&
+ !ascii_strcasecmp (p, "keys-only"))
+ t |= PGPKEY;
+
+ if(!t) t |= PGPENCRYPT; /* not necessarily correct, but... */
+ }
+
+ if (!ascii_strcasecmp (m->subtype, "pgp-signed"))
+ t |= PGPSIGN;
+
+ if (!ascii_strcasecmp (m->subtype, "pgp-keys"))
+ t |= PGPKEY;
+ }
+ else if (m->type == TYPETEXT && ascii_strcasecmp ("plain", m->subtype) == 0)
+ {
+ if (((p = mutt_get_parameter ("x-mutt-action", m->parameter))
+ || (p = mutt_get_parameter ("x-action", m->parameter))
+ || (p = mutt_get_parameter ("action", m->parameter)))
+ && !ascii_strncasecmp ("pgp-sign", p, 8))
+ t |= PGPSIGN;
+ else if (p && !ascii_strncasecmp ("pgp-encrypt", p, 11))
+ t |= PGPENCRYPT;
+ else if (p && !ascii_strncasecmp ("pgp-keys", p, 7))
+ t |= PGPKEY;
+ }
+ return t;
+}
+
+int mutt_is_application_smime (BODY *m)
+{
+ char *t=NULL;
+ int len, complain=0;
+
+ if ((m->type & TYPEAPPLICATION) && m->subtype)
+ {
+ /* S/MIME MIME types don't need x- anymore, see RFC2311 */
+ if (!ascii_strcasecmp (m->subtype, "x-pkcs7-mime") ||
+ !ascii_strcasecmp (m->subtype, "pkcs7-mime"))
+ {
+ if ((t = mutt_get_parameter ("smime-type", m->parameter)))
+ {
+ if (!ascii_strcasecmp (t, "enveloped-data"))
+ return SMIMEENCRYPT;
+ else if (!ascii_strcasecmp (t, "signed-data"))
+ return (SMIMESIGN|SMIMEOPAQUE);
+ else return 0;
+ }
+ /* Netscape 4.7 uses
+ * Content-Description: S/MIME Encrypted Message
+ * instead of Content-Type parameter
+ */
+ if (!ascii_strcasecmp (m->description, "S/MIME Encrypted Message"))
+ return SMIMEENCRYPT;
+ complain = 1;
+ }
+ else if (ascii_strcasecmp (m->subtype, "octet-stream"))
+ return 0;
+
+ t = mutt_get_parameter ("name", m->parameter);
+
+ if (!t) t = m->d_filename;
+ if (!t) t = m->filename;
+ if (!t)
+ {
+ if (complain)
+ mutt_message (_("S/MIME messages with no hints on content are unsupported."));
+ return 0;
+ }
+
+ /* no .p7c, .p10 support yet. */
- return ret;
+ len = mutt_strlen (t) - 4;
+ if (len > 0 && *(t+len) == '.')
+ {
+ len++;
+ if (!ascii_strcasecmp ((t+len), "p7m"))
+#if 0
+ return SMIMEENCRYPT;
+#else
+ /* Not sure if this is the correct thing to do, but
+ it's required for compatibility with Outlook */
+ return (SMIMESIGN|SMIMEOPAQUE);
+#endif
+ else if (!ascii_strcasecmp ((t+len), "p7s"))
+ return (SMIMESIGN|SMIMEOPAQUE);
+ }
+ }
+
+ return 0;
}
+
+
int crypt_query (BODY *m)
{
int t = 0;
+ if (!WithCrypto)
+ return 0;
if (m->type == TYPEAPPLICATION)
{
-#ifdef HAVE_PGP
- t |= mutt_is_application_pgp(m);
-#endif
-#ifdef HAVE_SMIME
- t |= mutt_is_application_smime(m);
- if (t && m->goodsig) t |= GOODSIGN;
- if (t && m->badsig) t |= BADSIGN;
-#endif
+ if ((WithCrypto & APPLICATION_PGP))
+ t |= mutt_is_application_pgp(m);
+
+ if ((WithCrypto & APPLICATION_SMIME))
+ {
+ t |= mutt_is_application_smime(m);
+ if (t && m->goodsig) t |= GOODSIGN;
+ if (t && m->badsig) t |= BADSIGN;
+ }
}
-#ifdef HAVE_PGP
- else if (m->type == TYPETEXT)
+ else if ((WithCrypto & APPLICATION_PGP) && m->type == TYPETEXT)
{
t |= mutt_is_application_pgp (m);
if (t && m->goodsig)
t |= GOODSIGN;
}
-#endif
-
if (m->type == TYPEMULTIPART)
{
short hadcr;
size_t bytes;
+ if (!WithCrypto)
+ return -1;
+
if (!(fp = safe_fopen (tempfile, "w")))
{
mutt_perror (tempfile);
void convert_to_7bit (BODY *a)
{
+ if (!WithCrypto)
+ return;
+
while (a)
{
if (a->type == TYPEMULTIPART)
a->encoding = ENC7BIT;
convert_to_7bit(a->parts);
}
-#ifdef HAVE_PGP
- else if (option (OPTPGPSTRICTENC))
+ else if ((WithCrypto & APPLICATION_PGP) && option (OPTPGPSTRICTENC))
convert_to_7bit (a->parts);
-#endif
}
else if (a->type == TYPEMESSAGE &&
mutt_strcasecmp(a->subtype, "delivery-status"))
ADDRESS *tmp = NULL;
FILE *fpout;
+ if (!WithCrypto)
+ return;
+
mutt_mktemp (tempfname);
if (!(fpout = safe_fopen (tempfname, "w")))
{
return;
}
-#ifdef HAVE_PGP
- set_option (OPTDONTHANDLEPGPKEYS);
-#endif
+ if ((WithCrypto & APPLICATION_PGP))
+ set_option (OPTDONTHANDLEPGPKEYS);
if (!h)
{
fclose (fpout);
break;
}
-#ifdef HAVE_PGP
- if (Context->hdrs[Context->v2r[i]]->security & APPLICATION_PGP)
+
+ if ((WithCrypto & APPLICATION_PGP)
+ && (Context->hdrs[Context->v2r[i]]->security & APPLICATION_PGP))
{
mutt_copy_message (fpout, Context, Context->hdrs[Context->v2r[i]],
M_CM_DECODE|M_CM_CHARCONV, 0);
fflush(fpout);
mutt_endwin (_("Trying to extract PGP keys...\n"));
- pgp_invoke_import (tempfname);
+ crypt_pgp_invoke_import (tempfname);
}
-#endif
-#ifdef HAVE_SMIME
- if (Context->hdrs[Context->v2r[i]]->security & APPLICATION_SMIME)
+
+ if ((WithCrypto & APPLICATION_SMIME)
+ && (Context->hdrs[Context->v2r[i]]->security & APPLICATION_SMIME))
{
if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT)
mutt_copy_message (fpout, Context, Context->hdrs[Context->v2r[i]],
- M_CM_NOHEADER|M_CM_DECODE_CRYPT|M_CM_DECODE_SMIME, 0);
+ M_CM_NOHEADER|M_CM_DECODE_CRYPT
+ |M_CM_DECODE_SMIME, 0);
else
mutt_copy_message (fpout, Context,
Context->hdrs[Context->v2r[i]], 0, 0);
if (Context->hdrs[Context->v2r[i]]->env->from)
tmp = mutt_expand_aliases (h->env->from);
else if (Context->hdrs[Context->v2r[i]]->env->sender)
- tmp = mutt_expand_aliases (Context->hdrs[Context->v2r[i]]->env->sender);
+ tmp = mutt_expand_aliases (Context->hdrs[Context->v2r[i]]
+ ->env->sender);
mbox = tmp ? tmp->mailbox : NULL;
if (mbox)
{
mutt_endwin (_("Trying to extract S/MIME certificates...\n"));
- smime_invoke_import (tempfname, mbox);
+ crypt_smime_invoke_import (tempfname, mbox);
tmp = NULL;
}
}
-#endif
+
rewind (fpout);
}
}
mutt_parse_mime_message (Context, h);
if (!(h->security & ENCRYPT && !crypt_valid_passphrase (h->security)))
{
-#ifdef HAVE_PGP
- if (h->security & APPLICATION_PGP)
+ if ((WithCrypto & APPLICATION_PGP)
+ && (h->security & APPLICATION_PGP))
{
mutt_copy_message (fpout, Context, h, M_CM_DECODE|M_CM_CHARCONV, 0);
fflush(fpout);
mutt_endwin (_("Trying to extract PGP keys...\n"));
- pgp_invoke_import (tempfname);
+ crypt_pgp_invoke_import (tempfname);
}
-#endif
-#ifdef HAVE_SMIME
- if (h->security & APPLICATION_SMIME)
+
+ if ((WithCrypto & APPLICATION_SMIME)
+ && (h->security & APPLICATION_SMIME))
{
if (h->security & ENCRYPT)
- mutt_copy_message (fpout, Context, h, M_CM_NOHEADER|M_CM_DECODE_CRYPT|M_CM_DECODE_SMIME, 0);
+ mutt_copy_message (fpout, Context, h, M_CM_NOHEADER
+ |M_CM_DECODE_CRYPT
+ |M_CM_DECODE_SMIME, 0);
else
mutt_copy_message (fpout, Context, h, 0, 0);
if (mbox) /* else ? */
{
mutt_message (_("Trying to extract S/MIME certificates...\n"));
- smime_invoke_import (tempfname, mbox);
+ crypt_smime_invoke_import (tempfname, mbox);
}
}
-#endif
}
}
mutt_unlink (tempfname);
-#ifdef HAVE_PGP
- unset_option (OPTDONTHANDLEPGPKEYS);
-#endif
+ if ((WithCrypto & APPLICATION_PGP))
+ unset_option (OPTDONTHANDLEPGPKEYS);
}
* keys if the user has requested this service.
*/
-#ifdef HAVE_SMIME
- extern char *smime_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc);
-#endif
-#ifdef HAVE_PGP
- extern char *pgp_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc);
+ if (!WithCrypto)
+ return 0;
+ if ((WithCrypto & APPLICATION_PGP))
set_option (OPTPGPCHECKTRUST);
-#endif
-
- *keylist = NULL;
-
+ *keylist = NULL;
- if (msg->security & ENCRYPT)
- {
-#ifdef HAVE_PGP
- if (msg->security & APPLICATION_PGP)
- {
- if ((*keylist = pgp_findKeys (msg->env->to, msg->env->cc,
- msg->env->bcc)) == NULL)
- return (-1);
- unset_option (OPTPGPCHECKTRUST);
- }
-#endif
-#ifdef HAVE_SMIME
- if (msg->security & APPLICATION_SMIME)
- {
- if ((*keylist = smime_findKeys (msg->env->to, msg->env->cc,
- msg->env->bcc)) == NULL)
- return (-1);
- }
-#endif
- }
+ if (msg->security & ENCRYPT)
+ {
+ if ((WithCrypto & APPLICATION_PGP)
+ && (msg->security & APPLICATION_PGP))
+ {
+ if ((*keylist = crypt_pgp_findkeys (msg->env->to, msg->env->cc,
+ msg->env->bcc)) == NULL)
+ return (-1);
+ unset_option (OPTPGPCHECKTRUST);
+ }
+ if ((WithCrypto & APPLICATION_SMIME)
+ && (msg->security & APPLICATION_SMIME))
+ {
+ if ((*keylist = crypt_smime_findkeys (msg->env->to, msg->env->cc,
+ msg->env->bcc)) == NULL)
+ return (-1);
+ }
+ }
- return (0);
+ return (0);
}
static void crypt_fetch_signatures (BODY ***signatures, BODY *a, int *n)
{
+ if (!WithCrypto)
+ return;
+
for (; a; a = a->next)
{
if (a->type == TYPEMULTIPART)
int i;
short goodsig = 1;
+ if (!WithCrypto)
+ return;
+
protocol = mutt_get_parameter ("protocol", a->parameter);
a = a->parts;
if (!(a && a->next && a->next->type == protocol_major &&
!mutt_strcasecmp (a->next->subtype, protocol_minor)))
{
- state_attach_puts (_("[-- Error: Inconsistent multipart/signed structure! --]\n\n"), s);
+ state_attach_puts (_("[-- Error: "
+ "Inconsistent multipart/signed structure! --]\n\n"),
+ s);
mutt_body_handler (a, s);
return;
}
-#ifdef HAVE_PGP
- if (protocol_major == TYPEAPPLICATION &&
- !mutt_strcasecmp (protocol_minor, "pgp-signature"));
-#endif
-#if defined(HAVE_PGP) && defined(HAVE_SMIME)
- else
-#endif
-#ifdef HAVE_SMIME
- if (protocol_major == TYPEAPPLICATION &&
- !mutt_strcasecmp (protocol_minor, "x-pkcs7-signature"));
-
-#endif
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- else
-#endif
- if (protocol_major == TYPEMULTIPART &&
- !mutt_strcasecmp (protocol_minor, "mixed"));
-
+ if ((WithCrypto & APPLICATION_PGP)
+ && protocol_major == TYPEAPPLICATION
+ && !mutt_strcasecmp (protocol_minor, "pgp-signature"))
+ ;
+ else if ((WithCrypto & APPLICATION_SMIME)
+ && protocol_major == TYPEAPPLICATION
+ && !mutt_strcasecmp (protocol_minor, "x-pkcs7-signature"))
+ ;
+ else if (protocol_major == TYPEMULTIPART
+ && !mutt_strcasecmp (protocol_minor, "mixed"))
+ ;
else
{
- state_printf (s, _("[-- Error: Unknown multipart/signed protocol %s! --]\n\n"), protocol);
+ state_printf (s, _("[-- Error: "
+ "Unknown multipart/signed protocol %s! --]\n\n"),
+ protocol);
mutt_body_handler (a, s);
return;
}
{
for (i = 0; i < sigcnt; i++)
{
-#ifdef HAVE_PGP
- if (signatures[i]->type == TYPEAPPLICATION
+ if ((WithCrypto & APPLICATION_PGP)
+ && signatures[i]->type == TYPEAPPLICATION
&& !mutt_strcasecmp (signatures[i]->subtype, "pgp-signature"))
{
- if (pgp_verify_one (signatures[i], s, tempfile) != 0)
+ if (crypt_pgp_verify_one (signatures[i], s, tempfile) != 0)
goodsig = 0;
continue;
}
-#endif
-#ifdef HAVE_SMIME
- if (signatures[i]->type == TYPEAPPLICATION
+
+ if ((WithCrypto & APPLICATION_SMIME)
+ && signatures[i]->type == TYPEAPPLICATION
&& !mutt_strcasecmp(signatures[i]->subtype, "x-pkcs7-signature"))
{
- if (smime_verify_one (signatures[i], s, tempfile) != 0)
+ if (crypt_smime_verify_one (signatures[i], s, tempfile) != 0)
goodsig = 0;
continue;
}
-#endif
- state_printf (s, _("[-- Warning: We can't verify %s/%s signatures. --]\n\n"),
+
+ state_printf (s, _("[-- Warning: "
+ "We can't verify %s/%s signatures. --]\n\n"),
TYPE(signatures[i]), signatures[i]->subtype);
}
}
}
-
-#endif
--- /dev/null
+/*
+ * Copyright (C) 2003 Werner Koch <wk@gnupg.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ */
+
+/*
+ This file dispatches the generic crytpo functions to the implemented
+ backend or provides dummy stubs. Note, that some generic functions are
+ handled in crypt.c.
+*/
+
+#include "mutt.h"
+#include "mutt_crypt.h"
+
+/* Make sure those macros are not defined. */
+#undef BFNC_PGP_VOID_PASSPHRASE
+#undef BFNC_PGP_DECRYPT_MIME
+#undef BFNC_PGP_APPLICATION_PGP_HANDLER
+#undef BFNC_PGP_ENCRYPTED_HANDLER
+#undef BFNC_PGP_INVOKE_GETKEYS
+#undef BFNC_PGP_ASK_FOR_KEY
+#undef BNFC_PGP_CHECK_TRADITIONAL
+#undef BFNC_PGP_TRADITIONAL_ENCRYPTSIGN
+#undef BFNC_PGP_FREE_KEY
+#undef BFNC_PGP_MAKE_KEY_ATTACHMENT
+#undef BFNC_PGP_FINDKEYS
+#undef BFNC_PGP_SIGN_MESSAGE
+#undef BFNC_PGP_ENCRYPT_MESSAGE
+#undef BFNC_PGP_INVOKE_IMPORT
+#undef BFNC_PGP_VERIFY_ONE
+#undef BFNC_PGP_KEYID
+#undef BFNC_PGP_EXTRACT_KEYS_FROM_ATTACHMENT_LIST
+
+#undef BFNC_SMIME_VOID_PASSPHRASE
+#undef BFNC_SMIME_DECRYPT_MIME
+#undef BFNC_SMIME_APPLICATION_SMIME_HANDLER
+#undef BFNC_SMIME_GETKEYS
+#undef BFNC_SMIME_VERIFY_SENDER
+#undef BFNC_SMIME_ASK_FOR_KEY
+#undef BFNC_SMIME_FINDKEYS
+#undef BFNC_SMIME_SIGN_MESSAGE
+#undef BFNC_SMIME_BUILD_SMIME_ENTITY
+#undef BFNC_SMIME_INVOKE_IMPORT
+#undef BFNC_SMIME_VERIFY_ONE
+
+
+/* The PGP backend */
+#if defined (CRYPT_BACKEND_CLASSIC_PGP)
+# include "pgp.h"
+# define BFNC_PGP_VOID_PASSPHRASE pgp_void_passphrase
+# define BFNC_PGP_DECRYPT_MIME pgp_decrypt_mime
+# define BFNC_PGP_APPLICATION_PGP_HANDLER pgp_application_pgp_handler
+# define BFNC_PGP_ENCRYPTED_HANDLER pgp_encrypted_handler
+# define BFNC_PGP_INVOKE_GETKEYS pgp_invoke_getkeys
+# define BFNC_PGP_ASK_FOR_KEY pgp_ask_for_key
+# define BNFC_PGP_CHECK_TRADITIONAL pgp_check_traditional
+# define BFNC_PGP_TRADITIONAL_ENCRYPTSIGN pgp_traditional_encryptsign
+# define BFNC_PGP_FREE_KEY pgp_free_key
+# define BFNC_PGP_MAKE_KEY_ATTACHMENT pgp_make_key_attachment
+# define BFNC_PGP_FINDKEYS pgp_findKeys
+# define BFNC_PGP_SIGN_MESSAGE pgp_sign_message
+# define BFNC_PGP_ENCRYPT_MESSAGE pgp_encrypt_message
+# define BFNC_PGP_INVOKE_IMPORT pgp_invoke_import
+# define BFNC_PGP_VERIFY_ONE pgp_verify_one
+# define BFNC_PGP_KEYID pgp_keyid
+# define BFNC_PGP_EXTRACT_KEYS_FROM_ATTACHMENT_LIST \
+ pgp_extract_keys_from_attachment_list
+
+
+#elif defined (CRYPT_BACKEND_GPGME)
+# include "crypt-gpgme.h"
+# define BFNC_PGP_VOID_PASSPHRASE NULL /* not required */
+# define BFNC_PGP_DECRYPT_MIME gpg_pgp_decrypt_mime
+
+#endif /* PGP backend */
+
+
+/* The SMIME backend */
+#ifdef CRYPT_BACKEND_CLASSIC_SMIME
+# include "smime.h"
+# define BFNC_SMIME_VOID_PASSPHRASE smime_void_passphrase
+# define BFNC_SMIME_DECRYPT_MIME smime_decrypt_mime
+# define BFNC_SMIME_APPLICATION_SMIME_HANDLER smime_application_smime_handler
+# define BFNC_SMIME_GETKEYS smime_getkeys
+# define BFNC_SMIME_VERIFY_SENDER smime_verify_sender
+# define BFNC_SMIME_ASK_FOR_KEY smime_ask_for_key
+# define BFNC_SMIME_FINDKEYS smime_findKeys
+# define BFNC_SMIME_SIGN_MESSAGE smime_sign_message
+# define BFNC_SMIME_BUILD_SMIME_ENTITY smime_build_smime_entity
+# define BFNC_SMIME_INVOKE_IMPORT smime_invoke_import
+# define BFNC_SMIME_VERIFY_ONE smime_verify_one
+
+#elif defined (CRYPT_BACKEND_GPGME)
+ /* Already included above (gpgme supports both). */
+# define BFNC_SMIME_VOID_PASSPHRASE NULL /* not required */
+
+#endif /* SMIME backend */
+
+\f
+/*
+
+ Generic
+
+*/
+
+/* Show a message that a backend will be invoked. */
+void crypt_invoke_message (int type)
+{
+#if defined (CRYPT_BACKEND_CLASSIC_PGP) || defined(CRYPT_BACKEND_CLASSIC_SMIME)
+ if ((type & APPLICATION_PGP))
+ mutt_message _("Invoking PGP...");
+ if ((type & APPLICATION_SMIME))
+ mutt_message _("Invoking OpenSSL...");
+#elif defined (CRYPT_BACKEND_GPGME)
+ if ((type & APPLICATION_PGP) || (type & APPLICATION_SMIME) )
+ mutt_message _("Invoking GnuPG...");
+#endif
+}
+
+
+\f
+/*
+
+ PGP
+
+*/
+
+
+/* Reset a PGP passphrase */
+void crypt_pgp_void_passphrase (void)
+{
+#ifdef BFNC_PGP_VOID_PASSPHRASE
+ BFNC_PGP_VOID_PASSPHRASE ();
+#endif
+}
+
+/* Decrypt a PGP/MIME message. */
+int crypt_pgp_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d)
+{
+#ifdef BFNC_PGP_DECRYPT_MIME
+ return BFNC_PGP_DECRYPT_MIME (a, b, c, d);
+#else
+ return -1; /* error */
+#endif
+}
+
+/* MIME handler for the application/pgp content-type. */
+void crypt_pgp_application_pgp_handler (BODY *m, STATE *s)
+{
+#ifdef BFNC_PGP_APPLICATION_PGP_HANDLER
+ BFNC_PGP_APPLICATION_PGP_HANDLER (m, s);
+#endif
+}
+
+/* MIME handler for an PGP/MIME encrypted message. */
+void crypt_pgp_encrypted_handler (BODY *a, STATE *s)
+{
+#ifdef BFNC_PGP_ENCRYPTED_HANDLER
+ BFNC_PGP_ENCRYPTED_HANDLER (a, s);
+#endif
+}
+
+/* fixme: needs documentation. */
+void crypt_pgp_invoke_getkeys (ADDRESS *addr)
+{
+#ifdef BFNC_PGP_INVOKE_GETKEYS
+ BFNC_PGP_INVOKE_GETKEYS (addr);
+#endif
+}
+
+/* Ask for a PGP key. */
+pgp_key_t crypt_pgp_ask_for_key (char *tag, char *whatfor,
+ short abilities, pgp_ring_t keyring)
+{
+#ifdef BFNC_PGP_ASK_FOR_KEY
+ return BFNC_PGP_ASK_FOR_KEY (tag, whatfor, abilities, keyring);
+#else
+ return NULL;
+#endif
+}
+
+
+/* Check for a traditional PGP message in body B. */
+int crypt_pgp_check_traditional (FILE *fp, BODY *b, int tagged_only)
+{
+#ifdef BFNC_PGP_CHECK_TRADITIONAL
+ return BNFC_PGP_CHECK_TRADITIONAL (fp, b, tagged_only);
+#else
+ return 0; /* no */
+#endif
+}
+
+/* fixme: needs documentation. */
+BODY *crypt_pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
+{
+#ifdef BFNC_PGP_TRADITIONAL_ENCRYPTSIGN
+ return BFNC_PGP_TRADITIONAL_ENCRYPTSIGN (a, flags, keylist);
+#else
+ return NULL;
+#endif
+}
+
+/* Release pgp key KPP. */
+void crypt_pgp_free_key (pgp_key_t *kpp)
+{
+#ifdef BFNC_PGP_FREE_KEY
+ BFNC_PGP_FREE_KEY (kpp);
+#endif
+}
+
+
+/* Generate a PGP public key attachment. */
+BODY *crypt_pgp_make_key_attachment (char *tempf)
+{
+#ifdef BFNC_PGP_MAKE_KEY_ATTACHMENT
+ return BFNC_PGP_MAKE_KEY_ATTACHMENT (tempf);
+#else
+ return NULL; /* error */
+#endif
+}
+
+/* This routine attempts to find the keyids of the recipients of a
+ message. It returns NULL if any of the keys can not be found. */
+char *crypt_pgp_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
+{
+#ifdef BFNC_PGP_FINDKEYS
+ return BFNC_PGP_FINDKEYS (to, cc, bcc);
+#else
+ return NULL;
+#endif
+}
+
+/* Create a new body with a PGP signed message from A. */
+BODY *crypt_pgp_sign_message (BODY *a)
+{
+#ifdef BFNC_PGP_SIGN_MESSAGE
+ return BFNC_PGP_SIGN_MESSAGE (a);
+#else
+ return NULL;
+#endif
+}
+
+/* Warning: A is no longer freed in this routine, you need to free it
+ later. This is necessary for $fcc_attach. */
+BODY *crypt_pgp_encrypt_message (BODY *a, char *keylist, int sign)
+{
+#ifdef BFNC_PGP_ENCRYPT_MESSAGE
+ return BFNC_PGP_ENCRYPT_MESSAGE (a, keylist, sign);
+#else
+ return NULL;
+#endif
+}
+
+/* Invoke the PGP command to import a key. */
+void crypt_pgp_invoke_import (const char *fname)
+{
+#ifdef BFNC_PGP_INVOKE_IMPORT
+ BFNC_PGP_INVOKE_IMPORT (fname);
+#endif
+}
+
+/* fixme: needs documentation */
+int crypt_pgp_verify_one (BODY *sigbdy, STATE *s, const char *tempf)
+{
+#ifdef BFNC_PGP_VERIFY_ONE
+ return BFNC_PGP_VERIFY_ONE (sigbdy, s, tempf);
+#else
+ return -1;
+#endif
+}
+
+
+/* Access the keyID in K. */
+char *crypt_pgp_keyid (pgp_key_t k)
+{
+#ifdef BFNC_PGP_KEYID
+ return pgp_keyid (k);
+#else
+ return "?";
+#endif
+}
+
+/* fixme: needs documentation */
+void crypt_pgp_extract_keys_from_attachment_list (FILE *fp, int tag, BODY *top)
+{
+#ifdef BFNC_PGP_EXTRACT_KEYS_FROM_ATTACHMENT_LIST
+ BFNC_PGP_EXTRACT_KEYS_FROM_ATTACHMENT_LIST (fp, tag, top);
+#endif
+}
+
+
+\f
+/*
+
+ S/MIME
+
+*/
+
+
+/* Reset an SMIME passphrase */
+void crypt_smime_void_passphrase (void)
+{
+#ifdef BFNC_SMIME_VOID_PASSPHRASE
+ BFNC_SMIME_VOID_PASSPHRASE ();
+#endif
+}
+
+
+/* Decrypt am S/MIME message. */
+int crypt_smime_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d)
+{
+#ifdef BFNC_SMIME_DECRYPT_MIME
+ return BFNC_SMIME_DECRYPT_MIME (a, b, c, d);
+#else
+ return -1; /* error */
+#endif
+}
+
+/* MIME handler for the application/smime content-type. */
+void crypt_smime_application_smime_handler (BODY *m, STATE *s)
+{
+#ifdef BFNC_SMIME_APPLICATION_SMIME_HANDLER
+ BFNC_SMIME_APPLICATION_SMIME_HANDLER (m, s);
+#endif
+}
+
+/* fixme: Needs documentation. */
+void crypt_smime_getkeys (ENVELOPE *env)
+{
+#ifdef BFNC_SMIME_GETKEYS
+ BFNC_SMIME_GETKEYS (env);
+#endif
+}
+
+/* Check that the sender matches. */
+int crypt_smime_verify_sender(HEADER *h)
+{
+#ifdef BFNC_SMIME_VERIFY_SENDER
+ return BFNC_SMIME_VERIFY_SENDER (h);
+#else
+ return 1; /* yes */
+#endif
+}
+
+/* Ask for an SMIME key. */
+char *crypt_smime_ask_for_key (char *prompt, char *mailbox, short public)
+{
+#ifdef BFNC_SMIME_ASK_FOR_KEY
+ return BFNC_SMIME_ASK_FOR_KEY (prompt, mailbox, public);
+#else
+ return NULL; /* error */
+#endif
+}
+
+
+/* This routine attempts to find the keyids of the recipients of a
+ message. It returns NULL if any of the keys can not be found. */
+char *crypt_smime_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
+{
+#ifdef BFNC_SMIME_FINDKEYS
+ return BFNC_SMIME_FINDKEYS (to, cc, bcc);
+#else
+ return NULL;
+#endif
+}
+
+/* fixme: Needs documentation. */
+BODY *crypt_smime_sign_message (BODY *a)
+{
+#ifdef BFNC_SMIME_SIGN_MESSAGE
+ return BFNC_SMIME_SIGN_MESSAGE (a);
+#else
+ return NULL;
+#endif
+}
+
+/* fixme: needs documentation. */
+BODY *crypt_smime_build_smime_entity (BODY *a, char *certlist)
+{
+#ifdef BFNC_SMIME_BUILD_SMIME_ENTITY
+ return BFNC_SMIME_BUILD_SMIME_ENTITY (a, certlist);
+#else
+ return NULL;
+#endif
+}
+
+/* Add a certificate and update index file (externally). */
+void crypt_smime_invoke_import (char *infile, char *mailbox)
+{
+#ifdef BFNC_SMIME_INVOKE_IMPORT
+ BFNC_SMIME_INVOKE_IMPORT (infile, mailbox);
+#endif
+}
+
+/* fixme: needs documentation */
+int crypt_smime_verify_one (BODY *sigbdy, STATE *s, const char *tempf)
+{
+#ifdef BFNC_SMIME_VERIFY_ONE
+ return BFNC_SMIME_VERIFY_ONE (sigbdy, s, tempf);
+#else
+ return -1;
+#endif
+}
#include "imap.h"
#endif
-
-
-#ifdef HAVE_PGP
-#include "pgp.h"
-#endif
-
-#ifdef HAVE_SMIME
-#include "smime.h"
-#endif
-
-
-
-
-
-
-
-
+#include "mutt_crypt.h"
#include <ctype.h>
menu->redraw = REDRAW_MOTION;
break;
+ case OP_DECRYPT_COPY:
+ case OP_DECRYPT_SAVE:
+ if (!WithCrypto)
+ break;
+ /* fall thru */
case OP_COPY_MESSAGE:
case OP_SAVE:
case OP_DECODE_COPY:
case OP_DECODE_SAVE:
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- case OP_DECRYPT_COPY:
- case OP_DECRYPT_SAVE:
-#endif
CHECK_MSGCOUNT;
CHECK_VISIBLE;
if (mutt_save_message (tag ? NULL : CURHDR,
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
(op == OP_DECRYPT_SAVE) ||
-#endif
(op == OP_SAVE) || (op == OP_DECODE_SAVE),
(op == OP_DECODE_SAVE) || (op == OP_DECODE_COPY),
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
(op == OP_DECRYPT_SAVE) || (op == OP_DECRYPT_COPY) ||
-#endif
0,
&menu->redraw) == 0 &&
- (op == OP_SAVE || op == OP_DECODE_SAVE
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- || op == OP_DECRYPT_SAVE
-#endif
- ))
+ (op == OP_SAVE || op == OP_DECODE_SAVE || op == OP_DECRYPT_SAVE)
+ )
{
if (tag)
menu->redraw |= REDRAW_INDEX;
break;
-
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
case OP_FORGET_PASSPHRASE:
-
crypt_forget_passphrase ();
break;
-#endif /* HAVE_PGP */
-
-
case OP_GROUP_REPLY:
menu->redraw = REDRAW_FULL;
break;
-
-
-
-
-
-
-#ifdef HAVE_PGP
case OP_MAIL_KEY:
-
+ if (!(WithCrypto & APPLICATION_PGP))
+ break;
CHECK_ATTACH;
ci_send_message (SENDKEY, NULL, NULL, NULL, NULL);
menu->redraw = REDRAW_FULL;
break;
-#endif /* HAVE_PGP */
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
case OP_EXTRACT_KEYS:
-
+ if (!WithCrypto)
+ break;
CHECK_MSGCOUNT;
CHECK_VISIBLE;
crypt_extract_keys_from_messages(tag ? NULL : CURHDR);
menu->redraw = REDRAW_FULL;
break;
-#endif /* HAVE_PGP || HAVE_SMIME */
-#ifdef HAVE_PGP
case OP_CHECK_TRADITIONAL:
-
+ if (!(WithCrypto & APPLICATION_PGP))
+ break;
CHECK_MSGCOUNT;
CHECK_VISIBLE;
mutt_check_traditional_pgp (tag ? NULL : CURHDR, &menu->redraw);
}
break;
-#endif /* HAVE_PGP */
-
-
-
-
-
-
-
case OP_PIPE:
CHECK_MSGCOUNT;
{ "parent-message", OP_MAIN_PARENT_MESSAGE, "P" },
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
{ "extract-keys", OP_EXTRACT_KEYS, "\013" },
{ "forget-passphrase", OP_FORGET_PASSPHRASE, "\006" },
-#ifdef HAVE_PGP
{ "check-traditional-pgp", OP_CHECK_TRADITIONAL, "\033P" },
{ "mail-key", OP_MAIL_KEY, "\033k" },
-#endif
{ "decrypt-copy", OP_DECRYPT_COPY, NULL },
{ "decrypt-save", OP_DECRYPT_SAVE, NULL },
-#endif
-
{ NULL, 0, NULL }
-#ifdef HAVE_PGP
- { "check-traditional-pgp", OP_CHECK_TRADITIONAL, "\033P" },
+ { "check-traditional-pgp", OP_CHECK_TRADITIONAL, "\033P" },
{ "mail-key", OP_MAIL_KEY, "\033k" },
-#endif
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
{ "extract-keys", OP_EXTRACT_KEYS, "\013" },
{ "forget-passphrase",OP_FORGET_PASSPHRASE, "\006" },
- { "decrypt-copy", OP_DECRYPT_COPY, NULL },
- { "decrypt-save", OP_DECRYPT_SAVE, NULL },
-#endif
-
-
+ { "decrypt-copy", OP_DECRYPT_COPY, NULL },
+ { "decrypt-save", OP_DECRYPT_SAVE, NULL },
{ NULL, 0, NULL }
{ "delete-entry", OP_DELETE, "d" },
{ "undelete-entry", OP_UNDELETE, "u" },
{ "collapse-parts", OP_ATTACH_COLLAPSE, "v" },
-
-#ifdef HAVE_PGP
{ "check-traditional-pgp", OP_CHECK_TRADITIONAL, "\033P" },
-#endif
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
{ "extract-keys", OP_EXTRACT_KEYS, "\013" },
{ "forget-passphrase", OP_FORGET_PASSPHRASE, "\006" },
-#endif
-
-
{ NULL, 0, NULL }
};
{ "send-message", OP_COMPOSE_SEND_MESSAGE, "y" },
{ "pipe-entry", OP_PIPE, "|" },
-#ifdef HAVE_PGP
{ "attach-key", OP_COMPOSE_ATTACH_KEY, "\033k" },
{ "pgp-menu", OP_COMPOSE_PGP_MENU, "p" },
-#endif
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
{ "forget-passphrase",OP_FORGET_PASSPHRASE, "\006" },
-#endif
-#ifdef HAVE_SMIME
{ "smime-menu", OP_COMPOSE_SMIME_MENU, "S" },
-#endif
#ifdef MIXMASTER
{ "mix", OP_COMPOSE_MIX, "M" },
-#ifdef HAVE_PGP
struct binding_t OpPgp[] = {
{ "verify-key", OP_VERIFY_KEY, "c" },
{ "view-name", OP_VIEW_ID, "%" },
{ NULL, 0, NULL }
};
-#endif /* HAVE_PGP */
-#ifdef HAVE_SMIME
/* Don't know an useful key binding yet. But. just in case, adding this already */
struct binding_t OpSmime[] = {
{ NULL, 0, NULL }
};
-#endif
#ifdef MIXMASTER
struct binding_t OpMix[] = {
WHERE ALIAS *Aliases INITVAL (0);
WHERE LIST *UserHeader INITVAL (0);
+/*-- formerly in pgp.h --*/
+WHERE REGEXP PgpGoodSign;
+WHERE char *PgpSignAs;
+WHERE short PgpTimeout;
+WHERE char *PgpEntryFormat;
+WHERE char *PgpClearSignCommand;
+WHERE char *PgpDecodeCommand;
+WHERE char *PgpVerifyCommand;
+WHERE char *PgpDecryptCommand;
+WHERE char *PgpSignCommand;
+WHERE char *PgpEncryptSignCommand;
+WHERE char *PgpEncryptOnlyCommand;
+WHERE char *PgpImportCommand;
+WHERE char *PgpExportCommand;
+WHERE char *PgpVerifyKeyCommand;
+WHERE char *PgpListSecringCommand;
+WHERE char *PgpListPubringCommand;
+WHERE char *PgpGetkeysCommand;
+
+/*-- formerly in smime.h --*/
+WHERE char *SmimeDefaultKey;
+WHERE char *SmimeCryptAlg;
+WHERE short SmimeTimeout;
+WHERE char *SmimeCertificates;
+WHERE char *SmimeKeys;
+WHERE char *SmimeCryptAlg;
+WHERE char *SmimeCALocation;
+WHERE char *SmimeVerifyCommand;
+WHERE char *SmimeVerifyOpaqueCommand;
+WHERE char *SmimeDecryptCommand;
+WHERE char *SmimeSignCommand;
+WHERE char *SmimeSignOpaqueCommand;
+WHERE char *SmimeEncryptCommand;
+WHERE char *SmimeGetSignerCertCommand;
+WHERE char *SmimePk7outCommand;
+WHERE char *SmimeGetCertCommand;
+WHERE char *SmimeImportCertCommand;
+WHERE char *SmimeGetCertEmailCommand;
+
+
+
#ifdef DEBUG
WHERE FILE *debugfile INITVAL (0);
WHERE int debuglevel INITVAL (0);
#include "mutt_regex.h"
#include "buffy.h"
#include "sort.h"
-#ifdef HAVE_PGP
-#include "pgp.h"
-#endif
-#ifdef HAVE_SMIME
-#include "smime.h"
-#endif
+#include "crypt.h"
#endif /* MAIN_C */
}
}
-static pgp_key_t *parse_pub_line (char *buf, int *is_subkey, pgp_key_t *k)
+static pgp_key_t parse_pub_line (char *buf, int *is_subkey, pgp_key_t k)
{
pgp_uid_t *uid = NULL;
int field = 0, is_uid = 0;
return NULL;
if (!(is_uid || (*is_subkey && option (OPTPGPIGNORESUB))))
- k = safe_calloc (sizeof (pgp_key_t), 1);
+ k = safe_calloc (sizeof *k, 1);
break;
}
return k;
}
-pgp_key_t *pgp_get_candidates (pgp_ring_t keyring, LIST * hints)
+pgp_key_t pgp_get_candidates (pgp_ring_t keyring, LIST * hints)
{
FILE *fp;
pid_t thepid;
char buf[LONG_STRING];
- pgp_key_t *db = NULL, **kend, *k = NULL, *kk, *mainkey = NULL;
+ pgp_key_t db = NULL, *kend, k = NULL, kk, mainkey = NULL;
int is_sub;
int devnull;
#include "mime.h"
#include "copy.h"
#include "charset.h"
-
-
-
-#ifdef HAVE_PGP
-#include "pgp.h"
-#endif
-
-#ifdef HAVE_SMIME
-#include "smime.h"
-#endif
+#include "mutt_crypt.h"
#define BUFI_SIZE 1000
return (1);
else if (a->type == TYPEMULTIPART)
{
+ BODY *p;
-
-
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- if (ascii_strcasecmp (a->subtype, "signed") == 0 ||
- ascii_strcasecmp (a->subtype, "encrypted") == 0)
- return (1);
- else
-#endif
-
-
-
+ if (WithCrypto)
{
- BODY *p;
+ if (ascii_strcasecmp (a->subtype, "signed") == 0 ||
+ ascii_strcasecmp (a->subtype, "encrypted") == 0)
+ return (1);
+ }
- for (p = a->parts; p; p = p->next)
- {
- if (mutt_can_decode (p))
- return (1);
- }
+ for (p = a->parts; p; p = p->next)
+ {
+ if (mutt_can_decode (p))
+ return (1);
}
+
}
-
-
-
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- else if (a->type == TYPEAPPLICATION)
+ else if (WithCrypto && a->type == TYPEAPPLICATION)
{
-#ifdef HAVE_PGP
- if (mutt_is_application_pgp(a))
+ if ((WithCrypto & APPLICATION_PGP) && mutt_is_application_pgp(a))
return (1);
-#ifdef HAVE_SMIME
- if (mutt_is_application_smime(a))
+ if ((WithCrypto & APPLICATION_SMIME) && mutt_is_application_smime(a))
return (1);
-#endif
-#endif
}
-#endif
-
-
-
-
return (0);
}
/* avoid copying this part twice since removing the transfer-encoding is
* the only operation needed.
*/
-#ifdef HAVE_PGP
- if (mutt_is_application_pgp (b))
- handler = pgp_application_pgp_handler;
- else
-#endif
- if (ascii_strcasecmp ("flowed", mutt_get_parameter ("format", b->parameter)) == 0)
+ if ((WithCrypto & APPLICATION_PGP) && mutt_is_application_pgp (b))
+ handler = crypt_pgp_application_pgp_handler;
+ else if (ascii_strcasecmp ("flowed", mutt_get_parameter ("format", b->parameter)) == 0)
handler = text_plain_flowed_handler;
else
plaintext = 1;
}
else if (b->type == TYPEMULTIPART)
{
-
-
-
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
char *p;
-#endif /* HAVE_(PGP||SMIME) */
-
-
if (ascii_strcasecmp ("alternative", b->subtype) == 0)
handler = alternative_handler;
-
-
-
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- else if (ascii_strcasecmp ("signed", b->subtype) == 0)
+ else if (WithCrypto && ascii_strcasecmp ("signed", b->subtype) == 0)
{
p = mutt_get_parameter ("protocol", b->parameter);
else if (s->flags & M_VERIFY)
handler = mutt_signed_handler;
}
-#ifdef HAVE_PGP
- else if (mutt_strcasecmp ("encrypted", b->subtype) == 0)
+ else if ((WithCrypto & APPLICATION_PGP)
+ && mutt_strcasecmp ("encrypted", b->subtype) == 0)
{
p = mutt_get_parameter ("protocol", b->parameter);
if (!p)
mutt_error _("Error: multipart/encrypted has no protocol parameter!");
else if (ascii_strcasecmp ("application/pgp-encrypted", p) == 0)
- handler = pgp_encrypted_handler;
+ handler = crypt_pgp_encrypted_handler;
}
-#endif /* HAVE_PGP */
-#endif /* HAVE_(PGP||SMIME) */
-
if (!handler)
handler = multipart_handler;
}
-
-
-
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- else if (b->type == TYPEAPPLICATION)
+ else if (WithCrypto && b->type == TYPEAPPLICATION)
{
-#ifdef HAVE_PGP
- if (mutt_is_application_pgp (b))
- handler = pgp_application_pgp_handler;
-#endif /* HAVE_PGP */
-#ifdef HAVE_SMIME
- if (mutt_is_application_smime(b))
- handler = smime_application_smime_handler;
-#endif /* HAVE_SMIME */
+ if ((WithCrypto & APPLICATION_PGP) && mutt_is_application_pgp (b))
+ handler = crypt_pgp_application_pgp_handler;
+ if ((WithCrypto & APPLICATION_SMIME) && mutt_is_application_smime(b))
+ handler = crypt_smime_application_smime_handler;
}
-#endif /* HAVE_(PGP||SMIME) */
-
-
if (plaintext || handler)
#include "mutt_curses.h"
#include "sort.h"
#include "charset.h"
-
-
-#ifdef HAVE_PGP
-#include "pgp.h"
-#endif
-
-#ifdef HAVE_SMIME
-#include "smime.h"
-#endif
-
-
+#include "mutt_crypt.h"
#include <ctype.h>
#include <stdlib.h>
ch = ' ';
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- if (hdr->security & GOODSIGN)
+ if (WithCrypto && hdr->security & GOODSIGN)
ch = 'S';
- else if (hdr->security & ENCRYPT)
+ else if (WithCrypto && hdr->security & ENCRYPT)
ch = 'P';
- else if (hdr->security & SIGN)
+ else if (WithCrypto && hdr->security & SIGN)
ch = 's';
-#ifdef HAVE_PGP
- else if (hdr->security & PGPKEY)
+ else if ((WithCrypto & APPLICATION_PGP) && hdr->security & PGPKEY)
ch = 'K';
-#endif
-#endif
snprintf (buf2, sizeof (buf2),
"%c%c%c", (THREAD_NEW ? 'n' : (THREAD_OLD ? 'o' :
#include "mutt.h"
-#ifdef HAVE_PGP
-#include "pgp.h"
-#endif
+#include "mutt_crypt.h"
#include <sys/stat.h>
#include <string.h>
}
-
-#ifdef HAVE_PGP
- else if (ascii_strncasecmp ("pgp:", cur->data, 4) == 0)
+ else if ((WithCrypto & APPLICATION_PGP)
+ &&ascii_strncasecmp ("pgp:", cur->data, 4) == 0)
{
msg->security = mutt_parse_crypt_hdr (cur->data + 4, 0);
keep = 0;
}
-#endif
-
if (keep)
{
#include "mutt.h"
#include "mailbox.h"
+#include "mutt_crypt.h"
#include <limits.h>
#include <string.h>
pattern.data = safe_strdup (path);
}
else if (DefaultHook && !(data & (M_CHARSETHOOK | M_ACCOUNTHOOK))
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- && !(data & M_CRYPTHOOK)
-#endif /* HAVE_PGP */
+ && (!WithCrypto || !(data & M_CRYPTHOOK))
)
{
char tmp[HUGE_STRING];
return _mutt_string_hook (chs, M_ICONVHOOK);
}
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
char *mutt_crypt_hook (ADDRESS *adr)
{
return _mutt_string_hook (adr->mailbox, M_CRYPTHOOK);
}
-#endif /* HAVE_PGP */
#ifdef USE_SOCKET
void mutt_account_hook (const char* url)
#include "keymap.h"
#include "mbyte.h"
#include "charset.h"
-
-
-#ifdef HAVE_PGP
-#include "pgp.h"
-#endif
-
-
-#ifdef HAVE_SMIME
-#include "smime.h"
-#endif
-
+#include "mutt_crypt.h"
#if defined(USE_SSL) || defined(USE_NSS)
#include "mutt_ssl.h"
case DT_SORT_BROWSER:
map = SortBrowserMethods;
break;
-#ifdef HAVE_PGP
case DT_SORT_KEYS:
- map = SortKeyMethods;
+ if ((WithCrypto & APPLICATION_PGP))
+ map = SortKeyMethods;
break;
-#endif
case DT_SORT_AUX:
map = SortAuxMethods;
break;
case DT_SORT_BROWSER:
map = SortBrowserMethods;
break;
-#ifdef HAVE_PGP
case DT_SORT_KEYS:
- map = SortKeyMethods;
+ if ((WithCrypto & APPLICATION_PGP))
+ map = SortKeyMethods;
+ else
+ map = SortMethods;
break;
-#endif
default:
map = SortMethods;
break;
# ifndef MIXMASTER
# define MIXMASTER "mixmaster"
# endif
-# ifndef HAVE_PGP
-# define HAVE_PGP
-# endif
-# ifndef HAVE_SMIME
-# define HAVE_SMIME
-# endif
# ifndef USE_POP
# define USE_POP
# endif
** This variable controls whether or not attachments on outgoing messages
** are saved along with the main body of your message.
*/
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
{ "fcc_clear", DT_BOOL, R_NONE, OPTFCCCLEAR, 0 },
/*
** .pp
** When this variable is \fIset\fP, FCCs will be stored unencrypted and
** unsigned, even when the actual message is encrypted and/or signed.
+ ** (PGP only)
*/
-#endif
{ "folder", DT_PATH, R_NONE, UL &Maildir, UL "~/Mail" },
/*
** .pp
*/
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
-# ifdef HAVE_PGP
{ "pgp_autosign", DT_SYN, R_NONE, UL "crypt_autosign", 0 },
-# endif
{ "crypt_autosign", DT_BOOL, R_NONE, OPTCRYPTAUTOSIGN, 0 },
/*
** .pp
** encryption is requested as well. IF ``$$smime_is_default'' is set,
** then OpenSSL is used instead to create S/MIME messages and settings can
** be overridden by use of the \fIsmime-menu\fP.
+ ** (Crypto only)
*/
-# ifdef HAVE_PGP
{ "pgp_autoencrypt", DT_SYN, R_NONE, UL "crypt_autoencrypt", 0 },
-# endif
{ "crypt_autoencrypt", DT_BOOL, R_NONE, OPTCRYPTAUTOENCRYPT, 0 },
/*
** .pp
** requested as well. IF ``$$smime_is_default'' is set, then
** OpenSSL is used instead to create S/MIME messages and settings can
** be overridden by use of the \fIsmime-menu\fP.
+ ** (Crypto only)
*/
-#ifdef HAVE_PGP
{ "pgp_ignore_subkeys", DT_BOOL, R_NONE, OPTPGPIGNORESUB, 1},
/*
** .pp
** Setting this variable will cause Mutt to ignore OpenPGP subkeys. Instead,
** the principal key will inherit the subkeys' capabilities. Unset this
** if you want to play interesting key selection games.
+ ** (PGP only)
*/
-#endif
-#ifdef HAVE_PGP
{ "pgp_replyencrypt", DT_SYN, R_NONE, UL "crypt_replyencrypt", 0 },
-#endif
{ "crypt_replyencrypt", DT_BOOL, R_NONE, OPTCRYPTREPLYENCRYPT, 0 },
/*
** .pp
** If set, automatically PGP or OpenSSL encrypt replies to messages which are
** encrypted.
+ ** (Crypto only)
*/
-#ifdef HAVE_PGP
{ "pgp_replysign", DT_SYN, R_NONE, UL "crypt_replysign", 0 },
-#endif
{ "crypt_replysign", DT_BOOL, R_NONE, OPTCRYPTREPLYSIGN, 0 },
/*
** .pp
** .pp
** \fBNote:\fP this does not work on messages that are encrypted
** \fBand\fP signed!
+ ** (Crypto only)
*/
-#ifdef HAVE_PGP
{ "pgp_replysignencrypted", DT_SYN, R_NONE, UL "crypt_replysignencrypted", 0},
-#endif
{ "crypt_replysignencrypted", DT_BOOL, R_NONE, OPTCRYPTREPLYSIGNENCRYPTED, 0 },
/*
** .pp
** which are automatically encrypted. This works around the problem
** noted in ``$$crypt_replysign'', that mutt is not able to find out
** whether an encrypted message is also signed.
+ ** (Crypto only)
*/
{ "crypt_timestamp", DT_BOOL, R_NONE, OPTCRYPTTIMESTAMP, 1 },
/*
** PGP or S/MIME output, so spoofing such lines is more difficult.
** If you are using colors to mark these lines, and rely on these,
** you may unset this setting.
+ ** (Crypto only)
+ */
+ { "pgp_use_gpg_agent", DT_BOOL, R_NONE, OPTUSEGPGAGENT, 0},
+ /*
+ ** .pp
+ ** If set, mutt will use a possibly-running gpg-agent process.
+ ** (PGP only)
*/
-#ifdef HAVE_PGP
{ "pgp_verify_sig", DT_SYN, R_NONE, UL "crypt_verify_sig", 0},
-#endif
{ "crypt_verify_sig", DT_QUAD, R_NONE, OPT_VERIFYSIG, M_YES },
/*
** .pp
** If ``yes'', always attempt to verify PGP or S/MIME signatures.
** If ``ask'', ask whether or not to verify the signature.
** If ``no'', never attempt to verify cryptographic signatures.
+ ** (Crypto only)
*/
-#endif /* defined(HAVE_PGP) || defined(HAVE_SMIME) */
-#ifdef HAVE_SMIME
{ "smime_is_default", DT_BOOL, R_NONE, OPTSMIMEISDEFAULT, 0},
/*
** .pp
** However, this has no effect while replying, since mutt will automatically
** select the same application that was used to sign/encrypt the original
** message.
+ ** (S/MIME only)
*/
{ "smime_ask_cert_label", DT_BOOL, R_NONE, OPTASKCERTLABEL, 1 },
/*
** .pp
** This flag controls wether you want to be asked to enter a label for a certificate
** about to be added to the database or not. It is set by default.
+ ** (S/MIME only)
*/
{ "smime_decrypt_use_default_key", DT_BOOL, R_NONE, OPTSDEFAULTDECRYPTKEY, 1 },
/*
** If set (default) this tells mutt to use the default key for decryption. Otherwise,
** if manage multiple certificate-key-pairs, mutt will try to use the mailbox-address
** to determine the key to use. It will ask you to supply a key, if it can't find one.
+ ** (S/MIME only)
*/
-#endif
-#ifdef HAVE_PGP
{ "pgp_entry_format", DT_STR, R_NONE, UL &PgpEntryFormat, UL "%4n %t%f %4l/0x%k %-4a %2c %u" },
/*
** .pp
** .dt %t .dd trust/validity of the key-uid association
** .dt %[<s>] .dd date of the key where <s> is an strftime(3) expression
** .de
+ ** (PGP only)
*/
{ "pgp_good_sign", DT_RX, R_NONE, UL &PgpGoodSign, 0 },
/*
** considered verified if the output from $$pgp_verify_command contains
** the text. Use this variable if the exit code from the command is 0
** even for bad signatures.
+ ** (PGP only)
*/
{ "pgp_long_ids", DT_BOOL, R_NONE, OPTPGPLONGIDS, 0 },
/*
** .pp
** If set, use 64 bit PGP key IDs. Unset uses the normal 32 bit Key IDs.
+ ** (PGP only)
*/
{ "pgp_retainable_sigs", DT_BOOL, R_NONE, OPTPGPRETAINABLESIG, 0 },
/*
** This is useful for applications like encrypted and signed mailing
** lists, where the outer layer (multipart/encrypted) can be easily
** removed, while the inner multipart/signed part is retained.
+ ** (PGP only)
*/
{ "pgp_show_unusable", DT_BOOL, R_NONE, OPTPGPSHOWUNUSABLE, 1 },
/*
** If set, mutt will display non-usable keys on the PGP key selection
** menu. This includes keys which have been revoked, have expired, or
** have been marked as ``disabled'' by the user.
+ ** (PGP only)
*/
{ "pgp_sign_as", DT_STR, R_NONE, UL &PgpSignAs, 0 },
/*
** If you have more than one key pair, this option allows you to specify
** which of your private keys to use. It is recommended that you use the
** keyid form to specify your key (e.g., ``0x00112233'').
+ ** (PGP only)
*/
{ "pgp_strict_enc", DT_BOOL, R_NONE, OPTPGPSTRICTENC, 1 },
/*
** \fIquoted-printable\fP. Please note that unsetting this variable may
** lead to problems with non-verifyable PGP signatures, so only change
** this if you know what you are doing.
+ ** (PGP only)
*/
{ "pgp_timeout", DT_NUM, R_NONE, UL &PgpTimeout, 300 },
/*
** .pp
** The number of seconds after which a cached passphrase will expire if
** not used.
+ ** (PGP only)
*/
{ "pgp_sort_keys", DT_SORT|DT_SORT_KEYS, R_NONE, UL &PgpSortKeys, SORT_ADDRESS },
/*
** .pp
** If you prefer reverse order of the above values, prefix it with
** `reverse-'.
+ ** (PGP only)
*/
{ "pgp_create_traditional", DT_QUAD, R_NONE, OPT_PGPTRADITIONAL, M_NO },
/*
** .pp
** Also note that using the old-style PGP message format is \fBstrongly\fP
** \fBdeprecated\fP.
+ ** (PGP only)
*/
/* XXX Default values! */
** of PGP which are floating around, see the pgp*.rc and gpg.rc files in
** the samples/ subdirectory which has been installed on your system
** alongside the documentation.
+ ** (PGP only)
*/
{ "pgp_getkeys_command", DT_STR, R_NONE, UL &PgpGetkeysCommand, 0},
/*
** .pp
** This command is invoked whenever mutt will need public key information.
** %r is the only printf-like sequence used with this format.
+ ** (PGP only)
*/
{ "pgp_verify_command", DT_STR, R_NONE, UL &PgpVerifyCommand, 0},
/*
** .pp
** This command is used to verify PGP/MIME signatures.
+ ** (PGP only)
*/
{ "pgp_decrypt_command", DT_STR, R_NONE, UL &PgpDecryptCommand, 0},
/*
** .pp
** This command is used to decrypt a PGP/MIME encrypted message.
+ ** (PGP only)
*/
{ "pgp_clearsign_command", DT_STR, R_NONE, UL &PgpClearSignCommand, 0 },
/*
** .pp
** This format is used to create a "clearsigned" old-style PGP attachment.
** Note that the use of this format is \fBstrongly\fP \fBdeprecated\fP.
+ ** (PGP only)
*/
{ "pgp_sign_command", DT_STR, R_NONE, UL &PgpSignCommand, 0},
/*
** .pp
** This command is used to create the detached PGP signature for a
** multipart/signed PGP/MIME body part.
+ ** (PGP only)
*/
{ "pgp_encrypt_sign_command", DT_STR, R_NONE, UL &PgpEncryptSignCommand, 0},
/*
** .pp
** This command is used to combinedly sign/encrypt a body part.
+ ** (PGP only)
*/
{ "pgp_encrypt_only_command", DT_STR, R_NONE, UL &PgpEncryptOnlyCommand, 0},
/*
** .pp
** This command is used to encrypt a body part without signing it.
+ ** (PGP only)
*/
{ "pgp_import_command", DT_STR, R_NONE, UL &PgpImportCommand, 0},
/*
** .pp
** This command is used to import a key from a message into
** the user's public key ring.
+ ** (PGP only)
*/
{ "pgp_export_command", DT_STR, R_NONE, UL &PgpExportCommand, 0},
/*
** .pp
** This command is used to export a public key from the user's
** key ring.
+ ** (PGP only)
*/
{ "pgp_verify_key_command", DT_STR, R_NONE, UL &PgpVerifyKeyCommand, 0},
/*
** .pp
** This command is used to verify key information from the key selection
** menu.
+ ** (PGP only)
*/
{ "pgp_list_secring_command", DT_STR, R_NONE, UL &PgpListSecringCommand, 0},
/*
** .pp
** This format is also generated by the pgpring utility which comes
** with mutt.
+ ** (PGP only)
*/
{ "pgp_list_pubring_command", DT_STR, R_NONE, UL &PgpListPubringCommand, 0},
/*
** .pp
** This format is also generated by the pgpring utility which comes
** with mutt.
+ ** (PGP only)
*/
{ "forward_decrypt", DT_BOOL, R_NONE, OPTFORWDECRYPT, 1 },
/*
** When set, the outer layer of encryption is stripped off. This
** variable is only used if ``$$mime_forward'' is \fIset\fP and
** ``$$mime_forward_decode'' is \fIunset\fP.
+ ** (PGP only)
*/
{ "forw_decrypt", DT_SYN, R_NONE, UL "forward_decrypt", 0 },
/*
*/
-#endif /* HAVE_PGP */
-#ifdef HAVE_SMIME
{ "smime_timeout", DT_NUM, R_NONE, UL &SmimeTimeout, 300 },
/*
** .pp
** The number of seconds after which a cached passphrase will expire if
** not used.
+ ** (S/MIME only)
*/
{ "smime_encrypt_with", DT_STR, R_NONE, UL &SmimeCryptAlg, 0 },
/*
** This sets the algorithm that should be used for encryption.
** Valid choices are "des", "des3", "rc2-40", "rc2-64", "rc2-128".
** If unset "3des" (TrippleDES) is used.
+ ** (S/MIME only)
*/
{ "smime_keys", DT_PATH, R_NONE, UL &SmimeKeys, 0 },
/*
** named as the hash-value retrieved from OpenSSL. There is an index file
** which contains mailbox-address keyid pair, and which can be manually
** edited. This one points to the location of the private keys.
+ ** (S/MIME only)
*/
{ "smime_ca_location", DT_PATH, R_NONE, UL &SmimeCALocation, 0 },
/*
** .pp
** This variable contains the name of either a directory, or a file which
** contains trusted certificates for use with OpenSSL.
+ ** (S/MIME only)
*/
{ "smime_certificates", DT_PATH, R_NONE, UL &SmimeCertificates, 0 },
/*
** named as the hash-value retrieved from OpenSSl. There is an index file
** which contains mailbox-address keyid pai, and which can be manually
** edited. This one points to the location of the certificates.
+ ** (S/MIME only)
*/
{ "smime_decrypt_command", DT_STR, R_NONE, UL &SmimeDecryptCommand, 0},
/*
** For examples on how to configure these formats, see the smime.rc in
** the samples/ subdirectory which has been installed on your system
** alongside the documentation.
+ ** (S/MIME only)
*/
{ "smime_verify_command", DT_STR, R_NONE, UL &SmimeVerifyCommand, 0},
/*
** .pp
** This command is used to verify S/MIME signatures of type multipart/signed.
+ ** (S/MIME only)
*/
{ "smime_verify_opaque_command", DT_STR, R_NONE, UL &SmimeVerifyOpaqueCommand, 0},
/*
** .pp
** This command is used to verify S/MIME signatures of type
** application/x-pkcs7-mime.
+ ** (S/MIME only)
*/
{ "smime_sign_command", DT_STR, R_NONE, UL &SmimeSignCommand, 0},
/*
** .pp
** This command is used to created S/MIME signatures of type
** multipart/signed, which can be read by all mail clients.
+ ** (S/MIME only)
*/
{ "smime_sign_opaque_command", DT_STR, R_NONE, UL &SmimeSignOpaqueCommand, 0},
/*
** This command is used to created S/MIME signatures of type
** applicatipn/x-pkcs7-signature, which can only be handled by mail
** clients supporting the S/MIME extension
+ ** (S/MIME only)
*/
{ "smime_encrypt_command", DT_STR, R_NONE, UL &SmimeEncryptCommand, 0},
/*
** .pp
** This command is used to create encrypted S/MIME messages.
+ ** (S/MIME only)
*/
{ "smime_pk7out_command", DT_STR, R_NONE, UL &SmimePk7outCommand, 0},
/*
** .pp
** This command is used to extract PKCS7 structures of S/MIME signatures,
** in order to extract the public X509 certificate(s).
+ ** (S/MIME only)
*/
{ "smime_get_cert_command", DT_STR, R_NONE, UL &SmimeGetCertCommand, 0},
/*
** .pp
** This command is used to extract X509 certificates from a PKCS7 structure.
+ ** (S/MIME only)
*/
{ "smime_get_signer_cert_command", DT_STR, R_NONE, UL &SmimeGetSignerCertCommand, 0},
/*
** This command is used to extract only the signers X509 certificate from a S/MIME
** signature, so that the certificate's owner may get compared to the email's
** 'From'-field.
+ ** (S/MIME only)
*/
{ "smime_import_cert_command", DT_STR, R_NONE, UL &SmimeImportCertCommand, 0},
/*
** .pp
** This command is used to import a certificate via smime_keys.
+ ** (S/MIME only)
*/
{ "smime_get_cert_email_command", DT_STR, R_NONE, UL &SmimeGetCertEmailCommand, 0},
/*
** This command is used to extract the mail address(es) used for storing
** X509 certificates, and for verification purposes (to check, wether the
** certifacate was issued for the sender's mailbox).
+ ** (S/MIME only)
*/
{ "smime_sign_as", DT_SYN, R_NONE, UL "smime_default_key", 0 },
{ "smime_default_key", DT_STR, R_NONE, UL &SmimeDefaultKey, 0 },
** .pp
** This is the default key-pair to use vor signing. This must be set to the
** keyid (the hash-value that OpenSSL generates) to work properly
+ ** (S/MIME only)
*/
-#endif /* HAVE_SMIME */
#if defined(USE_SSL)||defined(USE_NSS)
# ifndef USE_NSS
{ NULL }
};
-#ifdef HAVE_PGP
const struct mapping_t SortKeyMethods[] = {
{ "address", SORT_ADDRESS },
{ "date", SORT_DATE },
{ "trust", SORT_TRUST },
{ NULL }
};
-#endif /* HAVE_PGP */
/* functions used to parse commands in a rc file */
{ "unmime_lookup", parse_unlist, UL &MimeLookupList },
{ "mono", mutt_parse_mono, 0 },
{ "my_hdr", parse_my_hdr, 0 },
-#ifdef HAVE_PGP
{ "pgp-hook", mutt_parse_hook, M_CRYPTHOOK },
-#endif
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
{ "crypt-hook", mutt_parse_hook, M_CRYPTHOOK },
-#endif /* HAVE_PGP */
{ "push", mutt_parse_push, 0 },
{ "reply-hook", mutt_parse_hook, M_REPLYHOOK },
{ "reset", parse_set, M_SET_RESET },
#include "mutt_curses.h"
#include "keymap.h"
#include "mapping.h"
+#include "mutt_crypt.h"
#include <stdlib.h>
#include <string.h>
{ "index", MENU_MAIN },
{ "pager", MENU_PAGER },
{ "postpone", MENU_POST },
-
-
-#ifdef HAVE_PGP
{ "pgp", MENU_PGP },
-#endif
-
-#ifdef HAVE_SMIME
{ "smime", MENU_SMIME },
-#endif
#ifdef MIXMASTER
{ "mix", MENU_MIX },
create_bindings (OpAlias, MENU_ALIAS);
-#ifdef HAVE_PGP
- create_bindings (OpPgp, MENU_PGP);
-#endif
+ if ((WithCrypto & APPLICATION_PGP))
+ create_bindings (OpPgp, MENU_PGP);
-#ifdef HAVE_SMIME
- create_bindings (OpSmime, MENU_SMIME);
-#endif
+ if ((WithCrypto & APPLICATION_SMIME))
+ create_bindings (OpSmime, MENU_SMIME);
#ifdef MIXMASTER
create_bindings (OpMix, MENU_MIX);
case MENU_QUERY:
return OpQuery;
-
-
-#ifdef HAVE_PGP
case MENU_PGP:
- return OpPgp;
-#endif
-
+ return (WithCrypto & APPLICATION_PGP)? OpPgp:NULL;
#ifdef MIXMASTER
case MENU_MIX:
MENU_QUERY,
-#ifdef HAVE_PGP
MENU_PGP,
-#endif
-#ifdef HAVE_SMIME
MENU_SMIME,
-#endif
#ifdef MIXMASTER
MENU_MIX,
extern struct binding_t OpQuery[];
extern struct binding_t OpAlias[];
-#ifdef HAVE_PGP
extern struct binding_t OpPgp[];
-#endif /* HAVE_PGP */
-#ifdef HAVE_SMIME
extern struct binding_t OpSmime[];
-#endif /* HAVE_SMIME */
#ifdef MIXMASTER
extern struct binding_t OpMix[];
#include "keymap.h"
#include "mailbox.h"
#include "url.h"
+#include "mutt_crypt.h"
#include <string.h>
#include <stdlib.h>
#else
"-HAVE_RESIZETERM "
#endif
-
-
- );
-
+ );
puts (
-
-#ifdef HAVE_PGP
- "+HAVE_PGP "
+#ifdef CRYPT_BACKEND_CLASSIC_PGP
+ "+CRYPT_BACKEND_CLASSIC_PGP "
#else
- "-HAVE_PGP "
+ "-CRYPT_BACKEND_CLASSIC_PGP "
#endif
-
-#ifdef HAVE_SMIME
- "+HAVE_SMIME "
+#ifdef CRYPT_BACKEND_CLASSIC_SMIME
+ "+CRYPT_BACKEND_CLASSIC_SMIME "
+#else
+ "-CRYPT_BACKEND_CLASSIC_SMIME "
+#endif
+#ifdef CRYPT_BACKEND_GPGME
+ "+CRYPT_BACKEND_GPGME "
#else
- "-HAVE_SMIME "
+ "-CRYPT_BACKEND_GPGME "
#endif
#ifdef BUFFY_SIZE
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*/
+#ifndef MUTT_H
+#define MUTT_H
+
#include "config.h"
#include <stdio.h>
#define M_CHARSETHOOK (1<<5)
#define M_ICONVHOOK (1<<6)
#define M_MESSAGEHOOK (1<<7)
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
#define M_CRYPTHOOK (1<<8)
-#endif
#define M_ACCOUNTHOOK (1<<9)
#define M_REPLYHOOK (1<<10)
M_PERSONAL_RECIP,
M_PERSONAL_FROM,
M_ADDRESS,
-#if defined (HAVE_PGP) || defined (HAVE_SMIME)
M_CRYPT_SIGN,
M_CRYPT_VERIFIED,
M_CRYPT_ENCRYPT,
-#endif
-#ifdef HAVE_PGP
M_PGP_KEY,
-#endif
M_XLABEL,
/* Options for Mailcap lookup */
enum
{
-#if defined(HAVE_PGP)|| defined(HAVE_SMIME)
OPT_VERIFYSIG, /* verify PGP signatures */
-#ifdef HAVE_PGP
OPT_PGPTRADITIONAL, /* create old-style PGP messages */
-#endif
-#endif
#ifdef USE_SSL
OPT_SSLSTARTTLS,
OPTUSE8BITMIME,
OPTUSEDOMAIN,
OPTUSEFROM,
+ OPTUSEGPGAGENT,
#ifdef HAVE_GETADDRINFO
OPTUSEIPV6,
#endif
/* PGP options */
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
OPTCRYPTAUTOSIGN,
OPTCRYPTAUTOENCRYPT,
OPTCRYPTREPLYENCRYPT,
OPTCRYPTREPLYSIGN,
OPTCRYPTREPLYSIGNENCRYPTED,
OPTCRYPTTIMESTAMP,
-#ifdef HAVE_SMIME
OPTSMIMEISDEFAULT,
OPTASKCERTLABEL,
OPTSDEFAULTDECRYPTKEY,
-#endif
-#ifdef HAVE_PGP
OPTPGPIGNORESUB,
OPTPGPLONGIDS,
-#endif
#if 0
OPTPGPENCRYPTSELF,
#endif
OPTPGPSTRICTENC,
OPTFORWDECRYPT,
OPTPGPSHOWUNUSABLE,
-#endif
/* pseudo options */
*/
OPTMENUCALLER, /* (pseudo) tell menu to give caller a take */
OPTREDRAWTREE, /* (pseudo) redraw the thread tree */
-#ifdef HAVE_PGP
OPTPGPCHECKTRUST, /* (pseudo) used by pgp_select_key () */
OPTDONTHANDLEPGPKEYS, /* (pseudo) used to extract PGP keys */
-#endif
-
-
-
OPTMAX
};
* set when in send-mode.
*/
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
unsigned int goodsig : 1; /* good cryptographic signature */
unsigned int badsig : 1; /* bad cryptographic signature (needed to check encrypted s/mime-signatures */
-#endif
unsigned int collapsed : 1; /* used by recvattach */
typedef struct header
{
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
unsigned int security : 7; /* bit 0-4: flags, bit 5,6: application.
see: crypt.h pgplib.h, smime.h */
-#endif
unsigned int mime : 1; /* has a Mime-Version header? */
unsigned int flagged : 1; /* marked important? */
/* flags for the STATE struct */
#define M_DISPLAY (1<<0) /* output is displayed to the user */
-
-
-
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
#define M_VERIFY (1<<1) /* perform signature verification */
-#endif
-
-
-
#define M_PENDINGPREFIX (1<<2) /* prefix to write, but character must follow */
#define M_WEED (1<<3) /* weed headers even when not in display mode */
#define M_CHARCONV (1<<4) /* Do character set conversions */
#include "protos.h"
#include "lib.h"
#include "globals.h"
+
+#endif /*MUTT_H*/
/*
- * Copyright (C) 1996,1997 Michael R. Elkins <me@mutt.org>
- * Copyright (C) 1999-2000 Thomas Roessler <roessler@does-not-exist.org>
- * Copyright (C) 2001 Thomas Roessler <roessler@does-not-exist.org>
- * Oliver Ehli <elmy@acm.org>
- *
+ * Copyright (C) 2003 Werner Koch <wk@gnupg.org>
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
- */
+ */
+
+/*
+ Common definitions and prototypes for the crypt functions. They are
+ all defined in crypt.c and cryptglue.c
+*/
+
+#ifndef CRYPT_H
+#define CRYPT_H
+
+#include "mutt.h" /* Need this to declarer BODY, ADDTESS. 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 APPLICATION_PGP (1 << 5)
+#define APPLICATION_SMIME (1 << 6)
+
+#define PGPENCRYPT (APPLICATION_PGP | ENCRYPT)
+#define PGPSIGN (APPLICATION_PGP | SIGN)
+#define PGPGOODSIGN (APPLICATION_PGP | GOODSIGN)
+#define PGPKEY (APPLICATION_PGP | (1 << 3))
+
+#define SMIMEENCRYPT (APPLICATION_SMIME | ENCRYPT)
+#define SMIMESIGN (APPLICATION_SMIME | SIGN)
+#define SMIMEGOODSIGN (APPLICATION_SMIME | GOODSIGN)
+#define SMIMEBADSIGN (APPLICATION_SMIME | BADSIGN)
+#define SMIMEOPAQUE (APPLICATION_SMIME | SIGNOPAQUE)
+
+
+/* WITHCRYPTO actually replaces ifdefs so make the code more readable.
+ Because it is defined as a constant and known at compile time, the
+ compiler can do dead code elimination and thus it behaves
+ effectively as a conditional compile directive. It is set to false
+ if no crypto backend is configures or to a bit vector denoting the
+ configured backends. */
+#if defined(CRYPT_BACKEND_CLASSIC_PGP) && defined(CRYPT_BACKEND_CLASSIC_SMIME)
+# define WithCrypto (APPLICATION_PGP | APPLICATION_SMIME)
+#elif defined(CRYPT_BACKEND_CLASSIC_PGP)
+# define WithCrypto APPLICATION_PGP
+#elif defined(CRYPT_BACKEND_CLASSIC_SMIME)
+# define WithCrypto APPLICATION_SMIME
+#elif defined(CRYPT_BACKEND_GPGME)
+# define WithCrypto (APPLICATION_PGP | APPLICATION_SMIME)
+#else
+# define WithCrypto 0
+#endif
+
+
+#define KEYFLAG_CANSIGN (1 << 0)
+#define KEYFLAG_CANENCRYPT (1 << 1)
+#define KEYFLAG_SECRET (1 << 7)
+#define KEYFLAG_EXPIRED (1 << 8)
+#define KEYFLAG_REVOKED (1 << 9)
+#define KEYFLAG_DISABLED (1 << 10)
+#define KEYFLAG_SUBKEY (1 << 11)
+#define KEYFLAG_CRITICAL (1 << 12)
+#define KEYFLAG_PREFER_ENCRYPTION (1 << 13)
+#define KEYFLAG_PREFER_SIGNING (1 << 14)
+
+#define KEYFLAG_CANTUSE (KEYFLAG_DISABLED|KEYFLAG_REVOKED|KEYFLAG_EXPIRED)
+#define KEYFLAG_RESTRICTIONS (KEYFLAG_CANTUSE|KEYFLAG_CRITICAL)
+#define KEYFLAG_ABILITIES (KEYFLAG_CANSIGN|KEYFLAG_CANENCRYPT|KEYFLAG_PREFER_ENCRYPTION|KEYFLAG_PREFER_SIGNING)
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
+enum pgp_ring
+{
+ PGP_PUBRING,
+ PGP_SECRING
+};
+typedef enum pgp_ring pgp_ring_t;
-#define ENCRYPT (1 << 0)
-#define SIGN (1 << 1)
-#define GOODSIGN (1 << 2)
-#define BADSIGN (1 << 3)
+
+struct pgp_keyinfo;
+typedef struct pgp_keyinfo *pgp_key_t;
+
+
+
+/* Some prototypes -- old crypt.h. */
int mutt_protect (HEADER *, char *);
int mutt_is_multipart_signed (BODY *);
+int mutt_is_application_pgp (BODY *);
+
+int mutt_is_application_smime (BODY *);
+
void mutt_signed_handler (BODY *, STATE *);
int mutt_parse_crypt_hdr (char *, int);
-int crypt_query (BODY *);
-void crypt_extract_keys_from_messages (HEADER *);
+void convert_to_7bit (BODY *);
-int crypt_get_keys (HEADER *, char **);
+/*-- crypt.c --*/
+
+/* Print the current time. */
+void crypt_current_time(STATE *s, char *app_name);
+
+/* Check out the type of encryption used and set the cached status
+ values if there are any. */
+int crypt_query (BODY *m);
+
+/* Fixme: To be documented. */
+void crypt_extract_keys_from_messages (HEADER *h);
+
+/* Do a quick check to make sure that we can find all of the
+ encryption keys if the user has requested this service.
+ Return the list of keys in KEYLIST. */
+int crypt_get_keys (HEADER *msg, char **keylist);
+
+/* Forget a passphrase and display a message. */
void crypt_forget_passphrase (void);
+/* Check that we have a usable passphrase, ask if not. */
int crypt_valid_passphrase (int);
+/* Write the message body/part A described by state S to a the given
+ TEMPFILE. */
+int crypt_write_signed(BODY *a, STATE *s, const char *tempf);
-int crypt_write_signed(BODY *, STATE *, const char *);
-void convert_to_7bit (BODY *);
+/*-- cryptglue.c --*/
-/* private ? */
+/* Show a message that a backend will be invoked. */
+void crypt_invoke_message (int type);
-void crypt_current_time(STATE *, char *);
+/* Silently forget about a passphrase. */
+void crypt_pgp_void_passphrase (void);
-#endif
+/* Decrypt a PGP/MIME message. */
+int crypt_pgp_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d);
+
+/* MIME handler for the application/pgp content-type. */
+void crypt_pgp_application_pgp_handler (BODY *m, STATE *s);
+
+/* MIME handler for an PGP/MIME encrypted message. */
+void crypt_pgp_encrypted_handler (BODY *a, STATE *s);
+
+/* fixme: needs documentation. */
+void crypt_pgp_invoke_getkeys (ADDRESS *addr);
+
+/* Ask for a PGP key. */
+pgp_key_t crypt_pgp_ask_for_key (char *tag, char *whatfor,
+ short abilities, pgp_ring_t keyring);
+
+/* Check for a traditional PGP message in body B. */
+int crypt_pgp_check_traditional (FILE *fp, BODY *b, int tagged_only);
+
+/* fixme: needs documentation. */
+BODY *crypt_pgp_traditional_encryptsign (BODY *a, int flags, char *keylist);
+
+/* Release the PGP key KPP (note, that we pass a pointer to it). */
+void crypt_pgp_free_key (pgp_key_t *kpp);
+
+/* Generate a PGP public key attachment. */
+BODY *crypt_pgp_make_key_attachment (char *tempf);
+
+/* This routine attempts to find the keyids of the recipients of a
+ message. It returns NULL if any of the keys can not be found. */
+char *crypt_pgp_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc);
+
+/* Create a new body with a PGP signed message from A. */
+BODY *crypt_pgp_sign_message (BODY *a);
+
+/* Warning: A is no longer freed in this routine, you need to free it
+ later. This is necessary for $fcc_attach. */
+BODY *crypt_pgp_encrypt_message (BODY *a, char *keylist, int sign);
+
+/* Invoke the PGP command to import a key. */
+void crypt_pgp_invoke_import (const char *fname);
+
+/* fixme: needs documentation */
+int crypt_pgp_verify_one (BODY *sigbdy, STATE *s, const char *tempf);
+
+/* Access the keyID in K. */
+char *crypt_pgp_keyid (pgp_key_t k);
+
+/* fixme: needs documentation */
+void crypt_pgp_extract_keys_from_attachment_list (FILE *fp, int tag,BODY *top);
+
+
+
+
+
+/* Silently forget about a passphrase. */
+void crypt_smime_void_passphrase (void);
+
+/* Decrypt an S/MIME message. */
+int crypt_smime_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d);
+
+/* MIME handler for the application/smime content-type. */
+void crypt_smime_application_smime_handler (BODY *m, STATE *s);
+
+/* fixme: Needs documentation. */
+void crypt_smime_getkeys (ENVELOPE *env);
+
+/* Check that the sender matches. */
+int crypt_smime_verify_sender(HEADER *h);
+
+/* Ask for an SMIME key. */
+char *crypt_smime_ask_for_key (char *prompt, char *mailbox, short public);
+
+/* This routine attempts to find the keyids of the recipients of a
+ message. It returns NULL if any of the keys can not be found. */
+char *crypt_smime_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc);
+
+/* fixme: Needs documentation. */
+BODY *crypt_smime_sign_message (BODY *a);
+
+/* fixme: needs documentation. */
+BODY *crypt_smime_build_smime_entity (BODY *a, char *certlist);
+
+/* Add a certificate and update index file (externally). */
+void crypt_smime_invoke_import (char *infile, char *mailbox);
+
+/* fixme: needs documentation */
+int crypt_smime_verify_one (BODY *sigbdy, STATE *s, const char *tempf);
+
+
+#endif /*CRYPT_H*/
#ifdef USE_IMAP
#include "imap.h"
- #endif
-
-#ifdef HAVE_PGP
-#include "pgp.h"
#endif
-#ifdef HAVE_SMIME
-#include "smime.h"
-#endif
+#include "mutt_crypt.h"
#include <string.h>
#include <ctype.h>
return 0;
break;
-
-
-#ifdef HAVE_PGP
case TYPEAPPLICATION:
- if(mutt_is_application_pgp(m))
+ if((WithCrypto & APPLICATION_PGP) && mutt_is_application_pgp(m))
return 0;
-#endif /* HAVE_PGP */
-
-#ifdef HAVE_SMIME
- if(mutt_is_application_smime(m))
+ if((WithCrypto & APPLICATION_SMIME) && mutt_is_application_smime(m))
return 0;
break;
-#endif /* HAVE_SMIME */
-
case TYPEMULTIPART:
case TYPEMESSAGE:
-
return 0;
}
int t = b->type;
char *s = b->subtype;
-
-#ifdef HAVE_PGP
- if (mutt_is_application_pgp (b))
+ if ((WithCrypto & APPLICATION_PGP) && mutt_is_application_pgp (b))
return 0;
-#endif
+
if (t == TYPETEXT)
return 1;
return 1;
}
-
-
-#ifdef HAVE_PGP
- if (t == TYPEAPPLICATION)
+ if ((WithCrypto & APPLICATION_PGP) && t == TYPEAPPLICATION)
{
if (!ascii_strcasecmp ("pgp-keys", s))
return 1;
}
-#endif /* HAVE_PGP */
-
-
return 0;
}
#include "keymap.h"
#include "url.h"
-#ifdef HAVE_PGP
-#include "pgp.h"
-#endif
-
-#ifdef HAVE_SMIME
-#include "smime.h"
-#endif
-
#ifdef USE_IMAP
#include "imap.h"
#endif
#include "dotlock.h"
#endif
+#include "mutt_crypt.h"
+
#include <dirent.h>
#include <fcntl.h>
#include <sys/file.h>
{
h = ctx->hdrs[msgno];
-
-
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- /* NOTE: this _must_ be done before the check for mailcap! */
- h->security = crypt_query (h->content);
-#endif /* HAVE_PGP || HAVE_SMIME */
+ if (WithCrypto)
+ {
+ /* NOTE: this _must_ be done before the check for mailcap! */
+ h->security = crypt_query (h->content);
+ }
if (!ctx->pattern)
{
#include "imap.h"
#endif
-
-#ifdef HAVE_PGP
-#include "pgp.h"
-#endif
-
-#ifdef HAVE_SMIME
-#include "smime.h"
-#endif
-
-
-
-
-
-
-
-
+#include "mutt_crypt.h"
#include <sys/stat.h>
#include <ctype.h>
redraw = REDRAW_FULL;
break;
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
case OP_DECRYPT_SAVE:
-#endif
+ if (!WithCrypto)
+ {
+ ch = -1;
+ break;
+ }
+ /* fall through */
case OP_SAVE:
if (IsAttach (extra))
{
case OP_COPY_MESSAGE:
case OP_DECODE_SAVE:
case OP_DECODE_COPY:
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
case OP_DECRYPT_COPY:
-#endif
+ if (!WithCrypto && ch == OP_DECRYPT_COPY)
+ {
+ ch = -1;
+ break;
+ }
CHECK_MODE(IsHeader (extra));
if (mutt_save_message (extra->hdr,
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
(ch == OP_DECRYPT_SAVE) ||
-#endif
(ch == OP_SAVE) || (ch == OP_DECODE_SAVE),
(ch == OP_DECODE_SAVE) || (ch == OP_DECODE_COPY),
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
(ch == OP_DECRYPT_SAVE) || (ch == OP_DECRYPT_COPY) ||
-#endif
0,
&redraw) == 0 && (ch == OP_SAVE || ch == OP_DECODE_SAVE
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
|| ch == OP_DECRYPT_SAVE
-#endif
))
{
if (option (OPTRESOLVE))
break;
-
-#ifdef HAVE_PGP
case OP_MAIL_KEY:
+ if (!(WithCrypto & APPLICATION_PGP))
+ {
+ ch = -1;
+ break;
+ }
CHECK_MODE(IsHeader(extra));
CHECK_ATTACH;
ci_send_message (SENDKEY, NULL, NULL, extra->ctx, extra->hdr);
redraw = REDRAW_FULL;
break;
-#endif /* HAVE_PGP || HAVE_SMIME */
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
case OP_FORGET_PASSPHRASE:
crypt_forget_passphrase ();
break;
case OP_EXTRACT_KEYS:
+ if (!WithCrypto)
+ {
+ ch = -1;
+ break;
+ }
CHECK_MODE(IsHeader(extra));
crypt_extract_keys_from_messages(extra->hdr);
redraw = REDRAW_FULL;
break;
-#endif /* HAVE_PGP || HAVE_SMIME */
-
-
default:
ch = -1;
#include "mime.h"
#include "rfc2047.h"
#include "rfc2231.h"
-
-
-#ifdef HAVE_PGP
-#include "pgp.h"
-#endif /* HAVE_PGP */
-
-#ifdef HAVE_SMIME
-#include "smime.h"
-#endif /* HAVE_SMIME */
-
-
+#include "mutt_crypt.h"
#include <string.h>
#include <ctype.h>
{
mutt_parse_part (msg->fp, cur->content);
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- cur->security = crypt_query (cur->content);
-#endif
+ if (WithCrypto)
+ cur->security = crypt_query (cur->content);
mx_close_message (&msg);
}
#include <unistd.h>
#include <stdarg.h>
-
-
-#ifdef HAVE_PGP
-#include "pgp.h"
-#endif
-
-#ifdef HAVE_SMIME
-#include "smime.h"
-#endif
-
-
+#include "mutt_crypt.h"
static int eat_regexp (pattern_t *pat, BUFFER *, BUFFER *);
static int eat_date (pattern_t *pat, BUFFER *, BUFFER *);
{ 'E', M_EXPIRED, 0, NULL },
{ 'f', M_FROM, 0, eat_regexp },
{ 'F', M_FLAG, 0, NULL },
-#if defined (HAVE_PGP) || defined (HAVE_SMIME)
{ 'g', M_CRYPT_SIGN, 0, NULL },
{ 'G', M_CRYPT_ENCRYPT, 0, NULL },
-#endif
{ 'h', M_HEADER, M_FULL_MSG, eat_regexp },
{ 'i', M_ID, 0, eat_regexp },
-#ifdef HAVE_PGP
{ 'k', M_PGP_KEY, 0, NULL },
-#endif
{ 'L', M_ADDRESS, 0, eat_regexp },
{ 'l', M_LIST, 0, NULL },
{ 'm', M_MESSAGE, 0, eat_range },
{ 't', M_TO, 0, eat_regexp },
{ 'U', M_UNREAD, 0, NULL },
{ 'v', M_COLLAPSED, 0, NULL },
-#if defined (HAVE_PGP) || defined (HAVE_SMIME)
{ 'V', M_CRYPT_VERIFIED, 0, NULL },
-#endif
{ 'x', M_REFERENCE, 0, eat_regexp },
{ 'y', M_XLABEL, 0, eat_regexp },
{ 'z', M_SIZE, 0, eat_range },
{
mutt_parse_mime_message (ctx, h);
-
-
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- if (h->security & ENCRYPT && !crypt_valid_passphrase(h->security))
+ if (WithCrypto && (h->security & ENCRYPT)
+ && !crypt_valid_passphrase(h->security))
{
mx_close_message (&msg);
if (fp)
}
return (0);
}
-#endif
-
-
fseek (msg->fp, h->offset, 0);
mutt_body_handler (h->content, &s);
return (pat->not ^ match_user (pat->alladdr, h->env->from, NULL));
case M_COLLAPSED:
return (pat->not ^ (h->collapsed && h->num_hidden > 1));
-#if defined (HAVE_PGP) || defined (HAVE_SMIME)
case M_CRYPT_SIGN:
+ if (!WithCrypto)
+ break;
return (pat->not ^ ((h->security & SIGN) ? 1 : 0));
case M_CRYPT_VERIFIED:
+ if (!WithCrypto)
+ break;
return (pat->not ^ ((h->security & GOODSIGN) ? 1 : 0));
case M_CRYPT_ENCRYPT:
+ if (!WithCrypto)
+ break;
return (pat->not ^ ((h->security & ENCRYPT) ? 1 : 0));
-#endif
-#ifdef HAVE_PGP
case M_PGP_KEY:
+ if (!(WithCrypto & APPLICATION_PGP))
+ break;
return (pat->not ^ ((h->security & APPLICATION_PGP) && (h->security & PGPKEY)));
-#endif
case M_XLABEL:
return (pat->not ^ (h->env->x_label && regexec (pat->rx, h->env->x_label, 0, NULL, 0) == 0));
case M_DUPLICATED:
# include <sys/resource.h>
#endif
-#ifdef HAVE_PGP
+#ifdef CRYPT_BACKEND_CLASSIC_PGP
#include "mutt_crypt.h"
mutt_message _("PGP passphrase forgotten.");
}
+int pgp_use_gpg_agent (void)
+{
+ return option (OPTUSEGPGAGENT) && getenv ("GPG_TTY") && getenv ("GPG_AGENT_INFO");
+}
-char *pgp_keyid(pgp_key_t *k)
+char *pgp_keyid(pgp_key_t k)
{
if((k->flags & KEYFLAG_SUBKEY) && k->parent)
k = k->parent;
return _pgp_keyid(k);
}
-char *_pgp_keyid(pgp_key_t *k)
+char *_pgp_keyid(pgp_key_t k)
{
if(option(OPTPGPLONGIDS))
return k->keyid;
if (needpass)
{
if (!pgp_valid_passphrase ()) pgp_void_passphrase();
+ if (pgp_use_gpg_agent())
+ *PgpPass = 0;
fprintf (pgpin, "%s\n", PgpPass);
}
}
-int pgp_is_multipart_encrypted (BODY *b)
-{
- char *p;
-
- if (!b || b->type != TYPEMULTIPART ||
- !b->subtype || ascii_strcasecmp (b->subtype, "encrypted") ||
- !(p = mutt_get_parameter ("protocol", b->parameter)) ||
- ascii_strcasecmp (p, "application/pgp-encrypted"))
- return 0;
-
- return PGPENCRYPT;
-}
-
-int mutt_is_application_pgp (BODY *m)
-{
- int t = 0;
- char *p;
-
- if (m->type == TYPEAPPLICATION)
- {
- if (!ascii_strcasecmp (m->subtype, "pgp") || !ascii_strcasecmp (m->subtype, "x-pgp-message"))
- {
- if ((p = mutt_get_parameter ("x-action", m->parameter))
- && (!ascii_strcasecmp (p, "sign") || !ascii_strcasecmp (p, "signclear")))
- t |= PGPSIGN;
-
- if ((p = mutt_get_parameter ("format", m->parameter)) &&
- !ascii_strcasecmp (p, "keys-only"))
- t |= PGPKEY;
-
- if(!t) t |= PGPENCRYPT; /* not necessarily correct, but... */
- }
-
- if (!ascii_strcasecmp (m->subtype, "pgp-signed"))
- t |= PGPSIGN;
-
- if (!ascii_strcasecmp (m->subtype, "pgp-keys"))
- t |= PGPKEY;
- }
- else if (m->type == TYPETEXT && ascii_strcasecmp ("plain", m->subtype) == 0)
- {
- if (((p = mutt_get_parameter ("x-mutt-action", m->parameter))
- || (p = mutt_get_parameter ("x-action", m->parameter))
- || (p = mutt_get_parameter ("action", m->parameter)))
- && !ascii_strncasecmp ("pgp-sign", p, 8))
- t |= PGPSIGN;
- else if (p && !ascii_strncasecmp ("pgp-encrypt", p, 11))
- t |= PGPENCRYPT;
- else if (p && !ascii_strncasecmp ("pgp-keys", p, 7))
- t |= PGPKEY;
- }
- return t;
-}
-
return (NULL);
}
- /* send the PGP passphrase to the subprocess */
- fputs (PgpPass, pgpin);
+ /* send the PGP passphrase to the subprocess. Never do this if the
+ agent is active, because this might lead to a passphrase send as
+ the message. */
+ if (!pgp_use_gpg_agent())
+ fputs (PgpPass, pgpin);
fputc ('\n', pgpin);
fclose(pgpin);
return NULL;
}
- fputs(PgpPass, pgpin);
+ if (!pgp_use_gpg_agent())
+ fputs(PgpPass, pgpin);
fputc('\n', pgpin);
fclose(pgpin);
ADDRESS **last = &tmp;
ADDRESS *p, *q;
int i;
- pgp_key_t *k_info, *key;
+ pgp_key_t k_info, key;
const char *fqdn = mutt_fqdn (1);
if (sign)
{
- fputs (PgpPass, pgpin);
+ if (!pgp_use_gpg_agent())
+ fputs (PgpPass, pgpin);
fputc ('\n', pgpin);
}
fclose(pgpin);
return NULL;
}
+ if (pgp_use_gpg_agent())
+ *PgpPass = 0;
if (flags & SIGN)
fprintf (pgpin, "%s\n", PgpPass);
fclose (pgpin);
return b;
}
-
-
-
-#endif /* HAVE_PGP */
+#endif /* CRYPT_BACKEND_CLASSIC_PGP */
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*/
-#ifdef HAVE_PGP
+#ifdef CRYPT_BACKEND_CLASSIC_PGP
#include "mutt_crypt.h"
#include "pgplib.h"
-WHERE REGEXP PgpGoodSign;
-
-WHERE char *PgpSignAs;
-WHERE short PgpTimeout;
-WHERE char *PgpEntryFormat;
-
-
-/* The command formats */
-
-WHERE char *PgpClearSignCommand;
-WHERE char *PgpDecodeCommand;
-WHERE char *PgpVerifyCommand;
-WHERE char *PgpDecryptCommand;
-WHERE char *PgpSignCommand;
-WHERE char *PgpEncryptSignCommand;
-WHERE char *PgpEncryptOnlyCommand;
-WHERE char *PgpImportCommand;
-WHERE char *PgpExportCommand;
-WHERE char *PgpVerifyKeyCommand;
-WHERE char *PgpListSecringCommand;
-WHERE char *PgpListPubringCommand;
-WHERE char *PgpGetkeysCommand;
/* prototypes */
+int pgp_use_gpg_agent();
+
int pgp_check_traditional (FILE *, BODY *, int);
BODY *pgp_decrypt_part (BODY *, STATE *, FILE *, BODY *);
BODY *pgp_make_key_attachment (char *);
const char *pgp_micalg (const char *fname);
-char *_pgp_keyid (pgp_key_t *);
-char *pgp_keyid (pgp_key_t *);
+char *_pgp_keyid (pgp_key_t);
+char *pgp_keyid (pgp_key_t);
int mutt_check_pgp (HEADER * h);
-int mutt_is_application_pgp (BODY *);
-
-int pgp_is_multipart_encrypted (BODY *);
-
int pgp_decrypt_mime (FILE *, FILE **, BODY *, BODY **);
#define pgp_valid_passphrase() crypt_valid_passphrase(APPLICATION_PGP)
-/* pgp_key_t *gpg_get_candidates (struct pgp_vinfo *, pgp_ring_t, LIST *); */
-pgp_key_t *pgp_ask_for_key (char *, char *, short, pgp_ring_t);
-pgp_key_t *pgp_get_candidates (pgp_ring_t, LIST *);
-pgp_key_t *pgp_getkeybyaddr (ADDRESS *, short, pgp_ring_t);
-pgp_key_t *pgp_getkeybystr (char *, short, pgp_ring_t);
+/* pgp_key_t gpg_get_candidates (struct pgp_vinfo *, pgp_ring_t, LIST *); */
+pgp_key_t pgp_ask_for_key (char *, char *, short, pgp_ring_t);
+pgp_key_t pgp_get_candidates (pgp_ring_t, LIST *);
+pgp_key_t pgp_getkeybyaddr (ADDRESS *, short, pgp_ring_t);
+pgp_key_t pgp_getkeybystr (char *, short, pgp_ring_t);
+
+char *pgp_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc);
void pgp_forget_passphrase (void);
void pgp_application_pgp_handler (BODY *, STATE *);
BODY *pgp_sign_message (BODY *);
-#endif /* HAVE_PGP */
+#endif /* CRYPT_BACKEND_CLASSIC_PGP */
#include <locale.h>
-#ifdef HAVE_PGP
+#ifdef CRYPT_BACKEND_CLASSIC_PGP
struct pgp_cache
{
return ' ';
}
-static pgp_key_t *pgp_principal_key (pgp_key_t *key)
+static pgp_key_t pgp_principal_key (pgp_key_t key)
{
if (key->flags & KEYFLAG_SUBKEY && key->parent)
return key->parent;
char fmt[16];
pgp_entry_t *entry;
pgp_uid_t *uid;
- pgp_key_t *key, *pkey;
+ pgp_key_t key, pkey;
int kflags = 0;
int optional = (flags & M_FORMAT_OPTIONAL);
: _pgp_compare_trust (a, b));
}
-static int pgp_key_is_valid (pgp_key_t *k)
+static int pgp_key_is_valid (pgp_key_t k)
{
- pgp_key_t *pk = pgp_principal_key (k);
+ pgp_key_t pk = pgp_principal_key (k);
if (k->flags & KEYFLAG_CANTUSE)
return 0;
if (pk->flags & KEYFLAG_CANTUSE)
return rv;
}
-static pgp_key_t *pgp_select_key (pgp_key_t *keys,
- ADDRESS * p, const char *s)
+static pgp_key_t pgp_select_key (pgp_key_t keys,
+ ADDRESS * p, const char *s)
{
int keymax;
pgp_uid_t **KeyTable;
char cmd[LONG_STRING], tempfile[_POSIX_PATH_MAX];
FILE *fp, *devnull;
pid_t thepid;
- pgp_key_t *kp;
+ pgp_key_t kp;
pgp_uid_t *a;
int (*f) (const void *, const void *);
if (i == keymax)
{
keymax += 5;
- safe_realloc ((void **) &KeyTable, sizeof (pgp_key_t *) * keymax);
+ safe_realloc ((void **) &KeyTable, sizeof (pgp_key_t) * keymax);
}
KeyTable[i++] = a;
f = pgp_compare_trust;
break;
}
- qsort (KeyTable, i, sizeof (pgp_key_t *), f);
+ qsort (KeyTable, i, sizeof (pgp_key_t), f);
helpstr[0] = 0;
mutt_make_help (buf, sizeof (buf), _("Exit "), MENU_PGP, OP_EXIT);
return (kp);
}
-pgp_key_t *pgp_ask_for_key (char *tag, char *whatfor,
- short abilities, pgp_ring_t keyring)
+pgp_key_t pgp_ask_for_key (char *tag, char *whatfor,
+ short abilities, pgp_ring_t keyring)
{
- pgp_key_t *key;
+ pgp_key_t key;
char resp[SHORT_STRING];
struct pgp_cache *l = NULL;
FILE *devnull;
struct stat sb;
pid_t thepid;
- pgp_key_t *key;
+ pgp_key_t key;
unset_option (OPTPGPCHECKTRUST);
key = pgp_ask_for_key (_("Please enter the key ID: "), NULL, 0, PGP_PUBRING);
return hints;
}
-static pgp_key_t **pgp_get_lastp (pgp_key_t *p)
+static pgp_key_t *pgp_get_lastp (pgp_key_t p)
{
for (; p; p = p->next)
if (!p->next)
return NULL;
}
-pgp_key_t *pgp_getkeybyaddr (ADDRESS * a, short abilities, pgp_ring_t keyring)
+pgp_key_t pgp_getkeybyaddr (ADDRESS * a, short abilities, pgp_ring_t keyring)
{
ADDRESS *r, *p;
LIST *hints = NULL;
int this_key_has_invalid;
int match;
- pgp_key_t *keys, *k, *kn;
- pgp_key_t *the_valid_key = NULL;
- pgp_key_t *matches = NULL;
- pgp_key_t **last = &matches;
+ pgp_key_t keys, k, kn;
+ pgp_key_t the_valid_key = NULL;
+ pgp_key_t matches = NULL;
+ pgp_key_t *last = &matches;
pgp_uid_t *q;
if (a && a->mailbox)
return NULL;
}
-pgp_key_t *pgp_getkeybystr (char *p, short abilities, pgp_ring_t keyring)
+pgp_key_t pgp_getkeybystr (char *p, short abilities, pgp_ring_t keyring)
{
LIST *hints = NULL;
- pgp_key_t *keys;
- pgp_key_t *matches = NULL;
- pgp_key_t **last = &matches;
- pgp_key_t *k, *kn;
+ pgp_key_t keys;
+ pgp_key_t matches = NULL;
+ pgp_key_t *last = &matches;
+ pgp_key_t k, kn;
pgp_uid_t *a;
short match;
-#endif /* HAVE_PGP */
+#endif /* CRYPT_BACKEND_CLASSIC_PGP */
#include <unistd.h>
#include <time.h>
+#include "mutt.h"
#include "lib.h"
#include "pgplib.h"
*upp = NULL;
}
-pgp_uid_t *pgp_copy_uids (pgp_uid_t *up, pgp_key_t *parent)
+pgp_uid_t *pgp_copy_uids (pgp_uid_t *up, pgp_key_t parent)
{
pgp_uid_t *l = NULL;
pgp_uid_t **lp = &l;
return l;
}
-static void _pgp_free_key (pgp_key_t ** kpp)
+static void _pgp_free_key (pgp_key_t *kpp)
{
- pgp_key_t *kp;
+ pgp_key_t kp;
if (!kpp || !*kpp)
return;
FREE (kpp);
}
-pgp_key_t *pgp_remove_key (pgp_key_t ** klist, pgp_key_t * key)
+pgp_key_t pgp_remove_key (pgp_key_t *klist, pgp_key_t key)
{
- pgp_key_t **last;
- pgp_key_t *p, *q, *r;
+ pgp_key_t *last;
+ pgp_key_t p, q, r;
if (!klist || !*klist || !key)
return NULL;
return q;
}
-void pgp_free_key (pgp_key_t ** kpp)
+void pgp_free_key (pgp_key_t *kpp)
{
- pgp_key_t *p, *q, *r;
+ pgp_key_t p, q, r;
if (!kpp || !*kpp)
return;
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*/
-#ifdef HAVE_PGP
+#ifdef CRYPT_BACKEND_CLASSIC_PGP
-#define APPLICATION_PGP (1 << 5)
+#include "mutt_crypt.h"
-#define PGPENCRYPT (APPLICATION_PGP | ENCRYPT)
-#define PGPSIGN (APPLICATION_PGP | SIGN)
-#define PGPGOODSIGN (APPLICATION_PGP | GOODSIGN)
-#define PGPKEY (APPLICATION_PGP | (1 << 3))
-
-#define KEYFLAG_CANSIGN (1 << 0)
-#define KEYFLAG_CANENCRYPT (1 << 1)
-#define KEYFLAG_SECRET (1 << 7)
-#define KEYFLAG_EXPIRED (1 << 8)
-#define KEYFLAG_REVOKED (1 << 9)
-#define KEYFLAG_DISABLED (1 << 10)
-#define KEYFLAG_SUBKEY (1 << 11)
-#define KEYFLAG_CRITICAL (1 << 12)
-#define KEYFLAG_PREFER_ENCRYPTION (1 << 13)
-#define KEYFLAG_PREFER_SIGNING (1 << 14)
-
-#define KEYFLAG_CANTUSE (KEYFLAG_DISABLED|KEYFLAG_REVOKED|KEYFLAG_EXPIRED)
-#define KEYFLAG_RESTRICTIONS (KEYFLAG_CANTUSE|KEYFLAG_CRITICAL)
-
-#define KEYFLAG_ABILITIES (KEYFLAG_CANSIGN|KEYFLAG_CANENCRYPT|KEYFLAG_PREFER_ENCRYPTION|KEYFLAG_PREFER_SIGNING)
typedef struct pgp_signature
{
}
pgp_sig_t;
-typedef struct pgp_keyinfo
+struct pgp_keyinfo
{
char *keyid;
struct pgp_uid *address;
unsigned char fingerprint[20]; /* large enough to hold SHA-1 and RIPEMD160
hashes (20 bytes), MD5 hashes just use the
first 16 bytes */
-}
-pgp_key_t;
+};
+/* Note, that pgp_key_t is now pointer and declared in crypt.h */
typedef struct pgp_uid
{
PGP_UNKNOWN
};
-enum pgp_ring
-{
- PGP_PUBRING,
- PGP_SECRING
-};
-
-typedef enum pgp_ring pgp_ring_t;
-
/* prototypes */
const char *pgp_pkalgbytype (unsigned char);
-pgp_key_t *pgp_remove_key (pgp_key_t **, pgp_key_t *);
-pgp_uid_t *pgp_copy_uids (pgp_uid_t *, pgp_key_t *);
+pgp_key_t pgp_remove_key (pgp_key_t *, pgp_key_t );
+pgp_uid_t *pgp_copy_uids (pgp_uid_t *, pgp_key_t );
short pgp_canencrypt (unsigned char);
short pgp_cansign (unsigned char);
short pgp_get_abilities (unsigned char);
-void pgp_free_key (pgp_key_t **kpp);
+void pgp_free_key (pgp_key_t *kpp);
-#define pgp_new_keyinfo() safe_calloc (sizeof (pgp_key_t), 1)
+#define pgp_new_keyinfo() safe_calloc (sizeof *((pgp_key_t)0), 1)
-#endif /* HAVE_PGP */
+#endif /* CRYPT_BACKEND_CLASSIC_PGP */
static void pgpring_find_candidates (char *ringfile, const char *hints[], int nhints);
-static void pgpring_dump_keyblock (pgp_key_t *p);
+static void pgpring_dump_keyblock (pgp_key_t p);
int main (int argc, char * const argv[])
{
} /* pgp_make_pgp2_fingerprint() */
-static pgp_key_t *pgp_parse_pgp2_key (unsigned char *buff, size_t l)
+static pgp_key_t pgp_parse_pgp2_key (unsigned char *buff, size_t l)
{
- pgp_key_t *p;
+ pgp_key_t p;
unsigned char alg;
unsigned char digest[MD5_DIGEST_LENGTH];
size_t expl;
}
-static pgp_key_t *pgp_parse_pgp3_key (unsigned char *buff, size_t l)
+static pgp_key_t pgp_parse_pgp3_key (unsigned char *buff, size_t l)
{
- pgp_key_t *p;
+ pgp_key_t p;
unsigned char alg;
unsigned char digest[SHA_DIGEST_LENGTH];
unsigned char scratch[LONG_STRING];
return p;
}
-static pgp_key_t *pgp_parse_keyinfo (unsigned char *buff, size_t l)
+static pgp_key_t pgp_parse_keyinfo (unsigned char *buff, size_t l)
{
if (!buff || l < 2)
return NULL;
}
}
-static int pgp_parse_pgp2_sig (unsigned char *buff, size_t l, pgp_key_t * p, pgp_sig_t *s)
+static int pgp_parse_pgp2_sig (unsigned char *buff, size_t l,
+ pgp_key_t p, pgp_sig_t *s)
{
unsigned char sigtype;
time_t sig_gen_time;
return 0;
}
-static int pgp_parse_pgp3_sig (unsigned char *buff, size_t l, pgp_key_t * p, pgp_sig_t *s)
+static int pgp_parse_pgp3_sig (unsigned char *buff, size_t l,
+ pgp_key_t p, pgp_sig_t *s)
{
unsigned char sigtype;
unsigned char pkalg;
}
-static int pgp_parse_sig (unsigned char *buff, size_t l, pgp_key_t * p, pgp_sig_t *sig)
+static int pgp_parse_sig (unsigned char *buff, size_t l,
+ pgp_key_t p, pgp_sig_t *sig)
{
if (!buff || l < 2 || !p)
return -1;
/* parse one key block, including all subkeys. */
-static pgp_key_t *pgp_parse_keyblock (FILE * fp)
+static pgp_key_t pgp_parse_keyblock (FILE * fp)
{
unsigned char *buff;
unsigned char pt = 0;
long pos;
#endif
- pgp_key_t *root = NULL;
- pgp_key_t **last = &root;
- pgp_key_t *p = NULL;
+ pgp_key_t root = NULL;
+ pgp_key_t *last = &root;
+ pgp_key_t p = NULL;
pgp_uid_t *uid = NULL;
pgp_uid_t **addr = NULL;
pgp_sig_t **lsig = NULL;
if (pgpring_string_matches_hint (tmp, hints, nhints))
{
- pgp_key_t *p;
+ pgp_key_t p;
FSETPOS(rfp, keypos);
}
}
-static void print_fingerprint (pgp_key_t *p)
+static void print_fingerprint (pgp_key_t p)
{
int i = 0;
return 'q';
}
-static void pgpring_dump_keyblock (pgp_key_t *p)
+static void pgpring_dump_keyblock (pgp_key_t p)
{
pgp_uid_t *uid;
short first;
#include "mutt.h"
#include "mx.h"
#include "pop.h"
-
-#ifdef HAVE_PGP
-#include "pgp.h"
-#endif
-
-#ifdef HAVE_SMIME
-#include "smime.h"
-#endif
+#include "mutt_crypt.h"
#include <string.h>
#include <unistd.h>
h->content->length = ftell (msg->fp) - h->content->offset;
/* This needs to be done in case this is a multipart message */
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- h->security = crypt_query (h->content);
-#endif
+ if (!WithCrypto)
+ h->security = crypt_query (h->content);
mutt_clear_error();
rewind (msg->fp);
#include "mx.h"
#include "imap.h"
#endif
+#include "mutt_crypt.h"
#include <ctype.h>
#include <unistd.h>
-#ifdef HAVE_PGP
-#include "pgp.h"
-#endif /* HAVE_PGP */
-
-#ifdef HAVE_SMIME
-#include "smime.h"
-#endif /* HAVE_SMIME */
-
-
static short PostCount = 0;
static CONTEXT *PostContext = NULL;
static short UpdateNumPostponed = 0;
mutt_free_list (&tmp);
tmp = next;
}
-
-
-
-#ifdef HAVE_PGP
- else if (mutt_strncmp ("Pgp:", tmp->data, 4) == 0 /* this is generated
+ else if ((WithCrypto & APPLICATION_PGP)
+ && (mutt_strncmp ("Pgp:", tmp->data, 4) == 0 /* this is generated
* by old mutt versions
*/
- || mutt_strncmp ("X-Mutt-PGP:", tmp->data, 11) == 0)
+ || mutt_strncmp ("X-Mutt-PGP:", tmp->data, 11) == 0))
{
hdr->security = mutt_parse_crypt_hdr (strchr (tmp->data, ':') + 1, 1);
hdr->security |= APPLICATION_PGP;
mutt_free_list (&tmp);
tmp = next;
}
-#endif /* HAVE_PGP */
-
-
-#ifdef HAVE_SMIME
- else if (mutt_strncmp ("X-Mutt-SMIME:", tmp->data, 13) == 0)
+ else if ((WithCrypto & APPLICATION_SMIME)
+ && mutt_strncmp ("X-Mutt-SMIME:", tmp->data, 13) == 0)
{
hdr->security = mutt_parse_crypt_hdr (strchr (tmp->data, ':') + 1, 1);
hdr->security |= APPLICATION_SMIME;
mutt_free_list (&tmp);
tmp = next;
}
-#endif /* HAVE_SMIME */
-
#ifdef MIXMASTER
else if (mutt_strncmp ("X-Mutt-Mix:", tmp->data, 11) == 0)
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
-
int mutt_parse_crypt_hdr (char *p, int set_signas)
{
int pgp = 0;
char pgp_sign_as[LONG_STRING] = "\0", *q;
char smime_cryptalg[LONG_STRING] = "\0";
+
+ if (!WithCrypto)
+ return 0;
SKIPWS (p);
for (; *p; p++)
}
/* the cryptalg field must not be empty */
-#ifdef HAVE_SMIME
- if (*smime_cryptalg)
+ if ((WithCrypto & APPLICATION_SMIME) && *smime_cryptalg)
mutt_str_replace (&SmimeCryptAlg, smime_cryptalg);
-#endif /* HAVE_SMIME */
-#ifdef HAVE_PGP
- if (set_signas || *pgp_sign_as)
+ if ((WithCrypto & APPLICATION_PGP) && (set_signas || *pgp_sign_as))
mutt_str_replace (&PgpSignAs, pgp_sign_as);
-#endif /* HAVE_PGP */
return pgp;
}
-#endif /* HAVE_PGP || HAVE_SMIME */
FREE (&newhdr->env->message_id);
FREE (&newhdr->env->mail_followup_to); /* really? */
-#ifdef HAVE_PGP
/* decrypt pgp/mime encoded messages */
/* XXX - what happens with S/MIME encrypted messages?!?!? - tlr, 020909*/
- if ((hdr->security & APPLICATION_PGP) &&
- mutt_is_multipart_encrypted (newhdr->content))
+ if ((WithCrypto & APPLICATION_PGP)
+ && (hdr->security & APPLICATION_PGP)
+ && mutt_is_multipart_encrypted (newhdr->content))
{
newhdr->security |= PGPENCRYPT;
- if (!pgp_valid_passphrase())
+ if (!crypt_valid_passphrase(APPLICATION_PGP))
goto err;
mutt_message _("Invoking PGP...");
- if (pgp_decrypt_mime (fp, &bfp, newhdr->content, &b) == -1 || b == NULL)
+ if (crypt_pgp_decrypt_mime (fp, &bfp, newhdr->content, &b) == -1 || b == NULL)
{
err:
mx_close_message (&msg);
mutt_clear_error ();
}
-#endif
-
-#if defined(HAVE_PGP)|| defined(HAVE_SMIME)
/*
* remove a potential multipart/signed layer - useful when
* resending messages
*/
- if (mutt_is_multipart_signed (newhdr->content))
+ if (WithCrypto && mutt_is_multipart_signed (newhdr->content))
{
newhdr->security |= SIGN;
-#ifdef HAVE_PGP
- if (ascii_strcasecmp (mutt_get_parameter ("protocol", newhdr->content->parameter),
- "application/pgp-signature") == 0)
+ if ((WithCrypto & APPLICATION_PGP)
+ && ascii_strcasecmp (mutt_get_parameter ("protocol", newhdr->content->parameter), "application/pgp-signature") == 0)
newhdr->security |= APPLICATION_PGP;
-#endif
-#if defined (HAVE_PGP) && defined (HAVE_SMIME)
- else
-#endif
-#ifdef HAVE_SMIME
+ else if ((WithCrypto & APPLICATION_SMIME))
newhdr->security |= APPLICATION_SMIME;
-#endif
/* destroy the signature */
mutt_free_body (&newhdr->content->parts->next);
newhdr->content = mutt_remove_multipart (newhdr->content);
}
-#endif
/*
* We don't need no primary multipart.
char *mutt_get_body_charset (char *, size_t, BODY *);
char *mutt_get_name (ADDRESS *);
char *mutt_get_parameter (const char *, PARAMETER *);
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
char *mutt_crypt_hook (ADDRESS *);
-#endif /* HAVE_PGP */
char *mutt_make_date (char *, size_t);
const char *mutt_make_version (void);
#include "mapping.h"
#include "mx.h"
#include "copy.h"
-
-
-
-#ifdef HAVE_PGP
-#include "pgp.h"
-#endif
-
-#ifdef HAVE_SMIME
-#include "smime.h"
-#endif
-
-
+#include "mutt_crypt.h"
#include <ctype.h>
#include <stdlib.h>
if (m->type == TYPEMULTIPART && m->parts
&& (compose || (parent_type == -1 && ascii_strcasecmp ("alternative", m->subtype)))
-#ifdef HAVE_PGP
- && !mutt_is_multipart_encrypted(m)
-#endif
+ && (!(WithCrypto & APPLICATION_PGP) || !mutt_is_multipart_encrypted(m))
)
{
idx = mutt_gen_attach_list (m->parts, m->type, idx, idxlen, idxmax, level, compose);
/* We don't support multipart messages in the compose menu yet */
if (!compose && !m->collapsed &&
((m->type == TYPEMULTIPART
-#ifdef HAVE_PGP
- && !mutt_is_multipart_encrypted (m)
-#endif
+ && (!(WithCrypto & APPLICATION_PGP)
+ || !mutt_is_multipart_encrypted (m))
)
|| mutt_is_message_type(m->type, m->subtype)))
{
op = OP_VIEW_ATTACH;
break;
/* functions which are passed through from the pager */
- case OP_ATTACH_COLLAPSE:
-#ifdef HAVE_PGP
case OP_CHECK_TRADITIONAL:
-#endif
+ if (!(WithCrypto & APPLICATION_PGP))
+ {
+ op = OP_NULL;
+ break;
+ }
+ /* fall through */
+ case OP_ATTACH_COLLAPSE:
if (recv)
return op;
default:
void mutt_view_attachments (HEADER *hdr)
{
-
-
-
-
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
int secured = 0;
int need_secured = 0;
-#endif
-
-
char helpstr[SHORT_STRING];
MUTTMENU *menu;
return;
-
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- if (hdr->security & ENCRYPT)
+ if (WithCrypto && (hdr->security & ENCRYPT))
{
need_secured = 1;
mx_close_message (&msg);
return;
}
-#ifdef HAVE_SMIME
- if (hdr->security & APPLICATION_SMIME)
+ if ((WithCrypto & APPLICATION_SMIME) && hdr->security & APPLICATION_SMIME)
{
if (hdr->env)
- smime_getkeys (hdr->env);
+ crypt_smime_getkeys (hdr->env);
if (mutt_is_application_smime(hdr->content))
- secured = ! smime_decrypt_mime (msg->fp, &fp, hdr->content, &cur);
+ secured = ! crypt_smime_decrypt_mime (msg->fp, &fp,
+ hdr->content, &cur);
else
need_secured = 0;
}
-#endif
-#ifdef HAVE_PGP
- if (hdr->security & APPLICATION_PGP)
+ if ((WithCrypto & APPLICATION_PGP) && hdr->security & APPLICATION_PGP)
{
if (mutt_is_multipart_encrypted(hdr->content))
- secured = !pgp_decrypt_mime (msg->fp, &fp, hdr->content, &cur);
+ secured = !crypt_pgp_decrypt_mime (msg->fp, &fp, hdr->content, &cur);
else
need_secured = 0;
}
-#endif
if (need_secured && !secured)
{
}
}
- if (!need_secured)
-#endif /* HAVE_SMIME || HAVVE_PGP */
+ if (!WithCrypto || !need_secured)
{
fp = msg->fp;
cur = hdr->content;
mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
break;
-
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
case OP_FORGET_PASSPHRASE:
crypt_forget_passphrase ();
break;
-#endif
-
-#ifdef HAVE_PGP
case OP_EXTRACT_KEYS:
- pgp_extract_keys_from_attachment_list (fp, menu->tagprefix,
- menu->tagprefix ? cur : idx[menu->current]->content);
- menu->redraw = REDRAW_FULL;
+ if ((WithCrypto & APPLICATION_PGP))
+ {
+ crypt_pgp_extract_keys_from_attachment_list (fp, menu->tagprefix,
+ menu->tagprefix ? cur : idx[menu->current]->content);
+ menu->redraw = REDRAW_FULL;
+ }
break;
case OP_CHECK_TRADITIONAL:
- if (pgp_check_traditional (fp, menu->tagprefix ? cur : idx[menu->current]->content,
- menu->tagprefix))
+ if ((WithCrypto & APPLICATION_PGP)
+ && crypt_pgp_check_traditional (fp, menu->tagprefix ? cur
+ : idx[menu->current]->content,
+ menu->tagprefix))
{
hdr->security = crypt_query (cur);
menu->redraw = REDRAW_FULL;
}
break;
-#endif
-
-
case OP_PRINT:
mutt_print_attachment_list (fp, menu->tagprefix,
}
#endif
-
-
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- if (hdr->security)
+ if (WithCrypto && hdr->security)
{
mutt_message _(
"Deletion of attachments from encrypted messages is unsupported.");
}
else
-#endif
{
if (!menu->tagprefix)
{
FREE (&idx);
idxmax = 0;
-
-
-
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- if (need_secured && secured)
+ if (WithCrypto && need_secured && secured)
{
fclose (fp);
mutt_free_body (&cur);
}
-#endif /* HAVE_PGP || HAVE_SMIME */
-
-
mutt_menuDestroy (&menu);
return;
#include "mailbox.h"
#include "copy.h"
#include "mx.h"
+#include "mutt_crypt.h"
#include <ctype.h>
#include <stdlib.h>
#include <sys/types.h>
#include <utime.h>
-#ifdef HAVE_PGP
-#include "pgp.h"
-#endif
-
-#ifdef HAVE_SMIME
-#include "smime.h"
-#endif
-
#ifdef MIXMASTER
#include "remailer.h"
#endif
mutt_parse_mime_message (ctx, cur);
mutt_message_hook (ctx, cur, M_MESSAGEHOOK);
-#ifdef HAVE_PGP
- if ((cur->security & ENCRYPT) && option (OPTFORWDECODE))
+ if (WithCrypto && (cur->security & ENCRYPT) && option (OPTFORWDECODE))
{
/* make sure we have the user's passphrase before proceeding... */
crypt_valid_passphrase (cur->security);
}
-#endif /* HAVE_SMIME */
mutt_forward_intro (out, cur);
int cmflags = M_CM_PREFIX | M_CM_DECODE | M_CM_CHARCONV;
int chflags = CH_DECODE;
-#ifdef HAVE_PGP
- if (cur->security & ENCRYPT)
- {
- /* make sure we have the user's passphrase before proceeding... */
- crypt_valid_passphrase (cur->security);
- }
-#endif /* HAVE_SMIME */
+ if (WithCrypto && (cur->security & ENCRYPT))
+ {
+ /* make sure we have the user's passphrase before proceeding... */
+ crypt_valid_passphrase (cur->security);
+ }
mutt_parse_mime_message (ctx, cur);
mutt_message_hook (ctx, cur, M_MESSAGEHOOK);
else if (i == -1)
return -1;
}
-
-
-
-#if defined(HAVE_PGP)
-/* || defined(HAVE_SMIME) */
- else if (flags & SENDKEY)
+ /* if (WithCrypto && (flags & SENDKEY)) */
+ else if ((WithCrypto & APPLICATION_PGP) && (flags & SENDKEY))
{
BODY *tmp;
-#ifdef HAVE_PGP
- if ((tmp = pgp_make_key_attachment (NULL)) == NULL)
+
+ if ((WithCrypto & APPLICATION_PGP)
+ && (tmp = crypt_pgp_make_key_attachment (NULL)) == NULL)
return -1;
-#endif
tmp->next = msg->content;
msg->content = tmp;
}
-#endif
mutt_clear_error ();
int fcc_error = 0;
int free_clear_content = 0;
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
BODY *save_content = NULL;
BODY *clear_content = NULL;
char *pgpkeylist = NULL;
/* save current value of "pgp_sign_as" */
char *signas = NULL;
-#endif
int rv = -1;
}
-#ifdef HAVE_PGP
- if (flags & SENDPOSTPONED)
+ if ((WithCrypto & APPLICATION_PGP) && (flags & SENDPOSTPONED))
signas = safe_strdup(PgpSignAs);
-#endif /* HAVE_PGP */
/* Delay expansion of aliases until absolutely necessary--shouldn't
* be necessary unless we are prompting the user or about to execute a
* can take effect.
*/
-#if defined(HAVE_PGP)|| defined(HAVE_SMIME)
- if (! (flags & SENDMAILX))
+ if (WithCrypto && !(flags & SENDMAILX))
{
if (option (OPTCRYPTAUTOSIGN))
msg->security |= SIGN;
msg->security |= SIGN;
}
- if (msg->security && cur)
+ if (WithCrypto && msg->security && cur)
{
-#ifdef HAVE_SMIME
- if ((cur->security & APPLICATION_SMIME) || option (OPTSMIMEISDEFAULT))
+ if ((WithCrypto & APPLICATION_SMIME)
+ && ((cur->security & APPLICATION_SMIME)
+ || option (OPTSMIMEISDEFAULT)))
msg->security |= APPLICATION_SMIME;
-#endif
-#ifdef HAVE_PGP
- if (cur->security & APPLICATION_PGP)
+
+ if ((WithCrypto & APPLICATION_PGP) && (cur->security & APPLICATION_PGP))
{
-#ifdef HAVE_SMIME
msg->security &= ~APPLICATION_SMIME;
-#endif
msg->security |= APPLICATION_PGP;
}
-#ifdef HAVE_SMIME
- if (!(cur->security & (APPLICATION_PGP|APPLICATION_SMIME)))
-#endif
+ if ((WithCrypto & APPLICATION_SMIME)
+ && !(cur->security & (APPLICATION_PGP|APPLICATION_SMIME)))
msg->security |= APPLICATION_PGP;
-#endif /* HAVE_PGP */
}
- else if (msg->security)
+ else if ((WithCrypto & APPLICATION_PGP) && msg->security)
{
-#ifdef HAVE_PGP
msg->security |= APPLICATION_PGP;
-#ifdef HAVE_SMIME
- if (option (OPTSMIMEISDEFAULT))
+ if ((WithCrypto & APPLICATION_SMIME) && option (OPTSMIMEISDEFAULT))
{
msg->security |= APPLICATION_SMIME;
msg->security &= ~APPLICATION_PGP;
}
-#endif
-#endif /* HAVE_PGP */
}
-#endif /* HAVE_PGP || HAVE_SMIME */
-
}
/* wait until now to set the real name portion of our return address so
that $realname can be set in a send-hook */
- if (msg->env->from && !msg->env->from->personal && !(flags & (SENDRESEND|SENDPOSTPONED)))
+ if (msg->env->from && !msg->env->from->personal
+ && !(flags & (SENDRESEND|SENDPOSTPONED)))
msg->env->from->personal = safe_strdup (Realname);
-
-
-#ifdef HAVE_PGP
- if (! (flags & SENDKEY))
-#endif
+ if ((WithCrypto & APPLICATION_PGP) && !(flags & SENDKEY))
safe_fclose (&tempfp);
-
-
if (flags & SENDMAILX)
{
if (mutt_builtin_editor (msg->content->filename, msg, cur) == -1)
encode_descriptions (msg->content, 1);
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- if (msg->security)
+ if (WithCrypto)
{
- /* save the decrypted attachments */
- clear_content = msg->content;
-
- if ((crypt_get_keys (msg, &pgpkeylist) == -1) ||
- mutt_protect (msg, pgpkeylist) == -1)
+ if (msg->security)
{
- msg->content = mutt_remove_multipart (msg->content);
-
- if (pgpkeylist)
- FREE (&pgpkeylist);
-
- decode_descriptions (msg->content);
- goto main_loop;
+ /* save the decrypted attachments */
+ clear_content = msg->content;
+
+ if ((crypt_get_keys (msg, &pgpkeylist) == -1) ||
+ mutt_protect (msg, pgpkeylist) == -1)
+ {
+ msg->content = mutt_remove_multipart (msg->content);
+
+ if (pgpkeylist)
+ FREE (&pgpkeylist);
+
+ decode_descriptions (msg->content);
+ goto main_loop;
+ }
+ encode_descriptions (msg->content, 0);
}
- encode_descriptions (msg->content, 0);
- }
-
- /*
- * at this point, msg->content is one of the following three things:
- * - multipart/signed. In this case, clear_content is a child.
- * - multipart/encrypted. In this case, clear_content exists
- * independently
- * - application/pgp. In this case, clear_content exists independently.
- * - something else. In this case, it's the same as clear_content.
- */
-
- /* This is ugly -- lack of "reporting back" from mutt_protect(). */
- if (clear_content && (msg->content != clear_content)
- && (msg->content->parts != clear_content))
- free_clear_content = 1;
+ /*
+ * at this point, msg->content is one of the following three things:
+ * - multipart/signed. In this case, clear_content is a child.
+ * - multipart/encrypted. In this case, clear_content exists
+ * independently
+ * - application/pgp. In this case, clear_content exists independently.
+ * - something else. In this case, it's the same as clear_content.
+ */
-#endif /* HAVE_PGP */
+ /* This is ugly -- lack of "reporting back" from mutt_protect(). */
+
+ if (clear_content && (msg->content != clear_content)
+ && (msg->content->parts != clear_content))
+ free_clear_content = 1;
+ }
if (!option (OPTNOCURSES) && !(flags & SENDMAILX))
mutt_message _("Sending message...");
if (*fcc && mutt_strcmp ("/dev/null", fcc) != 0)
{
BODY *tmpbody = msg->content;
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
BODY *save_sig = NULL;
BODY *save_parts = NULL;
-#endif /* HAVE_PGP */
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- if (msg->security && option (OPTFCCCLEAR))
+ if (WithCrypto && msg->security && option (OPTFCCCLEAR))
msg->content = clear_content;
-#endif
/* check to see if the user wants copies of all attachments */
if (!option (OPTFCCATTACH) && msg->content->type == TYPEMULTIPART)
{
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- if (mutt_strcmp (msg->content->subtype, "encrypted") == 0 ||
- mutt_strcmp (msg->content->subtype, "signed") == 0)
+ if (WithCrypto
+ && (mutt_strcmp (msg->content->subtype, "encrypted") == 0 ||
+ mutt_strcmp (msg->content->subtype, "signed") == 0))
{
if (clear_content->type == TYPEMULTIPART)
{
}
}
else
-#endif /* HAVE_PGP || HAVE_SMIME */
msg->content = msg->content->parts;
}
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
full_fcc:
-#endif /* HAVE_PGP || HAVE_SMIME */
if (msg->content)
{
/* update received time so that when storing to a mbox-style folder
msg->content = tmpbody;
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- if (save_sig)
+ if (WithCrypto && save_sig)
{
/* cleanup the second signature structures */
if (save_content->parts)
msg->content->parts->next = save_sig;
msg->content->parts->parts->next = save_parts;
}
- else if (save_content)
+ else if (WithCrypto && save_content)
{
/* destroy the new encrypted body. */
mutt_free_body (&save_content);
}
-
-#endif /* HAVE_PGP || HAVE_SMIME */
+
}
{
if (!(flags & SENDBATCH))
{
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- if ((msg->security & ENCRYPT) ||
- ((msg->security & SIGN) && msg->content->type == TYPEAPPLICATION))
+ if (!WithCrypto)
+ ;
+ else if ((msg->security & ENCRYPT) ||
+ ((msg->security & SIGN)
+ && msg->content->type == TYPEAPPLICATION))
{
mutt_free_body (&msg->content); /* destroy PGP data */
msg->content = clear_content; /* restore clear text. */
}
else if ((msg->security & SIGN) && msg->content->type == TYPEMULTIPART)
{
- mutt_free_body (&msg->content->parts->next); /* destroy sig */
- msg->content = mutt_remove_multipart (msg->content); /* remove multipart */
+ mutt_free_body (&msg->content->parts->next); /* destroy sig */
+ msg->content = mutt_remove_multipart (msg->content);
}
-#endif
+
msg->content = mutt_remove_multipart (msg->content);
decode_descriptions (msg->content);
mutt_unprepare_envelope (msg->env);
else if (!option (OPTNOCURSES) && ! (flags & SENDMAILX))
mutt_message (i == 0 ? _("Mail sent.") : _("Sending in background."));
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- if (msg->security & ENCRYPT)
+ if (WithCrypto && (msg->security & ENCRYPT))
FREE (&pgpkeylist);
- if (free_clear_content)
+ if (WithCrypto && free_clear_content)
mutt_free_body (&clear_content);
-#endif
if (flags & SENDREPLY)
{
cleanup:
-
-
-#ifdef HAVE_PGP
- if (flags & SENDPOSTPONED)
+ if ((WithCrypto & APPLICATION_PGP) && (flags & SENDPOSTPONED))
{
-
if(signas)
{
FREE (&PgpSignAs);
PgpSignAs = signas;
}
}
-#endif /* HAVE_PGP */
safe_fclose (&tempfp);
mutt_free_header (&msg);
return rv;
-
}
/* vim: set sw=2: */
#include "copy.h"
#include "pager.h"
#include "charset.h"
-
+#include "mutt_crypt.h"
#include <string.h>
#include <stdlib.h>
};
-#ifdef HAVE_PGP
-#include "pgp.h"
-#endif /* HAVE_PGP */
-
-
-#ifdef HAVE_SMIME
-#include "smime.h"
-#endif /* HAVE_SMIME */
-
-
#define DISPOSITION(X) X==DISPATTACH?"attachment":"inline"
return (ferror (f) ? -1 : 0);
}
-#ifdef HAVE_PGP
-# define write_as_text_part(a) (mutt_is_text_part(a) || mutt_is_application_pgp(a))
-#else
-# define write_as_text_part(a) (mutt_is_text_part(a))
-#endif
+# define write_as_text_part(a) (mutt_is_text_part(a) \
+ || ((WithCrypto & APPLICATION_PGP)\
+ && mutt_is_application_pgp(a)))
int mutt_write_mime_body (BODY *a, FILE *f)
{
return (ferror (f) ? -1 : 0);
}
-
-
-#ifdef HAVE_PGP
/* This is pretty gross, but it's the best solution for now... */
- if (a->type == TYPEAPPLICATION && mutt_strcmp (a->subtype, "pgp-encrypted") == 0)
+ if ((WithCrypto & APPLICATION_PGP)
+ && a->type == TYPEAPPLICATION
+ && mutt_strcmp (a->subtype, "pgp-encrypted") == 0)
{
fputs ("Version: 1\n", f);
return 0;
}
-#endif /* HAVE_PGP */
-
-
if ((fpin = fopen (a->filename, "r")) == NULL)
{
BODY *body;
FILE *fp;
int cmflags, chflags;
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- int pgp = hdr->security;
-#endif
+ int pgp = WithCrypto? hdr->security : 0;
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- if ((option(OPTMIMEFORWDECODE) || option(OPTFORWDECRYPT)) &&
- (hdr->security & ENCRYPT)) {
- if (!crypt_valid_passphrase(hdr->security))
- return (NULL);
+ if (WithCrypto)
+ {
+ if ((option(OPTMIMEFORWDECODE) || option(OPTFORWDECRYPT)) &&
+ (hdr->security & ENCRYPT)) {
+ if (!crypt_valid_passphrase(hdr->security))
+ return (NULL);
+ }
}
-#endif /* defined(HAVE_PGP) || defined(HAVE_SMIME) */
mutt_mktemp (buffer);
if ((fp = safe_fopen (buffer, "w+")) == NULL)
{
chflags |= CH_MIME | CH_TXTPLAIN;
cmflags = M_CM_DECODE | M_CM_CHARCONV;
-#ifdef HAVE_PGP
- pgp &= ~PGPENCRYPT;
-#endif
-#ifdef HAVE_SMIME
- pgp &= ~SMIMEENCRYPT;
-#endif
+ if ((WithCrypto & APPLICATION_PGP))
+ pgp &= ~PGPENCRYPT;
+ if ((WithCrypto & APPLICATION_SMIME))
+ pgp &= ~SMIMEENCRYPT;
}
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- else
- if (option (OPTFORWDECRYPT)
- && (hdr->security & ENCRYPT))
+ else if (WithCrypto
+ && option (OPTFORWDECRYPT) && (hdr->security & ENCRYPT))
{
-#ifdef HAVE_PGP
- if (mutt_is_multipart_encrypted (hdr->content))
+ if ((WithCrypto & APPLICATION_PGP)
+ && mutt_is_multipart_encrypted (hdr->content))
{
chflags |= CH_MIME | CH_NONEWLINE;
cmflags = M_CM_DECODE_PGP;
pgp &= ~PGPENCRYPT;
}
- else if (mutt_is_application_pgp (hdr->content) & PGPENCRYPT)
+ else if ((WithCrypto & APPLICATION_PGP)
+ && (mutt_is_application_pgp (hdr->content) & PGPENCRYPT))
{
chflags |= CH_MIME | CH_TXTPLAIN;
cmflags = M_CM_DECODE | M_CM_CHARCONV;
pgp &= ~PGPENCRYPT;
}
-#endif
-#if defined(HAVE_PGP) && defined(HAVE_SMIME)
- else
-#endif
-#ifdef HAVE_SMIME
- if (mutt_is_application_smime (hdr->content) & SMIMEENCRYPT)
+ else if ((WithCrypto & APPLICATION_SMIME)
+ && mutt_is_application_smime (hdr->content) & SMIMEENCRYPT)
{
chflags |= CH_MIME | CH_TXTPLAIN;
cmflags = M_CM_DECODE | M_CM_CHARCONV;
pgp &= ~SMIMEENCRYPT;
}
-#endif
}
-#endif
mutt_copy_message (fp, ctx, hdr, cmflags, chflags);
body->hdr->offset = 0;
/* we don't need the user headers here */
body->hdr->env = mutt_read_rfc822_header(fp, body->hdr, 0, 0);
-#if defined(HAVE_PGP) || defined(HAVE_SMIME)
- body->hdr->security = pgp;
-#endif /* HAVE_PGP */
+ if (WithCrypto)
+ body->hdr->security = pgp;
mutt_update_encoding (body);
body->parts = body->hdr->content;
-#ifdef HAVE_PGP
/* (postponment) if the mail is to be signed or encrypted, save this info */
- if (post && (hdr->security & APPLICATION_PGP))
+ if ((WithCrypto & APPLICATION_PGP)
+ && post && (hdr->security & APPLICATION_PGP))
{
fputs ("X-Mutt-PGP: ", msg->fp);
if (hdr->security & ENCRYPT)
}
fputc ('\n', msg->fp);
}
-#endif /* HAVE_PGP */
-#ifdef HAVE_SMIME
/* (postponment) if the mail is to be signed or encrypted, save this info */
- if (post && (hdr->security & APPLICATION_SMIME))
+ if ((WithCrypto & APPLICATION_SMIME)
+ && post && (hdr->security & APPLICATION_SMIME))
{
fputs ("X-Mutt-SMIME: ", msg->fp);
if (hdr->security & ENCRYPT) {
}
fputc ('\n', msg->fp);
}
-#endif /* HAVE_SMIME */
#ifdef MIXMASTER
/* (postponement) if the mail is to be sent through a mixmaster
# include <sys/resource.h>
#endif
-#ifdef HAVE_SMIME
+#ifdef CRYPT_BACKEND_CLASSIC_SMIME
#include "mutt_crypt.h"
-int mutt_is_application_smime (BODY *m)
-{
- char *t=NULL;
- int len, complain=0;
-
- if ((m->type & TYPEAPPLICATION) && m->subtype)
- {
- /* S/MIME MIME types don't need x- anymore, see RFC2311 */
- if (!ascii_strcasecmp (m->subtype, "x-pkcs7-mime") ||
- !ascii_strcasecmp (m->subtype, "pkcs7-mime"))
- {
- if ((t = mutt_get_parameter ("smime-type", m->parameter)))
- {
- if (!ascii_strcasecmp (t, "enveloped-data"))
- return SMIMEENCRYPT;
- else if (!ascii_strcasecmp (t, "signed-data"))
- return (SMIMESIGN|SMIMEOPAQUE);
- else return 0;
- }
- /* Netscape 4.7 uses
- * Content-Description: S/MIME Encrypted Message
- * instead of Content-Type parameter
- */
- if (!ascii_strcasecmp (m->description, "S/MIME Encrypted Message"))
- return SMIMEENCRYPT;
- complain = 1;
- }
- else if (ascii_strcasecmp (m->subtype, "octet-stream"))
- return 0;
-
- t = mutt_get_parameter ("name", m->parameter);
-
- if (!t) t = m->d_filename;
- if (!t) t = m->filename;
- if (!t)
- {
- if (complain)
- mutt_message (_("S/MIME messages with no hints on content are unsupported."));
- return 0;
- }
-
- /* no .p7c, .p10 support yet. */
-
- len = mutt_strlen (t) - 4;
- if (len > 0 && *(t+len) == '.')
- {
- len++;
- if (!ascii_strcasecmp ((t+len), "p7m"))
-#if 0
- return SMIMEENCRYPT;
-#else
- /* Not sure if this is the correct thing to do, but
- it's required for compatibility with Outlook */
- return (SMIMESIGN|SMIMEOPAQUE);
-#endif
- else if (!ascii_strcasecmp ((t+len), "p7s"))
- return (SMIMESIGN|SMIMEOPAQUE);
- }
- }
-
- return 0;
-}
-
-
-
smime_handle_entity (m, s, NULL);
}
-#endif /* HAVE_SMIME */
-
-
-
-
-
-
+#endif /* CRYPT_BACKEND_CLASSIC_SMIME */
*/
-#ifdef HAVE_SMIME
+#ifdef CRYPT_BACKEND_CLASSIC_SMIME
#include "mutt_crypt.h"
-WHERE char *SmimeDefaultKey;
-WHERE char *SmimeCryptAlg;
-WHERE short SmimeTimeout;
-WHERE char *SmimeCertificates;
-WHERE char *SmimeKeys;
-WHERE char *SmimeCryptAlg;
-WHERE char *SmimeCALocation;
-/* The command formats */
-
-WHERE char *SmimeVerifyCommand;
-WHERE char *SmimeVerifyOpaqueCommand;
-WHERE char *SmimeDecryptCommand;
-
-WHERE char *SmimeSignCommand;
-WHERE char *SmimeSignOpaqueCommand;
-WHERE char *SmimeEncryptCommand;
-
-WHERE char *SmimeGetSignerCertCommand;
-WHERE char *SmimePk7outCommand;
-WHERE char *SmimeGetCertCommand;
-WHERE char *SmimeImportCertCommand;
-WHERE char *SmimeGetCertEmailCommand;
-
-
-#define APPLICATION_SMIME (1 << 6)
-
-#define SIGNOPAQUE (1 << 4)
-
-#define SMIMEENCRYPT (APPLICATION_SMIME | ENCRYPT)
-#define SMIMESIGN (APPLICATION_SMIME | SIGN)
-#define SMIMEGOODSIGN (APPLICATION_SMIME | GOODSIGN)
-#define SMIMEBADSIGN (APPLICATION_SMIME | BADSIGN)
-#define SMIMEOPAQUE (APPLICATION_SMIME | SIGNOPAQUE)
void smime_void_passphrase (void);
-int mutt_is_application_smime (BODY *);
-
-
int smime_decrypt_mime (FILE *, FILE **, BODY *, BODY **);
void smime_application_smime_handler (BODY *, STATE *);
char* smime_ask_for_key (char *, char *, short);
+char *smime_findKeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc);
void smime_invoke_import (char *, char *);
#endif
+
+
WHERE short Sort INITVAL (SORT_DATE);
WHERE short SortAux INITVAL (SORT_DATE); /* auxiallary sorting method */
WHERE short SortAlias INITVAL (SORT_ALIAS);
-#ifdef HAVE_PGP
+
+/* FIXME: This one does not belong to here */
WHERE short PgpSortKeys INITVAL (SORT_ADDRESS);
-#endif
#include "mapping.h"
extern const struct mapping_t SortMethods[];