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