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