Commit e48dd50a authored by Moritz Schulte's avatar Moritz Schulte

This is the sequel to the crypto modularization changes I did on

2003-01-21.  Moritz added another abstraction layer which cleans up
the code and allows the crypto modules to use their own option menu.
Everything should work as it used to but is now in a really good
shape for part III, the Return of the GnuPG Easy Makers. -wk

* crypt-mod-pgp-classic.c, crypt-mod-smime-classic.c, crypt-mod.c,
crypt-mod.h: New files.

* smime.c (smime_valid_passphrase, smime_send_menu): New functions.
* smime.h: Removed macro: smime_valid_passphrase.
Declared: smime_valid_passphrase, smime_send_menu.
* pgp.c: Include "mutt_menu.h".
(pgp_valid_passphrase, pgp_send_menu): New functions.
* pgp.h: Removed macro: pgp_valid_passphrase.
Declared: pgp_valid_passphrase, pgp_send_menu.
* mutt_curses.h: Declare: mutt_need_hard_redraw.
* mutt_crypt.h: Declare: crypt_pgp_valid_passphrase,
crypt_pgp_send_menu, crypt_smime_valid_passphrase,
crypt_smime_send_menu, crypt_init.
Adjust WithCrypto definition since the GPGME backend does not
exclude anymore the other `classic' backends.
(KEYFLAG_ISX509): New symbol.
* mutt.h (enum): New symbol: OPTCRYPTUSEGPGME.
(struct body): New member: is_signed_data, warnsig.
* main.c (main): Call crypt_init.
* keymap.c (km_get_table): Support for MENU_KEY_SELECT_PGP and
MENU_KEY_SELECT_SMIME.
(Menus): Added entries fuer MENU_KEY_SELECT_PGP and
MENU_KEY_SELECT_SMIME.
(km_init): Create bindings for MENU_KEY_SELECT_PGP and
MENU_KEY_SELECT_SMIME.
* keymap.h (enum): New enum symbols: MENU_KEY_SELECT_PGP,
MENU_KEY_SELECT_SMIME.
* init.h: New configuration variable: crypt_use_gpgme.
* compose.c (pgp_send_menu, smime_send_menu): Removed functions,
they are now contained in the crypto backend modules.
(mutt_compose_menu): Use crypt_pgp_send_menu and
crypt_smime_send_menu instead pgp_send_menu and smime_send_menu.
* cryptglue.c: Slightly rewritten in order to make use of the
module mechanism used to access crypto backends.
* curs_lib.c (mutt_need_hard_redraw): New function.
* crypt.c (crypt_forget_passphrase): Adjust for new crypto backend
interface.
(crypt_valid_passphrase): Stripped, use calls to
crypt_pgp_valid_passphrase and crypt_smime_valid_passphrase.
parent 6c365235
......@@ -28,10 +28,10 @@ mutt_SOURCES = $(BUILT_SOURCES) \
score.c send.c sendlib.c signal.c sort.c \
status.c system.c thread.c charset.c history.c lib.c \
muttlib.c editmsg.c utf8.c mbyte.c wcwidth.c \
url.c ascii.c mutt_idna.c
url.c ascii.c mutt_idna.c crypt-mod.c crypt-mod.h
mutt_LDADD = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAP) $(MUTTLIBS) \
$(INTLLIBS) $(LIBICONV)
$(INTLLIBS) $(LIBICONV)
mutt_DEPENDENCIES = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAPDEPS) \
$(INTLDEPS)
......@@ -55,13 +55,14 @@ DEFS=-DPKGDATADIR=\"$(pkgdatadir)\" -DSYSCONFDIR=\"$(sysconfdir)\" \
INCLUDES=-I. -I$(top_srcdir) $(IMAP_INCLUDES) -Iintl
CPPFLAGS=@CPPFLAGS@ -I$(includedir)
CPPFLAGS=@CPPFLAGS@ -I$(includedir) -D_FILE_OFFSET_BITS=64
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 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 \
crypt-mod-pgp-classic.c crypt-mod-smime-classic.c \
pgppacket.c mutt_idna.h
EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP OPS.CRYPT OPS.SMIME TODO \
......
/*
* Copyright (C) 1996-2000 Michael R. Elkins <me@mutt.org>
* Copyright (C) 2004 g10 Code GmbH
*
* 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
......@@ -162,167 +163,6 @@ static void redraw_crypt_lines (HEADER *msg)
}
static int pgp_send_menu (HEADER *msg, int *redraw)
{
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, (i)nline, or (f)orget it? "),
_("esabif")))
{
case 1: /* (e)ncrypt */
msg->security ^= ENCRYPT;
break;
case 2: /* (s)ign */
msg->security ^= SIGN;
break;
case 3: /* sign (a)s */
unset_option(OPTPGPCHECKTRUST);
if ((p = crypt_pgp_ask_for_key (_("Sign as: "), NULL,
KEYFLAG_CANSIGN, PGP_PUBRING)))
{
snprintf (input_signas, sizeof (input_signas), "0x%s",
crypt_pgp_keyid (p));
mutt_str_replace (&PgpSignAs, input_signas);
crypt_pgp_free_key (&p);
msg->security |= SIGN;
crypt_pgp_void_passphrase (); /* probably need a different passphrase */
}
else
{
msg->security &= ~SIGN;
}
*redraw = REDRAW_FULL;
break;
case 4: /* (b)oth */
if ((msg->security & (ENCRYPT | SIGN)) == (ENCRYPT | SIGN))
msg->security = 0;
else
msg->security |= (ENCRYPT | SIGN);
break;
case 5: /* (i)nline */
if ((msg->security & (ENCRYPT | SIGN)))
msg->security ^= INLINE;
else
msg->security &= ~INLINE;
break;
case 6: /* (f)orget it */
msg->security = 0;
break;
}
if (msg->security)
{
if (! (msg->security & (ENCRYPT | SIGN)))
msg->security = 0;
else
msg->security |= APPLICATION_PGP;
}
if(*redraw)
redraw_crypt_lines (msg);
return (msg->security);
}
static int smime_send_menu (HEADER *msg, int *redraw)
{
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 1: /* (e)ncrypt */
msg->security |= ENCRYPT;
break;
case 3: /* encrypt (w)ith */
msg->security |= ENCRYPT;
switch (mutt_multi_choice (_("1: DES, 2: Triple-DES, 3: RC2-40,"
" 4: RC2-64, 5: RC2-128, or (f)orget it? "),
_("12345f"))) {
case 1:
mutt_str_replace (&SmimeCryptAlg, "des");
break;
case 2:
mutt_str_replace (&SmimeCryptAlg, "des3");
break;
case 3:
mutt_str_replace (&SmimeCryptAlg, "rc2-40");
break;
case 4:
mutt_str_replace (&SmimeCryptAlg, "rc2-64");
break;
case 5:
mutt_str_replace (&SmimeCryptAlg, "rc2-128");
break;
case 6: /* forget it */
break;
}
break;
case 2: /* (s)ign */
if(!SmimeDefaultKey)
mutt_message("Can\'t sign: No key specified. use sign(as).");
else
msg->security |= SIGN;
break;
case 4: /* sign (a)s */
if ((p = crypt_smime_ask_for_key (_("Sign as: "), NULL, 0))) {
p[mutt_strlen (p)-1] = '\0';
mutt_str_replace (&SmimeDefaultKey, p);
msg->security |= SIGN;
/* probably need a different passphrase */
crypt_smime_void_passphrase ();
}
else
msg->security &= ~SIGN;
*redraw = REDRAW_FULL;
break;
case 5: /* (b)oth */
msg->security = ENCRYPT | SIGN;
break;
case 6: /* (f)orget it */
msg->security = 0;
break;
}
if (msg->security && msg->security != APPLICATION_SMIME)
msg->security |= APPLICATION_SMIME;
else
msg->security = 0;
if(*redraw)
redraw_crypt_lines (msg);
return (msg->security);
}
#ifdef MIXMASTER
static void redraw_mix_line (LIST *chain)
......@@ -1344,7 +1184,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
}
msg->security = 0;
}
msg->security = pgp_send_menu (msg, &menu->redraw);
msg->security = crypt_pgp_send_menu (msg, &menu->redraw);
redraw_crypt_lines (msg);
break;
......@@ -1369,7 +1209,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */
}
msg->security = 0;
}
msg->security = smime_send_menu(msg, &menu->redraw);
msg->security = crypt_smime_send_menu(msg, &menu->redraw);
redraw_crypt_lines (msg);
break;
......
......@@ -105,7 +105,7 @@ else
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"
MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS pgp.o pgpinvoke.o pgpkey.o pgplib.o gnupgparse.o pgpmicalg.o pgppacket.o crypt-mod-pgp-classic.o"
fi
AC_ARG_ENABLE(smime, [ --disable-smime Disable SMIME support],
......@@ -117,7 +117,7 @@ else
if test x$have_smime != xno ; then
AC_DEFINE(CRYPT_BACKEND_CLASSIC_SMIME,1,
[ Define if you want clasic S/MIME support. ])
MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS smime.o "
MUTT_LIB_OBJECTS="$MUTT_LIB_OBJECTS smime.o crypt-mod-smime-classic.o"
SMIMEAUX_TARGET="smime_keys"
fi
......
/*
* Copyright (C) 2004 g10 Code GmbH
*
* 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 is a crytpo module wrapping the classic pgp code.
*/
#include "crypt-mod.h"
#include "pgp.h"
static void crypt_mod_pgp_void_passphrase (void)
{
pgp_void_passphrase ();
}
static int crypt_mod_pgp_valid_passphrase (void)
{
return pgp_valid_passphrase ();
}
static int crypt_mod_pgp_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d)
{
return pgp_decrypt_mime (a, b, c, d);
}
static void crypt_mod_pgp_application_handler (BODY *m, STATE *s)
{
pgp_application_pgp_handler (m, s);
}
static char *crypt_mod_pgp_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
{
return pgp_findKeys (to, cc, bcc);
}
static BODY *crypt_mod_pgp_sign_message (BODY *a)
{
return pgp_sign_message (a);
}
static int crypt_mod_pgp_verify_one (BODY *sigbdy, STATE *s, const char *tempf)
{
return pgp_verify_one (sigbdy, s, tempf);
}
static int crypt_mod_pgp_send_menu (HEADER *msg, int *redraw)
{
return pgp_send_menu (msg, redraw);
}
static BODY *crypt_mod_pgp_encrypt_message (BODY *a, char *keylist, int sign)
{
return pgp_encrypt_message (a, keylist, sign);
}
static BODY *crypt_mod_pgp_make_key_attachment (char *tempf)
{
return pgp_make_key_attachment (tempf);
}
static int crypt_mod_pgp_check_traditional (FILE *fp, BODY *b, int tagged_only)
{
return pgp_check_traditional (fp, b, tagged_only);
}
static BODY *crypt_mod_pgp_traditional_encryptsign (BODY *a, int flags, char *keylist)
{
return pgp_traditional_encryptsign (a, flags, keylist);
}
static void crypt_mod_pgp_encrypted_handler (BODY *m, STATE *s)
{
pgp_encrypted_handler (m, s);
}
static void crypt_mod_pgp_invoke_getkeys (ADDRESS *addr)
{
pgp_invoke_getkeys (addr);
}
static void crypt_mod_pgp_invoke_import (const char *fname)
{
pgp_invoke_import (fname);
}
static void crypt_mod_pgp_extract_keys_from_attachment_list (FILE *fp, int tag, BODY *top)
{
pgp_extract_keys_from_attachment_list (fp, tag, top);
}
struct crypt_module_specs crypt_mod_pgp_classic =
{ APPLICATION_PGP,
{
NULL, /* init */
crypt_mod_pgp_void_passphrase,
crypt_mod_pgp_valid_passphrase,
crypt_mod_pgp_decrypt_mime,
crypt_mod_pgp_application_handler,
crypt_mod_pgp_encrypted_handler,
crypt_mod_pgp_findkeys,
crypt_mod_pgp_sign_message,
crypt_mod_pgp_verify_one,
crypt_mod_pgp_send_menu,
crypt_mod_pgp_encrypt_message,
crypt_mod_pgp_make_key_attachment,
crypt_mod_pgp_check_traditional,
crypt_mod_pgp_traditional_encryptsign,
crypt_mod_pgp_invoke_getkeys,
crypt_mod_pgp_invoke_import,
crypt_mod_pgp_extract_keys_from_attachment_list,
NULL, /* smime_getkeys */
NULL, /* smime_verify_sender */
NULL, /* smime_build_smime_entity */
NULL, /* smime_invoke_import */
}
};
/*
* Copyright (C) 2004 g10 Code GmbH
*
* 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 is a crytpo module wrapping the classic smime code.
*/
#include "crypt-mod.h"
#include "smime.h"
static void crypt_mod_smime_void_passphrase (void)
{
smime_void_passphrase ();
}
static int crypt_mod_smime_valid_passphrase (void)
{
return smime_valid_passphrase ();
}
static int crypt_mod_smime_decrypt_mime (FILE *a, FILE **b, BODY *c, BODY **d)
{
return smime_decrypt_mime (a, b, c, d);
}
static void crypt_mod_smime_application_handler (BODY *m, STATE *s)
{
smime_application_smime_handler (m, s);
}
static char *crypt_mod_smime_findkeys (ADDRESS *to, ADDRESS *cc, ADDRESS *bcc)
{
return smime_findKeys (to, cc, bcc);
}
static BODY *crypt_mod_smime_sign_message (BODY *a)
{
return smime_sign_message (a);
}
static int crypt_mod_smime_verify_one (BODY *sigbdy, STATE *s, const char *tempf)
{
return smime_verify_one (sigbdy, s, tempf);
}
static int crypt_mod_smime_send_menu (HEADER *msg, int *redraw)
{
return smime_send_menu (msg, redraw);
}
static void crypt_mod_smime_getkeys (ENVELOPE *env)
{
smime_getkeys (env);
}
static int crypt_mod_smime_verify_sender (HEADER *h)
{
return smime_verify_sender (h);
}
static BODY *crypt_mod_smime_build_smime_entity (BODY *a, char *certlist)
{
return smime_build_smime_entity (a, certlist);
}
static void crypt_mod_smime_invoke_import (char *infile, char *mailbox)
{
smime_invoke_import (infile, mailbox);
}
struct crypt_module_specs crypt_mod_smime_classic =
{ APPLICATION_SMIME,
{
NULL, /* init */
crypt_mod_smime_void_passphrase,
crypt_mod_smime_valid_passphrase,
crypt_mod_smime_decrypt_mime,
crypt_mod_smime_application_handler,
NULL, /* encrypted_handler */
crypt_mod_smime_findkeys,
crypt_mod_smime_sign_message,
crypt_mod_smime_verify_one,
crypt_mod_smime_send_menu,
NULL, /* pgp_encrypt_message */
NULL, /* pgp_make_key_attachment */
NULL, /* pgp_check_traditional */
NULL, /* pgp_traditional_encryptsign */
NULL, /* pgp_invoke_getkeys */
NULL, /* pgp_invoke_import */
NULL, /* pgp_extract_keys_from_attachment_list */
crypt_mod_smime_getkeys,
crypt_mod_smime_verify_sender,
crypt_mod_smime_build_smime_entity,
crypt_mod_smime_invoke_import,
}
};
/*
* Copyright (C) 2004 g10 Code GmbH
*
* 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.
*/
#include "crypt-mod.h"
/* A type an a variable to keep track of registered crypto modules. */
typedef struct crypt_module *crypt_module_t;
struct crypt_module
{
crypt_module_specs_t specs;
crypt_module_t next, *prevp;
};
static crypt_module_t modules;
/* Register a new crypto module. */
void crypto_module_register (crypt_module_specs_t specs)
{
crypt_module_t module_new = safe_malloc (sizeof (*module_new));
module_new->specs = specs;
module_new->next = modules;
if (modules)
modules->prevp = &module_new->next;
modules = module_new;
}
/* Return the crypto module specs for IDENTIFIER. This function is
usually used via the CRYPT_MOD_CALL[_CHECK] macros. */
crypt_module_specs_t crypto_module_lookup (int identifier)
{
crypt_module_t module = modules;
while (module && (module->specs->identifier != identifier))
module = module->next;
return module ? module->specs : NULL;
}
/*
* Copyright (C) 2004 g10 Code GmbH
*
* 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.
*/
#ifndef CRYPTOGRAPHY_H
#define CRYPTOGRAPHY_H
#include "mutt.h"
#include "mutt_crypt.h"
#define CRYPTO_SUPPORT(identifier) (WithCrypto & APPLICATION_ ## identifier)
/*
Type defintions for crypto module functions.
*/
typedef void (*crypt_func_void_passphrase_t) (void);
typedef int (*crypt_func_valid_passphrase_t) (void);
typedef int (*crypt_func_decrypt_mime_t) (FILE *a, FILE **b,
BODY *c, BODY **d);
typedef void (*crypt_func_application_handler_t) (BODY *m, STATE *s);
typedef void (*crypt_func_encrypted_handler_t) (BODY *m, STATE *s);
typedef void (*crypt_func_pgp_invoke_getkeys_t) (ADDRESS *addr);
typedef int (*crypt_func_pgp_check_traditional_t) (FILE *fp, BODY *b,
int tagged_only);
typedef BODY *(*crypt_func_pgp_traditional_encryptsign_t) (BODY *a, int flags,
char *keylist);
typedef BODY *(*crypt_func_pgp_make_key_attachment_t) (char *tempf);
typedef char *(*crypt_func_findkeys_t) (ADDRESS *to,
ADDRESS *cc, ADDRESS *bcc);
typedef BODY *(*crypt_func_sign_message_t) (BODY *a);
typedef BODY *(*crypt_func_pgp_encrypt_message_t) (BODY *a, char *keylist,
int sign);
typedef void (*crypt_func_pgp_invoke_import_t) (const char *fname);
typedef int (*crypt_func_verify_one_t) (BODY *sigbdy, STATE *s,
const char *tempf);
typedef void (*crypt_func_pgp_extract_keys_from_attachment_list_t)
(FILE *fp, int tag, BODY *top);
typedef int (*crypt_func_send_menu_t) (HEADER *msg, int *redraw);
/* (SMIME) */
typedef void (*crypt_func_smime_getkeys_t) (ENVELOPE *env);
typedef int (*crypt_func_smime_verify_sender_t) (HEADER *h);
typedef BODY *(*crypt_func_smime_build_smime_entity_t) (BODY *a,
char *certlist);
typedef void (*crypt_func_smime_invoke_import_t) (char *infile, char *mailbox);
typedef void (*crypt_func_init_t) (void);
/*
A structure to keep all crypto module fucntions together.
*/
typedef struct crypt_module_functions
{
/* Common/General functions. */
crypt_func_init_t init;
crypt_func_void_passphrase_t void_passphrase;
crypt_func_valid_passphrase_t valid_passphrase;
crypt_func_decrypt_mime_t decrypt_mime;
crypt_func_application_handler_t application_handler;
crypt_func_encrypted_handler_t encrypted_handler;
crypt_func_findkeys_t findkeys;
crypt_func_sign_message_t sign_message;
crypt_func_verify_one_t verify_one;
crypt_func_send_menu_t send_menu;
/* PGP specific functions. */
crypt_func_pgp_encrypt_message_t pgp_encrypt_message;
crypt_func_pgp_make_key_attachment_t pgp_make_key_attachment;
crypt_func_pgp_check_traditional_t pgp_check_traditional;
crypt_func_pgp_traditional_encryptsign_t pgp_traditional_encryptsign;
crypt_func_pgp_invoke_getkeys_t pgp_invoke_getkeys;
crypt_func_pgp_invoke_import_t pgp_invoke_import;
crypt_func_pgp_extract_keys_from_attachment_list_t
pgp_extract_keys_from_attachment_list;
/* S/MIME specific functions. */
crypt_func_smime_getkeys_t smime_getkeys;
crypt_func_smime_verify_sender_t smime_verify_sender;
crypt_func_smime_build_smime_entity_t smime_build_smime_entity;
crypt_func_smime_invoke_import_t smime_invoke_import;
} crypt_module_functions_t;
/*
A structure to decribe a crypto module.
*/
typedef struct crypt_module_specs
{
int identifier; /* Identifying bit. */
crypt_module_functions_t functions;
} *crypt_module_specs_t;
/*
High Level crypto module interface.
*/
void crypto_module_register (crypt_module_specs_t specs);
crypt_module_specs_t crypto_module_lookup (int identifier);
/* If the crypto module identifier by IDENTIFIER has been registered,
call its function FUNC. Do nothing else. This may be used as an
expression. */
#define CRYPT_MOD_CALL_CHECK(identifier, func) \
(crypto_module_lookup (APPLICATION_ ## identifier) \
&& (crypto_module_lookup (APPLICATION_ ## identifier))->functions.func)
/* Call the function FUNC in the crypto module identified by
IDENTIFIER. This may be used as an expression. */
#define CRYPT_MOD_CALL(identifier, func) \
*(crypto_module_lookup (APPLICATION_ ## identifier))->functions.func
#endif
......@@ -4,6 +4,7 @@
* Copyright (C) 2001 Thomas Roessler <roessler@does-not-exist.org>
* Oliver Ehli <elmy@acm.org>
* Copyright (C) 2003 Werner Koch <wk@gnupg.org>
* Copyright (C) 2004 g10code GmbH
*
* 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
......@@ -107,54 +108,19 @@ static void disable_coredumps (void)
int crypt_valid_passphrase(int flags)
{
time_t now = time (NULL);
int ret = 0;
# if defined(HAVE_SETRLIMIT) &&(!defined(DEBUG))
disable_coredumps ();
# endif
if ((WithCrypto & APPLICATION_PGP) && (flags & APPLICATION_PGP))
{
extern char PgpPass[STRING];
extern time_t PgpExptime;
if (pgp_use_gpg_agent())
{
*PgpPass = 0;
return 1; /* handled by gpg-agent */
}
if (now < PgpExptime) return 1; /* just use the cached copy. */
crypt_pgp_void_passphrase ();
if (mutt_get_password (_("Enter PGP passphrase:"),
PgpPass, sizeof (PgpPass)) == 0)
{
PgpExptime = time (NULL) + PgpTimeout;
return (1);
}
else
PgpExptime = 0;
}
ret = crypt_pgp_valid_passphrase ();
if ((WithCrypto & APPLICATION_SMIME) && (flags & APPLICATION_SMIME))
{
extern char SmimePass[STRING];
extern time_t SmimeExptime;
if (now < SmimeExptime) return (1);
crypt_smime_void_passphrase ();
if (mutt_get_password (_("Enter SMIME passphrase:"), SmimePass,
sizeof (SmimePass)) == 0)
{
SmimeExptime = time (NULL) + SmimeTimeout;
return (1);
}
else
SmimeExptime = 0;
}
ret = crypt_smime_valid_passphrase ();
return (0);
return ret;
}
......@@ -275,6 +241,7 @@ int mutt_protect (HEADER *msg, char *keylist)
/* destroy temporary signature envelope when doing retainable
* signatures.
*/
if (flags != msg->security)