+++ /dev/null
-/*
- * Copyright notice from original mutt:
- * Copyright (C) 2004 g10 Code GmbH
- *
- * This file is part of mutt-ng, see http://www.muttng.org/.
- * It's licensed under the GNU General Public License,
- * please see the file GPL in the top level source directory.
- */
-
-#include <lib-lib/lib-lib.h>
-
-#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 = p_new(struct crypt_module, 1);
-
- 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;
-}
typedef void (*crypt_func_init_t) (void);
-/*
- A structure to keep all crypto module fucntions together.
- */
-typedef struct crypt_module_functions {
+typedef struct crypt_module_specs {
/* Common/General functions. */
crypt_func_init_t init;
crypt_func_decrypt_mime_t decrypt_mime;
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.
- */
+} crypt_module_specs_t;
-void crypto_module_register (crypt_module_specs_t specs);
-crypt_module_specs_t crypto_module_lookup (int identifier);
+struct crypt_module_specs crypt_mod_SMIME_gpgme;
+struct crypt_module_specs crypt_mod_PGP_gpgme;
-/* 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)
+ ((crypt_mod_##identifier##_gpgme).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
+ (*((crypt_mod_##identifier##_gpgme).func))
#endif
#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 */
- }
+struct crypt_module_specs crypt_mod_SMIME_gpgme = {
+ 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 */
- }
+struct crypt_module_specs crypt_mod_PGP_gpgme = {
+ 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)) ();
+ (CRYPT_MOD_CALL(SMIME, init))();
}
/* Show a message that a backend will be invoked. */
}
-/*
-
- PGP
-
-*/
-
+/* PGP */
/* Decrypt a PGP/MIME message. */
int crypt_pgp_decrypt_mime (FILE * a, FILE ** b, BODY * c, BODY ** d)