VirtualBox

source: vbox/trunk/src/libs/openssl-3.0.1/include/openssl/evp.h@ 94082

Last change on this file since 94082 was 94082, checked in by vboxsync, 3 years ago

libs/openssl-3.0.1: started applying and adjusting our OpenSSL changes to 3.0.1. bugref:10128

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette