contained in this file and the functions implemented by the crypto
modules. */
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
#include <lib-lib/lib-lib.h>
#include "mutt.h"
#include "crypt.h"
+#include "crypt-gpgme.h"
+#define CRYPT_MOD_CALL_CHECK(identifier, func) \
+ ((crypt_mod_##identifier##_gpgme).func)
-#include "crypt-mod.h"
-
-/*
- Generic
-*/
-
-extern struct crypt_module_specs crypt_mod_pgp_classic;
-extern struct crypt_module_specs crypt_mod_smime_classic;
-
-#ifdef CRYPT_BACKEND_GPGME
-extern struct crypt_module_specs crypt_mod_pgp_gpgme;
-extern struct crypt_module_specs crypt_mod_smime_gpgme;
-#endif
+#define CRYPT_MOD_CALL(identifier, func) \
+ (*((crypt_mod_##identifier##_gpgme).func))
-void crypt_init (void)
-{
- if (
-#ifdef CRYPT_BACKEND_GPGME
- (!option (OPTCRYPTUSEGPGME))
-#else
- 1
-#endif
- )
- crypto_module_register (&crypt_mod_pgp_classic);
- if (
-#ifdef CRYPT_BACKEND_GPGME
- (!option (OPTCRYPTUSEGPGME))
-#else
- 1
-#endif
- )
- crypto_module_register (&crypt_mod_smime_classic);
+struct crypt_module_specs crypt_mod_SMIME_gpgme = {
+ NULL, /* encrypted_handler */
- if (option (OPTCRYPTUSEGPGME)) {
-#ifdef CRYPT_BACKEND_GPGME
- crypto_module_register (&crypt_mod_pgp_gpgme);
- crypto_module_register (&crypt_mod_smime_gpgme);
-#else
- mutt_message (_("\"crypt_use_gpgme\" set"
- " but not build with GPGME support."));
- if (mutt_any_key_to_continue (NULL) == -1)
- mutt_exit (1);
-#endif
- }
+ NULL, /* pgp_make_key_attachment */
+ NULL, /* pgp_invoke_getkeys */
-#if defined CRYPT_BACKEND_CLASSIG_PGP || defined CRYPT_BACKEND_CLASSIG_SMIME || defined CRYPT_BACKEND_GPGME
- if (CRYPT_MOD_CALL_CHECK (PGP, init))
- (CRYPT_MOD_CALL (PGP, init)) ();
+ NULL, /* smime_getkeys */
+ smime_gpgme_build_smime_entity,
+};
- if (CRYPT_MOD_CALL_CHECK (SMIME, init))
- (CRYPT_MOD_CALL (SMIME, init)) ();
-#endif
-}
+struct crypt_module_specs crypt_mod_PGP_gpgme = {
+ pgp_gpgme_encrypted_handler,
+ /* PGP specific. */
+ NULL, /* pgp_make_key_attachment, */
+ NULL, /* pgp_invoke_getkeys */
-/* Show a message that a backend will be invoked. */
-void crypt_invoke_message (int type)
-{
- if (type & APPLICATION_PGP) {
- mutt_message _("Invoking PGP...");
- }
- else if (type & APPLICATION_SMIME) {
- mutt_message _("Invoking S/MIME...");
- }
-}
-\f
-
-
-/*
-
- PGP
-
-*/
+ NULL, /* smime_getkeys */
+ NULL, /* smime_build_smime_entity */
+};
-/* 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)
-{
- if (CRYPT_MOD_CALL_CHECK (PGP, decrypt_mime))
- return (CRYPT_MOD_CALL (PGP, decrypt_mime)) (a, b, c, d);
-
- return -1;
-}
-
-/* MIME handler for the application/pgp content-type. */
-int crypt_pgp_application_pgp_handler (BODY * m, STATE * s)
-{
- if (CRYPT_MOD_CALL_CHECK (PGP, application_handler))
- return (CRYPT_MOD_CALL (PGP, application_handler)) (m, s);
- return (-1);
-}
+/* PGP */
/* MIME handler for an PGP/MIME encrypted message. */
int crypt_pgp_encrypted_handler (BODY * a, STATE * s)
{
- if (CRYPT_MOD_CALL_CHECK (PGP, encrypted_handler))
- return (CRYPT_MOD_CALL (PGP, encrypted_handler)) (a, s);
- return (-1);
+ if (CRYPT_MOD_CALL_CHECK (PGP, encrypted_handler))
+ return (CRYPT_MOD_CALL (PGP, encrypted_handler)) (a, s);
+ return (-1);
}
/* fixme: needs documentation. */
void crypt_pgp_invoke_getkeys (address_t * addr)
{
- if (CRYPT_MOD_CALL_CHECK (PGP, pgp_invoke_getkeys))
- (CRYPT_MOD_CALL (PGP, pgp_invoke_getkeys)) (addr);
-}
-
-/* Check for a traditional PGP message in body B. */
-int crypt_pgp_check_traditional (FILE * fp, BODY * b, int tagged_only)
-{
- if (CRYPT_MOD_CALL_CHECK (PGP, pgp_check_traditional))
- return (CRYPT_MOD_CALL (PGP, pgp_check_traditional)) (fp, b, tagged_only);
-
- return 0;
-}
-
-/* fixme: needs documentation. */
-BODY *crypt_pgp_traditional_encryptsign (BODY * a, int flags, char *keylist)
-{
- if (CRYPT_MOD_CALL_CHECK (PGP, pgp_traditional_encryptsign))
- return (CRYPT_MOD_CALL (PGP, pgp_traditional_encryptsign)) (a, flags,
- keylist);
-
- return NULL;
+ if (CRYPT_MOD_CALL_CHECK (PGP, pgp_invoke_getkeys))
+ (CRYPT_MOD_CALL (PGP, pgp_invoke_getkeys)) (addr);
}
/* Generate a PGP public key attachment. */
BODY *crypt_pgp_make_key_attachment (char *tempf)
{
- if (CRYPT_MOD_CALL_CHECK (PGP, pgp_make_key_attachment))
- return (CRYPT_MOD_CALL (PGP, pgp_make_key_attachment)) (tempf);
-
- return NULL;
-}
-
-/* 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_t * to, address_t * cc, address_t * bcc)
-{
- if (CRYPT_MOD_CALL_CHECK (PGP, findkeys))
- return (CRYPT_MOD_CALL (PGP, findkeys)) (to, cc, bcc);
-
- return NULL;
-}
-
-/* Create a new body with a PGP signed message from A. */
-BODY *crypt_pgp_sign_message (BODY * a)
-{
- if (CRYPT_MOD_CALL_CHECK (PGP, sign_message))
- return (CRYPT_MOD_CALL (PGP, sign_message)) (a);
-
- return NULL;
-}
-
-/* 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)
-{
- if (CRYPT_MOD_CALL_CHECK (PGP, pgp_encrypt_message))
- return (CRYPT_MOD_CALL (PGP, pgp_encrypt_message)) (a, keylist, sign);
-
- return NULL;
-}
-
-/* Invoke the PGP command to import a key. */
-void crypt_pgp_invoke_import (const char *fname)
-{
- if (CRYPT_MOD_CALL_CHECK (PGP, pgp_invoke_import))
- (CRYPT_MOD_CALL (PGP, pgp_invoke_import)) (fname);
-}
-
-/* fixme: needs documentation */
-int crypt_pgp_verify_one (BODY * sigbdy, STATE * s, const char *tempf)
-{
- if (CRYPT_MOD_CALL_CHECK (PGP, verify_one))
- return (CRYPT_MOD_CALL (PGP, verify_one)) (sigbdy, s, tempf);
+ if (CRYPT_MOD_CALL_CHECK (PGP, pgp_make_key_attachment))
+ return (CRYPT_MOD_CALL (PGP, pgp_make_key_attachment)) (tempf);
- return -1;
+ return NULL;
}
-
-int crypt_pgp_send_menu (HEADER * msg, int *redraw)
-{
- if (CRYPT_MOD_CALL_CHECK (PGP, send_menu))
- return (CRYPT_MOD_CALL (PGP, send_menu)) (msg, redraw);
-
- return 0;
-}
-
-
-/* fixme: needs documentation */
-void crypt_pgp_extract_keys_from_attachment_list (FILE * fp, int tag,
- BODY * top)
-{
- if (CRYPT_MOD_CALL_CHECK (PGP, pgp_extract_keys_from_attachment_list))
- (CRYPT_MOD_CALL (PGP, pgp_extract_keys_from_attachment_list)) (fp, tag,
- top);
-}
-\f
-
-
-/*
-
- S/MIME
-
-*/
-
-
-/* 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)
-{
- if (CRYPT_MOD_CALL_CHECK (SMIME, decrypt_mime))
- return (CRYPT_MOD_CALL (SMIME, decrypt_mime)) (a, b, c, d);
-
- return -1;
-}
-
-/* MIME handler for the application/smime content-type. */
-int crypt_smime_application_smime_handler (BODY * m, STATE * s)
-{
- if (CRYPT_MOD_CALL_CHECK (SMIME, application_handler))
- return (CRYPT_MOD_CALL (SMIME, application_handler)) (m, s);
- return (-1);
-}
-
-/* MIME handler for an PGP/MIME encrypted message. */
-int crypt_smime_encrypted_handler (BODY * a, STATE * s)
-{
- if (CRYPT_MOD_CALL_CHECK (SMIME, encrypted_handler))
- return (CRYPT_MOD_CALL (SMIME, encrypted_handler)) (a, s);
- return (-1);
-}
+/* S/MIME */
/* fixme: Needs documentation. */
void crypt_smime_getkeys (ENVELOPE * env)
{
- if (CRYPT_MOD_CALL_CHECK (SMIME, smime_getkeys))
- (CRYPT_MOD_CALL (SMIME, smime_getkeys)) (env);
-}
-
-/* Check that the sender matches. */
-int crypt_smime_verify_sender (HEADER * h)
-{
- if (CRYPT_MOD_CALL_CHECK (SMIME, smime_verify_sender))
- return (CRYPT_MOD_CALL (SMIME, smime_verify_sender)) (h);
-
- return 1;
-}
-
-/* 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_t * to, address_t * cc, address_t * bcc)
-{
- if (CRYPT_MOD_CALL_CHECK (SMIME, findkeys))
- return (CRYPT_MOD_CALL (SMIME, findkeys)) (to, cc, bcc);
-
- return NULL;
-}
-
-/* fixme: Needs documentation. */
-BODY *crypt_smime_sign_message (BODY * a)
-{
- if (CRYPT_MOD_CALL_CHECK (SMIME, sign_message))
- return (CRYPT_MOD_CALL (SMIME, sign_message)) (a);
-
- return NULL;
+ if (CRYPT_MOD_CALL_CHECK (SMIME, smime_getkeys))
+ (CRYPT_MOD_CALL (SMIME, smime_getkeys)) (env);
}
/* fixme: needs documentation. */
BODY *crypt_smime_build_smime_entity (BODY * a, char *certlist)
{
- if (CRYPT_MOD_CALL_CHECK (SMIME, smime_build_smime_entity))
- return (CRYPT_MOD_CALL (SMIME, smime_build_smime_entity)) (a, certlist);
-
- return NULL;
-}
-
-/* Add a certificate and update index file (externally). */
-void crypt_smime_invoke_import (char *infile, char *mailbox)
-{
- if (CRYPT_MOD_CALL_CHECK (SMIME, smime_invoke_import))
- (CRYPT_MOD_CALL (SMIME, smime_invoke_import)) (infile, mailbox);
-}
-
-/* fixme: needs documentation */
-int crypt_smime_verify_one (BODY * sigbdy, STATE * s, const char *tempf)
-{
- if (CRYPT_MOD_CALL_CHECK (SMIME, verify_one))
- return (CRYPT_MOD_CALL (SMIME, verify_one)) (sigbdy, s, tempf);
-
- return -1;
-}
-
-int crypt_smime_send_menu (HEADER * msg, int *redraw)
-{
- if (CRYPT_MOD_CALL_CHECK (SMIME, send_menu))
- return (CRYPT_MOD_CALL (SMIME, send_menu)) (msg, redraw);
+ if (CRYPT_MOD_CALL_CHECK (SMIME, smime_build_smime_entity))
+ return (CRYPT_MOD_CALL (SMIME, smime_build_smime_entity)) (a, certlist);
- return 0;
+ return NULL;
}