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