int pagerfd = -1;
is_message = mutt_is_message_type(a);
- if (is_message && a->hdr && (a->hdr->security & ENCRYPT) &&
- !crypt_valid_passphrase (a->hdr->security))
- return (rc);
use_mailcap = (flag == M_MAILCAP ||
(flag == M_REGULAR && rfc1524_mailcap_isneeded(a)));
snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype);
if (cur->security & ENCRYPT) {
if (cur->security & APPLICATION_SMIME)
crypt_smime_getkeys (cur->env);
- if (!crypt_valid_passphrase (cur->security))
- return 0;
-
cmflags |= M_CM_VERIFY;
}
else if (cur->security & SIGN) {
pipe_set_flags (decode, print, &cmflags, &chflags);
if (decode && h->security & ENCRYPT) {
- if (!crypt_valid_passphrase (h->security))
- return;
endwin ();
}
if (decode) {
mutt_parse_mime_message (Context, h);
- if (h->security & ENCRYPT && !crypt_valid_passphrase (h->security))
- return 1;
}
mutt_endwin (NULL);
mutt_message_hook (Context, Context->hdrs[Context->v2r[i]],
M_MESSAGEHOOK);
mutt_parse_mime_message (Context, Context->hdrs[Context->v2r[i]]);
- if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT &&
- !crypt_valid_passphrase (Context->hdrs[Context->v2r[i]]->
- security))
- return 1;
}
}
if (mutt_save_confirm (buf, &st) != 0)
return -1;
- if (need_passphrase && (decode || decrypt)
- && !crypt_valid_passphrase (app))
- return -1;
-
mutt_message (_("Copying to %s..."), buf);
if (Context->magic == M_IMAP && !(decode || decrypt) && mx_get_magic (buf) == M_IMAP) {
mutt_message_hook (NULL, msg, M_SEND2HOOK);
break;
- case OP_FORGET_PASSPHRASE:
- crypt_forget_passphrase ();
- break;
-
case OP_COMPOSE_SMIME_MENU:
if (msg->security & APPLICATION_PGP) {
if (mutt_yesorno (_("PGP already selected. Clear & continue ? "),
noinst_LIBRARIES = libcrypt.a
-libcrypt_a_SOURCES = smime.h crypt.h crypt-mod.h \
- smime.c crypt.c crypt-mod.c \
+libcrypt_a_SOURCES = crypt.h crypt-mod.h \
+ crypt.c crypt-mod.c \
cryptglue.c \
crypt-gpgme.h crypt-gpgme.c crypt-mod-pgp-gpgme.c crypt-mod-smime-gpgme.c
#include <lib-crypt/crypt-mod.h>
#include "crypt-gpgme.h"
-static void crypt_mod_pgp_void_passphrase (void)
-{
- /* Handled by gpg-agent. */
-}
-
-static int crypt_mod_pgp_valid_passphrase (void)
-{
- /* Handled by gpg-agent. */
- return 1;
-}
-
struct crypt_module_specs crypt_mod_pgp_gpgme = { APPLICATION_PGP,
{
/* Common. */
pgp_gpgme_init,
- crypt_mod_pgp_void_passphrase,
- crypt_mod_pgp_valid_passphrase,
pgp_gpgme_decrypt_mime,
pgp_gpgme_application_handler,
pgp_gpgme_encrypted_handler,
smime_gpgme_init ();
}
-static void crypt_mod_smime_void_passphrase (void)
-{
- /* Handled by gpg-agent. */
-}
-
-static int crypt_mod_smime_valid_passphrase (void)
-{
- /* Handled by gpg-agent. */
- return 1;
-}
-
static int crypt_mod_smime_decrypt_mime (FILE * a, FILE ** b, BODY * c,
BODY ** d)
{
struct crypt_module_specs crypt_mod_smime_gpgme = { APPLICATION_SMIME,
{
crypt_mod_smime_init,
- crypt_mod_smime_void_passphrase,
- crypt_mod_smime_valid_passphrase,
crypt_mod_smime_decrypt_mime,
crypt_mod_smime_application_handler,
NULL, /* encrypted_handler */
#include <lib-mime/mime.h>
#include "crypt.h"
-/*
- Type defintions for crypto module functions.
- */
-typedef void (*crypt_func_void_passphrase_t) (void);
-typedef int (*crypt_func_valid_passphrase_t) (void);
-
+/* Type defintions for crypto module functions. */
typedef int (*crypt_func_decrypt_mime_t) (FILE * a, FILE ** b,
BODY * c, BODY ** d);
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;
state_attach_puts (tmp, s);
}
-
-
-void crypt_forget_passphrase (void)
-{
- crypt_pgp_void_passphrase ();
- crypt_smime_void_passphrase ();
- mutt_message _("Passphrase(s) forgotten.");
-}
-
-
#if defined(HAVE_SETRLIMIT)
static void disable_coredumps (void)
#endif /* HAVE_SETRLIMIT */
-
-int crypt_valid_passphrase (int flags)
-{
- int ret = 0;
-
-# if defined(HAVE_SETRLIMIT)
- disable_coredumps ();
-# endif
-
- if (flags & APPLICATION_PGP)
- ret = crypt_pgp_valid_passphrase ();
-
- if (flags & APPLICATION_SMIME)
- ret = crypt_smime_valid_passphrase ();
-
- return ret;
-}
-
-
-
int mutt_protect (HEADER * msg, char *keylist)
{
BODY *pbody = NULL, *tmp_pbody = NULL;
int flags = msg->security;
int i;
- if ((msg->security & SIGN) && !crypt_valid_passphrase (msg->security))
- return (-1);
-
if ((msg->security & PGPINLINE) == PGPINLINE) {
/* they really want to send it inline... go for it */
if (!isendwin ())
for (i = 0; i < Context->vcount; i++) {
if (Context->hdrs[Context->v2r[i]]->tagged) {
mutt_parse_mime_message (Context, Context->hdrs[Context->v2r[i]]);
- if (Context->hdrs[Context->v2r[i]]->security & ENCRYPT &&
- !crypt_valid_passphrase (Context->hdrs[Context->v2r[i]]->
- security)) {
- m_fclose(&fpout);
- break;
- }
-
if (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);
}
else {
mutt_parse_mime_message (Context, h);
- if (!(h->security & ENCRYPT && !crypt_valid_passphrase (h->security))) {
- if (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"));
- crypt_pgp_invoke_import (tempfname);
- }
+ if (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"));
+ crypt_pgp_invoke_import (tempfname);
+ }
- if (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);
- else
- mutt_copy_message (fpout, Context, h, 0, 0);
-
- fflush (fpout);
- if (h->env->from)
- tmp = mutt_expand_aliases (h->env->from);
- else if (h->env->sender)
- tmp = mutt_expand_aliases (h->env->sender);
- mbox = tmp ? tmp->mailbox : NULL;
- if (mbox) { /* else ? */
- mutt_message (_("Trying to extract S/MIME certificates...\n"));
- crypt_smime_invoke_import (tempfname, mbox);
- }
+ if (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);
+ else
+ mutt_copy_message (fpout, Context, h, 0, 0);
+
+ fflush (fpout);
+ if (h->env->from)
+ tmp = mutt_expand_aliases (h->env->from);
+ else if (h->env->sender)
+ tmp = mutt_expand_aliases (h->env->sender);
+ mbox = tmp ? tmp->mailbox : NULL;
+ if (mbox) { /* else ? */
+ mutt_message (_("Trying to extract S/MIME certificates...\n"));
+ crypt_smime_invoke_import (tempfname, mbox);
}
}
}
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);
-
-
/*-- cryptglue.c --*/
/* Show a message that a backend will be invoked. */
void crypt_invoke_message (int type);
-
-/* Silently forget about a passphrase. */
-void crypt_pgp_void_passphrase (void);
-
-int crypt_pgp_valid_passphrase (void);
-
-
/* Decrypt a PGP/MIME message. */
int crypt_pgp_decrypt_mime (FILE * a, FILE ** b, BODY * c, BODY ** d);
BODY * top);
-
-
-
-/* Silently forget about a passphrase. */
-void crypt_smime_void_passphrase (void);
-
-int crypt_smime_valid_passphrase (void);
-
/* Decrypt an S/MIME message. */
int crypt_smime_decrypt_mime (FILE * a, FILE ** b, BODY * c, BODY ** d);
*/
-/* Reset a PGP passphrase */
-void crypt_pgp_void_passphrase (void)
-{
- if (CRYPT_MOD_CALL_CHECK (PGP, void_passphrase))
- (CRYPT_MOD_CALL (PGP, void_passphrase)) ();
-}
-
-int crypt_pgp_valid_passphrase (void)
-{
- if (CRYPT_MOD_CALL_CHECK (PGP, valid_passphrase))
- return (CRYPT_MOD_CALL (PGP, valid_passphrase)) ();
-
- return 0;
-}
-
-
/* Decrypt a PGP/MIME message. */
int crypt_pgp_decrypt_mime (FILE * a, FILE ** b, BODY * c, BODY ** d)
{
*/
-/* Reset an SMIME passphrase */
-void crypt_smime_void_passphrase (void)
-{
- if (CRYPT_MOD_CALL_CHECK (SMIME, void_passphrase))
- (CRYPT_MOD_CALL (SMIME, void_passphrase)) ();
-}
-
-int crypt_smime_valid_passphrase (void)
-{
- if (CRYPT_MOD_CALL_CHECK (SMIME, valid_passphrase))
- return (CRYPT_MOD_CALL (SMIME, valid_passphrase)) ();
-
- return 0;
-}
-
/* Decrypt am S/MIME message. */
int crypt_smime_decrypt_mime (FILE * a, FILE ** b, BODY * c, BODY ** d)
{
m_fclose(&tempfp);
- if (CRYPT_MOD_CALL_CHECK (PGP, pgp_invoke_import)) {
- (CRYPT_MOD_CALL (PGP, pgp_invoke_import)) (fname);
- mutt_any_key_to_continue (NULL);
- }
+ pgp_invoke_import (tempfname);
+ mutt_any_key_to_continue (NULL);
mutt_unlink (tempfname);
}
char *pgp_findKeys (address_t * to, address_t * cc, address_t * bcc);
-void pgp_forget_passphrase (void);
int pgp_application_pgp_handler (BODY *, STATE *);
int pgp_encrypted_handler (BODY *, STATE *);
void pgp_extract_keys_from_attachment_list (FILE * fp, int tag, BODY * top);
-void pgp_void_passphrase (void);
-int pgp_valid_passphrase (void);
-
/* The PGP invocation interface - not really beautiful. */
#include "crypt.h"
-void smime_void_passphrase (void);
-int smime_valid_passphrase (void);
-
int smime_decrypt_mime (FILE *, FILE **, BODY *, BODY **);
int smime_application_smime_handler (BODY *, STATE *);
menu->redraw = REDRAW_FULL;
break;
-
- case OP_FORGET_PASSPHRASE:
- crypt_forget_passphrase ();
- break;
-
case OP_GROUP_REPLY:
CHECK_MSGCOUNT;
redraw = REDRAW_FULL;
break;
-
- case OP_FORGET_PASSPHRASE:
- crypt_forget_passphrase ();
- break;
-
case OP_EXTRACT_KEYS:
CHECK_MODE (IsHeader (extra));
crypt_extract_keys_from_messages (extra->hdr);
if (pat->op != M_HEADER) {
mutt_parse_mime_message (ctx, h);
-
- if ((h->security & ENCRYPT) && !crypt_valid_passphrase (h->security))
- {
- mx_close_message (&msg);
- if (fp) {
- m_fclose(&fp);
- unlink (tempfile);
- }
- return (0);
- }
-
fseeko (msg->fp, h->offset, 0);
mutt_body_handler (h->content, &s);
}
{
int ccap = (APPLICATION_PGP | APPLICATION_SMIME) & hdr->security;
newhdr->security |= ENCRYPT | ccap;
- if (!crypt_valid_passphrase (ccap))
- goto err;
-
mutt_message _("Decrypting message...");
if (((ccap & APPLICATION_PGP)
{
need_secured = 1;
- if ((hdr->security & ENCRYPT) && !crypt_valid_passphrase (hdr->security)) {
- mx_close_message (&msg);
- return;
- }
if (hdr->security & APPLICATION_SMIME) {
if (hdr->env)
crypt_smime_getkeys (hdr->env);
mutt_update_attach_index (cur, &idx, &idxlen, &idxmax, menu);
break;
- case OP_FORGET_PASSPHRASE:
- crypt_forget_passphrase ();
- break;
-
case OP_EXTRACT_KEYS:
crypt_pgp_extract_keys_from_attachment_list (fp, menu->tagprefix,
menu->
mutt_parse_mime_message (ctx, cur);
mutt_message_hook (ctx, cur, M_MESSAGEHOOK);
- if ((cur->security & ENCRYPT) && option (OPTFORWDECODE)) {
- /* make sure we have the user's passphrase before proceeding... */
- crypt_valid_passphrase (cur->security);
- }
-
mutt_forward_intro (out, cur);
if (option (OPTFORWDECODE)) {
int cmflags = M_CM_PREFIX | M_CM_DECODE | M_CM_CHARCONV | M_CM_REPLYING;
int chflags = CH_DECODE;
- if ((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);
if ((option (OPTMIMEFORWDECODE) || option (OPTFORWDECRYPT)) &&
(hdr->security & ENCRYPT)) {
- if (!crypt_valid_passphrase (hdr->security))
- return (NULL);
}
fp = m_tempfile(buffer, sizeof(buffer), NONULL(MCore.tmpdir), NULL);