xref: /minix3/crypto/external/bsd/netpgp/dist/src/lib/crypto.h (revision ebfedea0ce5bbe81e252ddf32d732e40fb633fae)
1*ebfedea0SLionel Sambuc /*-
2*ebfedea0SLionel Sambuc  * Copyright (c) 2009 The NetBSD Foundation, Inc.
3*ebfedea0SLionel Sambuc  * All rights reserved.
4*ebfedea0SLionel Sambuc  *
5*ebfedea0SLionel Sambuc  * This code is derived from software contributed to The NetBSD Foundation
6*ebfedea0SLionel Sambuc  * by Alistair Crooks (agc@NetBSD.org)
7*ebfedea0SLionel Sambuc  *
8*ebfedea0SLionel Sambuc  * Redistribution and use in source and binary forms, with or without
9*ebfedea0SLionel Sambuc  * modification, are permitted provided that the following conditions
10*ebfedea0SLionel Sambuc  * are met:
11*ebfedea0SLionel Sambuc  * 1. Redistributions of source code must retain the above copyright
12*ebfedea0SLionel Sambuc  *    notice, this list of conditions and the following disclaimer.
13*ebfedea0SLionel Sambuc  * 2. Redistributions in binary form must reproduce the above copyright
14*ebfedea0SLionel Sambuc  *    notice, this list of conditions and the following disclaimer in the
15*ebfedea0SLionel Sambuc  *    documentation and/or other materials provided with the distribution.
16*ebfedea0SLionel Sambuc  *
17*ebfedea0SLionel Sambuc  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18*ebfedea0SLionel Sambuc  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19*ebfedea0SLionel Sambuc  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20*ebfedea0SLionel Sambuc  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21*ebfedea0SLionel Sambuc  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22*ebfedea0SLionel Sambuc  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23*ebfedea0SLionel Sambuc  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24*ebfedea0SLionel Sambuc  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25*ebfedea0SLionel Sambuc  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26*ebfedea0SLionel Sambuc  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27*ebfedea0SLionel Sambuc  * POSSIBILITY OF SUCH DAMAGE.
28*ebfedea0SLionel Sambuc  */
29*ebfedea0SLionel Sambuc /*
30*ebfedea0SLionel Sambuc  * Copyright (c) 2005-2008 Nominet UK (www.nic.uk)
31*ebfedea0SLionel Sambuc  * All rights reserved.
32*ebfedea0SLionel Sambuc  * Contributors: Ben Laurie, Rachel Willmer. The Contributors have asserted
33*ebfedea0SLionel Sambuc  * their moral rights under the UK Copyright Design and Patents Act 1988 to
34*ebfedea0SLionel Sambuc  * be recorded as the authors of this copyright work.
35*ebfedea0SLionel Sambuc  *
36*ebfedea0SLionel Sambuc  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
37*ebfedea0SLionel Sambuc  * use this file except in compliance with the License.
38*ebfedea0SLionel Sambuc  *
39*ebfedea0SLionel Sambuc  * You may obtain a copy of the License at
40*ebfedea0SLionel Sambuc  *     http://www.apache.org/licenses/LICENSE-2.0
41*ebfedea0SLionel Sambuc  *
42*ebfedea0SLionel Sambuc  * Unless required by applicable law or agreed to in writing, software
43*ebfedea0SLionel Sambuc  * distributed under the License is distributed on an "AS IS" BASIS,
44*ebfedea0SLionel Sambuc  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
45*ebfedea0SLionel Sambuc  *
46*ebfedea0SLionel Sambuc  * See the License for the specific language governing permissions and
47*ebfedea0SLionel Sambuc  * limitations under the License.
48*ebfedea0SLionel Sambuc  */
49*ebfedea0SLionel Sambuc 
50*ebfedea0SLionel Sambuc /** \file
51*ebfedea0SLionel Sambuc  */
52*ebfedea0SLionel Sambuc 
53*ebfedea0SLionel Sambuc #ifndef CRYPTO_H_
54*ebfedea0SLionel Sambuc #define CRYPTO_H_
55*ebfedea0SLionel Sambuc 
56*ebfedea0SLionel Sambuc #include "keyring.h"
57*ebfedea0SLionel Sambuc #include "packet.h"
58*ebfedea0SLionel Sambuc #include "memory.h"
59*ebfedea0SLionel Sambuc #include "packet-parse.h"
60*ebfedea0SLionel Sambuc 
61*ebfedea0SLionel Sambuc #include <openssl/dsa.h>
62*ebfedea0SLionel Sambuc 
63*ebfedea0SLionel Sambuc #define PGP_MIN_HASH_SIZE	16
64*ebfedea0SLionel Sambuc 
65*ebfedea0SLionel Sambuc /** pgp_hash_t */
66*ebfedea0SLionel Sambuc struct pgp_hash_t {
67*ebfedea0SLionel Sambuc 	pgp_hash_alg_t		 alg;		/* algorithm */
68*ebfedea0SLionel Sambuc 	size_t			 size;		/* size */
69*ebfedea0SLionel Sambuc 	const char		*name;		/* what it's known as */
70*ebfedea0SLionel Sambuc 	int			(*init)(pgp_hash_t *);
71*ebfedea0SLionel Sambuc 	void			(*add)(pgp_hash_t *, const uint8_t *, unsigned);
72*ebfedea0SLionel Sambuc 	unsigned		(*finish)(pgp_hash_t *, uint8_t *);
73*ebfedea0SLionel Sambuc 	void		 	*data;		/* blob for data */
74*ebfedea0SLionel Sambuc };
75*ebfedea0SLionel Sambuc 
76*ebfedea0SLionel Sambuc /** pgp_crypt_t */
77*ebfedea0SLionel Sambuc struct pgp_crypt_t {
78*ebfedea0SLionel Sambuc 	pgp_symm_alg_t	alg;
79*ebfedea0SLionel Sambuc 	size_t			blocksize;
80*ebfedea0SLionel Sambuc 	size_t			keysize;
81*ebfedea0SLionel Sambuc 	void 			(*set_iv)(pgp_crypt_t *, const uint8_t *);
82*ebfedea0SLionel Sambuc 	void			(*set_crypt_key)(pgp_crypt_t *, const uint8_t *);
83*ebfedea0SLionel Sambuc 	int			(*base_init)(pgp_crypt_t *);
84*ebfedea0SLionel Sambuc 	void			(*decrypt_resync)(pgp_crypt_t *);
85*ebfedea0SLionel Sambuc 	/* encrypt/decrypt one block */
86*ebfedea0SLionel Sambuc 	void			(*block_encrypt)(pgp_crypt_t *, void *, const void *);
87*ebfedea0SLionel Sambuc 	void			(*block_decrypt)(pgp_crypt_t *, void *, const void *);
88*ebfedea0SLionel Sambuc 	/* Standard CFB encrypt/decrypt (as used by Sym Enc Int Prot packets) */
89*ebfedea0SLionel Sambuc 	void 			(*cfb_encrypt)(pgp_crypt_t *, void *, const void *, size_t);
90*ebfedea0SLionel Sambuc 	void			(*cfb_decrypt)(pgp_crypt_t *, void *, const void *, size_t);
91*ebfedea0SLionel Sambuc 	void			(*decrypt_finish)(pgp_crypt_t *);
92*ebfedea0SLionel Sambuc 	uint8_t			iv[PGP_MAX_BLOCK_SIZE];
93*ebfedea0SLionel Sambuc 	uint8_t			civ[PGP_MAX_BLOCK_SIZE];
94*ebfedea0SLionel Sambuc 	uint8_t			siv[PGP_MAX_BLOCK_SIZE];
95*ebfedea0SLionel Sambuc 		/* siv is needed for weird v3 resync */
96*ebfedea0SLionel Sambuc 	uint8_t			key[PGP_MAX_KEY_SIZE];
97*ebfedea0SLionel Sambuc 	int			num;
98*ebfedea0SLionel Sambuc 		/* num is offset - see openssl _encrypt doco */
99*ebfedea0SLionel Sambuc 	void			*encrypt_key;
100*ebfedea0SLionel Sambuc 	void			*decrypt_key;
101*ebfedea0SLionel Sambuc };
102*ebfedea0SLionel Sambuc 
103*ebfedea0SLionel Sambuc void pgp_crypto_finish(void);
104*ebfedea0SLionel Sambuc void pgp_hash_md5(pgp_hash_t *);
105*ebfedea0SLionel Sambuc void pgp_hash_sha1(pgp_hash_t *);
106*ebfedea0SLionel Sambuc void pgp_hash_sha256(pgp_hash_t *);
107*ebfedea0SLionel Sambuc void pgp_hash_sha512(pgp_hash_t *);
108*ebfedea0SLionel Sambuc void pgp_hash_sha384(pgp_hash_t *);
109*ebfedea0SLionel Sambuc void pgp_hash_sha224(pgp_hash_t *);
110*ebfedea0SLionel Sambuc void pgp_hash_any(pgp_hash_t *, pgp_hash_alg_t);
111*ebfedea0SLionel Sambuc pgp_hash_alg_t pgp_str_to_hash_alg(const char *);
112*ebfedea0SLionel Sambuc const char *pgp_text_from_hash(pgp_hash_t *);
113*ebfedea0SLionel Sambuc unsigned pgp_hash_size(pgp_hash_alg_t);
114*ebfedea0SLionel Sambuc unsigned pgp_hash(uint8_t *, pgp_hash_alg_t, const void *, size_t);
115*ebfedea0SLionel Sambuc 
116*ebfedea0SLionel Sambuc void pgp_hash_add_int(pgp_hash_t *, unsigned, unsigned);
117*ebfedea0SLionel Sambuc 
118*ebfedea0SLionel Sambuc unsigned pgp_dsa_verify(const uint8_t *, size_t,
119*ebfedea0SLionel Sambuc 			const pgp_dsa_sig_t *,
120*ebfedea0SLionel Sambuc 			const pgp_dsa_pubkey_t *);
121*ebfedea0SLionel Sambuc 
122*ebfedea0SLionel Sambuc int pgp_rsa_public_decrypt(uint8_t *, const uint8_t *, size_t,
123*ebfedea0SLionel Sambuc 			const pgp_rsa_pubkey_t *);
124*ebfedea0SLionel Sambuc int pgp_rsa_public_encrypt(uint8_t *, const uint8_t *, size_t,
125*ebfedea0SLionel Sambuc 			const pgp_rsa_pubkey_t *);
126*ebfedea0SLionel Sambuc 
127*ebfedea0SLionel Sambuc int pgp_rsa_private_encrypt(uint8_t *, const uint8_t *, size_t,
128*ebfedea0SLionel Sambuc 			const pgp_rsa_seckey_t *, const pgp_rsa_pubkey_t *);
129*ebfedea0SLionel Sambuc int pgp_rsa_private_decrypt(uint8_t *, const uint8_t *, size_t,
130*ebfedea0SLionel Sambuc 			const pgp_rsa_seckey_t *, const pgp_rsa_pubkey_t *);
131*ebfedea0SLionel Sambuc 
132*ebfedea0SLionel Sambuc int pgp_elgamal_public_encrypt(uint8_t *, uint8_t *, const uint8_t *, size_t,
133*ebfedea0SLionel Sambuc 			const pgp_elgamal_pubkey_t *);
134*ebfedea0SLionel Sambuc int pgp_elgamal_private_decrypt(uint8_t *, const uint8_t *, const uint8_t *, size_t,
135*ebfedea0SLionel Sambuc 			const pgp_elgamal_seckey_t *, const pgp_elgamal_pubkey_t *);
136*ebfedea0SLionel Sambuc 
137*ebfedea0SLionel Sambuc pgp_symm_alg_t pgp_str_to_cipher(const char *);
138*ebfedea0SLionel Sambuc unsigned pgp_block_size(pgp_symm_alg_t);
139*ebfedea0SLionel Sambuc unsigned pgp_key_size(pgp_symm_alg_t);
140*ebfedea0SLionel Sambuc 
141*ebfedea0SLionel Sambuc int pgp_decrypt_data(pgp_content_enum, pgp_region_t *,
142*ebfedea0SLionel Sambuc 			pgp_stream_t *);
143*ebfedea0SLionel Sambuc 
144*ebfedea0SLionel Sambuc int pgp_crypt_any(pgp_crypt_t *, pgp_symm_alg_t);
145*ebfedea0SLionel Sambuc void pgp_decrypt_init(pgp_crypt_t *);
146*ebfedea0SLionel Sambuc void pgp_encrypt_init(pgp_crypt_t *);
147*ebfedea0SLionel Sambuc size_t pgp_decrypt_se(pgp_crypt_t *, void *, const void *, size_t);
148*ebfedea0SLionel Sambuc size_t pgp_encrypt_se(pgp_crypt_t *, void *, const void *, size_t);
149*ebfedea0SLionel Sambuc size_t pgp_decrypt_se_ip(pgp_crypt_t *, void *, const void *, size_t);
150*ebfedea0SLionel Sambuc size_t pgp_encrypt_se_ip(pgp_crypt_t *, void *, const void *, size_t);
151*ebfedea0SLionel Sambuc unsigned pgp_is_sa_supported(pgp_symm_alg_t);
152*ebfedea0SLionel Sambuc 
153*ebfedea0SLionel Sambuc void pgp_reader_push_decrypt(pgp_stream_t *, pgp_crypt_t *,
154*ebfedea0SLionel Sambuc 			pgp_region_t *);
155*ebfedea0SLionel Sambuc void pgp_reader_pop_decrypt(pgp_stream_t *);
156*ebfedea0SLionel Sambuc 
157*ebfedea0SLionel Sambuc /* Hash everything that's read */
158*ebfedea0SLionel Sambuc void pgp_reader_push_hash(pgp_stream_t *, pgp_hash_t *);
159*ebfedea0SLionel Sambuc void pgp_reader_pop_hash(pgp_stream_t *);
160*ebfedea0SLionel Sambuc 
161*ebfedea0SLionel Sambuc int pgp_decrypt_decode_mpi(uint8_t *, unsigned, const BIGNUM *,
162*ebfedea0SLionel Sambuc 			const BIGNUM *, const pgp_seckey_t *);
163*ebfedea0SLionel Sambuc 
164*ebfedea0SLionel Sambuc unsigned pgp_rsa_encrypt_mpi(const uint8_t *, const size_t,
165*ebfedea0SLionel Sambuc 			const pgp_pubkey_t *,
166*ebfedea0SLionel Sambuc 			pgp_pk_sesskey_params_t *);
167*ebfedea0SLionel Sambuc unsigned pgp_elgamal_encrypt_mpi(const uint8_t *, const size_t,
168*ebfedea0SLionel Sambuc 			const pgp_pubkey_t *,
169*ebfedea0SLionel Sambuc 			pgp_pk_sesskey_params_t *);
170*ebfedea0SLionel Sambuc 
171*ebfedea0SLionel Sambuc /* Encrypt everything that's written */
172*ebfedea0SLionel Sambuc struct pgp_key_data;
173*ebfedea0SLionel Sambuc void pgp_writer_push_encrypt(pgp_output_t *,
174*ebfedea0SLionel Sambuc 			const struct pgp_key_data *);
175*ebfedea0SLionel Sambuc 
176*ebfedea0SLionel Sambuc unsigned   pgp_encrypt_file(pgp_io_t *, const char *, const char *,
177*ebfedea0SLionel Sambuc 			const pgp_key_t *,
178*ebfedea0SLionel Sambuc 			const unsigned, const unsigned, const char *);
179*ebfedea0SLionel Sambuc unsigned   pgp_decrypt_file(pgp_io_t *,
180*ebfedea0SLionel Sambuc 			const char *,
181*ebfedea0SLionel Sambuc 			const char *,
182*ebfedea0SLionel Sambuc 			pgp_keyring_t *,
183*ebfedea0SLionel Sambuc 			pgp_keyring_t *,
184*ebfedea0SLionel Sambuc 			const unsigned,
185*ebfedea0SLionel Sambuc 			const unsigned,
186*ebfedea0SLionel Sambuc 			const unsigned,
187*ebfedea0SLionel Sambuc 			void *,
188*ebfedea0SLionel Sambuc 			int,
189*ebfedea0SLionel Sambuc 			pgp_cbfunc_t *);
190*ebfedea0SLionel Sambuc 
191*ebfedea0SLionel Sambuc pgp_memory_t *
192*ebfedea0SLionel Sambuc pgp_encrypt_buf(pgp_io_t *, const void *, const size_t,
193*ebfedea0SLionel Sambuc 			const pgp_key_t *,
194*ebfedea0SLionel Sambuc 			const unsigned, const char *);
195*ebfedea0SLionel Sambuc pgp_memory_t *
196*ebfedea0SLionel Sambuc pgp_decrypt_buf(pgp_io_t *,
197*ebfedea0SLionel Sambuc 			const void *,
198*ebfedea0SLionel Sambuc 			const size_t,
199*ebfedea0SLionel Sambuc 			pgp_keyring_t *,
200*ebfedea0SLionel Sambuc 			pgp_keyring_t *,
201*ebfedea0SLionel Sambuc 			const unsigned,
202*ebfedea0SLionel Sambuc 			const unsigned,
203*ebfedea0SLionel Sambuc 			void *,
204*ebfedea0SLionel Sambuc 			int,
205*ebfedea0SLionel Sambuc 			pgp_cbfunc_t *);
206*ebfedea0SLionel Sambuc 
207*ebfedea0SLionel Sambuc /* Keys */
208*ebfedea0SLionel Sambuc pgp_key_t  *pgp_rsa_new_selfsign_key(const int,
209*ebfedea0SLionel Sambuc 			const unsigned long, uint8_t *, const char *,
210*ebfedea0SLionel Sambuc 			const char *);
211*ebfedea0SLionel Sambuc 
212*ebfedea0SLionel Sambuc int pgp_dsa_size(const pgp_dsa_pubkey_t *);
213*ebfedea0SLionel Sambuc DSA_SIG *pgp_dsa_sign(uint8_t *, unsigned,
214*ebfedea0SLionel Sambuc 				const pgp_dsa_seckey_t *,
215*ebfedea0SLionel Sambuc 				const pgp_dsa_pubkey_t *);
216*ebfedea0SLionel Sambuc 
217*ebfedea0SLionel Sambuc int openssl_read_pem_seckey(const char *, pgp_key_t *, const char *, int);
218*ebfedea0SLionel Sambuc 
219*ebfedea0SLionel Sambuc /** pgp_reader_t */
220*ebfedea0SLionel Sambuc struct pgp_reader_t {
221*ebfedea0SLionel Sambuc 	pgp_reader_func_t	*reader; /* reader func to get parse data */
222*ebfedea0SLionel Sambuc 	pgp_reader_destroyer_t	*destroyer;
223*ebfedea0SLionel Sambuc 	void			*arg;	/* args to pass to reader function */
224*ebfedea0SLionel Sambuc 	unsigned		 accumulate:1;	/* set to gather packet data */
225*ebfedea0SLionel Sambuc 	uint8_t			*accumulated;	/* the accumulated data */
226*ebfedea0SLionel Sambuc 	unsigned		 asize;	/* size of the buffer */
227*ebfedea0SLionel Sambuc 	unsigned		 alength;/* used buffer */
228*ebfedea0SLionel Sambuc 	unsigned		 position;	/* reader-specific offset */
229*ebfedea0SLionel Sambuc 	pgp_reader_t		*next;
230*ebfedea0SLionel Sambuc 	pgp_stream_t		*parent;/* parent parse_info structure */
231*ebfedea0SLionel Sambuc };
232*ebfedea0SLionel Sambuc 
233*ebfedea0SLionel Sambuc 
234*ebfedea0SLionel Sambuc /** pgp_cryptinfo_t
235*ebfedea0SLionel Sambuc  Encrypt/decrypt settings
236*ebfedea0SLionel Sambuc */
237*ebfedea0SLionel Sambuc struct pgp_cryptinfo_t {
238*ebfedea0SLionel Sambuc 	char			*passphrase;
239*ebfedea0SLionel Sambuc 	pgp_keyring_t		*secring;
240*ebfedea0SLionel Sambuc 	const pgp_key_t		*keydata;
241*ebfedea0SLionel Sambuc 	pgp_cbfunc_t		*getpassphrase;
242*ebfedea0SLionel Sambuc 	pgp_keyring_t		*pubring;
243*ebfedea0SLionel Sambuc };
244*ebfedea0SLionel Sambuc 
245*ebfedea0SLionel Sambuc /** pgp_cbdata_t */
246*ebfedea0SLionel Sambuc struct pgp_cbdata_t {
247*ebfedea0SLionel Sambuc 	pgp_cbfunc_t		*cbfunc;	/* callback function */
248*ebfedea0SLionel Sambuc 	void			*arg;	/* args to pass to callback func */
249*ebfedea0SLionel Sambuc 	pgp_error_t		**errors; /* address of error stack */
250*ebfedea0SLionel Sambuc 	pgp_cbdata_t		*next;
251*ebfedea0SLionel Sambuc 	pgp_output_t		*output;	/* when writing out parsed info */
252*ebfedea0SLionel Sambuc 	pgp_io_t		*io;		/* error/output messages */
253*ebfedea0SLionel Sambuc 	void			*passfp;	/* fp for passphrase input */
254*ebfedea0SLionel Sambuc 	pgp_cryptinfo_t		 cryptinfo;	/* used when decrypting */
255*ebfedea0SLionel Sambuc 	pgp_printstate_t	 printstate;	/* used to keep printing state */
256*ebfedea0SLionel Sambuc 	pgp_seckey_t		*sshseckey;	/* secret key for ssh */
257*ebfedea0SLionel Sambuc 	int			 numtries;	/* # of passphrase attempts */
258*ebfedea0SLionel Sambuc 	int			 gotpass;	/* when passphrase entered */
259*ebfedea0SLionel Sambuc };
260*ebfedea0SLionel Sambuc 
261*ebfedea0SLionel Sambuc /** pgp_hashtype_t */
262*ebfedea0SLionel Sambuc typedef struct {
263*ebfedea0SLionel Sambuc 	pgp_hash_t	hash;	/* hashes we should hash data with */
264*ebfedea0SLionel Sambuc 	uint8_t	keyid[PGP_KEY_ID_SIZE];
265*ebfedea0SLionel Sambuc } pgp_hashtype_t;
266*ebfedea0SLionel Sambuc 
267*ebfedea0SLionel Sambuc #define NTAGS	0x100	/* == 256 */
268*ebfedea0SLionel Sambuc 
269*ebfedea0SLionel Sambuc /** \brief Structure to hold information about a packet parse.
270*ebfedea0SLionel Sambuc  *
271*ebfedea0SLionel Sambuc  *  This information includes options about the parse:
272*ebfedea0SLionel Sambuc  *  - whether the packet contents should be accumulated or not
273*ebfedea0SLionel Sambuc  *  - whether signature subpackets should be parsed or left raw
274*ebfedea0SLionel Sambuc  *
275*ebfedea0SLionel Sambuc  *  It contains options specific to the parsing of armoured data:
276*ebfedea0SLionel Sambuc  *  - whether headers are allowed in armoured data without a gap
277*ebfedea0SLionel Sambuc  *  - whether a blank line is allowed at the start of the armoured data
278*ebfedea0SLionel Sambuc  *
279*ebfedea0SLionel Sambuc  *  It also specifies :
280*ebfedea0SLionel Sambuc  *  - the callback function to use and its arguments
281*ebfedea0SLionel Sambuc  *  - the reader function to use and its arguments
282*ebfedea0SLionel Sambuc  *
283*ebfedea0SLionel Sambuc  *  It also contains information about the current state of the parse:
284*ebfedea0SLionel Sambuc  *  - offset from the beginning
285*ebfedea0SLionel Sambuc  *  - the accumulated data, if any
286*ebfedea0SLionel Sambuc  *  - the size of the buffer, and how much has been used
287*ebfedea0SLionel Sambuc  *
288*ebfedea0SLionel Sambuc  *  It has a linked list of errors.
289*ebfedea0SLionel Sambuc  */
290*ebfedea0SLionel Sambuc 
291*ebfedea0SLionel Sambuc struct pgp_stream_t {
292*ebfedea0SLionel Sambuc 	uint8_t		 	ss_raw[NTAGS / 8];
293*ebfedea0SLionel Sambuc 		/* 1 bit / sig-subpkt type; set to get raw data */
294*ebfedea0SLionel Sambuc 	uint8_t		 	ss_parsed[NTAGS / 8];
295*ebfedea0SLionel Sambuc 		/* 1 bit / sig-subpkt type; set to get parsed data */
296*ebfedea0SLionel Sambuc 	pgp_reader_t	 	 readinfo;
297*ebfedea0SLionel Sambuc 	pgp_cbdata_t		 cbinfo;
298*ebfedea0SLionel Sambuc 	pgp_error_t		*errors;
299*ebfedea0SLionel Sambuc 	void			*io;		/* io streams */
300*ebfedea0SLionel Sambuc 	pgp_crypt_t		 decrypt;
301*ebfedea0SLionel Sambuc 	pgp_cryptinfo_t		 cryptinfo;
302*ebfedea0SLionel Sambuc 	size_t			 hashc;
303*ebfedea0SLionel Sambuc 	pgp_hashtype_t		*hashes;
304*ebfedea0SLionel Sambuc 	unsigned		 reading_v3_secret:1;
305*ebfedea0SLionel Sambuc 	unsigned		 reading_mpi_len:1;
306*ebfedea0SLionel Sambuc 	unsigned		 exact_read:1;
307*ebfedea0SLionel Sambuc 	unsigned		 partial_read:1;
308*ebfedea0SLionel Sambuc 	unsigned		 coalescing:1;
309*ebfedea0SLionel Sambuc 	/* used for partial length coalescing */
310*ebfedea0SLionel Sambuc 	unsigned		 virtualc;
311*ebfedea0SLionel Sambuc 	unsigned		 virtualoff;
312*ebfedea0SLionel Sambuc 	uint8_t			*virtualpkt;
313*ebfedea0SLionel Sambuc };
314*ebfedea0SLionel Sambuc 
315*ebfedea0SLionel Sambuc #endif /* CRYPTO_H_ */
316