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