mutt stable branch with some hacks
at master 138 lines 5.3 kB view raw
1/* 2 * Copyright (C) 2004 g10 Code GmbH 3 * 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. 8 * 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. 13 * 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. 17 */ 18 19#ifndef CRYPTOGRAPHY_H 20#define CRYPTOGRAPHY_H 21 22#include "mutt.h" 23#include "mutt_crypt.h" 24 25#define CRYPTO_SUPPORT(identifier) (WithCrypto & APPLICATION_ ## identifier) 26 27 28/* 29 Type definitions for crypto module functions. 30 */ 31typedef void (*crypt_func_void_passphrase_t) (void); 32typedef int (*crypt_func_valid_passphrase_t) (void); 33 34typedef int (*crypt_func_decrypt_mime_t) (FILE *a, FILE **b, 35 BODY *c, BODY **d); 36 37typedef int (*crypt_func_application_handler_t) (BODY *m, STATE *s); 38typedef int (*crypt_func_encrypted_handler_t) (BODY *m, STATE *s); 39 40typedef void (*crypt_func_pgp_invoke_getkeys_t) (ADDRESS *addr); 41typedef int (*crypt_func_pgp_check_traditional_t) (FILE *fp, BODY *b, 42 int tagged_only); 43typedef BODY *(*crypt_func_pgp_traditional_encryptsign_t) (BODY *a, int flags, 44 char *keylist); 45typedef BODY *(*crypt_func_pgp_make_key_attachment_t) (char *tempf); 46typedef char *(*crypt_func_findkeys_t) (ADDRESS *adrlist, int oppenc_mode); 47typedef BODY *(*crypt_func_sign_message_t) (BODY *a); 48typedef BODY *(*crypt_func_pgp_encrypt_message_t) (BODY *a, char *keylist, 49 int sign); 50typedef void (*crypt_func_pgp_invoke_import_t) (const char *fname); 51typedef int (*crypt_func_verify_one_t) (BODY *sigbdy, STATE *s, 52 const char *tempf); 53typedef void (*crypt_func_pgp_extract_keys_from_attachment_list_t) 54 (FILE *fp, int tag, BODY *top); 55 56typedef int (*crypt_func_send_menu_t) (HEADER *msg, int *redraw); 57 58 /* (SMIME) */ 59typedef void (*crypt_func_smime_getkeys_t) (ENVELOPE *env); 60typedef int (*crypt_func_smime_verify_sender_t) (HEADER *h); 61 62typedef BODY *(*crypt_func_smime_build_smime_entity_t) (BODY *a, 63 char *certlist); 64 65typedef void (*crypt_func_smime_invoke_import_t) (char *infile, char *mailbox); 66 67typedef void (*crypt_func_init_t) (void); 68 69typedef void (*crypt_func_set_sender_t) (const char *sender); 70 71/* 72 A structure to keep all crypto module fucntions together. 73 */ 74typedef struct crypt_module_functions 75{ 76 /* Common/General functions. */ 77 crypt_func_init_t init; 78 crypt_func_void_passphrase_t void_passphrase; 79 crypt_func_valid_passphrase_t valid_passphrase; 80 crypt_func_decrypt_mime_t decrypt_mime; 81 crypt_func_application_handler_t application_handler; 82 crypt_func_encrypted_handler_t encrypted_handler; 83 crypt_func_findkeys_t findkeys; 84 crypt_func_sign_message_t sign_message; 85 crypt_func_verify_one_t verify_one; 86 crypt_func_send_menu_t send_menu; 87 crypt_func_set_sender_t set_sender; 88 89 /* PGP specific functions. */ 90 crypt_func_pgp_encrypt_message_t pgp_encrypt_message; 91 crypt_func_pgp_make_key_attachment_t pgp_make_key_attachment; 92 crypt_func_pgp_check_traditional_t pgp_check_traditional; 93 crypt_func_pgp_traditional_encryptsign_t pgp_traditional_encryptsign; 94 crypt_func_pgp_invoke_getkeys_t pgp_invoke_getkeys; 95 crypt_func_pgp_invoke_import_t pgp_invoke_import; 96 crypt_func_pgp_extract_keys_from_attachment_list_t 97 pgp_extract_keys_from_attachment_list; 98 99 /* S/MIME specific functions. */ 100 101 crypt_func_smime_getkeys_t smime_getkeys; 102 crypt_func_smime_verify_sender_t smime_verify_sender; 103 crypt_func_smime_build_smime_entity_t smime_build_smime_entity; 104 crypt_func_smime_invoke_import_t smime_invoke_import; 105} crypt_module_functions_t; 106 107 108/* 109 A structure to describe a crypto module. 110 */ 111typedef struct crypt_module_specs 112{ 113 int identifier; /* Identifying bit. */ 114 crypt_module_functions_t functions; 115} *crypt_module_specs_t; 116 117 118 119/* 120 High Level crypto module interface. 121 */ 122 123void crypto_module_register (crypt_module_specs_t specs); 124crypt_module_specs_t crypto_module_lookup (int identifier); 125 126/* If the crypto module identifier by IDENTIFIER has been registered, 127 call its function FUNC. Do nothing else. This may be used as an 128 expression. */ 129#define CRYPT_MOD_CALL_CHECK(identifier, func) \ 130 (crypto_module_lookup (APPLICATION_ ## identifier) \ 131 && (crypto_module_lookup (APPLICATION_ ## identifier))->functions.func) 132 133/* Call the function FUNC in the crypto module identified by 134 IDENTIFIER. This may be used as an expression. */ 135#define CRYPT_MOD_CALL(identifier, func) \ 136 *(crypto_module_lookup (APPLICATION_ ## identifier))->functions.func 137 138#endif