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