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