X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=lib-crypt%2Fcryptglue.c;h=e349698c1e796cfe687e3a6914caadbb6aa370e4;hp=742c4a0daa8e99e6aa59d73538de60a4c64bcdac;hb=c55aa3dacb53b38f4acc9f8679927756c6ddde2a;hpb=6d2a5b1e45ea9606d27a23c068bd4e8e5f94f341 diff --git a/lib-crypt/cryptglue.c b/lib-crypt/cryptglue.c index 742c4a0..e349698 100644 --- a/lib-crypt/cryptglue.c +++ b/lib-crypt/cryptglue.c @@ -23,305 +23,24 @@ #include "mutt.h" #include "crypt.h" -#include "crypt-mod.h" -#include "crypt-gpgme.h" -static struct crypt_module_specs crypt_mod_smime_gpgme = { APPLICATION_SMIME, - { - smime_gpgme_init, - smime_gpgme_decrypt_mime, - smime_gpgme_application_handler, - NULL, /* encrypted_handler */ - smime_gpgme_findkeys, - smime_gpgme_sign_message, - smime_gpgme_verify_one, - smime_gpgme_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 */ - - NULL, /* smime_getkeys */ - smime_gpgme_verify_sender, - smime_gpgme_build_smime_entity, - NULL, /* smime_invoke_import */ - } -}; - -static struct crypt_module_specs crypt_mod_pgp_gpgme = { APPLICATION_PGP, - { - pgp_gpgme_init, - pgp_gpgme_decrypt_mime, - pgp_gpgme_application_handler, - pgp_gpgme_encrypted_handler, - pgp_gpgme_findkeys, - pgp_gpgme_sign_message, - pgp_gpgme_verify_one, - pgp_gpgme_send_menu, - - /* PGP specific. */ - pgp_gpgme_encrypt_message, - NULL, /* pgp_make_key_attachment, */ - pgp_gpgme_check_traditional, - NULL, /* pgp_traditional_encryptsign */ - NULL, /* pgp_invoke_getkeys */ - pgp_gpgme_invoke_import, /* pgp_invoke_import */ - pgp_gpgme_from_attachment_list, - /* pgp_extract_keys_from_attachment_list */ - - NULL, /* smime_getkeys */ - NULL, /* smime_verify_sender */ - NULL, /* smime_build_smime_entity */ - NULL, /* smime_invoke_import */ - } -}; - -void crypt_init (void) -{ - crypto_module_register (&crypt_mod_pgp_gpgme); - crypto_module_register (&crypt_mod_smime_gpgme); - - (CRYPT_MOD_CALL(PGP, init))(); - (CRYPT_MOD_CALL (SMIME, init)) (); -} - -/* 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..."); - } -} - - -/* - - PGP - -*/ - - -/* 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); -} - -/* 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); -} +/* PGP */ /* 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; } /* 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); + return NULL; } -/* 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); - - return -1; -} - - -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); -} - - - -/* - - S/MIME - -*/ - - -/* 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); -} +/* 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; -} - -/* 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); - - return 0; -}