2 * Copyright (C) 2004 g10 Code GmbH
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #ifndef CRYPTOGRAPHY_H
20 #define CRYPTOGRAPHY_H
23 #include "mutt_crypt.h"
25 #define CRYPTO_SUPPORT(identifier) (WithCrypto & APPLICATION_ ## identifier)
29 Type defintions for crypto module functions.
31 typedef void (*crypt_func_void_passphrase_t) (void);
32 typedef int (*crypt_func_valid_passphrase_t) (void);
34 typedef int (*crypt_func_decrypt_mime_t) (FILE *a, FILE **b,
37 typedef int (*crypt_func_application_handler_t) (BODY *m, STATE *s);
38 typedef int (*crypt_func_encrypted_handler_t) (BODY *m, STATE *s);
40 typedef void (*crypt_func_pgp_invoke_getkeys_t) (ADDRESS *addr);
41 typedef int (*crypt_func_pgp_check_traditional_t) (FILE *fp, BODY *b,
43 typedef BODY *(*crypt_func_pgp_traditional_encryptsign_t) (BODY *a, int flags,
45 typedef BODY *(*crypt_func_pgp_make_key_attachment_t) (char *tempf);
46 typedef char *(*crypt_func_findkeys_t) (ADDRESS *to,
47 ADDRESS *cc, ADDRESS *bcc);
48 typedef BODY *(*crypt_func_sign_message_t) (BODY *a);
49 typedef BODY *(*crypt_func_pgp_encrypt_message_t) (BODY *a, char *keylist,
51 typedef void (*crypt_func_pgp_invoke_import_t) (const char *fname);
52 typedef int (*crypt_func_verify_one_t) (BODY *sigbdy, STATE *s,
54 typedef void (*crypt_func_pgp_extract_keys_from_attachment_list_t)
55 (FILE *fp, int tag, BODY *top);
57 typedef int (*crypt_func_send_menu_t) (HEADER *msg, int *redraw);
60 typedef void (*crypt_func_smime_getkeys_t) (ENVELOPE *env);
61 typedef int (*crypt_func_smime_verify_sender_t) (HEADER *h);
63 typedef BODY *(*crypt_func_smime_build_smime_entity_t) (BODY *a,
66 typedef void (*crypt_func_smime_invoke_import_t) (char *infile, char *mailbox);
68 typedef void (*crypt_func_init_t) (void);
70 typedef void (*crypt_func_set_sender_t) (const char *sender);
73 A structure to keep all crypto module fucntions together.
75 typedef struct crypt_module_functions
77 /* Common/General functions. */
78 crypt_func_init_t init;
79 crypt_func_void_passphrase_t void_passphrase;
80 crypt_func_valid_passphrase_t valid_passphrase;
81 crypt_func_decrypt_mime_t decrypt_mime;
82 crypt_func_application_handler_t application_handler;
83 crypt_func_encrypted_handler_t encrypted_handler;
84 crypt_func_findkeys_t findkeys;
85 crypt_func_sign_message_t sign_message;
86 crypt_func_verify_one_t verify_one;
87 crypt_func_send_menu_t send_menu;
88 crypt_func_set_sender_t set_sender;
90 /* PGP specific functions. */
91 crypt_func_pgp_encrypt_message_t pgp_encrypt_message;
92 crypt_func_pgp_make_key_attachment_t pgp_make_key_attachment;
93 crypt_func_pgp_check_traditional_t pgp_check_traditional;
94 crypt_func_pgp_traditional_encryptsign_t pgp_traditional_encryptsign;
95 crypt_func_pgp_invoke_getkeys_t pgp_invoke_getkeys;
96 crypt_func_pgp_invoke_import_t pgp_invoke_import;
97 crypt_func_pgp_extract_keys_from_attachment_list_t
98 pgp_extract_keys_from_attachment_list;
100 /* S/MIME specific functions. */
102 crypt_func_smime_getkeys_t smime_getkeys;
103 crypt_func_smime_verify_sender_t smime_verify_sender;
104 crypt_func_smime_build_smime_entity_t smime_build_smime_entity;
105 crypt_func_smime_invoke_import_t smime_invoke_import;
106 } crypt_module_functions_t;
110 A structure to decribe a crypto module.
112 typedef struct crypt_module_specs
114 int identifier; /* Identifying bit. */
115 crypt_module_functions_t functions;
116 } *crypt_module_specs_t;
121 High Level crypto module interface.
124 void crypto_module_register (crypt_module_specs_t specs);
125 crypt_module_specs_t crypto_module_lookup (int identifier);
127 /* If the crypto module identifier by IDENTIFIER has been registered,
128 call its function FUNC. Do nothing else. This may be used as an
130 #define CRYPT_MOD_CALL_CHECK(identifier, func) \
131 (crypto_module_lookup (APPLICATION_ ## identifier) \
132 && (crypto_module_lookup (APPLICATION_ ## identifier))->functions.func)
134 /* Call the function FUNC in the crypto module identified by
135 IDENTIFIER. This may be used as an expression. */
136 #define CRYPT_MOD_CALL(identifier, func) \
137 *(crypto_module_lookup (APPLICATION_ ## identifier))->functions.func