VirtualBox

source: vbox/trunk/src/libs/openssl-1.1.1l/include/openssl/evp.h@ 91772

Last change on this file since 91772 was 91772, checked in by vboxsync, 3 years ago

openssl-1.1.1l: Applied and adjusted our OpenSSL changes to 1.1.1l. bugref:10126

File size: 75.5 KB
Line 
1/*
2 * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10#ifndef HEADER_ENVELOPE_H
11# define HEADER_ENVELOPE_H
12
13# include <openssl/opensslconf.h>
14# include <openssl/ossl_typ.h>
15# include <openssl/symhacks.h>
16# include <openssl/bio.h>
17# include <openssl/evperr.h>
18
19#ifdef ___openssl_mangling_h___
20# undef EVP_idea_cfb
21# undef EVP_rc2_cfb
22# undef EVP_bf_cfb
23# undef EVP_cast5_cfb
24# undef EVP_rc5_32_12_16_cfb
25# undef EVP_aes_128_cfb
26# undef EVP_aes_192_cfb
27# undef EVP_aes_256_cfb
28# undef EVP_aria_128_cfb
29# undef EVP_aria_192_cfb
30# undef EVP_aria_256_cfb
31# undef EVP_camellia_128_cfb
32# undef EVP_camellia_192_cfb
33# undef EVP_camellia_256_cfb
34# undef EVP_seed_cfb
35# undef EVP_sm4_cfb
36#endif /* ___openssl_mangling_h___ */
37
38# define EVP_MAX_MD_SIZE 64/* longest known is SHA512 */
39# define EVP_MAX_KEY_LENGTH 64
40# define EVP_MAX_IV_LENGTH 16
41# define EVP_MAX_BLOCK_LENGTH 32
42
43# define PKCS5_SALT_LEN 8
44/* Default PKCS#5 iteration count */
45# define PKCS5_DEFAULT_ITER 2048
46
47# include <openssl/objects.h>
48
49# define EVP_PK_RSA 0x0001
50# define EVP_PK_DSA 0x0002
51# define EVP_PK_DH 0x0004
52# define EVP_PK_EC 0x0008
53# define EVP_PKT_SIGN 0x0010
54# define EVP_PKT_ENC 0x0020
55# define EVP_PKT_EXCH 0x0040
56# define EVP_PKS_RSA 0x0100
57# define EVP_PKS_DSA 0x0200
58# define EVP_PKS_EC 0x0400
59
60# define EVP_PKEY_NONE NID_undef
61# define EVP_PKEY_RSA NID_rsaEncryption
62# define EVP_PKEY_RSA2 NID_rsa
63# define EVP_PKEY_RSA_PSS NID_rsassaPss
64# define EVP_PKEY_DSA NID_dsa
65# define EVP_PKEY_DSA1 NID_dsa_2
66# define EVP_PKEY_DSA2 NID_dsaWithSHA
67# define EVP_PKEY_DSA3 NID_dsaWithSHA1
68# define EVP_PKEY_DSA4 NID_dsaWithSHA1_2
69# define EVP_PKEY_DH NID_dhKeyAgreement
70# define EVP_PKEY_DHX NID_dhpublicnumber
71# define EVP_PKEY_EC NID_X9_62_id_ecPublicKey
72# define EVP_PKEY_SM2 NID_sm2
73# define EVP_PKEY_HMAC NID_hmac
74# define EVP_PKEY_CMAC NID_cmac
75# define EVP_PKEY_SCRYPT NID_id_scrypt
76# define EVP_PKEY_TLS1_PRF NID_tls1_prf
77# define EVP_PKEY_HKDF NID_hkdf
78# define EVP_PKEY_POLY1305 NID_poly1305
79# define EVP_PKEY_SIPHASH NID_siphash
80# define EVP_PKEY_X25519 NID_X25519
81# define EVP_PKEY_ED25519 NID_ED25519
82# define EVP_PKEY_X448 NID_X448
83# define EVP_PKEY_ED448 NID_ED448
84
85#ifdef __cplusplus
86extern "C" {
87#endif
88
89# define EVP_PKEY_MO_SIGN 0x0001
90# define EVP_PKEY_MO_VERIFY 0x0002
91# define EVP_PKEY_MO_ENCRYPT 0x0004
92# define EVP_PKEY_MO_DECRYPT 0x0008
93
94# ifndef EVP_MD
95EVP_MD *EVP_MD_meth_new(int md_type, int pkey_type);
96EVP_MD *EVP_MD_meth_dup(const EVP_MD *md);
97void EVP_MD_meth_free(EVP_MD *md);
98
99int EVP_MD_meth_set_input_blocksize(EVP_MD *md, int blocksize);
100int EVP_MD_meth_set_result_size(EVP_MD *md, int resultsize);
101int EVP_MD_meth_set_app_datasize(EVP_MD *md, int datasize);
102int EVP_MD_meth_set_flags(EVP_MD *md, unsigned long flags);
103int EVP_MD_meth_set_init(EVP_MD *md, int (*init)(EVP_MD_CTX *ctx));
104int EVP_MD_meth_set_update(EVP_MD *md, int (*update)(EVP_MD_CTX *ctx,
105 const void *data,
106 size_t count));
107int EVP_MD_meth_set_final(EVP_MD *md, int (*final)(EVP_MD_CTX *ctx,
108 unsigned char *md));
109int EVP_MD_meth_set_copy(EVP_MD *md, int (*copy)(EVP_MD_CTX *to,
110 const EVP_MD_CTX *from));
111int EVP_MD_meth_set_cleanup(EVP_MD *md, int (*cleanup)(EVP_MD_CTX *ctx));
112int EVP_MD_meth_set_ctrl(EVP_MD *md, int (*ctrl)(EVP_MD_CTX *ctx, int cmd,
113 int p1, void *p2));
114
115int EVP_MD_meth_get_input_blocksize(const EVP_MD *md);
116int EVP_MD_meth_get_result_size(const EVP_MD *md);
117int EVP_MD_meth_get_app_datasize(const EVP_MD *md);
118unsigned long EVP_MD_meth_get_flags(const EVP_MD *md);
119int (*EVP_MD_meth_get_init(const EVP_MD *md))(EVP_MD_CTX *ctx);
120int (*EVP_MD_meth_get_update(const EVP_MD *md))(EVP_MD_CTX *ctx,
121 const void *data,
122 size_t count);
123int (*EVP_MD_meth_get_final(const EVP_MD *md))(EVP_MD_CTX *ctx,
124 unsigned char *md);
125int (*EVP_MD_meth_get_copy(const EVP_MD *md))(EVP_MD_CTX *to,
126 const EVP_MD_CTX *from);
127int (*EVP_MD_meth_get_cleanup(const EVP_MD *md))(EVP_MD_CTX *ctx);
128int (*EVP_MD_meth_get_ctrl(const EVP_MD *md))(EVP_MD_CTX *ctx, int cmd,
129 int p1, void *p2);
130
131/* digest can only handle a single block */
132# define EVP_MD_FLAG_ONESHOT 0x0001
133
134/* digest is extensible-output function, XOF */
135# define EVP_MD_FLAG_XOF 0x0002
136
137/* DigestAlgorithmIdentifier flags... */
138
139# define EVP_MD_FLAG_DIGALGID_MASK 0x0018
140
141/* NULL or absent parameter accepted. Use NULL */
142
143# define EVP_MD_FLAG_DIGALGID_NULL 0x0000
144
145/* NULL or absent parameter accepted. Use NULL for PKCS#1 otherwise absent */
146
147# define EVP_MD_FLAG_DIGALGID_ABSENT 0x0008
148
149/* Custom handling via ctrl */
150
151# define EVP_MD_FLAG_DIGALGID_CUSTOM 0x0018
152
153/* Note if suitable for use in FIPS mode */
154# define EVP_MD_FLAG_FIPS 0x0400
155
156/* Digest ctrls */
157
158# define EVP_MD_CTRL_DIGALGID 0x1
159# define EVP_MD_CTRL_MICALG 0x2
160# define EVP_MD_CTRL_XOF_LEN 0x3
161
162/* Minimum Algorithm specific ctrl value */
163
164# define EVP_MD_CTRL_ALG_CTRL 0x1000
165
166# endif /* !EVP_MD */
167
168/* values for EVP_MD_CTX flags */
169
170# define EVP_MD_CTX_FLAG_ONESHOT 0x0001/* digest update will be
171 * called once only */
172# define EVP_MD_CTX_FLAG_CLEANED 0x0002/* context has already been
173 * cleaned */
174# define EVP_MD_CTX_FLAG_REUSE 0x0004/* Don't free up ctx->md_data
175 * in EVP_MD_CTX_reset */
176/*
177 * FIPS and pad options are ignored in 1.0.0, definitions are here so we
178 * don't accidentally reuse the values for other purposes.
179 */
180
181# define EVP_MD_CTX_FLAG_NON_FIPS_ALLOW 0x0008/* Allow use of non FIPS
182 * digest in FIPS mode */
183
184/*
185 * The following PAD options are also currently ignored in 1.0.0, digest
186 * parameters are handled through EVP_DigestSign*() and EVP_DigestVerify*()
187 * instead.
188 */
189# define EVP_MD_CTX_FLAG_PAD_MASK 0xF0/* RSA mode to use */
190# define EVP_MD_CTX_FLAG_PAD_PKCS1 0x00/* PKCS#1 v1.5 mode */
191# define EVP_MD_CTX_FLAG_PAD_X931 0x10/* X9.31 mode */
192# define EVP_MD_CTX_FLAG_PAD_PSS 0x20/* PSS mode */
193
194# define EVP_MD_CTX_FLAG_NO_INIT 0x0100/* Don't initialize md_data */
195/*
196 * Some functions such as EVP_DigestSign only finalise copies of internal
197 * contexts so additional data can be included after the finalisation call.
198 * This is inefficient if this functionality is not required: it is disabled
199 * if the following flag is set.
200 */
201# define EVP_MD_CTX_FLAG_FINALISE 0x0200
202/* NOTE: 0x0400 is reserved for internal usage */
203
204EVP_CIPHER *EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len);
205EVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher);
206void EVP_CIPHER_meth_free(EVP_CIPHER *cipher);
207
208int EVP_CIPHER_meth_set_iv_length(EVP_CIPHER *cipher, int iv_len);
209int EVP_CIPHER_meth_set_flags(EVP_CIPHER *cipher, unsigned long flags);
210int EVP_CIPHER_meth_set_impl_ctx_size(EVP_CIPHER *cipher, int ctx_size);
211int EVP_CIPHER_meth_set_init(EVP_CIPHER *cipher,
212 int (*init) (EVP_CIPHER_CTX *ctx,
213 const unsigned char *key,
214 const unsigned char *iv,
215 int enc));
216int EVP_CIPHER_meth_set_do_cipher(EVP_CIPHER *cipher,
217 int (*do_cipher) (EVP_CIPHER_CTX *ctx,
218 unsigned char *out,
219 const unsigned char *in,
220 size_t inl));
221int EVP_CIPHER_meth_set_cleanup(EVP_CIPHER *cipher,
222 int (*cleanup) (EVP_CIPHER_CTX *));
223int EVP_CIPHER_meth_set_set_asn1_params(EVP_CIPHER *cipher,
224 int (*set_asn1_parameters) (EVP_CIPHER_CTX *,
225 ASN1_TYPE *));
226int EVP_CIPHER_meth_set_get_asn1_params(EVP_CIPHER *cipher,
227 int (*get_asn1_parameters) (EVP_CIPHER_CTX *,
228 ASN1_TYPE *));
229int EVP_CIPHER_meth_set_ctrl(EVP_CIPHER *cipher,
230 int (*ctrl) (EVP_CIPHER_CTX *, int type,
231 int arg, void *ptr));
232
233int (*EVP_CIPHER_meth_get_init(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx,
234 const unsigned char *key,
235 const unsigned char *iv,
236 int enc);
237int (*EVP_CIPHER_meth_get_do_cipher(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx,
238 unsigned char *out,
239 const unsigned char *in,
240 size_t inl);
241int (*EVP_CIPHER_meth_get_cleanup(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *);
242int (*EVP_CIPHER_meth_get_set_asn1_params(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,
243 ASN1_TYPE *);
244int (*EVP_CIPHER_meth_get_get_asn1_params(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,
245 ASN1_TYPE *);
246int (*EVP_CIPHER_meth_get_ctrl(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,
247 int type, int arg,
248 void *ptr);
249
250/* Values for cipher flags */
251
252/* Modes for ciphers */
253
254# define EVP_CIPH_STREAM_CIPHER 0x0
255# define EVP_CIPH_ECB_MODE 0x1
256# define EVP_CIPH_CBC_MODE 0x2
257# define EVP_CIPH_CFB_MODE 0x3
258# define EVP_CIPH_OFB_MODE 0x4
259# define EVP_CIPH_CTR_MODE 0x5
260# define EVP_CIPH_GCM_MODE 0x6
261# define EVP_CIPH_CCM_MODE 0x7
262# define EVP_CIPH_XTS_MODE 0x10001
263# define EVP_CIPH_WRAP_MODE 0x10002
264# define EVP_CIPH_OCB_MODE 0x10003
265# define EVP_CIPH_MODE 0xF0007
266/* Set if variable length cipher */
267# define EVP_CIPH_VARIABLE_LENGTH 0x8
268/* Set if the iv handling should be done by the cipher itself */
269# define EVP_CIPH_CUSTOM_IV 0x10
270/* Set if the cipher's init() function should be called if key is NULL */
271# define EVP_CIPH_ALWAYS_CALL_INIT 0x20
272/* Call ctrl() to init cipher parameters */
273# define EVP_CIPH_CTRL_INIT 0x40
274/* Don't use standard key length function */
275# define EVP_CIPH_CUSTOM_KEY_LENGTH 0x80
276/* Don't use standard block padding */
277# define EVP_CIPH_NO_PADDING 0x100
278/* cipher handles random key generation */
279# define EVP_CIPH_RAND_KEY 0x200
280/* cipher has its own additional copying logic */
281# define EVP_CIPH_CUSTOM_COPY 0x400
282/* Don't use standard iv length function */
283# define EVP_CIPH_CUSTOM_IV_LENGTH 0x800
284/* Allow use default ASN1 get/set iv */
285# define EVP_CIPH_FLAG_DEFAULT_ASN1 0x1000
286/* Buffer length in bits not bytes: CFB1 mode only */
287# define EVP_CIPH_FLAG_LENGTH_BITS 0x2000
288/* Note if suitable for use in FIPS mode */
289# define EVP_CIPH_FLAG_FIPS 0x4000
290/* Allow non FIPS cipher in FIPS mode */
291# define EVP_CIPH_FLAG_NON_FIPS_ALLOW 0x8000
292/*
293 * Cipher handles any and all padding logic as well as finalisation.
294 */
295# define EVP_CIPH_FLAG_CUSTOM_CIPHER 0x100000
296# define EVP_CIPH_FLAG_AEAD_CIPHER 0x200000
297# define EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK 0x400000
298/* Cipher can handle pipeline operations */
299# define EVP_CIPH_FLAG_PIPELINE 0X800000
300
301/*
302 * Cipher context flag to indicate we can handle wrap mode: if allowed in
303 * older applications it could overflow buffers.
304 */
305
306# define EVP_CIPHER_CTX_FLAG_WRAP_ALLOW 0x1
307
308/* ctrl() values */
309
310# define EVP_CTRL_INIT 0x0
311# define EVP_CTRL_SET_KEY_LENGTH 0x1
312# define EVP_CTRL_GET_RC2_KEY_BITS 0x2
313# define EVP_CTRL_SET_RC2_KEY_BITS 0x3
314# define EVP_CTRL_GET_RC5_ROUNDS 0x4
315# define EVP_CTRL_SET_RC5_ROUNDS 0x5
316# define EVP_CTRL_RAND_KEY 0x6
317# define EVP_CTRL_PBE_PRF_NID 0x7
318# define EVP_CTRL_COPY 0x8
319# define EVP_CTRL_AEAD_SET_IVLEN 0x9
320# define EVP_CTRL_AEAD_GET_TAG 0x10
321# define EVP_CTRL_AEAD_SET_TAG 0x11
322# define EVP_CTRL_AEAD_SET_IV_FIXED 0x12
323# define EVP_CTRL_GCM_SET_IVLEN EVP_CTRL_AEAD_SET_IVLEN
324# define EVP_CTRL_GCM_GET_TAG EVP_CTRL_AEAD_GET_TAG
325# define EVP_CTRL_GCM_SET_TAG EVP_CTRL_AEAD_SET_TAG
326# define EVP_CTRL_GCM_SET_IV_FIXED EVP_CTRL_AEAD_SET_IV_FIXED
327# define EVP_CTRL_GCM_IV_GEN 0x13
328# define EVP_CTRL_CCM_SET_IVLEN EVP_CTRL_AEAD_SET_IVLEN
329# define EVP_CTRL_CCM_GET_TAG EVP_CTRL_AEAD_GET_TAG
330# define EVP_CTRL_CCM_SET_TAG EVP_CTRL_AEAD_SET_TAG
331# define EVP_CTRL_CCM_SET_IV_FIXED EVP_CTRL_AEAD_SET_IV_FIXED
332# define EVP_CTRL_CCM_SET_L 0x14
333# define EVP_CTRL_CCM_SET_MSGLEN 0x15
334/*
335 * AEAD cipher deduces payload length and returns number of bytes required to
336 * store MAC and eventual padding. Subsequent call to EVP_Cipher even
337 * appends/verifies MAC.
338 */
339# define EVP_CTRL_AEAD_TLS1_AAD 0x16
340/* Used by composite AEAD ciphers, no-op in GCM, CCM... */
341# define EVP_CTRL_AEAD_SET_MAC_KEY 0x17
342/* Set the GCM invocation field, decrypt only */
343# define EVP_CTRL_GCM_SET_IV_INV 0x18
344
345# define EVP_CTRL_TLS1_1_MULTIBLOCK_AAD 0x19
346# define EVP_CTRL_TLS1_1_MULTIBLOCK_ENCRYPT 0x1a
347# define EVP_CTRL_TLS1_1_MULTIBLOCK_DECRYPT 0x1b
348# define EVP_CTRL_TLS1_1_MULTIBLOCK_MAX_BUFSIZE 0x1c
349
350# define EVP_CTRL_SSL3_MASTER_SECRET 0x1d
351
352/* EVP_CTRL_SET_SBOX takes the char * specifying S-boxes */
353# define EVP_CTRL_SET_SBOX 0x1e
354/*
355 * EVP_CTRL_SBOX_USED takes a 'size_t' and 'char *', pointing at a
356 * pre-allocated buffer with specified size
357 */
358# define EVP_CTRL_SBOX_USED 0x1f
359/* EVP_CTRL_KEY_MESH takes 'size_t' number of bytes to mesh the key after,
360 * 0 switches meshing off
361 */
362# define EVP_CTRL_KEY_MESH 0x20
363/* EVP_CTRL_BLOCK_PADDING_MODE takes the padding mode */
364# define EVP_CTRL_BLOCK_PADDING_MODE 0x21
365
366/* Set the output buffers to use for a pipelined operation */
367# define EVP_CTRL_SET_PIPELINE_OUTPUT_BUFS 0x22
368/* Set the input buffers to use for a pipelined operation */
369# define EVP_CTRL_SET_PIPELINE_INPUT_BUFS 0x23
370/* Set the input buffer lengths to use for a pipelined operation */
371# define EVP_CTRL_SET_PIPELINE_INPUT_LENS 0x24
372
373# define EVP_CTRL_GET_IVLEN 0x25
374
375/* Padding modes */
376#define EVP_PADDING_PKCS7 1
377#define EVP_PADDING_ISO7816_4 2
378#define EVP_PADDING_ANSI923 3
379#define EVP_PADDING_ISO10126 4
380#define EVP_PADDING_ZERO 5
381
382/* RFC 5246 defines additional data to be 13 bytes in length */
383# define EVP_AEAD_TLS1_AAD_LEN 13
384
385typedef struct {
386 unsigned char *out;
387 const unsigned char *inp;
388 size_t len;
389 unsigned int interleave;
390} EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM;
391
392/* GCM TLS constants */
393/* Length of fixed part of IV derived from PRF */
394# define EVP_GCM_TLS_FIXED_IV_LEN 4
395/* Length of explicit part of IV part of TLS records */
396# define EVP_GCM_TLS_EXPLICIT_IV_LEN 8
397/* Length of tag for TLS */
398# define EVP_GCM_TLS_TAG_LEN 16
399
400/* CCM TLS constants */
401/* Length of fixed part of IV derived from PRF */
402# define EVP_CCM_TLS_FIXED_IV_LEN 4
403/* Length of explicit part of IV part of TLS records */
404# define EVP_CCM_TLS_EXPLICIT_IV_LEN 8
405/* Total length of CCM IV length for TLS */
406# define EVP_CCM_TLS_IV_LEN 12
407/* Length of tag for TLS */
408# define EVP_CCM_TLS_TAG_LEN 16
409/* Length of CCM8 tag for TLS */
410# define EVP_CCM8_TLS_TAG_LEN 8
411
412/* Length of tag for TLS */
413# define EVP_CHACHAPOLY_TLS_TAG_LEN 16
414
415typedef struct evp_cipher_info_st {
416 const EVP_CIPHER *cipher;
417 unsigned char iv[EVP_MAX_IV_LENGTH];
418} EVP_CIPHER_INFO;
419
420
421/* Password based encryption function */
422typedef int (EVP_PBE_KEYGEN) (EVP_CIPHER_CTX *ctx, const char *pass,
423 int passlen, ASN1_TYPE *param,
424 const EVP_CIPHER *cipher, const EVP_MD *md,
425 int en_de);
426
427# ifndef OPENSSL_NO_RSA
428# define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\
429 (char *)(rsa))
430# endif
431
432# ifndef OPENSSL_NO_DSA
433# define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\
434 (char *)(dsa))
435# endif
436
437# ifndef OPENSSL_NO_DH
438# define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\
439 (char *)(dh))
440# endif
441
442# ifndef OPENSSL_NO_EC
443# define EVP_PKEY_assign_EC_KEY(pkey,eckey) EVP_PKEY_assign((pkey),EVP_PKEY_EC,\
444 (char *)(eckey))
445# endif
446# ifndef OPENSSL_NO_SIPHASH
447# define EVP_PKEY_assign_SIPHASH(pkey,shkey) EVP_PKEY_assign((pkey),EVP_PKEY_SIPHASH,\
448 (char *)(shkey))
449# endif
450
451# ifndef OPENSSL_NO_POLY1305
452# define EVP_PKEY_assign_POLY1305(pkey,polykey) EVP_PKEY_assign((pkey),EVP_PKEY_POLY1305,\
453 (char *)(polykey))
454# endif
455
456/* Add some extra combinations */
457# define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
458# define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))
459# define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))
460# define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))
461
462int EVP_MD_type(const EVP_MD *md);
463# define EVP_MD_nid(e) EVP_MD_type(e)
464# define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e))
465int EVP_MD_pkey_type(const EVP_MD *md);
466int EVP_MD_size(const EVP_MD *md);
467int EVP_MD_block_size(const EVP_MD *md);
468unsigned long EVP_MD_flags(const EVP_MD *md);
469
470const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx);
471int (*EVP_MD_CTX_update_fn(EVP_MD_CTX *ctx))(EVP_MD_CTX *ctx,
472 const void *data, size_t count);
473void EVP_MD_CTX_set_update_fn(EVP_MD_CTX *ctx,
474 int (*update) (EVP_MD_CTX *ctx,
475 const void *data, size_t count));
476# define EVP_MD_CTX_size(e) EVP_MD_size(EVP_MD_CTX_md(e))
477# define EVP_MD_CTX_block_size(e) EVP_MD_block_size(EVP_MD_CTX_md(e))
478# define EVP_MD_CTX_type(e) EVP_MD_type(EVP_MD_CTX_md(e))
479EVP_PKEY_CTX *EVP_MD_CTX_pkey_ctx(const EVP_MD_CTX *ctx);
480void EVP_MD_CTX_set_pkey_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pctx);
481void *EVP_MD_CTX_md_data(const EVP_MD_CTX *ctx);
482
483int EVP_CIPHER_nid(const EVP_CIPHER *cipher);
484# define EVP_CIPHER_name(e) OBJ_nid2sn(EVP_CIPHER_nid(e))
485int EVP_CIPHER_block_size(const EVP_CIPHER *cipher);
486int EVP_CIPHER_impl_ctx_size(const EVP_CIPHER *cipher);
487int EVP_CIPHER_key_length(const EVP_CIPHER *cipher);
488int EVP_CIPHER_iv_length(const EVP_CIPHER *cipher);
489unsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher);
490# define EVP_CIPHER_mode(e) (EVP_CIPHER_flags(e) & EVP_CIPH_MODE)
491
492const EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx);
493int EVP_CIPHER_CTX_encrypting(const EVP_CIPHER_CTX *ctx);
494int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx);
495int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx);
496int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx);
497int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx);
498const unsigned char *EVP_CIPHER_CTX_iv(const EVP_CIPHER_CTX *ctx);
499const unsigned char *EVP_CIPHER_CTX_original_iv(const EVP_CIPHER_CTX *ctx);
500unsigned char *EVP_CIPHER_CTX_iv_noconst(EVP_CIPHER_CTX *ctx);
501unsigned char *EVP_CIPHER_CTX_buf_noconst(EVP_CIPHER_CTX *ctx);
502int EVP_CIPHER_CTX_num(const EVP_CIPHER_CTX *ctx);
503void EVP_CIPHER_CTX_set_num(EVP_CIPHER_CTX *ctx, int num);
504int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in);
505void *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx);
506void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data);
507void *EVP_CIPHER_CTX_get_cipher_data(const EVP_CIPHER_CTX *ctx);
508void *EVP_CIPHER_CTX_set_cipher_data(EVP_CIPHER_CTX *ctx, void *cipher_data);
509# define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))
510# if OPENSSL_API_COMPAT < 0x10100000L
511# define EVP_CIPHER_CTX_flags(c) EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(c))
512# endif
513# define EVP_CIPHER_CTX_mode(c) EVP_CIPHER_mode(EVP_CIPHER_CTX_cipher(c))
514
515# define EVP_ENCODE_LENGTH(l) ((((l)+2)/3*4)+((l)/48+1)*2+80)
516# define EVP_DECODE_LENGTH(l) (((l)+3)/4*3+80)
517
518# define EVP_SignInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c)
519# define EVP_SignInit(a,b) EVP_DigestInit(a,b)
520# define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
521# define EVP_VerifyInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c)
522# define EVP_VerifyInit(a,b) EVP_DigestInit(a,b)
523# define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
524# define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e)
525# define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e)
526# define EVP_DigestSignUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
527# define EVP_DigestVerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
528
529# ifdef CONST_STRICT
530void BIO_set_md(BIO *, const EVP_MD *md);
531# else
532# define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,0,(char *)(md))
533# endif
534# define BIO_get_md(b,mdp) BIO_ctrl(b,BIO_C_GET_MD,0,(char *)(mdp))
535# define BIO_get_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_GET_MD_CTX,0, \
536 (char *)(mdcp))
537# define BIO_set_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_SET_MD_CTX,0, \
538 (char *)(mdcp))
539# define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL)
540# define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0, \
541 (char *)(c_pp))
542
543/*__owur*/ int EVP_Cipher(EVP_CIPHER_CTX *c,
544 unsigned char *out,
545 const unsigned char *in, unsigned int inl);
546
547# define EVP_add_cipher_alias(n,alias) \
548 OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n))
549# define EVP_add_digest_alias(n,alias) \
550 OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n))
551# define EVP_delete_cipher_alias(alias) \
552 OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS);
553# define EVP_delete_digest_alias(alias) \
554 OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS);
555
556int EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2);
557EVP_MD_CTX *EVP_MD_CTX_new(void);
558int EVP_MD_CTX_reset(EVP_MD_CTX *ctx);
559void EVP_MD_CTX_free(EVP_MD_CTX *ctx);
560# define EVP_MD_CTX_create() EVP_MD_CTX_new()
561# define EVP_MD_CTX_init(ctx) EVP_MD_CTX_reset((ctx))
562# define EVP_MD_CTX_destroy(ctx) EVP_MD_CTX_free((ctx))
563__owur int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in);
564void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags);
565void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags);
566int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags);
567__owur int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type,
568 ENGINE *impl);
569__owur int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d,
570 size_t cnt);
571__owur int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md,
572 unsigned int *s);
573__owur int EVP_Digest(const void *data, size_t count,
574 unsigned char *md, unsigned int *size,
575 const EVP_MD *type, ENGINE *impl);
576
577__owur int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in);
578__owur int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
579__owur int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md,
580 unsigned int *s);
581__owur int EVP_DigestFinalXOF(EVP_MD_CTX *ctx, unsigned char *md,
582 size_t len);
583
584int EVP_read_pw_string(char *buf, int length, const char *prompt, int verify);
585int EVP_read_pw_string_min(char *buf, int minlen, int maxlen,
586 const char *prompt, int verify);
587void EVP_set_pw_prompt(const char *prompt);
588char *EVP_get_pw_prompt(void);
589
590__owur int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,
591 const unsigned char *salt,
592 const unsigned char *data, int datal, int count,
593 unsigned char *key, unsigned char *iv);
594
595void EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags);
596void EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX *ctx, int flags);
597int EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx, int flags);
598
599__owur int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
600 const unsigned char *key, const unsigned char *iv);
601/*__owur*/ int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,
602 const EVP_CIPHER *cipher, ENGINE *impl,
603 const unsigned char *key,
604 const unsigned char *iv);
605/*__owur*/ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
606 int *outl, const unsigned char *in, int inl);
607/*__owur*/ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out,
608 int *outl);
609/*__owur*/ int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out,
610 int *outl);
611
612__owur int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
613 const unsigned char *key, const unsigned char *iv);
614/*__owur*/ int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx,
615 const EVP_CIPHER *cipher, ENGINE *impl,
616 const unsigned char *key,
617 const unsigned char *iv);
618/*__owur*/ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
619 int *outl, const unsigned char *in, int inl);
620__owur int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
621 int *outl);
622/*__owur*/ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm,
623 int *outl);
624
625__owur int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
626 const unsigned char *key, const unsigned char *iv,
627 int enc);
628/*__owur*/ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx,
629 const EVP_CIPHER *cipher, ENGINE *impl,
630 const unsigned char *key,
631 const unsigned char *iv, int enc);
632__owur int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
633 int *outl, const unsigned char *in, int inl);
634__owur int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
635 int *outl);
636__owur int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm,
637 int *outl);
638
639__owur int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s,
640 EVP_PKEY *pkey);
641
642__owur int EVP_DigestSign(EVP_MD_CTX *ctx, unsigned char *sigret,
643 size_t *siglen, const unsigned char *tbs,
644 size_t tbslen);
645
646__owur int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf,
647 unsigned int siglen, EVP_PKEY *pkey);
648
649__owur int EVP_DigestVerify(EVP_MD_CTX *ctx, const unsigned char *sigret,
650 size_t siglen, const unsigned char *tbs,
651 size_t tbslen);
652
653/*__owur*/ int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
654 const EVP_MD *type, ENGINE *e,
655 EVP_PKEY *pkey);
656__owur int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
657 size_t *siglen);
658
659__owur int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
660 const EVP_MD *type, ENGINE *e,
661 EVP_PKEY *pkey);
662__owur int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig,
663 size_t siglen);
664
665# ifndef OPENSSL_NO_RSA
666__owur int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
667 const unsigned char *ek, int ekl,
668 const unsigned char *iv, EVP_PKEY *priv);
669__owur int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
670
671__owur int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
672 unsigned char **ek, int *ekl, unsigned char *iv,
673 EVP_PKEY **pubk, int npubk);
674__owur int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
675# endif
676
677EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void);
678void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx);
679int EVP_ENCODE_CTX_copy(EVP_ENCODE_CTX *dctx, EVP_ENCODE_CTX *sctx);
680int EVP_ENCODE_CTX_num(EVP_ENCODE_CTX *ctx);
681void EVP_EncodeInit(EVP_ENCODE_CTX *ctx);
682int EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
683 const unsigned char *in, int inl);
684void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl);
685int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n);
686
687void EVP_DecodeInit(EVP_ENCODE_CTX *ctx);
688int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
689 const unsigned char *in, int inl);
690int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned
691 char *out, int *outl);
692int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);
693
694# if OPENSSL_API_COMPAT < 0x10100000L
695# define EVP_CIPHER_CTX_init(c) EVP_CIPHER_CTX_reset(c)
696# define EVP_CIPHER_CTX_cleanup(c) EVP_CIPHER_CTX_reset(c)
697# endif
698EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);
699int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *c);
700void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *c);
701int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
702int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad);
703int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
704int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key);
705
706const BIO_METHOD *BIO_f_md(void);
707const BIO_METHOD *BIO_f_base64(void);
708const BIO_METHOD *BIO_f_cipher(void);
709const BIO_METHOD *BIO_f_reliable(void);
710__owur int BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k,
711 const unsigned char *i, int enc);
712
713const EVP_MD *EVP_md_null(void);
714# ifndef OPENSSL_NO_MD2
715const EVP_MD *EVP_md2(void);
716# endif
717# ifndef OPENSSL_NO_MD4
718const EVP_MD *EVP_md4(void);
719# endif
720# ifndef OPENSSL_NO_MD5
721const EVP_MD *EVP_md5(void);
722const EVP_MD *EVP_md5_sha1(void);
723# endif
724# ifndef OPENSSL_NO_BLAKE2
725const EVP_MD *EVP_blake2b512(void);
726const EVP_MD *EVP_blake2s256(void);
727# endif
728const EVP_MD *EVP_sha1(void);
729const EVP_MD *EVP_sha224(void);
730const EVP_MD *EVP_sha256(void);
731const EVP_MD *EVP_sha384(void);
732const EVP_MD *EVP_sha512(void);
733const EVP_MD *EVP_sha512_224(void);
734const EVP_MD *EVP_sha512_256(void);
735const EVP_MD *EVP_sha3_224(void);
736const EVP_MD *EVP_sha3_256(void);
737const EVP_MD *EVP_sha3_384(void);
738const EVP_MD *EVP_sha3_512(void);
739const EVP_MD *EVP_shake128(void);
740const EVP_MD *EVP_shake256(void);
741# ifndef OPENSSL_NO_MDC2
742const EVP_MD *EVP_mdc2(void);
743# endif
744# ifndef OPENSSL_NO_RMD160
745const EVP_MD *EVP_ripemd160(void);
746# endif
747# ifndef OPENSSL_NO_WHIRLPOOL
748const EVP_MD *EVP_whirlpool(void);
749# endif
750# ifndef OPENSSL_NO_SM3
751const EVP_MD *EVP_sm3(void);
752# endif
753const EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */
754# ifndef OPENSSL_NO_DES
755const EVP_CIPHER *EVP_des_ecb(void);
756const EVP_CIPHER *EVP_des_ede(void);
757const EVP_CIPHER *EVP_des_ede3(void);
758const EVP_CIPHER *EVP_des_ede_ecb(void);
759const EVP_CIPHER *EVP_des_ede3_ecb(void);
760const EVP_CIPHER *EVP_des_cfb64(void);
761# define EVP_des_cfb EVP_des_cfb64
762const EVP_CIPHER *EVP_des_cfb1(void);
763const EVP_CIPHER *EVP_des_cfb8(void);
764const EVP_CIPHER *EVP_des_ede_cfb64(void);
765# define EVP_des_ede_cfb EVP_des_ede_cfb64
766const EVP_CIPHER *EVP_des_ede3_cfb64(void);
767# define EVP_des_ede3_cfb EVP_des_ede3_cfb64
768const EVP_CIPHER *EVP_des_ede3_cfb1(void);
769const EVP_CIPHER *EVP_des_ede3_cfb8(void);
770const EVP_CIPHER *EVP_des_ofb(void);
771const EVP_CIPHER *EVP_des_ede_ofb(void);
772const EVP_CIPHER *EVP_des_ede3_ofb(void);
773const EVP_CIPHER *EVP_des_cbc(void);
774const EVP_CIPHER *EVP_des_ede_cbc(void);
775const EVP_CIPHER *EVP_des_ede3_cbc(void);
776const EVP_CIPHER *EVP_desx_cbc(void);
777const EVP_CIPHER *EVP_des_ede3_wrap(void);
778/*
779 * This should now be supported through the dev_crypto ENGINE. But also, why
780 * are rc4 and md5 declarations made here inside a "NO_DES" precompiler
781 * branch?
782 */
783# endif
784# ifndef OPENSSL_NO_RC4
785const EVP_CIPHER *EVP_rc4(void);
786const EVP_CIPHER *EVP_rc4_40(void);
787# ifndef OPENSSL_NO_MD5
788const EVP_CIPHER *EVP_rc4_hmac_md5(void);
789# endif
790# endif
791# ifndef OPENSSL_NO_IDEA
792const EVP_CIPHER *EVP_idea_ecb(void);
793const EVP_CIPHER *EVP_idea_cfb64(void);
794# define EVP_idea_cfb EVP_idea_cfb64
795const EVP_CIPHER *EVP_idea_ofb(void);
796const EVP_CIPHER *EVP_idea_cbc(void);
797# endif
798# ifndef OPENSSL_NO_RC2
799const EVP_CIPHER *EVP_rc2_ecb(void);
800const EVP_CIPHER *EVP_rc2_cbc(void);
801const EVP_CIPHER *EVP_rc2_40_cbc(void);
802const EVP_CIPHER *EVP_rc2_64_cbc(void);
803const EVP_CIPHER *EVP_rc2_cfb64(void);
804# define EVP_rc2_cfb EVP_rc2_cfb64
805const EVP_CIPHER *EVP_rc2_ofb(void);
806# endif
807# ifndef OPENSSL_NO_BF
808const EVP_CIPHER *EVP_bf_ecb(void);
809const EVP_CIPHER *EVP_bf_cbc(void);
810const EVP_CIPHER *EVP_bf_cfb64(void);
811# define EVP_bf_cfb EVP_bf_cfb64
812const EVP_CIPHER *EVP_bf_ofb(void);
813# endif
814# ifndef OPENSSL_NO_CAST
815const EVP_CIPHER *EVP_cast5_ecb(void);
816const EVP_CIPHER *EVP_cast5_cbc(void);
817const EVP_CIPHER *EVP_cast5_cfb64(void);
818# define EVP_cast5_cfb EVP_cast5_cfb64
819const EVP_CIPHER *EVP_cast5_ofb(void);
820# endif
821# ifndef OPENSSL_NO_RC5
822const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void);
823const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void);
824const EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void);
825# define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64
826const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void);
827# endif
828const EVP_CIPHER *EVP_aes_128_ecb(void);
829const EVP_CIPHER *EVP_aes_128_cbc(void);
830const EVP_CIPHER *EVP_aes_128_cfb1(void);
831const EVP_CIPHER *EVP_aes_128_cfb8(void);
832const EVP_CIPHER *EVP_aes_128_cfb128(void);
833# define EVP_aes_128_cfb EVP_aes_128_cfb128
834const EVP_CIPHER *EVP_aes_128_ofb(void);
835const EVP_CIPHER *EVP_aes_128_ctr(void);
836const EVP_CIPHER *EVP_aes_128_ccm(void);
837const EVP_CIPHER *EVP_aes_128_gcm(void);
838const EVP_CIPHER *EVP_aes_128_xts(void);
839const EVP_CIPHER *EVP_aes_128_wrap(void);
840const EVP_CIPHER *EVP_aes_128_wrap_pad(void);
841# ifndef OPENSSL_NO_OCB
842const EVP_CIPHER *EVP_aes_128_ocb(void);
843# endif
844const EVP_CIPHER *EVP_aes_192_ecb(void);
845const EVP_CIPHER *EVP_aes_192_cbc(void);
846const EVP_CIPHER *EVP_aes_192_cfb1(void);
847const EVP_CIPHER *EVP_aes_192_cfb8(void);
848const EVP_CIPHER *EVP_aes_192_cfb128(void);
849# define EVP_aes_192_cfb EVP_aes_192_cfb128
850const EVP_CIPHER *EVP_aes_192_ofb(void);
851const EVP_CIPHER *EVP_aes_192_ctr(void);
852const EVP_CIPHER *EVP_aes_192_ccm(void);
853const EVP_CIPHER *EVP_aes_192_gcm(void);
854const EVP_CIPHER *EVP_aes_192_wrap(void);
855const EVP_CIPHER *EVP_aes_192_wrap_pad(void);
856# ifndef OPENSSL_NO_OCB
857const EVP_CIPHER *EVP_aes_192_ocb(void);
858# endif
859const EVP_CIPHER *EVP_aes_256_ecb(void);
860const EVP_CIPHER *EVP_aes_256_cbc(void);
861const EVP_CIPHER *EVP_aes_256_cfb1(void);
862const EVP_CIPHER *EVP_aes_256_cfb8(void);
863const EVP_CIPHER *EVP_aes_256_cfb128(void);
864# define EVP_aes_256_cfb EVP_aes_256_cfb128
865const EVP_CIPHER *EVP_aes_256_ofb(void);
866const EVP_CIPHER *EVP_aes_256_ctr(void);
867const EVP_CIPHER *EVP_aes_256_ccm(void);
868const EVP_CIPHER *EVP_aes_256_gcm(void);
869const EVP_CIPHER *EVP_aes_256_xts(void);
870const EVP_CIPHER *EVP_aes_256_wrap(void);
871const EVP_CIPHER *EVP_aes_256_wrap_pad(void);
872# ifndef OPENSSL_NO_OCB
873const EVP_CIPHER *EVP_aes_256_ocb(void);
874# endif
875const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void);
876const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha1(void);
877const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha256(void);
878const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha256(void);
879# ifndef OPENSSL_NO_ARIA
880const EVP_CIPHER *EVP_aria_128_ecb(void);
881const EVP_CIPHER *EVP_aria_128_cbc(void);
882const EVP_CIPHER *EVP_aria_128_cfb1(void);
883const EVP_CIPHER *EVP_aria_128_cfb8(void);
884const EVP_CIPHER *EVP_aria_128_cfb128(void);
885# define EVP_aria_128_cfb EVP_aria_128_cfb128
886const EVP_CIPHER *EVP_aria_128_ctr(void);
887const EVP_CIPHER *EVP_aria_128_ofb(void);
888const EVP_CIPHER *EVP_aria_128_gcm(void);
889const EVP_CIPHER *EVP_aria_128_ccm(void);
890const EVP_CIPHER *EVP_aria_192_ecb(void);
891const EVP_CIPHER *EVP_aria_192_cbc(void);
892const EVP_CIPHER *EVP_aria_192_cfb1(void);
893const EVP_CIPHER *EVP_aria_192_cfb8(void);
894const EVP_CIPHER *EVP_aria_192_cfb128(void);
895# define EVP_aria_192_cfb EVP_aria_192_cfb128
896const EVP_CIPHER *EVP_aria_192_ctr(void);
897const EVP_CIPHER *EVP_aria_192_ofb(void);
898const EVP_CIPHER *EVP_aria_192_gcm(void);
899const EVP_CIPHER *EVP_aria_192_ccm(void);
900const EVP_CIPHER *EVP_aria_256_ecb(void);
901const EVP_CIPHER *EVP_aria_256_cbc(void);
902const EVP_CIPHER *EVP_aria_256_cfb1(void);
903const EVP_CIPHER *EVP_aria_256_cfb8(void);
904const EVP_CIPHER *EVP_aria_256_cfb128(void);
905# define EVP_aria_256_cfb EVP_aria_256_cfb128
906const EVP_CIPHER *EVP_aria_256_ctr(void);
907const EVP_CIPHER *EVP_aria_256_ofb(void);
908const EVP_CIPHER *EVP_aria_256_gcm(void);
909const EVP_CIPHER *EVP_aria_256_ccm(void);
910# endif
911# ifndef OPENSSL_NO_CAMELLIA
912const EVP_CIPHER *EVP_camellia_128_ecb(void);
913const EVP_CIPHER *EVP_camellia_128_cbc(void);
914const EVP_CIPHER *EVP_camellia_128_cfb1(void);
915const EVP_CIPHER *EVP_camellia_128_cfb8(void);
916const EVP_CIPHER *EVP_camellia_128_cfb128(void);
917# define EVP_camellia_128_cfb EVP_camellia_128_cfb128
918const EVP_CIPHER *EVP_camellia_128_ofb(void);
919const EVP_CIPHER *EVP_camellia_128_ctr(void);
920const EVP_CIPHER *EVP_camellia_192_ecb(void);
921const EVP_CIPHER *EVP_camellia_192_cbc(void);
922const EVP_CIPHER *EVP_camellia_192_cfb1(void);
923const EVP_CIPHER *EVP_camellia_192_cfb8(void);
924const EVP_CIPHER *EVP_camellia_192_cfb128(void);
925# define EVP_camellia_192_cfb EVP_camellia_192_cfb128
926const EVP_CIPHER *EVP_camellia_192_ofb(void);
927const EVP_CIPHER *EVP_camellia_192_ctr(void);
928const EVP_CIPHER *EVP_camellia_256_ecb(void);
929const EVP_CIPHER *EVP_camellia_256_cbc(void);
930const EVP_CIPHER *EVP_camellia_256_cfb1(void);
931const EVP_CIPHER *EVP_camellia_256_cfb8(void);
932const EVP_CIPHER *EVP_camellia_256_cfb128(void);
933# define EVP_camellia_256_cfb EVP_camellia_256_cfb128
934const EVP_CIPHER *EVP_camellia_256_ofb(void);
935const EVP_CIPHER *EVP_camellia_256_ctr(void);
936# endif
937# ifndef OPENSSL_NO_CHACHA
938const EVP_CIPHER *EVP_chacha20(void);
939# ifndef OPENSSL_NO_POLY1305
940const EVP_CIPHER *EVP_chacha20_poly1305(void);
941# endif
942# endif
943
944# ifndef OPENSSL_NO_SEED
945const EVP_CIPHER *EVP_seed_ecb(void);
946const EVP_CIPHER *EVP_seed_cbc(void);
947const EVP_CIPHER *EVP_seed_cfb128(void);
948# define EVP_seed_cfb EVP_seed_cfb128
949const EVP_CIPHER *EVP_seed_ofb(void);
950# endif
951
952# ifndef OPENSSL_NO_SM4
953const EVP_CIPHER *EVP_sm4_ecb(void);
954const EVP_CIPHER *EVP_sm4_cbc(void);
955const EVP_CIPHER *EVP_sm4_cfb128(void);
956# define EVP_sm4_cfb EVP_sm4_cfb128
957const EVP_CIPHER *EVP_sm4_ofb(void);
958const EVP_CIPHER *EVP_sm4_ctr(void);
959# endif
960
961# if OPENSSL_API_COMPAT < 0x10100000L
962# define OPENSSL_add_all_algorithms_conf() \
963 OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \
964 | OPENSSL_INIT_ADD_ALL_DIGESTS \
965 | OPENSSL_INIT_LOAD_CONFIG, NULL)
966# define OPENSSL_add_all_algorithms_noconf() \
967 OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \
968 | OPENSSL_INIT_ADD_ALL_DIGESTS, NULL)
969
970# ifdef OPENSSL_LOAD_CONF
971# define OpenSSL_add_all_algorithms() OPENSSL_add_all_algorithms_conf()
972# else
973# define OpenSSL_add_all_algorithms() OPENSSL_add_all_algorithms_noconf()
974# endif
975
976# define OpenSSL_add_all_ciphers() \
977 OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS, NULL)
978# define OpenSSL_add_all_digests() \
979 OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_DIGESTS, NULL)
980
981# define EVP_cleanup() while(0) continue
982# endif
983
984int EVP_add_cipher(const EVP_CIPHER *cipher);
985int EVP_add_digest(const EVP_MD *digest);
986
987const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
988const EVP_MD *EVP_get_digestbyname(const char *name);
989
990void EVP_CIPHER_do_all(void (*fn) (const EVP_CIPHER *ciph,
991 const char *from, const char *to, void *x),
992 void *arg);
993void EVP_CIPHER_do_all_sorted(void (*fn)
994 (const EVP_CIPHER *ciph, const char *from,
995 const char *to, void *x), void *arg);
996
997void EVP_MD_do_all(void (*fn) (const EVP_MD *ciph,
998 const char *from, const char *to, void *x),
999 void *arg);
1000void EVP_MD_do_all_sorted(void (*fn)
1001 (const EVP_MD *ciph, const char *from,
1002 const char *to, void *x), void *arg);
1003
1004int EVP_PKEY_decrypt_old(unsigned char *dec_key,
1005 const unsigned char *enc_key, int enc_key_len,
1006 EVP_PKEY *private_key);
1007int EVP_PKEY_encrypt_old(unsigned char *enc_key,
1008 const unsigned char *key, int key_len,
1009 EVP_PKEY *pub_key);
1010int EVP_PKEY_type(int type);
1011int EVP_PKEY_id(const EVP_PKEY *pkey);
1012int EVP_PKEY_base_id(const EVP_PKEY *pkey);
1013int EVP_PKEY_bits(const EVP_PKEY *pkey);
1014int EVP_PKEY_security_bits(const EVP_PKEY *pkey);
1015int EVP_PKEY_size(const EVP_PKEY *pkey);
1016int EVP_PKEY_set_type(EVP_PKEY *pkey, int type);
1017int EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len);
1018int EVP_PKEY_set_alias_type(EVP_PKEY *pkey, int type);
1019# ifndef OPENSSL_NO_ENGINE
1020int EVP_PKEY_set1_engine(EVP_PKEY *pkey, ENGINE *e);
1021ENGINE *EVP_PKEY_get0_engine(const EVP_PKEY *pkey);
1022# endif
1023int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key);
1024void *EVP_PKEY_get0(const EVP_PKEY *pkey);
1025const unsigned char *EVP_PKEY_get0_hmac(const EVP_PKEY *pkey, size_t *len);
1026# ifndef OPENSSL_NO_POLY1305
1027const unsigned char *EVP_PKEY_get0_poly1305(const EVP_PKEY *pkey, size_t *len);
1028# endif
1029# ifndef OPENSSL_NO_SIPHASH
1030const unsigned char *EVP_PKEY_get0_siphash(const EVP_PKEY *pkey, size_t *len);
1031# endif
1032
1033# ifndef OPENSSL_NO_RSA
1034struct rsa_st;
1035int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, struct rsa_st *key);
1036struct rsa_st *EVP_PKEY_get0_RSA(EVP_PKEY *pkey);
1037struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);
1038# endif
1039# ifndef OPENSSL_NO_DSA
1040struct dsa_st;
1041int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, struct dsa_st *key);
1042struct dsa_st *EVP_PKEY_get0_DSA(EVP_PKEY *pkey);
1043struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);
1044# endif
1045# ifndef OPENSSL_NO_DH
1046struct dh_st;
1047int EVP_PKEY_set1_DH(EVP_PKEY *pkey, struct dh_st *key);
1048struct dh_st *EVP_PKEY_get0_DH(EVP_PKEY *pkey);
1049struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey);
1050# endif
1051# ifndef OPENSSL_NO_EC
1052struct ec_key_st;
1053int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, struct ec_key_st *key);
1054struct ec_key_st *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey);
1055struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey);
1056# endif
1057
1058EVP_PKEY *EVP_PKEY_new(void);
1059int EVP_PKEY_up_ref(EVP_PKEY *pkey);
1060void EVP_PKEY_free(EVP_PKEY *pkey);
1061
1062EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,
1063 long length);
1064int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp);
1065
1066EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,
1067 long length);
1068EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp,
1069 long length);
1070int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp);
1071
1072int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from);
1073int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey);
1074int EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode);
1075int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b);
1076
1077int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b);
1078
1079int EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey,
1080 int indent, ASN1_PCTX *pctx);
1081int EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey,
1082 int indent, ASN1_PCTX *pctx);
1083int EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey,
1084 int indent, ASN1_PCTX *pctx);
1085
1086int EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid);
1087
1088int EVP_PKEY_set1_tls_encodedpoint(EVP_PKEY *pkey,
1089 const unsigned char *pt, size_t ptlen);
1090size_t EVP_PKEY_get1_tls_encodedpoint(EVP_PKEY *pkey, unsigned char **ppt);
1091
1092int EVP_CIPHER_type(const EVP_CIPHER *ctx);
1093
1094/* calls methods */
1095int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
1096int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
1097
1098/* These are used by EVP_CIPHER methods */
1099int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
1100int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
1101
1102/* PKCS5 password based encryption */
1103int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
1104 ASN1_TYPE *param, const EVP_CIPHER *cipher,
1105 const EVP_MD *md, int en_de);
1106int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
1107 const unsigned char *salt, int saltlen, int iter,
1108 int keylen, unsigned char *out);
1109int PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
1110 const unsigned char *salt, int saltlen, int iter,
1111 const EVP_MD *digest, int keylen, unsigned char *out);
1112int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
1113 ASN1_TYPE *param, const EVP_CIPHER *cipher,
1114 const EVP_MD *md, int en_de);
1115
1116#ifndef OPENSSL_NO_SCRYPT
1117int EVP_PBE_scrypt(const char *pass, size_t passlen,
1118 const unsigned char *salt, size_t saltlen,
1119 uint64_t N, uint64_t r, uint64_t p, uint64_t maxmem,
1120 unsigned char *key, size_t keylen);
1121
1122int PKCS5_v2_scrypt_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass,
1123 int passlen, ASN1_TYPE *param,
1124 const EVP_CIPHER *c, const EVP_MD *md, int en_de);
1125#endif
1126
1127void PKCS5_PBE_add(void);
1128
1129int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
1130 ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de);
1131
1132/* PBE type */
1133
1134/* Can appear as the outermost AlgorithmIdentifier */
1135# define EVP_PBE_TYPE_OUTER 0x0
1136/* Is an PRF type OID */
1137# define EVP_PBE_TYPE_PRF 0x1
1138/* Is a PKCS#5 v2.0 KDF */
1139# define EVP_PBE_TYPE_KDF 0x2
1140
1141int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid,
1142 int md_nid, EVP_PBE_KEYGEN *keygen);
1143int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
1144 EVP_PBE_KEYGEN *keygen);
1145int EVP_PBE_find(int type, int pbe_nid, int *pcnid, int *pmnid,
1146 EVP_PBE_KEYGEN **pkeygen);
1147void EVP_PBE_cleanup(void);
1148int EVP_PBE_get(int *ptype, int *ppbe_nid, size_t num);
1149
1150# define ASN1_PKEY_ALIAS 0x1
1151# define ASN1_PKEY_DYNAMIC 0x2
1152# define ASN1_PKEY_SIGPARAM_NULL 0x4
1153
1154# define ASN1_PKEY_CTRL_PKCS7_SIGN 0x1
1155# define ASN1_PKEY_CTRL_PKCS7_ENCRYPT 0x2
1156# define ASN1_PKEY_CTRL_DEFAULT_MD_NID 0x3
1157# define ASN1_PKEY_CTRL_CMS_SIGN 0x5
1158# define ASN1_PKEY_CTRL_CMS_ENVELOPE 0x7
1159# define ASN1_PKEY_CTRL_CMS_RI_TYPE 0x8
1160
1161# define ASN1_PKEY_CTRL_SET1_TLS_ENCPT 0x9
1162# define ASN1_PKEY_CTRL_GET1_TLS_ENCPT 0xa
1163
1164int EVP_PKEY_asn1_get_count(void);
1165const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx);
1166const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type);
1167const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,
1168 const char *str, int len);
1169int EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth);
1170int EVP_PKEY_asn1_add_alias(int to, int from);
1171int EVP_PKEY_asn1_get0_info(int *ppkey_id, int *pkey_base_id,
1172 int *ppkey_flags, const char **pinfo,
1173 const char **ppem_str,
1174 const EVP_PKEY_ASN1_METHOD *ameth);
1175
1176const EVP_PKEY_ASN1_METHOD *EVP_PKEY_get0_asn1(const EVP_PKEY *pkey);
1177EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags,
1178 const char *pem_str,
1179 const char *info);
1180void EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst,
1181 const EVP_PKEY_ASN1_METHOD *src);
1182void EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth);
1183void EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth,
1184 int (*pub_decode) (EVP_PKEY *pk,
1185 X509_PUBKEY *pub),
1186 int (*pub_encode) (X509_PUBKEY *pub,
1187 const EVP_PKEY *pk),
1188 int (*pub_cmp) (const EVP_PKEY *a,
1189 const EVP_PKEY *b),
1190 int (*pub_print) (BIO *out,
1191 const EVP_PKEY *pkey,
1192 int indent, ASN1_PCTX *pctx),
1193 int (*pkey_size) (const EVP_PKEY *pk),
1194 int (*pkey_bits) (const EVP_PKEY *pk));
1195void EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth,
1196 int (*priv_decode) (EVP_PKEY *pk,
1197 const PKCS8_PRIV_KEY_INFO
1198 *p8inf),
1199 int (*priv_encode) (PKCS8_PRIV_KEY_INFO *p8,
1200 const EVP_PKEY *pk),
1201 int (*priv_print) (BIO *out,
1202 const EVP_PKEY *pkey,
1203 int indent,
1204 ASN1_PCTX *pctx));
1205void EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD *ameth,
1206 int (*param_decode) (EVP_PKEY *pkey,
1207 const unsigned char **pder,
1208 int derlen),
1209 int (*param_encode) (const EVP_PKEY *pkey,
1210 unsigned char **pder),
1211 int (*param_missing) (const EVP_PKEY *pk),
1212 int (*param_copy) (EVP_PKEY *to,
1213 const EVP_PKEY *from),
1214 int (*param_cmp) (const EVP_PKEY *a,
1215 const EVP_PKEY *b),
1216 int (*param_print) (BIO *out,
1217 const EVP_PKEY *pkey,
1218 int indent,
1219 ASN1_PCTX *pctx));
1220
1221void EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth,
1222 void (*pkey_free) (EVP_PKEY *pkey));
1223void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
1224 int (*pkey_ctrl) (EVP_PKEY *pkey, int op,
1225 long arg1, void *arg2));
1226void EVP_PKEY_asn1_set_item(EVP_PKEY_ASN1_METHOD *ameth,
1227 int (*item_verify) (EVP_MD_CTX *ctx,
1228 const ASN1_ITEM *it,
1229 void *asn,
1230 X509_ALGOR *a,
1231 ASN1_BIT_STRING *sig,
1232 EVP_PKEY *pkey),
1233 int (*item_sign) (EVP_MD_CTX *ctx,
1234 const ASN1_ITEM *it,
1235 void *asn,
1236 X509_ALGOR *alg1,
1237 X509_ALGOR *alg2,
1238 ASN1_BIT_STRING *sig));
1239
1240void EVP_PKEY_asn1_set_siginf(EVP_PKEY_ASN1_METHOD *ameth,
1241 int (*siginf_set) (X509_SIG_INFO *siginf,
1242 const X509_ALGOR *alg,
1243 const ASN1_STRING *sig));
1244
1245void EVP_PKEY_asn1_set_check(EVP_PKEY_ASN1_METHOD *ameth,
1246 int (*pkey_check) (const EVP_PKEY *pk));
1247
1248void EVP_PKEY_asn1_set_public_check(EVP_PKEY_ASN1_METHOD *ameth,
1249 int (*pkey_pub_check) (const EVP_PKEY *pk));
1250
1251void EVP_PKEY_asn1_set_param_check(EVP_PKEY_ASN1_METHOD *ameth,
1252 int (*pkey_param_check) (const EVP_PKEY *pk));
1253
1254void EVP_PKEY_asn1_set_set_priv_key(EVP_PKEY_ASN1_METHOD *ameth,
1255 int (*set_priv_key) (EVP_PKEY *pk,
1256 const unsigned char
1257 *priv,
1258 size_t len));
1259void EVP_PKEY_asn1_set_set_pub_key(EVP_PKEY_ASN1_METHOD *ameth,
1260 int (*set_pub_key) (EVP_PKEY *pk,
1261 const unsigned char *pub,
1262 size_t len));
1263void EVP_PKEY_asn1_set_get_priv_key(EVP_PKEY_ASN1_METHOD *ameth,
1264 int (*get_priv_key) (const EVP_PKEY *pk,
1265 unsigned char *priv,
1266 size_t *len));
1267void EVP_PKEY_asn1_set_get_pub_key(EVP_PKEY_ASN1_METHOD *ameth,
1268 int (*get_pub_key) (const EVP_PKEY *pk,
1269 unsigned char *pub,
1270 size_t *len));
1271
1272void EVP_PKEY_asn1_set_security_bits(EVP_PKEY_ASN1_METHOD *ameth,
1273 int (*pkey_security_bits) (const EVP_PKEY
1274 *pk));
1275
1276# define EVP_PKEY_OP_UNDEFINED 0
1277# define EVP_PKEY_OP_PARAMGEN (1<<1)
1278# define EVP_PKEY_OP_KEYGEN (1<<2)
1279# define EVP_PKEY_OP_SIGN (1<<3)
1280# define EVP_PKEY_OP_VERIFY (1<<4)
1281# define EVP_PKEY_OP_VERIFYRECOVER (1<<5)
1282# define EVP_PKEY_OP_SIGNCTX (1<<6)
1283# define EVP_PKEY_OP_VERIFYCTX (1<<7)
1284# define EVP_PKEY_OP_ENCRYPT (1<<8)
1285# define EVP_PKEY_OP_DECRYPT (1<<9)
1286# define EVP_PKEY_OP_DERIVE (1<<10)
1287
1288# define EVP_PKEY_OP_TYPE_SIG \
1289 (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY | EVP_PKEY_OP_VERIFYRECOVER \
1290 | EVP_PKEY_OP_SIGNCTX | EVP_PKEY_OP_VERIFYCTX)
1291
1292# define EVP_PKEY_OP_TYPE_CRYPT \
1293 (EVP_PKEY_OP_ENCRYPT | EVP_PKEY_OP_DECRYPT)
1294
1295# define EVP_PKEY_OP_TYPE_NOGEN \
1296 (EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT | EVP_PKEY_OP_DERIVE)
1297
1298# define EVP_PKEY_OP_TYPE_GEN \
1299 (EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN)
1300
1301# define EVP_PKEY_CTX_set_signature_md(ctx, md) \
1302 EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG, \
1303 EVP_PKEY_CTRL_MD, 0, (void *)(md))
1304
1305# define EVP_PKEY_CTX_get_signature_md(ctx, pmd) \
1306 EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG, \
1307 EVP_PKEY_CTRL_GET_MD, 0, (void *)(pmd))
1308
1309# define EVP_PKEY_CTX_set_mac_key(ctx, key, len) \
1310 EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_KEYGEN, \
1311 EVP_PKEY_CTRL_SET_MAC_KEY, len, (void *)(key))
1312
1313# define EVP_PKEY_CTRL_MD 1
1314# define EVP_PKEY_CTRL_PEER_KEY 2
1315
1316# define EVP_PKEY_CTRL_PKCS7_ENCRYPT 3
1317# define EVP_PKEY_CTRL_PKCS7_DECRYPT 4
1318
1319# define EVP_PKEY_CTRL_PKCS7_SIGN 5
1320
1321# define EVP_PKEY_CTRL_SET_MAC_KEY 6
1322
1323# define EVP_PKEY_CTRL_DIGESTINIT 7
1324
1325/* Used by GOST key encryption in TLS */
1326# define EVP_PKEY_CTRL_SET_IV 8
1327
1328# define EVP_PKEY_CTRL_CMS_ENCRYPT 9
1329# define EVP_PKEY_CTRL_CMS_DECRYPT 10
1330# define EVP_PKEY_CTRL_CMS_SIGN 11
1331
1332# define EVP_PKEY_CTRL_CIPHER 12
1333
1334# define EVP_PKEY_CTRL_GET_MD 13
1335
1336# define EVP_PKEY_CTRL_SET_DIGEST_SIZE 14
1337
1338# define EVP_PKEY_ALG_CTRL 0x1000
1339
1340# define EVP_PKEY_FLAG_AUTOARGLEN 2
1341/*
1342 * Method handles all operations: don't assume any digest related defaults.
1343 */
1344# define EVP_PKEY_FLAG_SIGCTX_CUSTOM 4
1345
1346const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type);
1347EVP_PKEY_METHOD *EVP_PKEY_meth_new(int id, int flags);
1348void EVP_PKEY_meth_get0_info(int *ppkey_id, int *pflags,
1349 const EVP_PKEY_METHOD *meth);
1350void EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src);
1351void EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth);
1352int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth);
1353int EVP_PKEY_meth_remove(const EVP_PKEY_METHOD *pmeth);
1354size_t EVP_PKEY_meth_get_count(void);
1355const EVP_PKEY_METHOD *EVP_PKEY_meth_get0(size_t idx);
1356
1357EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
1358EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e);
1359EVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *ctx);
1360void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
1361
1362int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,
1363 int cmd, int p1, void *p2);
1364int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,
1365 const char *value);
1366int EVP_PKEY_CTX_ctrl_uint64(EVP_PKEY_CTX *ctx, int keytype, int optype,
1367 int cmd, uint64_t value);
1368
1369int EVP_PKEY_CTX_str2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *str);
1370int EVP_PKEY_CTX_hex2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *hex);
1371
1372int EVP_PKEY_CTX_md(EVP_PKEY_CTX *ctx, int optype, int cmd, const char *md);
1373
1374int EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx);
1375void EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen);
1376
1377EVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e,
1378 const unsigned char *key, int keylen);
1379EVP_PKEY *EVP_PKEY_new_raw_private_key(int type, ENGINE *e,
1380 const unsigned char *priv,
1381 size_t len);
1382EVP_PKEY *EVP_PKEY_new_raw_public_key(int type, ENGINE *e,
1383 const unsigned char *pub,
1384 size_t len);
1385int EVP_PKEY_get_raw_private_key(const EVP_PKEY *pkey, unsigned char *priv,
1386 size_t *len);
1387int EVP_PKEY_get_raw_public_key(const EVP_PKEY *pkey, unsigned char *pub,
1388 size_t *len);
1389
1390EVP_PKEY *EVP_PKEY_new_CMAC_key(ENGINE *e, const unsigned char *priv,
1391 size_t len, const EVP_CIPHER *cipher);
1392
1393void EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data);
1394void *EVP_PKEY_CTX_get_data(EVP_PKEY_CTX *ctx);
1395EVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx);
1396
1397EVP_PKEY *EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX *ctx);
1398
1399void EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data);
1400void *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx);
1401
1402int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx);
1403int EVP_PKEY_sign(EVP_PKEY_CTX *ctx,
1404 unsigned char *sig, size_t *siglen,
1405 const unsigned char *tbs, size_t tbslen);
1406int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx);
1407int EVP_PKEY_verify(EVP_PKEY_CTX *ctx,
1408 const unsigned char *sig, size_t siglen,
1409 const unsigned char *tbs, size_t tbslen);
1410int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx);
1411int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,
1412 unsigned char *rout, size_t *routlen,
1413 const unsigned char *sig, size_t siglen);
1414int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx);
1415int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx,
1416 unsigned char *out, size_t *outlen,
1417 const unsigned char *in, size_t inlen);
1418int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx);
1419int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx,
1420 unsigned char *out, size_t *outlen,
1421 const unsigned char *in, size_t inlen);
1422
1423int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx);
1424int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer);
1425int EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);
1426
1427typedef int EVP_PKEY_gen_cb(EVP_PKEY_CTX *ctx);
1428
1429int EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx);
1430int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);
1431int EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx);
1432int EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);
1433int EVP_PKEY_check(EVP_PKEY_CTX *ctx);
1434int EVP_PKEY_public_check(EVP_PKEY_CTX *ctx);
1435int EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
1436
1437void EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb);
1438EVP_PKEY_gen_cb *EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx);
1439
1440int EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx);
1441
1442void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth,
1443 int (*init) (EVP_PKEY_CTX *ctx));
1444
1445void EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth,
1446 int (*copy) (EVP_PKEY_CTX *dst,
1447 EVP_PKEY_CTX *src));
1448
1449void EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth,
1450 void (*cleanup) (EVP_PKEY_CTX *ctx));
1451
1452void EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth,
1453 int (*paramgen_init) (EVP_PKEY_CTX *ctx),
1454 int (*paramgen) (EVP_PKEY_CTX *ctx,
1455 EVP_PKEY *pkey));
1456
1457void EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth,
1458 int (*keygen_init) (EVP_PKEY_CTX *ctx),
1459 int (*keygen) (EVP_PKEY_CTX *ctx,
1460 EVP_PKEY *pkey));
1461
1462void EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD *pmeth,
1463 int (*sign_init) (EVP_PKEY_CTX *ctx),
1464 int (*sign) (EVP_PKEY_CTX *ctx,
1465 unsigned char *sig, size_t *siglen,
1466 const unsigned char *tbs,
1467 size_t tbslen));
1468
1469void EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD *pmeth,
1470 int (*verify_init) (EVP_PKEY_CTX *ctx),
1471 int (*verify) (EVP_PKEY_CTX *ctx,
1472 const unsigned char *sig,
1473 size_t siglen,
1474 const unsigned char *tbs,
1475 size_t tbslen));
1476
1477void EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD *pmeth,
1478 int (*verify_recover_init) (EVP_PKEY_CTX
1479 *ctx),
1480 int (*verify_recover) (EVP_PKEY_CTX
1481 *ctx,
1482 unsigned char
1483 *sig,
1484 size_t *siglen,
1485 const unsigned
1486 char *tbs,
1487 size_t tbslen));
1488
1489void EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD *pmeth,
1490 int (*signctx_init) (EVP_PKEY_CTX *ctx,
1491 EVP_MD_CTX *mctx),
1492 int (*signctx) (EVP_PKEY_CTX *ctx,
1493 unsigned char *sig,
1494 size_t *siglen,
1495 EVP_MD_CTX *mctx));
1496
1497void EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD *pmeth,
1498 int (*verifyctx_init) (EVP_PKEY_CTX *ctx,
1499 EVP_MD_CTX *mctx),
1500 int (*verifyctx) (EVP_PKEY_CTX *ctx,
1501 const unsigned char *sig,
1502 int siglen,
1503 EVP_MD_CTX *mctx));
1504
1505void EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD *pmeth,
1506 int (*encrypt_init) (EVP_PKEY_CTX *ctx),
1507 int (*encryptfn) (EVP_PKEY_CTX *ctx,
1508 unsigned char *out,
1509 size_t *outlen,
1510 const unsigned char *in,
1511 size_t inlen));
1512
1513void EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD *pmeth,
1514 int (*decrypt_init) (EVP_PKEY_CTX *ctx),
1515 int (*decrypt) (EVP_PKEY_CTX *ctx,
1516 unsigned char *out,
1517 size_t *outlen,
1518 const unsigned char *in,
1519 size_t inlen));
1520
1521void EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth,
1522 int (*derive_init) (EVP_PKEY_CTX *ctx),
1523 int (*derive) (EVP_PKEY_CTX *ctx,
1524 unsigned char *key,
1525 size_t *keylen));
1526
1527void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,
1528 int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1,
1529 void *p2),
1530 int (*ctrl_str) (EVP_PKEY_CTX *ctx,
1531 const char *type,
1532 const char *value));
1533
1534void EVP_PKEY_meth_set_digestsign(EVP_PKEY_METHOD *pmeth,
1535 int (*digestsign) (EVP_MD_CTX *ctx,
1536 unsigned char *sig,
1537 size_t *siglen,
1538 const unsigned char *tbs,
1539 size_t tbslen));
1540
1541void EVP_PKEY_meth_set_digestverify(EVP_PKEY_METHOD *pmeth,
1542 int (*digestverify) (EVP_MD_CTX *ctx,
1543 const unsigned char *sig,
1544 size_t siglen,
1545 const unsigned char *tbs,
1546 size_t tbslen));
1547
1548void EVP_PKEY_meth_set_check(EVP_PKEY_METHOD *pmeth,
1549 int (*check) (EVP_PKEY *pkey));
1550
1551void EVP_PKEY_meth_set_public_check(EVP_PKEY_METHOD *pmeth,
1552 int (*check) (EVP_PKEY *pkey));
1553
1554void EVP_PKEY_meth_set_param_check(EVP_PKEY_METHOD *pmeth,
1555 int (*check) (EVP_PKEY *pkey));
1556
1557void EVP_PKEY_meth_set_digest_custom(EVP_PKEY_METHOD *pmeth,
1558 int (*digest_custom) (EVP_PKEY_CTX *ctx,
1559 EVP_MD_CTX *mctx));
1560
1561void EVP_PKEY_meth_get_init(const EVP_PKEY_METHOD *pmeth,
1562 int (**pinit) (EVP_PKEY_CTX *ctx));
1563
1564void EVP_PKEY_meth_get_copy(const EVP_PKEY_METHOD *pmeth,
1565 int (**pcopy) (EVP_PKEY_CTX *dst,
1566 EVP_PKEY_CTX *src));
1567
1568void EVP_PKEY_meth_get_cleanup(const EVP_PKEY_METHOD *pmeth,
1569 void (**pcleanup) (EVP_PKEY_CTX *ctx));
1570
1571void EVP_PKEY_meth_get_paramgen(const EVP_PKEY_METHOD *pmeth,
1572 int (**pparamgen_init) (EVP_PKEY_CTX *ctx),
1573 int (**pparamgen) (EVP_PKEY_CTX *ctx,
1574 EVP_PKEY *pkey));
1575
1576void EVP_PKEY_meth_get_keygen(const EVP_PKEY_METHOD *pmeth,
1577 int (**pkeygen_init) (EVP_PKEY_CTX *ctx),
1578 int (**pkeygen) (EVP_PKEY_CTX *ctx,
1579 EVP_PKEY *pkey));
1580
1581void EVP_PKEY_meth_get_sign(const EVP_PKEY_METHOD *pmeth,
1582 int (**psign_init) (EVP_PKEY_CTX *ctx),
1583 int (**psign) (EVP_PKEY_CTX *ctx,
1584 unsigned char *sig, size_t *siglen,
1585 const unsigned char *tbs,
1586 size_t tbslen));
1587
1588void EVP_PKEY_meth_get_verify(const EVP_PKEY_METHOD *pmeth,
1589 int (**pverify_init) (EVP_PKEY_CTX *ctx),
1590 int (**pverify) (EVP_PKEY_CTX *ctx,
1591 const unsigned char *sig,
1592 size_t siglen,
1593 const unsigned char *tbs,
1594 size_t tbslen));
1595
1596void EVP_PKEY_meth_get_verify_recover(const EVP_PKEY_METHOD *pmeth,
1597 int (**pverify_recover_init) (EVP_PKEY_CTX
1598 *ctx),
1599 int (**pverify_recover) (EVP_PKEY_CTX
1600 *ctx,
1601 unsigned char
1602 *sig,
1603 size_t *siglen,
1604 const unsigned
1605 char *tbs,
1606 size_t tbslen));
1607
1608void EVP_PKEY_meth_get_signctx(const EVP_PKEY_METHOD *pmeth,
1609 int (**psignctx_init) (EVP_PKEY_CTX *ctx,
1610 EVP_MD_CTX *mctx),
1611 int (**psignctx) (EVP_PKEY_CTX *ctx,
1612 unsigned char *sig,
1613 size_t *siglen,
1614 EVP_MD_CTX *mctx));
1615
1616void EVP_PKEY_meth_get_verifyctx(const EVP_PKEY_METHOD *pmeth,
1617 int (**pverifyctx_init) (EVP_PKEY_CTX *ctx,
1618 EVP_MD_CTX *mctx),
1619 int (**pverifyctx) (EVP_PKEY_CTX *ctx,
1620 const unsigned char *sig,
1621 int siglen,
1622 EVP_MD_CTX *mctx));
1623
1624void EVP_PKEY_meth_get_encrypt(const EVP_PKEY_METHOD *pmeth,
1625 int (**pencrypt_init) (EVP_PKEY_CTX *ctx),
1626 int (**pencryptfn) (EVP_PKEY_CTX *ctx,
1627 unsigned char *out,
1628 size_t *outlen,
1629 const unsigned char *in,
1630 size_t inlen));
1631
1632void EVP_PKEY_meth_get_decrypt(const EVP_PKEY_METHOD *pmeth,
1633 int (**pdecrypt_init) (EVP_PKEY_CTX *ctx),
1634 int (**pdecrypt) (EVP_PKEY_CTX *ctx,
1635 unsigned char *out,
1636 size_t *outlen,
1637 const unsigned char *in,
1638 size_t inlen));
1639
1640void EVP_PKEY_meth_get_derive(const EVP_PKEY_METHOD *pmeth,
1641 int (**pderive_init) (EVP_PKEY_CTX *ctx),
1642 int (**pderive) (EVP_PKEY_CTX *ctx,
1643 unsigned char *key,
1644 size_t *keylen));
1645
1646void EVP_PKEY_meth_get_ctrl(const EVP_PKEY_METHOD *pmeth,
1647 int (**pctrl) (EVP_PKEY_CTX *ctx, int type, int p1,
1648 void *p2),
1649 int (**pctrl_str) (EVP_PKEY_CTX *ctx,
1650 const char *type,
1651 const char *value));
1652
1653void EVP_PKEY_meth_get_digestsign(EVP_PKEY_METHOD *pmeth,
1654 int (**digestsign) (EVP_MD_CTX *ctx,
1655 unsigned char *sig,
1656 size_t *siglen,
1657 const unsigned char *tbs,
1658 size_t tbslen));
1659
1660void EVP_PKEY_meth_get_digestverify(EVP_PKEY_METHOD *pmeth,
1661 int (**digestverify) (EVP_MD_CTX *ctx,
1662 const unsigned char *sig,
1663 size_t siglen,
1664 const unsigned char *tbs,
1665 size_t tbslen));
1666
1667void EVP_PKEY_meth_get_check(const EVP_PKEY_METHOD *pmeth,
1668 int (**pcheck) (EVP_PKEY *pkey));
1669
1670void EVP_PKEY_meth_get_public_check(const EVP_PKEY_METHOD *pmeth,
1671 int (**pcheck) (EVP_PKEY *pkey));
1672
1673void EVP_PKEY_meth_get_param_check(const EVP_PKEY_METHOD *pmeth,
1674 int (**pcheck) (EVP_PKEY *pkey));
1675
1676void EVP_PKEY_meth_get_digest_custom(EVP_PKEY_METHOD *pmeth,
1677 int (**pdigest_custom) (EVP_PKEY_CTX *ctx,
1678 EVP_MD_CTX *mctx));
1679void EVP_add_alg_module(void);
1680
1681
1682# ifdef __cplusplus
1683}
1684# endif
1685#endif
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette