2 * Copyright notice from original mutt:
3 * Copyright (C) 2003 Werner Koch <wk@gnupg.org>
4 * Copyright (C) 2004 g10code GmbH
6 * This file is part of mutt-ng, see http://www.muttng.org/.
7 * It's licensed under the GNU General Public License,
8 * please see the file GPL in the top level source directory.
12 Common definitions and prototypes for the crypt functions. They are
13 all defined in crypt.c and cryptglue.c
19 #include "mutt.h" /* Need this to declare BODY, address_t. STATE etc. */
22 /* FIXME: They should be pointer to anonymous structures for better
23 information hiding. */
27 #define ENCRYPT (1 << 0)
29 #define GOODSIGN (1 << 2)
30 #define BADSIGN (1 << 3)
31 #define PARTSIGN (1 << 4)
32 #define SIGNOPAQUE (1 << 5)
33 #define KEYBLOCK (1 << 6) /* KEY too generic? */
34 #define INLINE (1 << 7)
36 #define APPLICATION_PGP (1 << 8)
37 #define APPLICATION_SMIME (1 << 9)
39 #define PGP_TRADITIONAL_CHECKED (1 << 10)
41 #define PGPENCRYPT (APPLICATION_PGP | ENCRYPT)
42 #define PGPSIGN (APPLICATION_PGP | SIGN)
43 #define PGPGOODSIGN (APPLICATION_PGP | GOODSIGN)
44 #define PGPKEY (APPLICATION_PGP | KEYBLOCK)
45 #define PGPINLINE (APPLICATION_PGP | INLINE)
47 #define SMIMEENCRYPT (APPLICATION_SMIME | ENCRYPT)
48 #define SMIMESIGN (APPLICATION_SMIME | SIGN)
49 #define SMIMEGOODSIGN (APPLICATION_SMIME | GOODSIGN)
50 #define SMIMEBADSIGN (APPLICATION_SMIME | BADSIGN)
51 #define SMIMEOPAQUE (APPLICATION_SMIME | SIGNOPAQUE)
53 #define KEYFLAG_CANSIGN (1 << 0)
54 #define KEYFLAG_CANENCRYPT (1 << 1)
55 #define KEYFLAG_ISX509 (1 << 2)
56 #define KEYFLAG_SECRET (1 << 7)
57 #define KEYFLAG_EXPIRED (1 << 8)
58 #define KEYFLAG_REVOKED (1 << 9)
59 #define KEYFLAG_DISABLED (1 << 10)
60 #define KEYFLAG_SUBKEY (1 << 11)
61 #define KEYFLAG_CRITICAL (1 << 12)
62 #define KEYFLAG_PREFER_ENCRYPTION (1 << 13)
63 #define KEYFLAG_PREFER_SIGNING (1 << 14)
65 #define KEYFLAG_CANTUSE (KEYFLAG_DISABLED|KEYFLAG_REVOKED|KEYFLAG_EXPIRED)
66 #define KEYFLAG_RESTRICTIONS (KEYFLAG_CANTUSE|KEYFLAG_CRITICAL)
68 #define KEYFLAG_ABILITIES (KEYFLAG_CANSIGN|KEYFLAG_CANENCRYPT|KEYFLAG_PREFER_ENCRYPTION|KEYFLAG_PREFER_SIGNING)
74 typedef enum pgp_ring pgp_ring_t;
78 typedef struct pgp_keyinfo *pgp_key_t;
82 /* Some prototypes -- old crypt.h. */
84 int mutt_protect (HEADER *, char *);
86 int mutt_is_multipart_encrypted (BODY *);
88 int mutt_is_multipart_signed (BODY *);
90 int mutt_is_application_pgp (BODY *);
92 int mutt_is_application_smime (BODY *);
94 int mutt_signed_handler (BODY *, STATE *);
96 int mutt_parse_crypt_hdr (char *, int);
99 void convert_to_7bit (BODY *);
105 /* Print the current time. */
106 void crypt_current_time (STATE * s, const char *app_name);
108 /* Check out the type of encryption used and set the cached status
109 values if there are any. */
110 int crypt_query (BODY * m);
112 /* Fixme: To be documented. */
113 void crypt_extract_keys_from_messages (HEADER * h);
115 /* Do a quick check to make sure that we can find all of the
116 encryption keys if the user has requested this service.
117 Return the list of keys in KEYLIST. */
118 int crypt_get_keys (HEADER * msg, char **keylist);
120 /* Forget a passphrase and display a message. */
121 void crypt_forget_passphrase (void);
123 /* Check that we have a usable passphrase, ask if not. */
124 int crypt_valid_passphrase (int);
126 /* Write the message body/part A described by state S to a the given
128 int crypt_write_signed (BODY * a, STATE * s, const char *tempf);
132 /*-- cryptglue.c --*/
134 /* Show a message that a backend will be invoked. */
135 void crypt_invoke_message (int type);
138 /* Silently forget about a passphrase. */
139 void crypt_pgp_void_passphrase (void);
141 int crypt_pgp_valid_passphrase (void);
144 /* Decrypt a PGP/MIME message. */
145 int crypt_pgp_decrypt_mime (FILE * a, FILE ** b, BODY * c, BODY ** d);
147 /* MIME handler for the application/pgp content-type. */
148 int crypt_pgp_application_pgp_handler (BODY * m, STATE * s);
150 /* MIME handler for an PGP/MIME encrypted message. */
151 int crypt_pgp_encrypted_handler (BODY * a, STATE * s);
153 /* fixme: needs documentation. */
154 void crypt_pgp_invoke_getkeys (address_t * addr);
156 /* Ask for a PGP key. */
157 pgp_key_t crypt_pgp_ask_for_key (char *tag, char *whatfor,
158 short abilities, pgp_ring_t keyring);
160 /* Check for a traditional PGP message in body B. */
161 int crypt_pgp_check_traditional (FILE * fp, BODY * b, int tagged_only);
163 /* fixme: needs documentation. */
164 BODY *crypt_pgp_traditional_encryptsign (BODY * a, int flags, char *keylist);
166 /* Release the PGP key KPP (note, that we pass a pointer to it). */
167 void crypt_pgp_free_key (pgp_key_t * kpp);
169 /* Generate a PGP public key attachment. */
170 BODY *crypt_pgp_make_key_attachment (char *tempf);
172 /* This routine attempts to find the keyids of the recipients of a
173 message. It returns NULL if any of the keys can not be found. */
174 char *crypt_pgp_findkeys (address_t * to, address_t * cc, address_t * bcc);
176 /* Create a new body with a PGP signed message from A. */
177 BODY *crypt_pgp_sign_message (BODY * a);
179 /* Warning: A is no longer freed in this routine, you need to free it
180 later. This is necessary for $fcc_attach. */
181 BODY *crypt_pgp_encrypt_message (BODY * a, char *keylist, int sign);
183 /* Invoke the PGP command to import a key. */
184 void crypt_pgp_invoke_import (const char *fname);
186 int crypt_pgp_send_menu (HEADER * msg, int *redraw);
188 /* fixme: needs documentation */
189 int crypt_pgp_verify_one (BODY * sigbdy, STATE * s, const char *tempf);
191 /* Access the keyID in K. */
192 char *crypt_pgp_keyid (pgp_key_t k);
194 /* fixme: needs documentation */
195 void crypt_pgp_extract_keys_from_attachment_list (FILE * fp, int tag,
202 /* Silently forget about a passphrase. */
203 void crypt_smime_void_passphrase (void);
205 int crypt_smime_valid_passphrase (void);
207 /* Decrypt an S/MIME message. */
208 int crypt_smime_decrypt_mime (FILE * a, FILE ** b, BODY * c, BODY ** d);
210 /* MIME handler for the application/smime content-type. */
211 int crypt_smime_application_smime_handler (BODY * m, STATE * s);
213 /* fixme: Needs documentation. */
214 void crypt_smime_getkeys (ENVELOPE * env);
216 /* Check that the sender matches. */
217 int crypt_smime_verify_sender (HEADER * h);
219 /* Ask for an SMIME key. */
220 char *crypt_smime_ask_for_key (char *prompt, char *mailbox, short public);
222 /* This routine attempts to find the keyids of the recipients of a
223 message. It returns NULL if any of the keys can not be found. */
224 char *crypt_smime_findkeys (address_t * to, address_t * cc, address_t * bcc);
226 /* fixme: Needs documentation. */
227 BODY *crypt_smime_sign_message (BODY * a);
229 /* fixme: needs documentation. */
230 BODY *crypt_smime_build_smime_entity (BODY * a, char *certlist);
232 /* Add a certificate and update index file (externally). */
233 void crypt_smime_invoke_import (char *infile, char *mailbox);
235 int crypt_smime_send_menu (HEADER * msg, int *redraw);
237 /* fixme: needs documentation */
238 int crypt_smime_verify_one (BODY * sigbdy, STATE * s, const char *tempf);
240 void crypt_init (void);
242 #endif /*MUTT_CRYPT_H */