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