xref: /openbsd-src/lib/libcrypto/evp/evp_local.h (revision a8d73a0eea3b8859883553e5dde982e4a65ed0db)
1*a8d73a0eStb /* $OpenBSD: evp_local.h,v 1.25 2024/08/29 16:58:19 tb Exp $ */
2c9675a23Stb /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3c9675a23Stb  * project 2000.
4c9675a23Stb  */
5c9675a23Stb /* ====================================================================
6c9675a23Stb  * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
7c9675a23Stb  *
8c9675a23Stb  * Redistribution and use in source and binary forms, with or without
9c9675a23Stb  * modification, are permitted provided that the following conditions
10c9675a23Stb  * are met:
11c9675a23Stb  *
12c9675a23Stb  * 1. Redistributions of source code must retain the above copyright
13c9675a23Stb  *    notice, this list of conditions and the following disclaimer.
14c9675a23Stb  *
15c9675a23Stb  * 2. Redistributions in binary form must reproduce the above copyright
16c9675a23Stb  *    notice, this list of conditions and the following disclaimer in
17c9675a23Stb  *    the documentation and/or other materials provided with the
18c9675a23Stb  *    distribution.
19c9675a23Stb  *
20c9675a23Stb  * 3. All advertising materials mentioning features or use of this
21c9675a23Stb  *    software must display the following acknowledgment:
22c9675a23Stb  *    "This product includes software developed by the OpenSSL Project
23c9675a23Stb  *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24c9675a23Stb  *
25c9675a23Stb  * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26c9675a23Stb  *    endorse or promote products derived from this software without
27c9675a23Stb  *    prior written permission. For written permission, please contact
28c9675a23Stb  *    licensing@OpenSSL.org.
29c9675a23Stb  *
30c9675a23Stb  * 5. Products derived from this software may not be called "OpenSSL"
31c9675a23Stb  *    nor may "OpenSSL" appear in their names without prior written
32c9675a23Stb  *    permission of the OpenSSL Project.
33c9675a23Stb  *
34c9675a23Stb  * 6. Redistributions of any form whatsoever must retain the following
35c9675a23Stb  *    acknowledgment:
36c9675a23Stb  *    "This product includes software developed by the OpenSSL Project
37c9675a23Stb  *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38c9675a23Stb  *
39c9675a23Stb  * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40c9675a23Stb  * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41c9675a23Stb  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42c9675a23Stb  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
43c9675a23Stb  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44c9675a23Stb  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45c9675a23Stb  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46c9675a23Stb  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47c9675a23Stb  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48c9675a23Stb  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49c9675a23Stb  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50c9675a23Stb  * OF THE POSSIBILITY OF SUCH DAMAGE.
51c9675a23Stb  * ====================================================================
52c9675a23Stb  *
53c9675a23Stb  * This product includes cryptographic software written by Eric Young
54c9675a23Stb  * (eay@cryptsoft.com).  This product includes software written by Tim
55c9675a23Stb  * Hudson (tjh@cryptsoft.com).
56c9675a23Stb  *
57c9675a23Stb  */
58c9675a23Stb 
59a9199000Stb #ifndef HEADER_EVP_LOCAL_H
60a9199000Stb #define HEADER_EVP_LOCAL_H
61c9675a23Stb 
62c9675a23Stb __BEGIN_HIDDEN_DECLS
63c9675a23Stb 
6477e08d39Stb /* XXX - move these to evp.h after unlock. */
6577e08d39Stb #define	EVP_CTRL_GET_IVLEN		0x25
6677e08d39Stb #define	EVP_CIPH_FLAG_CUSTOM_IV_LENGTH	0x400000
6777e08d39Stb 
6877e08d39Stb #define	EVP_CTRL_AEAD_GET_IVLEN		EVP_CTRL_GET_IVLEN
6977e08d39Stb 
70c9675a23Stb /*
71c9675a23Stb  * Don't free md_ctx->pctx in EVP_MD_CTX_cleanup().  Needed for ownership
72c9675a23Stb  * handling in EVP_MD_CTX_set_pkey_ctx().
73c9675a23Stb  */
74c9675a23Stb #define EVP_MD_CTX_FLAG_KEEP_PKEY_CTX   0x0400
75c9675a23Stb 
76c9675a23Stb typedef int evp_sign_method(int type, const unsigned char *m,
77c9675a23Stb     unsigned int m_length, unsigned char *sigret, unsigned int *siglen,
78c9675a23Stb     void *key);
79c9675a23Stb typedef int evp_verify_method(int type, const unsigned char *m,
80c9675a23Stb     unsigned int m_length, const unsigned char *sigbuf, unsigned int siglen,
81c9675a23Stb     void *key);
82c9675a23Stb 
83c9675a23Stb struct ecx_key_st {
84c9675a23Stb 	int nid;
85c9675a23Stb 	int key_len;
86c9675a23Stb 	uint8_t *priv_key;
87c9675a23Stb 	size_t priv_key_len;
88c9675a23Stb 	uint8_t *pub_key;
89c9675a23Stb 	size_t pub_key_len;
90c9675a23Stb };
91c9675a23Stb 
92049ee4e2Stb struct evp_pkey_asn1_method_st {
939ed721ecStb 	const EVP_PKEY_ASN1_METHOD *base_method;
94049ee4e2Stb 	int pkey_id;
95049ee4e2Stb 	unsigned long pkey_flags;
96049ee4e2Stb 
97049ee4e2Stb 	char *pem_str;
98049ee4e2Stb 	char *info;
99049ee4e2Stb 
100049ee4e2Stb 	int (*pub_decode)(EVP_PKEY *pk, X509_PUBKEY *pub);
101049ee4e2Stb 	int (*pub_encode)(X509_PUBKEY *pub, const EVP_PKEY *pk);
102049ee4e2Stb 	int (*pub_cmp)(const EVP_PKEY *a, const EVP_PKEY *b);
103049ee4e2Stb 	int (*pub_print)(BIO *out, const EVP_PKEY *pkey, int indent,
104049ee4e2Stb 	    ASN1_PCTX *pctx);
105049ee4e2Stb 
106049ee4e2Stb 	int (*priv_decode)(EVP_PKEY *pk, const PKCS8_PRIV_KEY_INFO *p8inf);
107049ee4e2Stb 	int (*priv_encode)(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pk);
108049ee4e2Stb 	int (*priv_print)(BIO *out, const EVP_PKEY *pkey, int indent,
109049ee4e2Stb 	    ASN1_PCTX *pctx);
110049ee4e2Stb 
111049ee4e2Stb 	int (*pkey_size)(const EVP_PKEY *pk);
112049ee4e2Stb 	int (*pkey_bits)(const EVP_PKEY *pk);
113049ee4e2Stb 	int (*pkey_security_bits)(const EVP_PKEY *pk);
114049ee4e2Stb 
115c5d7bed5Stb 	int (*signature_info)(const X509_ALGOR *sig_alg, int *out_md_nid,
116c5d7bed5Stb 	    int *out_pkey_nid, int *out_security_bits, uint32_t *out_flags);
117c5d7bed5Stb 
118049ee4e2Stb 	int (*param_decode)(EVP_PKEY *pkey, const unsigned char **pder,
119049ee4e2Stb 	    int derlen);
120049ee4e2Stb 	int (*param_encode)(const EVP_PKEY *pkey, unsigned char **pder);
121049ee4e2Stb 	int (*param_missing)(const EVP_PKEY *pk);
122049ee4e2Stb 	int (*param_copy)(EVP_PKEY *to, const EVP_PKEY *from);
123049ee4e2Stb 	int (*param_cmp)(const EVP_PKEY *a, const EVP_PKEY *b);
124049ee4e2Stb 	int (*param_print)(BIO *out, const EVP_PKEY *pkey, int indent,
125049ee4e2Stb 	    ASN1_PCTX *pctx);
126049ee4e2Stb 	int (*sig_print)(BIO *out, const X509_ALGOR *sigalg,
127049ee4e2Stb 	    const ASN1_STRING *sig, int indent, ASN1_PCTX *pctx);
128049ee4e2Stb 
129049ee4e2Stb 	void (*pkey_free)(EVP_PKEY *pkey);
130049ee4e2Stb 	int (*pkey_ctrl)(EVP_PKEY *pkey, int op, long arg1, void *arg2);
131049ee4e2Stb 
132049ee4e2Stb 	/* Legacy functions for old PEM */
133049ee4e2Stb 
134049ee4e2Stb 	int (*old_priv_decode)(EVP_PKEY *pkey, const unsigned char **pder,
135049ee4e2Stb 	    int derlen);
136049ee4e2Stb 	int (*old_priv_encode)(const EVP_PKEY *pkey, unsigned char **pder);
137049ee4e2Stb 	/* Custom ASN1 signature verification */
138049ee4e2Stb 	int (*item_verify)(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
139049ee4e2Stb 	    X509_ALGOR *a, ASN1_BIT_STRING *sig, EVP_PKEY *pkey);
140049ee4e2Stb 	int (*item_sign)(EVP_MD_CTX *ctx, const ASN1_ITEM *it, void *asn,
141049ee4e2Stb 	    X509_ALGOR *alg1, X509_ALGOR *alg2, ASN1_BIT_STRING *sig);
142049ee4e2Stb 
143049ee4e2Stb 	int (*set_priv_key)(EVP_PKEY *pk, const unsigned char *private_key,
144049ee4e2Stb 	    size_t len);
145049ee4e2Stb 	int (*set_pub_key)(EVP_PKEY *pk, const unsigned char *public_key,
146049ee4e2Stb 	    size_t len);
147049ee4e2Stb 	int (*get_priv_key)(const EVP_PKEY *pk, unsigned char *out_private_key,
148049ee4e2Stb 	    size_t *out_len);
149049ee4e2Stb 	int (*get_pub_key)(const EVP_PKEY *pk, unsigned char *out_public_key,
150049ee4e2Stb 	    size_t *out_len);
151049ee4e2Stb } /* EVP_PKEY_ASN1_METHOD */;
152049ee4e2Stb 
153c9675a23Stb /* Type needs to be a bit field
154c9675a23Stb  * Sub-type needs to be for variations on the method, as in, can it do
155c9675a23Stb  * arbitrary encryption.... */
156c9675a23Stb struct evp_pkey_st {
157c9675a23Stb 	int type;
158c9675a23Stb 	int references;
159c9675a23Stb 	const EVP_PKEY_ASN1_METHOD *ameth;
160c9675a23Stb 	union	{
161c9675a23Stb 		void *ptr;
162c9675a23Stb #ifndef OPENSSL_NO_RSA
163c9675a23Stb 		struct rsa_st *rsa;	/* RSA */
164c9675a23Stb #endif
165c9675a23Stb #ifndef OPENSSL_NO_DSA
166c9675a23Stb 		struct dsa_st *dsa;	/* DSA */
167c9675a23Stb #endif
168c9675a23Stb #ifndef OPENSSL_NO_DH
169c9675a23Stb 		struct dh_st *dh;	/* DH */
170c9675a23Stb #endif
171c9675a23Stb #ifndef OPENSSL_NO_EC
172c9675a23Stb 		struct ec_key_st *ec;	/* ECC */
173c9675a23Stb 		struct ecx_key_st *ecx;	/* ECX */
174c9675a23Stb #endif
175c9675a23Stb 	} pkey;
176c9675a23Stb 	int save_parameters;
177c9675a23Stb } /* EVP_PKEY */;
178c9675a23Stb 
1797d242c13Stb struct evp_md_st {
180c9675a23Stb 	int type;
181c9675a23Stb 	int pkey_type;
182c9675a23Stb 	int md_size;
183c9675a23Stb 	unsigned long flags;
184c9675a23Stb 	int (*init)(EVP_MD_CTX *ctx);
185c9675a23Stb 	int (*update)(EVP_MD_CTX *ctx, const void *data, size_t count);
186c9675a23Stb 	int (*final)(EVP_MD_CTX *ctx, unsigned char *md);
187c9675a23Stb 	int (*copy)(EVP_MD_CTX *to, const EVP_MD_CTX *from);
188c9675a23Stb 	int (*cleanup)(EVP_MD_CTX *ctx);
189c9675a23Stb 
190c9675a23Stb 	int block_size;
191c9675a23Stb 	int ctx_size; /* how big does the ctx->md_data need to be */
192c9675a23Stb 	/* control function */
193c9675a23Stb 	int (*md_ctrl)(EVP_MD_CTX *ctx, int cmd, int p1, void *p2);
194c9675a23Stb } /* EVP_MD */;
195c9675a23Stb 
1967d242c13Stb struct evp_md_ctx_st {
197c9675a23Stb 	const EVP_MD *digest;
198c9675a23Stb 	unsigned long flags;
199c9675a23Stb 	void *md_data;
200c9675a23Stb 	/* Public key context for sign/verify */
201c9675a23Stb 	EVP_PKEY_CTX *pctx;
202c9675a23Stb 	/* Update function: usually copied from EVP_MD */
203c9675a23Stb 	int (*update)(EVP_MD_CTX *ctx, const void *data, size_t count);
204c9675a23Stb } /* EVP_MD_CTX */;
205c9675a23Stb 
206c9675a23Stb struct evp_cipher_st {
207c9675a23Stb 	int nid;
208c9675a23Stb 	int block_size;
209c9675a23Stb 	int key_len;		/* Default value for variable length ciphers */
210c9675a23Stb 	int iv_len;
211c9675a23Stb 	unsigned long flags;	/* Various flags */
212c9675a23Stb 	int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key,
213c9675a23Stb 	    const unsigned char *iv, int enc);	/* init key */
214c9675a23Stb 	int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out,
215c9675a23Stb 	    const unsigned char *in, size_t inl);/* encrypt/decrypt data */
216d8fdcedaStb 	int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */
217c9675a23Stb 	int ctx_size;		/* how big ctx->cipher_data needs to be */
218c9675a23Stb 	int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */
219c9675a23Stb 	int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Get parameters from a ASN1_TYPE */
220c9675a23Stb 	int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr); /* Miscellaneous operations */
221c9675a23Stb } /* EVP_CIPHER */;
222c9675a23Stb 
223c9675a23Stb struct evp_cipher_ctx_st {
224c9675a23Stb 	const EVP_CIPHER *cipher;
225c9675a23Stb 	int encrypt;		/* encrypt or decrypt */
2261420f9e4Stb 	int partial_len;	/* number of bytes written to buf */
227c9675a23Stb 
228c9675a23Stb 	unsigned char oiv[EVP_MAX_IV_LENGTH];	/* original iv */
229c9675a23Stb 	unsigned char iv[EVP_MAX_IV_LENGTH];	/* working iv */
230c9675a23Stb 	unsigned char buf[EVP_MAX_BLOCK_LENGTH];/* saved partial block */
231c9675a23Stb 	int num;				/* used by cfb/ofb/ctr mode */
232c9675a23Stb 
233c9675a23Stb 	void *app_data;		/* application stuff */
234c9675a23Stb 	int key_len;		/* May change for variable length cipher */
235c9675a23Stb 	unsigned long flags;	/* Various flags */
236c9675a23Stb 	void *cipher_data; /* per EVP data */
237c9675a23Stb 	int final_used;
238c9675a23Stb 	unsigned char final[EVP_MAX_BLOCK_LENGTH];/* possible final block */
239c9675a23Stb } /* EVP_CIPHER_CTX */;
240c9675a23Stb 
241c9675a23Stb struct evp_Encode_Ctx_st {
242c9675a23Stb 
243c9675a23Stb 	int num;	/* number saved in a partial encode/decode */
244c9675a23Stb 	int length;	/* The length is either the output line length
245c9675a23Stb 			 * (in input bytes) or the shortest input line
246c9675a23Stb 			 * length that is ok.  Once decoding begins,
247c9675a23Stb 			 * the length is adjusted up each time a longer
248c9675a23Stb 			 * line is decoded */
249c9675a23Stb 	unsigned char enc_data[80];	/* data to encode */
250c9675a23Stb 	int line_num;	/* number read on current line */
251c9675a23Stb 	int expect_nl;
252c9675a23Stb } /* EVP_ENCODE_CTX */;
253c9675a23Stb 
254c9675a23Stb #define EVP_MAXCHUNK ((size_t)1<<(sizeof(long)*8-2))
255c9675a23Stb 
256c9675a23Stb struct evp_pkey_ctx_st {
257c9675a23Stb 	/* Method associated with this operation */
258c9675a23Stb 	const EVP_PKEY_METHOD *pmeth;
259c9675a23Stb 	/* Key: may be NULL */
260c9675a23Stb 	EVP_PKEY *pkey;
261c9675a23Stb 	/* Peer key for key agreement, may be NULL */
262c9675a23Stb 	EVP_PKEY *peerkey;
263c9675a23Stb 	/* Actual operation */
264c9675a23Stb 	int operation;
265c9675a23Stb 	/* Algorithm specific data */
266c9675a23Stb 	void *data;
267c9675a23Stb 	/* Application specific data */
268c9675a23Stb 	void *app_data;
269c9675a23Stb 	/* Keygen callback */
270c9675a23Stb 	EVP_PKEY_gen_cb *pkey_gencb;
271c9675a23Stb 	/* implementation specific keygen data */
272c9675a23Stb 	int *keygen_info;
273c9675a23Stb 	int keygen_info_count;
274c9675a23Stb } /* EVP_PKEY_CTX */;
275c9675a23Stb 
276c9675a23Stb struct evp_pkey_method_st {
277c9675a23Stb 	int pkey_id;
278c9675a23Stb 	int flags;
279c9675a23Stb 
280c9675a23Stb 	int (*init)(EVP_PKEY_CTX *ctx);
281c9675a23Stb 	int (*copy)(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src);
282c9675a23Stb 	void (*cleanup)(EVP_PKEY_CTX *ctx);
283c9675a23Stb 
284c9675a23Stb 	int (*paramgen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
285c9675a23Stb 
286c9675a23Stb 	int (*keygen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
287c9675a23Stb 
288c9675a23Stb 	int (*sign_init)(EVP_PKEY_CTX *ctx);
289c9675a23Stb 	int (*sign)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
290c9675a23Stb 	    const unsigned char *tbs, size_t tbslen);
291c9675a23Stb 
292c9675a23Stb 	int (*verify_init)(EVP_PKEY_CTX *ctx);
293c9675a23Stb 	int (*verify)(EVP_PKEY_CTX *ctx,
294c9675a23Stb 	    const unsigned char *sig, size_t siglen,
295c9675a23Stb 	    const unsigned char *tbs, size_t tbslen);
296c9675a23Stb 
297c9675a23Stb 	int (*verify_recover)(EVP_PKEY_CTX *ctx,
298c9675a23Stb 	    unsigned char *rout, size_t *routlen,
299c9675a23Stb 	    const unsigned char *sig, size_t siglen);
300c9675a23Stb 
301c9675a23Stb 	int (*signctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
302c9675a23Stb 	int (*signctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
303c9675a23Stb 	    EVP_MD_CTX *mctx);
304c9675a23Stb 
305c9675a23Stb 	int (*encrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
306c9675a23Stb 	    const unsigned char *in, size_t inlen);
307c9675a23Stb 
308c9675a23Stb 	int (*decrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
309c9675a23Stb 	    const unsigned char *in, size_t inlen);
310c9675a23Stb 
311c9675a23Stb 	int (*derive_init)(EVP_PKEY_CTX *ctx);
312c9675a23Stb 	int (*derive)(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);
313c9675a23Stb 
314c9675a23Stb 	int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2);
315c9675a23Stb 	int (*ctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value);
316c9675a23Stb 
317c9675a23Stb 	int (*digestsign)(EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen,
318c9675a23Stb 	    const unsigned char *tbs, size_t tbslen);
319c9675a23Stb 	int (*digestverify) (EVP_MD_CTX *ctx, const unsigned char *sig,
320c9675a23Stb 	    size_t siglen, const unsigned char *tbs, size_t tbslen);
321c9675a23Stb } /* EVP_PKEY_METHOD */;
322c9675a23Stb 
323c9675a23Stb void evp_pkey_set_cb_translate(BN_GENCB *cb, EVP_PKEY_CTX *ctx);
324c9675a23Stb 
325c9675a23Stb /* EVP_AEAD represents a specific AEAD algorithm. */
326c9675a23Stb struct evp_aead_st {
327c9675a23Stb 	unsigned char key_len;
328c9675a23Stb 	unsigned char nonce_len;
329c9675a23Stb 	unsigned char overhead;
330c9675a23Stb 	unsigned char max_tag_len;
331c9675a23Stb 
332c9675a23Stb 	int (*init)(struct evp_aead_ctx_st*, const unsigned char *key,
333c9675a23Stb 	    size_t key_len, size_t tag_len);
334c9675a23Stb 	void (*cleanup)(struct evp_aead_ctx_st*);
335c9675a23Stb 
336c9675a23Stb 	int (*seal)(const struct evp_aead_ctx_st *ctx, unsigned char *out,
337c9675a23Stb 	    size_t *out_len, size_t max_out_len, const unsigned char *nonce,
338c9675a23Stb 	    size_t nonce_len, const unsigned char *in, size_t in_len,
339c9675a23Stb 	    const unsigned char *ad, size_t ad_len);
340c9675a23Stb 
341c9675a23Stb 	int (*open)(const struct evp_aead_ctx_st *ctx, unsigned char *out,
342c9675a23Stb 	    size_t *out_len, size_t max_out_len, const unsigned char *nonce,
343c9675a23Stb 	    size_t nonce_len, const unsigned char *in, size_t in_len,
344c9675a23Stb 	    const unsigned char *ad, size_t ad_len);
345c9675a23Stb };
346c9675a23Stb 
347c9675a23Stb /* An EVP_AEAD_CTX represents an AEAD algorithm configured with a specific key
348c9675a23Stb  * and message-independent IV. */
349c9675a23Stb struct evp_aead_ctx_st {
350c9675a23Stb 	const EVP_AEAD *aead;
351c9675a23Stb 	/* aead_state is an opaque pointer to the AEAD specific state. */
352c9675a23Stb 	void *aead_state;
353c9675a23Stb };
354c9675a23Stb 
3550659516dStb /* Legacy EVP_CIPHER methods used by CMS and its predecessors. */
3560659516dStb int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *cipher, ASN1_TYPE *type);
3570659516dStb int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *cipher, ASN1_TYPE *type);
3580659516dStb int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *cipher, ASN1_TYPE *type);
3590659516dStb int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *cipher, ASN1_TYPE *type);
3600659516dStb 
361573bb26aStb int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
362573bb26aStb     ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de);
363573bb26aStb 
364c9675a23Stb int EVP_PKEY_CTX_str2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *str);
365c9675a23Stb int EVP_PKEY_CTX_hex2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *hex);
366c9675a23Stb int EVP_PKEY_CTX_md(EVP_PKEY_CTX *ctx, int optype, int cmd, const char *md_name);
367c9675a23Stb 
36887da0f20Stb void EVP_CIPHER_CTX_legacy_clear(EVP_CIPHER_CTX *ctx);
369a88dcb3dStb void EVP_MD_CTX_legacy_clear(EVP_MD_CTX *ctx);
37087da0f20Stb 
371c9675a23Stb __END_HIDDEN_DECLS
372c9675a23Stb 
373a9199000Stb #endif /* !HEADER_EVP_LOCAL_H */
374