2 * Copyright notice from original mutt:
3 * Copyright (C) 2004 g10 Code GmbH
5 * This file is part of mutt-ng, see http://www.muttng.org/.
6 * It's licensed under the GNU General Public License,
7 * please see the file GPL in the top level source directory.
10 #ifndef CRYPTOGRAPHY_H
11 #define CRYPTOGRAPHY_H
14 #include "mutt_crypt.h"
16 #define CRYPTO_SUPPORT(identifier) (WithCrypto & APPLICATION_ ## identifier)
20 Type defintions for crypto module functions.
22 typedef void (*crypt_func_void_passphrase_t) (void);
23 typedef int (*crypt_func_valid_passphrase_t) (void);
25 typedef int (*crypt_func_decrypt_mime_t) (FILE * a, FILE ** b,
28 typedef void (*crypt_func_application_handler_t) (BODY * m, STATE * s);
29 typedef void (*crypt_func_encrypted_handler_t) (BODY * m, STATE * s);
31 typedef void (*crypt_func_pgp_invoke_getkeys_t) (ADDRESS * addr);
32 typedef int (*crypt_func_pgp_check_traditional_t) (FILE * fp, BODY * b,
34 typedef BODY *(*crypt_func_pgp_traditional_encryptsign_t) (BODY * a,
37 typedef BODY *(*crypt_func_pgp_make_key_attachment_t) (char *tempf);
38 typedef char *(*crypt_func_findkeys_t) (ADDRESS * to,
39 ADDRESS * cc, ADDRESS * bcc);
40 typedef BODY *(*crypt_func_sign_message_t) (BODY * a);
41 typedef BODY *(*crypt_func_pgp_encrypt_message_t) (BODY * a, char *keylist,
43 typedef void (*crypt_func_pgp_invoke_import_t) (const char *fname);
44 typedef int (*crypt_func_verify_one_t) (BODY * sigbdy, STATE * s,
46 typedef void (*crypt_func_pgp_extract_keys_from_attachment_list_t)
47 (FILE * fp, int tag, BODY * top);
49 typedef int (*crypt_func_send_menu_t) (HEADER * msg, int *redraw);
52 typedef void (*crypt_func_smime_getkeys_t) (ENVELOPE * env);
53 typedef int (*crypt_func_smime_verify_sender_t) (HEADER * h);
55 typedef BODY *(*crypt_func_smime_build_smime_entity_t) (BODY * a,
58 typedef void (*crypt_func_smime_invoke_import_t) (char *infile,
61 typedef void (*crypt_func_init_t) (void);
65 A structure to keep all crypto module fucntions together.
67 typedef struct crypt_module_functions {
68 /* Common/General functions. */
69 crypt_func_init_t init;
70 crypt_func_void_passphrase_t void_passphrase;
71 crypt_func_valid_passphrase_t valid_passphrase;
72 crypt_func_decrypt_mime_t decrypt_mime;
73 crypt_func_application_handler_t application_handler;
74 crypt_func_encrypted_handler_t encrypted_handler;
75 crypt_func_findkeys_t findkeys;
76 crypt_func_sign_message_t sign_message;
77 crypt_func_verify_one_t verify_one;
78 crypt_func_send_menu_t send_menu;
80 /* PGP specific functions. */
81 crypt_func_pgp_encrypt_message_t pgp_encrypt_message;
82 crypt_func_pgp_make_key_attachment_t pgp_make_key_attachment;
83 crypt_func_pgp_check_traditional_t pgp_check_traditional;
84 crypt_func_pgp_traditional_encryptsign_t pgp_traditional_encryptsign;
85 crypt_func_pgp_invoke_getkeys_t pgp_invoke_getkeys;
86 crypt_func_pgp_invoke_import_t pgp_invoke_import;
101 crypt_func_pgp_extract_keys_from_attachment_list_t
102 pgp_extract_keys_from_attachment_list;
104 /* S/MIME specific functions. */
106 crypt_func_smime_getkeys_t smime_getkeys;
107 crypt_func_smime_verify_sender_t smime_verify_sender;
108 crypt_func_smime_build_smime_entity_t smime_build_smime_entity;
109 crypt_func_smime_invoke_import_t smime_invoke_import;
110 } crypt_module_functions_t;
114 A structure to decribe a crypto module.
116 typedef struct crypt_module_specs {
117 int identifier; /* Identifying bit. */
118 crypt_module_functions_t functions;
119 } *crypt_module_specs_t;
124 High Level crypto module interface.
127 void crypto_module_register (crypt_module_specs_t specs);
128 crypt_module_specs_t crypto_module_lookup (int identifier);
130 /* If the crypto module identifier by IDENTIFIER has been registered,
131 call its function FUNC. Do nothing else. This may be used as an
133 #define CRYPT_MOD_CALL_CHECK(identifier, func) \
134 (crypto_module_lookup (APPLICATION_ ## identifier) \
135 && (crypto_module_lookup (APPLICATION_ ## identifier))->functions.func)
137 /* Call the function FUNC in the crypto module identified by
138 IDENTIFIER. This may be used as an expression. */
139 #define CRYPT_MOD_CALL(identifier, func) \
140 *(crypto_module_lookup (APPLICATION_ ## identifier))->functions.func