File indexing completed on 2025-01-18 10:05:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef OPENSSL_EVP_H
0011 # define OPENSSL_EVP_H
0012 # pragma once
0013
0014 # include <openssl/macros.h>
0015 # ifndef OPENSSL_NO_DEPRECATED_3_0
0016 # define HEADER_ENVELOPE_H
0017 # endif
0018
0019 # include <stdarg.h>
0020
0021 # ifndef OPENSSL_NO_STDIO
0022 # include <stdio.h>
0023 # endif
0024
0025 # include <openssl/opensslconf.h>
0026 # include <openssl/types.h>
0027 # include <openssl/core.h>
0028 # include <openssl/core_dispatch.h>
0029 # include <openssl/symhacks.h>
0030 # include <openssl/bio.h>
0031 # include <openssl/evperr.h>
0032 # include <openssl/params.h>
0033
0034 # define EVP_MAX_MD_SIZE 64
0035 # define EVP_MAX_KEY_LENGTH 64
0036 # define EVP_MAX_IV_LENGTH 16
0037 # define EVP_MAX_BLOCK_LENGTH 32
0038 # define EVP_MAX_AEAD_TAG_LENGTH 16
0039
0040 # define PKCS5_SALT_LEN 8
0041
0042 # define PKCS5_DEFAULT_ITER 2048
0043
0044 # include <openssl/objects.h>
0045
0046 # ifndef OPENSSL_NO_DEPRECATED_3_0
0047 # define EVP_PK_RSA 0x0001
0048 # define EVP_PK_DSA 0x0002
0049 # define EVP_PK_DH 0x0004
0050 # define EVP_PK_EC 0x0008
0051 # define EVP_PKT_SIGN 0x0010
0052 # define EVP_PKT_ENC 0x0020
0053 # define EVP_PKT_EXCH 0x0040
0054 # define EVP_PKS_RSA 0x0100
0055 # define EVP_PKS_DSA 0x0200
0056 # define EVP_PKS_EC 0x0400
0057 # endif
0058
0059 # define EVP_PKEY_NONE NID_undef
0060 # define EVP_PKEY_RSA NID_rsaEncryption
0061 # define EVP_PKEY_RSA2 NID_rsa
0062 # define EVP_PKEY_RSA_PSS NID_rsassaPss
0063 # define EVP_PKEY_DSA NID_dsa
0064 # define EVP_PKEY_DSA1 NID_dsa_2
0065 # define EVP_PKEY_DSA2 NID_dsaWithSHA
0066 # define EVP_PKEY_DSA3 NID_dsaWithSHA1
0067 # define EVP_PKEY_DSA4 NID_dsaWithSHA1_2
0068 # define EVP_PKEY_DH NID_dhKeyAgreement
0069 # define EVP_PKEY_DHX NID_dhpublicnumber
0070 # define EVP_PKEY_EC NID_X9_62_id_ecPublicKey
0071 # define EVP_PKEY_SM2 NID_sm2
0072 # define EVP_PKEY_HMAC NID_hmac
0073 # define EVP_PKEY_CMAC NID_cmac
0074 # define EVP_PKEY_SCRYPT NID_id_scrypt
0075 # define EVP_PKEY_TLS1_PRF NID_tls1_prf
0076 # define EVP_PKEY_HKDF NID_hkdf
0077 # define EVP_PKEY_POLY1305 NID_poly1305
0078 # define EVP_PKEY_SIPHASH NID_siphash
0079 # define EVP_PKEY_X25519 NID_X25519
0080 # define EVP_PKEY_ED25519 NID_ED25519
0081 # define EVP_PKEY_X448 NID_X448
0082 # define EVP_PKEY_ED448 NID_ED448
0083
0084 # define EVP_PKEY_KEYMGMT -1
0085
0086
0087 # define EVP_PKEY_KEY_PARAMETERS \
0088 ( OSSL_KEYMGMT_SELECT_ALL_PARAMETERS )
0089 # define EVP_PKEY_PRIVATE_KEY \
0090 ( EVP_PKEY_KEY_PARAMETERS | OSSL_KEYMGMT_SELECT_PRIVATE_KEY )
0091 # define EVP_PKEY_PUBLIC_KEY \
0092 ( EVP_PKEY_KEY_PARAMETERS | OSSL_KEYMGMT_SELECT_PUBLIC_KEY )
0093 # define EVP_PKEY_KEYPAIR \
0094 ( EVP_PKEY_PUBLIC_KEY | OSSL_KEYMGMT_SELECT_PRIVATE_KEY )
0095
0096 #ifdef __cplusplus
0097 extern "C" {
0098 #endif
0099
0100 int EVP_set_default_properties(OSSL_LIB_CTX *libctx, const char *propq);
0101 int EVP_default_properties_is_fips_enabled(OSSL_LIB_CTX *libctx);
0102 int EVP_default_properties_enable_fips(OSSL_LIB_CTX *libctx, int enable);
0103
0104 # define EVP_PKEY_MO_SIGN 0x0001
0105 # define EVP_PKEY_MO_VERIFY 0x0002
0106 # define EVP_PKEY_MO_ENCRYPT 0x0004
0107 # define EVP_PKEY_MO_DECRYPT 0x0008
0108
0109 # ifndef EVP_MD
0110 # ifndef OPENSSL_NO_DEPRECATED_3_0
0111 OSSL_DEPRECATEDIN_3_0 EVP_MD *EVP_MD_meth_new(int md_type, int pkey_type);
0112 OSSL_DEPRECATEDIN_3_0 EVP_MD *EVP_MD_meth_dup(const EVP_MD *md);
0113 OSSL_DEPRECATEDIN_3_0 void EVP_MD_meth_free(EVP_MD *md);
0114 OSSL_DEPRECATEDIN_3_0
0115 int EVP_MD_meth_set_input_blocksize(EVP_MD *md, int blocksize);
0116 OSSL_DEPRECATEDIN_3_0
0117 int EVP_MD_meth_set_result_size(EVP_MD *md, int resultsize);
0118 OSSL_DEPRECATEDIN_3_0
0119 int EVP_MD_meth_set_app_datasize(EVP_MD *md, int datasize);
0120 OSSL_DEPRECATEDIN_3_0
0121 int EVP_MD_meth_set_flags(EVP_MD *md, unsigned long flags);
0122 OSSL_DEPRECATEDIN_3_0
0123 int EVP_MD_meth_set_init(EVP_MD *md, int (*init)(EVP_MD_CTX *ctx));
0124 OSSL_DEPRECATEDIN_3_0
0125 int EVP_MD_meth_set_update(EVP_MD *md, int (*update)(EVP_MD_CTX *ctx,
0126 const void *data,
0127 size_t count));
0128 OSSL_DEPRECATEDIN_3_0
0129 int EVP_MD_meth_set_final(EVP_MD *md, int (*final)(EVP_MD_CTX *ctx,
0130 unsigned char *md));
0131 OSSL_DEPRECATEDIN_3_0
0132 int EVP_MD_meth_set_copy(EVP_MD *md, int (*copy)(EVP_MD_CTX *to,
0133 const EVP_MD_CTX *from));
0134 OSSL_DEPRECATEDIN_3_0
0135 int EVP_MD_meth_set_cleanup(EVP_MD *md, int (*cleanup)(EVP_MD_CTX *ctx));
0136 OSSL_DEPRECATEDIN_3_0
0137 int EVP_MD_meth_set_ctrl(EVP_MD *md, int (*ctrl)(EVP_MD_CTX *ctx, int cmd,
0138 int p1, void *p2));
0139 OSSL_DEPRECATEDIN_3_0 int EVP_MD_meth_get_input_blocksize(const EVP_MD *md);
0140 OSSL_DEPRECATEDIN_3_0 int EVP_MD_meth_get_result_size(const EVP_MD *md);
0141 OSSL_DEPRECATEDIN_3_0 int EVP_MD_meth_get_app_datasize(const EVP_MD *md);
0142 OSSL_DEPRECATEDIN_3_0 unsigned long EVP_MD_meth_get_flags(const EVP_MD *md);
0143 OSSL_DEPRECATEDIN_3_0
0144 int (*EVP_MD_meth_get_init(const EVP_MD *md))(EVP_MD_CTX *ctx);
0145 OSSL_DEPRECATEDIN_3_0
0146 int (*EVP_MD_meth_get_update(const EVP_MD *md))(EVP_MD_CTX *ctx,
0147 const void *data, size_t count);
0148 OSSL_DEPRECATEDIN_3_0
0149 int (*EVP_MD_meth_get_final(const EVP_MD *md))(EVP_MD_CTX *ctx,
0150 unsigned char *md);
0151 OSSL_DEPRECATEDIN_3_0
0152 int (*EVP_MD_meth_get_copy(const EVP_MD *md))(EVP_MD_CTX *to,
0153 const EVP_MD_CTX *from);
0154 OSSL_DEPRECATEDIN_3_0
0155 int (*EVP_MD_meth_get_cleanup(const EVP_MD *md))(EVP_MD_CTX *ctx);
0156 OSSL_DEPRECATEDIN_3_0
0157 int (*EVP_MD_meth_get_ctrl(const EVP_MD *md))(EVP_MD_CTX *ctx, int cmd,
0158 int p1, void *p2);
0159 # endif
0160
0161 # define EVP_MD_FLAG_ONESHOT 0x0001
0162
0163
0164 # define EVP_MD_FLAG_XOF 0x0002
0165
0166
0167
0168 # define EVP_MD_FLAG_DIGALGID_MASK 0x0018
0169
0170
0171
0172 # define EVP_MD_FLAG_DIGALGID_NULL 0x0000
0173
0174
0175
0176 # define EVP_MD_FLAG_DIGALGID_ABSENT 0x0008
0177
0178
0179
0180 # define EVP_MD_FLAG_DIGALGID_CUSTOM 0x0018
0181
0182
0183 # define EVP_MD_FLAG_FIPS 0x0400
0184
0185
0186
0187 # define EVP_MD_CTRL_DIGALGID 0x1
0188 # define EVP_MD_CTRL_MICALG 0x2
0189 # define EVP_MD_CTRL_XOF_LEN 0x3
0190 # define EVP_MD_CTRL_TLSTREE 0x4
0191
0192
0193
0194 # define EVP_MD_CTRL_ALG_CTRL 0x1000
0195
0196 # endif
0197
0198
0199
0200 # define EVP_MD_CTX_FLAG_ONESHOT 0x0001
0201
0202 # define EVP_MD_CTX_FLAG_CLEANED 0x0002
0203
0204 # define EVP_MD_CTX_FLAG_REUSE 0x0004
0205
0206
0207
0208
0209
0210
0211
0212 # define EVP_MD_CTX_FLAG_NON_FIPS_ALLOW 0x0008
0213
0214
0215
0216
0217
0218
0219 # define EVP_MD_CTX_FLAG_PAD_MASK 0xF0
0220 # define EVP_MD_CTX_FLAG_PAD_PKCS1 0x00
0221 # define EVP_MD_CTX_FLAG_PAD_X931 0x10
0222 # define EVP_MD_CTX_FLAG_PAD_PSS 0x20
0223
0224 # define EVP_MD_CTX_FLAG_NO_INIT 0x0100
0225
0226
0227
0228
0229
0230
0231 # define EVP_MD_CTX_FLAG_FINALISE 0x0200
0232
0233
0234 # ifndef OPENSSL_NO_DEPRECATED_3_0
0235 OSSL_DEPRECATEDIN_3_0
0236 EVP_CIPHER *EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len);
0237 OSSL_DEPRECATEDIN_3_0
0238 EVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher);
0239 OSSL_DEPRECATEDIN_3_0
0240 void EVP_CIPHER_meth_free(EVP_CIPHER *cipher);
0241 OSSL_DEPRECATEDIN_3_0
0242 int EVP_CIPHER_meth_set_iv_length(EVP_CIPHER *cipher, int iv_len);
0243 OSSL_DEPRECATEDIN_3_0
0244 int EVP_CIPHER_meth_set_flags(EVP_CIPHER *cipher, unsigned long flags);
0245 OSSL_DEPRECATEDIN_3_0
0246 int EVP_CIPHER_meth_set_impl_ctx_size(EVP_CIPHER *cipher, int ctx_size);
0247 OSSL_DEPRECATEDIN_3_0
0248 int EVP_CIPHER_meth_set_init(EVP_CIPHER *cipher,
0249 int (*init) (EVP_CIPHER_CTX *ctx,
0250 const unsigned char *key,
0251 const unsigned char *iv,
0252 int enc));
0253 OSSL_DEPRECATEDIN_3_0
0254 int EVP_CIPHER_meth_set_do_cipher(EVP_CIPHER *cipher,
0255 int (*do_cipher) (EVP_CIPHER_CTX *ctx,
0256 unsigned char *out,
0257 const unsigned char *in,
0258 size_t inl));
0259 OSSL_DEPRECATEDIN_3_0
0260 int EVP_CIPHER_meth_set_cleanup(EVP_CIPHER *cipher,
0261 int (*cleanup) (EVP_CIPHER_CTX *));
0262 OSSL_DEPRECATEDIN_3_0
0263 int EVP_CIPHER_meth_set_set_asn1_params(EVP_CIPHER *cipher,
0264 int (*set_asn1_parameters) (EVP_CIPHER_CTX *,
0265 ASN1_TYPE *));
0266 OSSL_DEPRECATEDIN_3_0
0267 int EVP_CIPHER_meth_set_get_asn1_params(EVP_CIPHER *cipher,
0268 int (*get_asn1_parameters) (EVP_CIPHER_CTX *,
0269 ASN1_TYPE *));
0270 OSSL_DEPRECATEDIN_3_0
0271 int EVP_CIPHER_meth_set_ctrl(EVP_CIPHER *cipher,
0272 int (*ctrl) (EVP_CIPHER_CTX *, int type,
0273 int arg, void *ptr));
0274 OSSL_DEPRECATEDIN_3_0 int
0275 (*EVP_CIPHER_meth_get_init(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx,
0276 const unsigned char *key,
0277 const unsigned char *iv,
0278 int enc);
0279 OSSL_DEPRECATEDIN_3_0 int
0280 (*EVP_CIPHER_meth_get_do_cipher(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx,
0281 unsigned char *out,
0282 const unsigned char *in,
0283 size_t inl);
0284 OSSL_DEPRECATEDIN_3_0 int
0285 (*EVP_CIPHER_meth_get_cleanup(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *);
0286 OSSL_DEPRECATEDIN_3_0 int
0287 (*EVP_CIPHER_meth_get_set_asn1_params(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,
0288 ASN1_TYPE *);
0289 OSSL_DEPRECATEDIN_3_0 int
0290 (*EVP_CIPHER_meth_get_get_asn1_params(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *,
0291 ASN1_TYPE *);
0292 OSSL_DEPRECATEDIN_3_0 int
0293 (*EVP_CIPHER_meth_get_ctrl(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *, int type,
0294 int arg, void *ptr);
0295 # endif
0296
0297
0298
0299
0300
0301 # define EVP_CIPH_STREAM_CIPHER 0x0
0302 # define EVP_CIPH_ECB_MODE 0x1
0303 # define EVP_CIPH_CBC_MODE 0x2
0304 # define EVP_CIPH_CFB_MODE 0x3
0305 # define EVP_CIPH_OFB_MODE 0x4
0306 # define EVP_CIPH_CTR_MODE 0x5
0307 # define EVP_CIPH_GCM_MODE 0x6
0308 # define EVP_CIPH_CCM_MODE 0x7
0309 # define EVP_CIPH_XTS_MODE 0x10001
0310 # define EVP_CIPH_WRAP_MODE 0x10002
0311 # define EVP_CIPH_OCB_MODE 0x10003
0312 # define EVP_CIPH_SIV_MODE 0x10004
0313 # define EVP_CIPH_GCM_SIV_MODE 0x10005
0314 # define EVP_CIPH_MODE 0xF0007
0315
0316 # define EVP_CIPH_VARIABLE_LENGTH 0x8
0317
0318 # define EVP_CIPH_CUSTOM_IV 0x10
0319
0320 # define EVP_CIPH_ALWAYS_CALL_INIT 0x20
0321
0322 # define EVP_CIPH_CTRL_INIT 0x40
0323
0324 # define EVP_CIPH_CUSTOM_KEY_LENGTH 0x80
0325
0326 # define EVP_CIPH_NO_PADDING 0x100
0327
0328 # define EVP_CIPH_RAND_KEY 0x200
0329
0330 # define EVP_CIPH_CUSTOM_COPY 0x400
0331
0332 # define EVP_CIPH_CUSTOM_IV_LENGTH 0x800
0333
0334 # define EVP_CIPH_FLAG_DEFAULT_ASN1 0
0335
0336
0337 # define EVP_CIPH_FLAG_LENGTH_BITS 0x2000
0338
0339 # define EVP_CIPH_FLAG_FIPS 0
0340
0341 # define EVP_CIPH_FLAG_NON_FIPS_ALLOW 0
0342
0343
0344
0345
0346 # define EVP_CIPH_FLAG_CTS 0x4000
0347 # define EVP_CIPH_FLAG_CUSTOM_CIPHER 0x100000
0348 # define EVP_CIPH_FLAG_AEAD_CIPHER 0x200000
0349 # define EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK 0x400000
0350
0351 # define EVP_CIPH_FLAG_PIPELINE 0X800000
0352
0353 # define EVP_CIPH_FLAG_CUSTOM_ASN1 0x1000000
0354
0355 # define EVP_CIPH_FLAG_CIPHER_WITH_MAC 0x2000000
0356
0357 # define EVP_CIPH_FLAG_GET_WRAP_CIPHER 0x4000000
0358 # define EVP_CIPH_FLAG_INVERSE_CIPHER 0x8000000
0359
0360
0361
0362
0363
0364
0365 # define EVP_CIPHER_CTX_FLAG_WRAP_ALLOW 0x1
0366
0367
0368
0369 # define EVP_CTRL_INIT 0x0
0370 # define EVP_CTRL_SET_KEY_LENGTH 0x1
0371 # define EVP_CTRL_GET_RC2_KEY_BITS 0x2
0372 # define EVP_CTRL_SET_RC2_KEY_BITS 0x3
0373 # define EVP_CTRL_GET_RC5_ROUNDS 0x4
0374 # define EVP_CTRL_SET_RC5_ROUNDS 0x5
0375 # define EVP_CTRL_RAND_KEY 0x6
0376 # define EVP_CTRL_PBE_PRF_NID 0x7
0377 # define EVP_CTRL_COPY 0x8
0378 # define EVP_CTRL_AEAD_SET_IVLEN 0x9
0379 # define EVP_CTRL_AEAD_GET_TAG 0x10
0380 # define EVP_CTRL_AEAD_SET_TAG 0x11
0381 # define EVP_CTRL_AEAD_SET_IV_FIXED 0x12
0382 # define EVP_CTRL_GCM_SET_IVLEN EVP_CTRL_AEAD_SET_IVLEN
0383 # define EVP_CTRL_GCM_GET_TAG EVP_CTRL_AEAD_GET_TAG
0384 # define EVP_CTRL_GCM_SET_TAG EVP_CTRL_AEAD_SET_TAG
0385 # define EVP_CTRL_GCM_SET_IV_FIXED EVP_CTRL_AEAD_SET_IV_FIXED
0386 # define EVP_CTRL_GCM_IV_GEN 0x13
0387 # define EVP_CTRL_CCM_SET_IVLEN EVP_CTRL_AEAD_SET_IVLEN
0388 # define EVP_CTRL_CCM_GET_TAG EVP_CTRL_AEAD_GET_TAG
0389 # define EVP_CTRL_CCM_SET_TAG EVP_CTRL_AEAD_SET_TAG
0390 # define EVP_CTRL_CCM_SET_IV_FIXED EVP_CTRL_AEAD_SET_IV_FIXED
0391 # define EVP_CTRL_CCM_SET_L 0x14
0392 # define EVP_CTRL_CCM_SET_MSGLEN 0x15
0393
0394
0395
0396
0397
0398 # define EVP_CTRL_AEAD_TLS1_AAD 0x16
0399
0400 # define EVP_CTRL_AEAD_SET_MAC_KEY 0x17
0401
0402 # define EVP_CTRL_GCM_SET_IV_INV 0x18
0403
0404 # define EVP_CTRL_TLS1_1_MULTIBLOCK_AAD 0x19
0405 # define EVP_CTRL_TLS1_1_MULTIBLOCK_ENCRYPT 0x1a
0406 # define EVP_CTRL_TLS1_1_MULTIBLOCK_DECRYPT 0x1b
0407 # define EVP_CTRL_TLS1_1_MULTIBLOCK_MAX_BUFSIZE 0x1c
0408
0409 # define EVP_CTRL_SSL3_MASTER_SECRET 0x1d
0410
0411
0412 # define EVP_CTRL_SET_SBOX 0x1e
0413
0414
0415
0416
0417 # define EVP_CTRL_SBOX_USED 0x1f
0418
0419
0420
0421 # define EVP_CTRL_KEY_MESH 0x20
0422
0423 # define EVP_CTRL_BLOCK_PADDING_MODE 0x21
0424
0425
0426 # define EVP_CTRL_SET_PIPELINE_OUTPUT_BUFS 0x22
0427
0428 # define EVP_CTRL_SET_PIPELINE_INPUT_BUFS 0x23
0429
0430 # define EVP_CTRL_SET_PIPELINE_INPUT_LENS 0x24
0431
0432 # define EVP_CTRL_GET_IVLEN 0x25
0433
0434
0435 # define EVP_CTRL_SET_SPEED 0x27
0436
0437 # define EVP_CTRL_PROCESS_UNPROTECTED 0x28
0438
0439 #define EVP_CTRL_GET_WRAP_CIPHER 0x29
0440
0441 #define EVP_CTRL_TLSTREE 0x2A
0442
0443
0444 #define EVP_PADDING_PKCS7 1
0445 #define EVP_PADDING_ISO7816_4 2
0446 #define EVP_PADDING_ANSI923 3
0447 #define EVP_PADDING_ISO10126 4
0448 #define EVP_PADDING_ZERO 5
0449
0450
0451 # define EVP_AEAD_TLS1_AAD_LEN 13
0452
0453 typedef struct {
0454 unsigned char *out;
0455 const unsigned char *inp;
0456 size_t len;
0457 unsigned int interleave;
0458 } EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM;
0459
0460
0461
0462 # define EVP_GCM_TLS_FIXED_IV_LEN 4
0463
0464 # define EVP_GCM_TLS_EXPLICIT_IV_LEN 8
0465
0466 # define EVP_GCM_TLS_TAG_LEN 16
0467
0468
0469
0470 # define EVP_CCM_TLS_FIXED_IV_LEN 4
0471
0472 # define EVP_CCM_TLS_EXPLICIT_IV_LEN 8
0473
0474 # define EVP_CCM_TLS_IV_LEN 12
0475
0476 # define EVP_CCM_TLS_TAG_LEN 16
0477
0478 # define EVP_CCM8_TLS_TAG_LEN 8
0479
0480
0481 # define EVP_CHACHAPOLY_TLS_TAG_LEN 16
0482
0483 typedef struct evp_cipher_info_st {
0484 const EVP_CIPHER *cipher;
0485 unsigned char iv[EVP_MAX_IV_LENGTH];
0486 } EVP_CIPHER_INFO;
0487
0488
0489
0490 typedef int (EVP_PBE_KEYGEN) (EVP_CIPHER_CTX *ctx, const char *pass,
0491 int passlen, ASN1_TYPE *param,
0492 const EVP_CIPHER *cipher, const EVP_MD *md,
0493 int en_de);
0494
0495 typedef int (EVP_PBE_KEYGEN_EX) (EVP_CIPHER_CTX *ctx, const char *pass,
0496 int passlen, ASN1_TYPE *param,
0497 const EVP_CIPHER *cipher, const EVP_MD *md,
0498 int en_de, OSSL_LIB_CTX *libctx, const char *propq);
0499
0500 # ifndef OPENSSL_NO_DEPRECATED_3_0
0501 # define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\
0502 (rsa))
0503 # endif
0504
0505 # ifndef OPENSSL_NO_DSA
0506 # define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\
0507 (dsa))
0508 # endif
0509
0510 # if !defined(OPENSSL_NO_DH) && !defined(OPENSSL_NO_DEPRECATED_3_0)
0511 # define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,(dh))
0512 # endif
0513
0514 # ifndef OPENSSL_NO_DEPRECATED_3_0
0515 # ifndef OPENSSL_NO_EC
0516 # define EVP_PKEY_assign_EC_KEY(pkey,eckey) \
0517 EVP_PKEY_assign((pkey), EVP_PKEY_EC, (eckey))
0518 # endif
0519 # endif
0520 # ifndef OPENSSL_NO_SIPHASH
0521 # define EVP_PKEY_assign_SIPHASH(pkey,shkey) EVP_PKEY_assign((pkey),\
0522 EVP_PKEY_SIPHASH,(shkey))
0523 # endif
0524
0525 # ifndef OPENSSL_NO_POLY1305
0526 # define EVP_PKEY_assign_POLY1305(pkey,polykey) EVP_PKEY_assign((pkey),\
0527 EVP_PKEY_POLY1305,(polykey))
0528 # endif
0529
0530
0531 # define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
0532 # define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))
0533 # define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))
0534 # define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))
0535
0536 int EVP_MD_get_type(const EVP_MD *md);
0537 # define EVP_MD_type EVP_MD_get_type
0538 # define EVP_MD_nid EVP_MD_get_type
0539 const char *EVP_MD_get0_name(const EVP_MD *md);
0540 # define EVP_MD_name EVP_MD_get0_name
0541 const char *EVP_MD_get0_description(const EVP_MD *md);
0542 int EVP_MD_is_a(const EVP_MD *md, const char *name);
0543 int EVP_MD_names_do_all(const EVP_MD *md,
0544 void (*fn)(const char *name, void *data),
0545 void *data);
0546 const OSSL_PROVIDER *EVP_MD_get0_provider(const EVP_MD *md);
0547 int EVP_MD_get_pkey_type(const EVP_MD *md);
0548 # define EVP_MD_pkey_type EVP_MD_get_pkey_type
0549 int EVP_MD_get_size(const EVP_MD *md);
0550 # define EVP_MD_size EVP_MD_get_size
0551 int EVP_MD_get_block_size(const EVP_MD *md);
0552 # define EVP_MD_block_size EVP_MD_get_block_size
0553 unsigned long EVP_MD_get_flags(const EVP_MD *md);
0554 # define EVP_MD_flags EVP_MD_get_flags
0555 int EVP_MD_xof(const EVP_MD *md);
0556
0557 const EVP_MD *EVP_MD_CTX_get0_md(const EVP_MD_CTX *ctx);
0558 EVP_MD *EVP_MD_CTX_get1_md(EVP_MD_CTX *ctx);
0559 # ifndef OPENSSL_NO_DEPRECATED_3_0
0560 OSSL_DEPRECATEDIN_3_0
0561 const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx);
0562 OSSL_DEPRECATEDIN_3_0
0563 int (*EVP_MD_CTX_update_fn(EVP_MD_CTX *ctx))(EVP_MD_CTX *ctx,
0564 const void *data, size_t count);
0565 OSSL_DEPRECATEDIN_3_0
0566 void EVP_MD_CTX_set_update_fn(EVP_MD_CTX *ctx,
0567 int (*update) (EVP_MD_CTX *ctx,
0568 const void *data, size_t count));
0569 # endif
0570 int EVP_MD_CTX_get_size_ex(const EVP_MD_CTX *ctx);
0571
0572 # define EVP_MD_CTX_get0_name(e) EVP_MD_get0_name(EVP_MD_CTX_get0_md(e))
0573 # define EVP_MD_CTX_get_size(e) EVP_MD_CTX_get_size_ex(e)
0574 # define EVP_MD_CTX_size EVP_MD_CTX_get_size_ex
0575 # define EVP_MD_CTX_get_block_size(e) EVP_MD_get_block_size(EVP_MD_CTX_get0_md(e))
0576 # define EVP_MD_CTX_block_size EVP_MD_CTX_get_block_size
0577 # define EVP_MD_CTX_get_type(e) EVP_MD_get_type(EVP_MD_CTX_get0_md(e))
0578 # define EVP_MD_CTX_type EVP_MD_CTX_get_type
0579 EVP_PKEY_CTX *EVP_MD_CTX_get_pkey_ctx(const EVP_MD_CTX *ctx);
0580 # define EVP_MD_CTX_pkey_ctx EVP_MD_CTX_get_pkey_ctx
0581 void EVP_MD_CTX_set_pkey_ctx(EVP_MD_CTX *ctx, EVP_PKEY_CTX *pctx);
0582 void *EVP_MD_CTX_get0_md_data(const EVP_MD_CTX *ctx);
0583 # define EVP_MD_CTX_md_data EVP_MD_CTX_get0_md_data
0584
0585 int EVP_CIPHER_get_nid(const EVP_CIPHER *cipher);
0586 # define EVP_CIPHER_nid EVP_CIPHER_get_nid
0587 const char *EVP_CIPHER_get0_name(const EVP_CIPHER *cipher);
0588 # define EVP_CIPHER_name EVP_CIPHER_get0_name
0589 const char *EVP_CIPHER_get0_description(const EVP_CIPHER *cipher);
0590 int EVP_CIPHER_is_a(const EVP_CIPHER *cipher, const char *name);
0591 int EVP_CIPHER_names_do_all(const EVP_CIPHER *cipher,
0592 void (*fn)(const char *name, void *data),
0593 void *data);
0594 const OSSL_PROVIDER *EVP_CIPHER_get0_provider(const EVP_CIPHER *cipher);
0595 int EVP_CIPHER_get_block_size(const EVP_CIPHER *cipher);
0596 # define EVP_CIPHER_block_size EVP_CIPHER_get_block_size
0597 # ifndef OPENSSL_NO_DEPRECATED_3_0
0598 OSSL_DEPRECATEDIN_3_0
0599 int EVP_CIPHER_impl_ctx_size(const EVP_CIPHER *cipher);
0600 # endif
0601 int EVP_CIPHER_get_key_length(const EVP_CIPHER *cipher);
0602 # define EVP_CIPHER_key_length EVP_CIPHER_get_key_length
0603 int EVP_CIPHER_get_iv_length(const EVP_CIPHER *cipher);
0604 # define EVP_CIPHER_iv_length EVP_CIPHER_get_iv_length
0605 unsigned long EVP_CIPHER_get_flags(const EVP_CIPHER *cipher);
0606 # define EVP_CIPHER_flags EVP_CIPHER_get_flags
0607 int EVP_CIPHER_get_mode(const EVP_CIPHER *cipher);
0608 # define EVP_CIPHER_mode EVP_CIPHER_get_mode
0609 int EVP_CIPHER_get_type(const EVP_CIPHER *cipher);
0610 # define EVP_CIPHER_type EVP_CIPHER_get_type
0611 EVP_CIPHER *EVP_CIPHER_fetch(OSSL_LIB_CTX *ctx, const char *algorithm,
0612 const char *properties);
0613 int EVP_CIPHER_up_ref(EVP_CIPHER *cipher);
0614 void EVP_CIPHER_free(EVP_CIPHER *cipher);
0615
0616 const EVP_CIPHER *EVP_CIPHER_CTX_get0_cipher(const EVP_CIPHER_CTX *ctx);
0617 EVP_CIPHER *EVP_CIPHER_CTX_get1_cipher(EVP_CIPHER_CTX *ctx);
0618 int EVP_CIPHER_CTX_is_encrypting(const EVP_CIPHER_CTX *ctx);
0619 # define EVP_CIPHER_CTX_encrypting EVP_CIPHER_CTX_is_encrypting
0620 int EVP_CIPHER_CTX_get_nid(const EVP_CIPHER_CTX *ctx);
0621 # define EVP_CIPHER_CTX_nid EVP_CIPHER_CTX_get_nid
0622 int EVP_CIPHER_CTX_get_block_size(const EVP_CIPHER_CTX *ctx);
0623 # define EVP_CIPHER_CTX_block_size EVP_CIPHER_CTX_get_block_size
0624 int EVP_CIPHER_CTX_get_key_length(const EVP_CIPHER_CTX *ctx);
0625 # define EVP_CIPHER_CTX_key_length EVP_CIPHER_CTX_get_key_length
0626 int EVP_CIPHER_CTX_get_iv_length(const EVP_CIPHER_CTX *ctx);
0627 # define EVP_CIPHER_CTX_iv_length EVP_CIPHER_CTX_get_iv_length
0628 int EVP_CIPHER_CTX_get_tag_length(const EVP_CIPHER_CTX *ctx);
0629 # define EVP_CIPHER_CTX_tag_length EVP_CIPHER_CTX_get_tag_length
0630 # ifndef OPENSSL_NO_DEPRECATED_3_0
0631 const EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx);
0632 OSSL_DEPRECATEDIN_3_0 const unsigned char *EVP_CIPHER_CTX_iv(const EVP_CIPHER_CTX *ctx);
0633 OSSL_DEPRECATEDIN_3_0 const unsigned char *EVP_CIPHER_CTX_original_iv(const EVP_CIPHER_CTX *ctx);
0634 OSSL_DEPRECATEDIN_3_0 unsigned char *EVP_CIPHER_CTX_iv_noconst(EVP_CIPHER_CTX *ctx);
0635 # endif
0636 int EVP_CIPHER_CTX_get_updated_iv(EVP_CIPHER_CTX *ctx, void *buf, size_t len);
0637 int EVP_CIPHER_CTX_get_original_iv(EVP_CIPHER_CTX *ctx, void *buf, size_t len);
0638 # ifndef OPENSSL_NO_DEPRECATED_3_0
0639 OSSL_DEPRECATEDIN_3_0
0640 unsigned char *EVP_CIPHER_CTX_buf_noconst(EVP_CIPHER_CTX *ctx);
0641 # endif
0642 int EVP_CIPHER_CTX_get_num(const EVP_CIPHER_CTX *ctx);
0643 # define EVP_CIPHER_CTX_num EVP_CIPHER_CTX_get_num
0644 int EVP_CIPHER_CTX_set_num(EVP_CIPHER_CTX *ctx, int num);
0645 EVP_CIPHER_CTX *EVP_CIPHER_CTX_dup(const EVP_CIPHER_CTX *in);
0646 int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in);
0647 void *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx);
0648 void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data);
0649 void *EVP_CIPHER_CTX_get_cipher_data(const EVP_CIPHER_CTX *ctx);
0650 void *EVP_CIPHER_CTX_set_cipher_data(EVP_CIPHER_CTX *ctx, void *cipher_data);
0651 # define EVP_CIPHER_CTX_get0_name(c) EVP_CIPHER_get0_name(EVP_CIPHER_CTX_get0_cipher(c))
0652 # define EVP_CIPHER_CTX_get_type(c) EVP_CIPHER_get_type(EVP_CIPHER_CTX_get0_cipher(c))
0653 # define EVP_CIPHER_CTX_type EVP_CIPHER_CTX_get_type
0654 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
0655 # define EVP_CIPHER_CTX_flags(c) EVP_CIPHER_get_flags(EVP_CIPHER_CTX_get0_cipher(c))
0656 # endif
0657 # define EVP_CIPHER_CTX_get_mode(c) EVP_CIPHER_get_mode(EVP_CIPHER_CTX_get0_cipher(c))
0658 # define EVP_CIPHER_CTX_mode EVP_CIPHER_CTX_get_mode
0659
0660 # define EVP_ENCODE_LENGTH(l) ((((l)+2)/3*4)+((l)/48+1)*2+80)
0661 # define EVP_DECODE_LENGTH(l) (((l)+3)/4*3+80)
0662
0663 # define EVP_SignInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c)
0664 # define EVP_SignInit(a,b) EVP_DigestInit(a,b)
0665 # define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
0666 # define EVP_VerifyInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c)
0667 # define EVP_VerifyInit(a,b) EVP_DigestInit(a,b)
0668 # define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
0669 # define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e)
0670 # define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e)
0671
0672 # ifdef CONST_STRICT
0673 void BIO_set_md(BIO *, const EVP_MD *md);
0674 # else
0675 # define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,0,(void *)(md))
0676 # endif
0677 # define BIO_get_md(b,mdp) BIO_ctrl(b,BIO_C_GET_MD,0,(mdp))
0678 # define BIO_get_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(mdcp))
0679 # define BIO_set_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_SET_MD_CTX,0,(mdcp))
0680 # define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL)
0681 # define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(c_pp))
0682
0683 __owur int EVP_Cipher(EVP_CIPHER_CTX *c,
0684 unsigned char *out,
0685 const unsigned char *in, unsigned int inl);
0686
0687 # define EVP_add_cipher_alias(n,alias) \
0688 OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n))
0689 # define EVP_add_digest_alias(n,alias) \
0690 OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n))
0691 # define EVP_delete_cipher_alias(alias) \
0692 OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS);
0693 # define EVP_delete_digest_alias(alias) \
0694 OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS);
0695
0696 int EVP_MD_get_params(const EVP_MD *digest, OSSL_PARAM params[]);
0697 int EVP_MD_CTX_set_params(EVP_MD_CTX *ctx, const OSSL_PARAM params[]);
0698 int EVP_MD_CTX_get_params(EVP_MD_CTX *ctx, OSSL_PARAM params[]);
0699 const OSSL_PARAM *EVP_MD_gettable_params(const EVP_MD *digest);
0700 const OSSL_PARAM *EVP_MD_settable_ctx_params(const EVP_MD *md);
0701 const OSSL_PARAM *EVP_MD_gettable_ctx_params(const EVP_MD *md);
0702 const OSSL_PARAM *EVP_MD_CTX_settable_params(EVP_MD_CTX *ctx);
0703 const OSSL_PARAM *EVP_MD_CTX_gettable_params(EVP_MD_CTX *ctx);
0704 int EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2);
0705 EVP_MD_CTX *EVP_MD_CTX_new(void);
0706 int EVP_MD_CTX_reset(EVP_MD_CTX *ctx);
0707 void EVP_MD_CTX_free(EVP_MD_CTX *ctx);
0708 # define EVP_MD_CTX_create() EVP_MD_CTX_new()
0709 # define EVP_MD_CTX_init(ctx) EVP_MD_CTX_reset((ctx))
0710 # define EVP_MD_CTX_destroy(ctx) EVP_MD_CTX_free((ctx))
0711 __owur EVP_MD_CTX *EVP_MD_CTX_dup(const EVP_MD_CTX *in);
0712 __owur int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in);
0713 void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags);
0714 void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags);
0715 int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags);
0716 __owur int EVP_DigestInit_ex2(EVP_MD_CTX *ctx, const EVP_MD *type,
0717 const OSSL_PARAM params[]);
0718 __owur int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type,
0719 ENGINE *impl);
0720 __owur int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d,
0721 size_t cnt);
0722 __owur int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md,
0723 unsigned int *s);
0724 __owur int EVP_Digest(const void *data, size_t count,
0725 unsigned char *md, unsigned int *size,
0726 const EVP_MD *type, ENGINE *impl);
0727 __owur int EVP_Q_digest(OSSL_LIB_CTX *libctx, const char *name,
0728 const char *propq, const void *data, size_t datalen,
0729 unsigned char *md, size_t *mdlen);
0730
0731 __owur int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in);
0732 __owur int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
0733 __owur int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md,
0734 unsigned int *s);
0735 __owur int EVP_DigestFinalXOF(EVP_MD_CTX *ctx, unsigned char *out,
0736 size_t outlen);
0737 __owur int EVP_DigestSqueeze(EVP_MD_CTX *ctx, unsigned char *out,
0738 size_t outlen);
0739
0740 __owur EVP_MD *EVP_MD_fetch(OSSL_LIB_CTX *ctx, const char *algorithm,
0741 const char *properties);
0742
0743 int EVP_MD_up_ref(EVP_MD *md);
0744 void EVP_MD_free(EVP_MD *md);
0745
0746 int EVP_read_pw_string(char *buf, int length, const char *prompt, int verify);
0747 int EVP_read_pw_string_min(char *buf, int minlen, int maxlen,
0748 const char *prompt, int verify);
0749 void EVP_set_pw_prompt(const char *prompt);
0750 char *EVP_get_pw_prompt(void);
0751
0752 __owur int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md,
0753 const unsigned char *salt,
0754 const unsigned char *data, int datal, int count,
0755 unsigned char *key, unsigned char *iv);
0756
0757 void EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags);
0758 void EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX *ctx, int flags);
0759 int EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx, int flags);
0760
0761 __owur int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
0762 const unsigned char *key, const unsigned char *iv);
0763 __owur int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,
0764 const EVP_CIPHER *cipher, ENGINE *impl,
0765 const unsigned char *key,
0766 const unsigned char *iv);
0767 __owur int EVP_EncryptInit_ex2(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
0768 const unsigned char *key,
0769 const unsigned char *iv,
0770 const OSSL_PARAM params[]);
0771 __owur int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
0772 int *outl, const unsigned char *in, int inl);
0773 __owur int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out,
0774 int *outl);
0775 __owur int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out,
0776 int *outl);
0777
0778 __owur int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
0779 const unsigned char *key, const unsigned char *iv);
0780 __owur int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx,
0781 const EVP_CIPHER *cipher, ENGINE *impl,
0782 const unsigned char *key,
0783 const unsigned char *iv);
0784 __owur int EVP_DecryptInit_ex2(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
0785 const unsigned char *key,
0786 const unsigned char *iv,
0787 const OSSL_PARAM params[]);
0788 __owur int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
0789 int *outl, const unsigned char *in, int inl);
0790 __owur int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
0791 int *outl);
0792 __owur int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm,
0793 int *outl);
0794
0795 __owur int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
0796 const unsigned char *key, const unsigned char *iv,
0797 int enc);
0798 __owur int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx,
0799 const EVP_CIPHER *cipher, ENGINE *impl,
0800 const unsigned char *key,
0801 const unsigned char *iv, int enc);
0802 __owur int EVP_CipherInit_ex2(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
0803 const unsigned char *key, const unsigned char *iv,
0804 int enc, const OSSL_PARAM params[]);
0805 __owur int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
0806 int *outl, const unsigned char *in, int inl);
0807 __owur int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm,
0808 int *outl);
0809 __owur int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm,
0810 int *outl);
0811
0812 __owur int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s,
0813 EVP_PKEY *pkey);
0814 __owur int EVP_SignFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s,
0815 EVP_PKEY *pkey, OSSL_LIB_CTX *libctx,
0816 const char *propq);
0817
0818 __owur int EVP_DigestSign(EVP_MD_CTX *ctx, unsigned char *sigret,
0819 size_t *siglen, const unsigned char *tbs,
0820 size_t tbslen);
0821
0822 __owur int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf,
0823 unsigned int siglen, EVP_PKEY *pkey);
0824 __owur int EVP_VerifyFinal_ex(EVP_MD_CTX *ctx, const unsigned char *sigbuf,
0825 unsigned int siglen, EVP_PKEY *pkey,
0826 OSSL_LIB_CTX *libctx, const char *propq);
0827
0828 __owur int EVP_DigestVerify(EVP_MD_CTX *ctx, const unsigned char *sigret,
0829 size_t siglen, const unsigned char *tbs,
0830 size_t tbslen);
0831
0832 __owur int EVP_DigestSignInit_ex(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
0833 const char *mdname, OSSL_LIB_CTX *libctx,
0834 const char *props, EVP_PKEY *pkey,
0835 const OSSL_PARAM params[]);
0836 __owur int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
0837 const EVP_MD *type, ENGINE *e,
0838 EVP_PKEY *pkey);
0839 __owur int EVP_DigestSignUpdate(EVP_MD_CTX *ctx, const void *data, size_t dsize);
0840 __owur int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret,
0841 size_t *siglen);
0842
0843 __owur int EVP_DigestVerifyInit_ex(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
0844 const char *mdname, OSSL_LIB_CTX *libctx,
0845 const char *props, EVP_PKEY *pkey,
0846 const OSSL_PARAM params[]);
0847 __owur int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx,
0848 const EVP_MD *type, ENGINE *e,
0849 EVP_PKEY *pkey);
0850 int EVP_DigestVerifyUpdate(EVP_MD_CTX *ctx, const void *data, size_t dsize);
0851 __owur int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig,
0852 size_t siglen);
0853
0854 __owur int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
0855 const unsigned char *ek, int ekl,
0856 const unsigned char *iv, EVP_PKEY *priv);
0857 __owur int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
0858
0859 __owur int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
0860 unsigned char **ek, int *ekl, unsigned char *iv,
0861 EVP_PKEY **pubk, int npubk);
0862 __owur int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
0863
0864 EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void);
0865 void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx);
0866 int EVP_ENCODE_CTX_copy(EVP_ENCODE_CTX *dctx, const EVP_ENCODE_CTX *sctx);
0867 int EVP_ENCODE_CTX_num(EVP_ENCODE_CTX *ctx);
0868 void EVP_EncodeInit(EVP_ENCODE_CTX *ctx);
0869 int EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
0870 const unsigned char *in, int inl);
0871 void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl);
0872 int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n);
0873
0874 void EVP_DecodeInit(EVP_ENCODE_CTX *ctx);
0875 int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl,
0876 const unsigned char *in, int inl);
0877 int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned
0878 char *out, int *outl);
0879 int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);
0880
0881 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
0882 # define EVP_CIPHER_CTX_init(c) EVP_CIPHER_CTX_reset(c)
0883 # define EVP_CIPHER_CTX_cleanup(c) EVP_CIPHER_CTX_reset(c)
0884 # endif
0885 EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);
0886 int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *c);
0887 void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *c);
0888 int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
0889 int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad);
0890 int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
0891 int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key);
0892 int EVP_CIPHER_get_params(EVP_CIPHER *cipher, OSSL_PARAM params[]);
0893 int EVP_CIPHER_CTX_set_params(EVP_CIPHER_CTX *ctx, const OSSL_PARAM params[]);
0894 int EVP_CIPHER_CTX_get_params(EVP_CIPHER_CTX *ctx, OSSL_PARAM params[]);
0895 const OSSL_PARAM *EVP_CIPHER_gettable_params(const EVP_CIPHER *cipher);
0896 const OSSL_PARAM *EVP_CIPHER_settable_ctx_params(const EVP_CIPHER *cipher);
0897 const OSSL_PARAM *EVP_CIPHER_gettable_ctx_params(const EVP_CIPHER *cipher);
0898 const OSSL_PARAM *EVP_CIPHER_CTX_settable_params(EVP_CIPHER_CTX *ctx);
0899 const OSSL_PARAM *EVP_CIPHER_CTX_gettable_params(EVP_CIPHER_CTX *ctx);
0900
0901 int EVP_CIPHER_CTX_set_algor_params(EVP_CIPHER_CTX *ctx, const X509_ALGOR *alg);
0902 int EVP_CIPHER_CTX_get_algor_params(EVP_CIPHER_CTX *ctx, X509_ALGOR *alg);
0903 int EVP_CIPHER_CTX_get_algor(EVP_CIPHER_CTX *ctx, X509_ALGOR **alg);
0904
0905 const BIO_METHOD *BIO_f_md(void);
0906 const BIO_METHOD *BIO_f_base64(void);
0907 const BIO_METHOD *BIO_f_cipher(void);
0908 const BIO_METHOD *BIO_f_reliable(void);
0909 __owur int BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k,
0910 const unsigned char *i, int enc);
0911
0912 const EVP_MD *EVP_md_null(void);
0913 # ifndef OPENSSL_NO_MD2
0914 const EVP_MD *EVP_md2(void);
0915 # endif
0916 # ifndef OPENSSL_NO_MD4
0917 const EVP_MD *EVP_md4(void);
0918 # endif
0919 # ifndef OPENSSL_NO_MD5
0920 const EVP_MD *EVP_md5(void);
0921 const EVP_MD *EVP_md5_sha1(void);
0922 # endif
0923 # ifndef OPENSSL_NO_BLAKE2
0924 const EVP_MD *EVP_blake2b512(void);
0925 const EVP_MD *EVP_blake2s256(void);
0926 # endif
0927 const EVP_MD *EVP_sha1(void);
0928 const EVP_MD *EVP_sha224(void);
0929 const EVP_MD *EVP_sha256(void);
0930 const EVP_MD *EVP_sha384(void);
0931 const EVP_MD *EVP_sha512(void);
0932 const EVP_MD *EVP_sha512_224(void);
0933 const EVP_MD *EVP_sha512_256(void);
0934 const EVP_MD *EVP_sha3_224(void);
0935 const EVP_MD *EVP_sha3_256(void);
0936 const EVP_MD *EVP_sha3_384(void);
0937 const EVP_MD *EVP_sha3_512(void);
0938 const EVP_MD *EVP_shake128(void);
0939 const EVP_MD *EVP_shake256(void);
0940
0941 # ifndef OPENSSL_NO_MDC2
0942 const EVP_MD *EVP_mdc2(void);
0943 # endif
0944 # ifndef OPENSSL_NO_RMD160
0945 const EVP_MD *EVP_ripemd160(void);
0946 # endif
0947 # ifndef OPENSSL_NO_WHIRLPOOL
0948 const EVP_MD *EVP_whirlpool(void);
0949 # endif
0950 # ifndef OPENSSL_NO_SM3
0951 const EVP_MD *EVP_sm3(void);
0952 # endif
0953 const EVP_CIPHER *EVP_enc_null(void);
0954 # ifndef OPENSSL_NO_DES
0955 const EVP_CIPHER *EVP_des_ecb(void);
0956 const EVP_CIPHER *EVP_des_ede(void);
0957 const EVP_CIPHER *EVP_des_ede3(void);
0958 const EVP_CIPHER *EVP_des_ede_ecb(void);
0959 const EVP_CIPHER *EVP_des_ede3_ecb(void);
0960 const EVP_CIPHER *EVP_des_cfb64(void);
0961 # define EVP_des_cfb EVP_des_cfb64
0962 const EVP_CIPHER *EVP_des_cfb1(void);
0963 const EVP_CIPHER *EVP_des_cfb8(void);
0964 const EVP_CIPHER *EVP_des_ede_cfb64(void);
0965 # define EVP_des_ede_cfb EVP_des_ede_cfb64
0966 const EVP_CIPHER *EVP_des_ede3_cfb64(void);
0967 # define EVP_des_ede3_cfb EVP_des_ede3_cfb64
0968 const EVP_CIPHER *EVP_des_ede3_cfb1(void);
0969 const EVP_CIPHER *EVP_des_ede3_cfb8(void);
0970 const EVP_CIPHER *EVP_des_ofb(void);
0971 const EVP_CIPHER *EVP_des_ede_ofb(void);
0972 const EVP_CIPHER *EVP_des_ede3_ofb(void);
0973 const EVP_CIPHER *EVP_des_cbc(void);
0974 const EVP_CIPHER *EVP_des_ede_cbc(void);
0975 const EVP_CIPHER *EVP_des_ede3_cbc(void);
0976 const EVP_CIPHER *EVP_desx_cbc(void);
0977 const EVP_CIPHER *EVP_des_ede3_wrap(void);
0978
0979
0980
0981
0982
0983 # endif
0984 # ifndef OPENSSL_NO_RC4
0985 const EVP_CIPHER *EVP_rc4(void);
0986 const EVP_CIPHER *EVP_rc4_40(void);
0987 # ifndef OPENSSL_NO_MD5
0988 const EVP_CIPHER *EVP_rc4_hmac_md5(void);
0989 # endif
0990 # endif
0991 # ifndef OPENSSL_NO_IDEA
0992 const EVP_CIPHER *EVP_idea_ecb(void);
0993 const EVP_CIPHER *EVP_idea_cfb64(void);
0994 # define EVP_idea_cfb EVP_idea_cfb64
0995 const EVP_CIPHER *EVP_idea_ofb(void);
0996 const EVP_CIPHER *EVP_idea_cbc(void);
0997 # endif
0998 # ifndef OPENSSL_NO_RC2
0999 const EVP_CIPHER *EVP_rc2_ecb(void);
1000 const EVP_CIPHER *EVP_rc2_cbc(void);
1001 const EVP_CIPHER *EVP_rc2_40_cbc(void);
1002 const EVP_CIPHER *EVP_rc2_64_cbc(void);
1003 const EVP_CIPHER *EVP_rc2_cfb64(void);
1004 # define EVP_rc2_cfb EVP_rc2_cfb64
1005 const EVP_CIPHER *EVP_rc2_ofb(void);
1006 # endif
1007 # ifndef OPENSSL_NO_BF
1008 const EVP_CIPHER *EVP_bf_ecb(void);
1009 const EVP_CIPHER *EVP_bf_cbc(void);
1010 const EVP_CIPHER *EVP_bf_cfb64(void);
1011 # define EVP_bf_cfb EVP_bf_cfb64
1012 const EVP_CIPHER *EVP_bf_ofb(void);
1013 # endif
1014 # ifndef OPENSSL_NO_CAST
1015 const EVP_CIPHER *EVP_cast5_ecb(void);
1016 const EVP_CIPHER *EVP_cast5_cbc(void);
1017 const EVP_CIPHER *EVP_cast5_cfb64(void);
1018 # define EVP_cast5_cfb EVP_cast5_cfb64
1019 const EVP_CIPHER *EVP_cast5_ofb(void);
1020 # endif
1021 # ifndef OPENSSL_NO_RC5
1022 const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void);
1023 const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void);
1024 const EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void);
1025 # define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64
1026 const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void);
1027 # endif
1028 const EVP_CIPHER *EVP_aes_128_ecb(void);
1029 const EVP_CIPHER *EVP_aes_128_cbc(void);
1030 const EVP_CIPHER *EVP_aes_128_cfb1(void);
1031 const EVP_CIPHER *EVP_aes_128_cfb8(void);
1032 const EVP_CIPHER *EVP_aes_128_cfb128(void);
1033 # define EVP_aes_128_cfb EVP_aes_128_cfb128
1034 const EVP_CIPHER *EVP_aes_128_ofb(void);
1035 const EVP_CIPHER *EVP_aes_128_ctr(void);
1036 const EVP_CIPHER *EVP_aes_128_ccm(void);
1037 const EVP_CIPHER *EVP_aes_128_gcm(void);
1038 const EVP_CIPHER *EVP_aes_128_xts(void);
1039 const EVP_CIPHER *EVP_aes_128_wrap(void);
1040 const EVP_CIPHER *EVP_aes_128_wrap_pad(void);
1041 # ifndef OPENSSL_NO_OCB
1042 const EVP_CIPHER *EVP_aes_128_ocb(void);
1043 # endif
1044 const EVP_CIPHER *EVP_aes_192_ecb(void);
1045 const EVP_CIPHER *EVP_aes_192_cbc(void);
1046 const EVP_CIPHER *EVP_aes_192_cfb1(void);
1047 const EVP_CIPHER *EVP_aes_192_cfb8(void);
1048 const EVP_CIPHER *EVP_aes_192_cfb128(void);
1049 # define EVP_aes_192_cfb EVP_aes_192_cfb128
1050 const EVP_CIPHER *EVP_aes_192_ofb(void);
1051 const EVP_CIPHER *EVP_aes_192_ctr(void);
1052 const EVP_CIPHER *EVP_aes_192_ccm(void);
1053 const EVP_CIPHER *EVP_aes_192_gcm(void);
1054 const EVP_CIPHER *EVP_aes_192_wrap(void);
1055 const EVP_CIPHER *EVP_aes_192_wrap_pad(void);
1056 # ifndef OPENSSL_NO_OCB
1057 const EVP_CIPHER *EVP_aes_192_ocb(void);
1058 # endif
1059 const EVP_CIPHER *EVP_aes_256_ecb(void);
1060 const EVP_CIPHER *EVP_aes_256_cbc(void);
1061 const EVP_CIPHER *EVP_aes_256_cfb1(void);
1062 const EVP_CIPHER *EVP_aes_256_cfb8(void);
1063 const EVP_CIPHER *EVP_aes_256_cfb128(void);
1064 # define EVP_aes_256_cfb EVP_aes_256_cfb128
1065 const EVP_CIPHER *EVP_aes_256_ofb(void);
1066 const EVP_CIPHER *EVP_aes_256_ctr(void);
1067 const EVP_CIPHER *EVP_aes_256_ccm(void);
1068 const EVP_CIPHER *EVP_aes_256_gcm(void);
1069 const EVP_CIPHER *EVP_aes_256_xts(void);
1070 const EVP_CIPHER *EVP_aes_256_wrap(void);
1071 const EVP_CIPHER *EVP_aes_256_wrap_pad(void);
1072 # ifndef OPENSSL_NO_OCB
1073 const EVP_CIPHER *EVP_aes_256_ocb(void);
1074 # endif
1075 const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void);
1076 const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha1(void);
1077 const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha256(void);
1078 const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha256(void);
1079 # ifndef OPENSSL_NO_ARIA
1080 const EVP_CIPHER *EVP_aria_128_ecb(void);
1081 const EVP_CIPHER *EVP_aria_128_cbc(void);
1082 const EVP_CIPHER *EVP_aria_128_cfb1(void);
1083 const EVP_CIPHER *EVP_aria_128_cfb8(void);
1084 const EVP_CIPHER *EVP_aria_128_cfb128(void);
1085 # define EVP_aria_128_cfb EVP_aria_128_cfb128
1086 const EVP_CIPHER *EVP_aria_128_ctr(void);
1087 const EVP_CIPHER *EVP_aria_128_ofb(void);
1088 const EVP_CIPHER *EVP_aria_128_gcm(void);
1089 const EVP_CIPHER *EVP_aria_128_ccm(void);
1090 const EVP_CIPHER *EVP_aria_192_ecb(void);
1091 const EVP_CIPHER *EVP_aria_192_cbc(void);
1092 const EVP_CIPHER *EVP_aria_192_cfb1(void);
1093 const EVP_CIPHER *EVP_aria_192_cfb8(void);
1094 const EVP_CIPHER *EVP_aria_192_cfb128(void);
1095 # define EVP_aria_192_cfb EVP_aria_192_cfb128
1096 const EVP_CIPHER *EVP_aria_192_ctr(void);
1097 const EVP_CIPHER *EVP_aria_192_ofb(void);
1098 const EVP_CIPHER *EVP_aria_192_gcm(void);
1099 const EVP_CIPHER *EVP_aria_192_ccm(void);
1100 const EVP_CIPHER *EVP_aria_256_ecb(void);
1101 const EVP_CIPHER *EVP_aria_256_cbc(void);
1102 const EVP_CIPHER *EVP_aria_256_cfb1(void);
1103 const EVP_CIPHER *EVP_aria_256_cfb8(void);
1104 const EVP_CIPHER *EVP_aria_256_cfb128(void);
1105 # define EVP_aria_256_cfb EVP_aria_256_cfb128
1106 const EVP_CIPHER *EVP_aria_256_ctr(void);
1107 const EVP_CIPHER *EVP_aria_256_ofb(void);
1108 const EVP_CIPHER *EVP_aria_256_gcm(void);
1109 const EVP_CIPHER *EVP_aria_256_ccm(void);
1110 # endif
1111 # ifndef OPENSSL_NO_CAMELLIA
1112 const EVP_CIPHER *EVP_camellia_128_ecb(void);
1113 const EVP_CIPHER *EVP_camellia_128_cbc(void);
1114 const EVP_CIPHER *EVP_camellia_128_cfb1(void);
1115 const EVP_CIPHER *EVP_camellia_128_cfb8(void);
1116 const EVP_CIPHER *EVP_camellia_128_cfb128(void);
1117 # define EVP_camellia_128_cfb EVP_camellia_128_cfb128
1118 const EVP_CIPHER *EVP_camellia_128_ofb(void);
1119 const EVP_CIPHER *EVP_camellia_128_ctr(void);
1120 const EVP_CIPHER *EVP_camellia_192_ecb(void);
1121 const EVP_CIPHER *EVP_camellia_192_cbc(void);
1122 const EVP_CIPHER *EVP_camellia_192_cfb1(void);
1123 const EVP_CIPHER *EVP_camellia_192_cfb8(void);
1124 const EVP_CIPHER *EVP_camellia_192_cfb128(void);
1125 # define EVP_camellia_192_cfb EVP_camellia_192_cfb128
1126 const EVP_CIPHER *EVP_camellia_192_ofb(void);
1127 const EVP_CIPHER *EVP_camellia_192_ctr(void);
1128 const EVP_CIPHER *EVP_camellia_256_ecb(void);
1129 const EVP_CIPHER *EVP_camellia_256_cbc(void);
1130 const EVP_CIPHER *EVP_camellia_256_cfb1(void);
1131 const EVP_CIPHER *EVP_camellia_256_cfb8(void);
1132 const EVP_CIPHER *EVP_camellia_256_cfb128(void);
1133 # define EVP_camellia_256_cfb EVP_camellia_256_cfb128
1134 const EVP_CIPHER *EVP_camellia_256_ofb(void);
1135 const EVP_CIPHER *EVP_camellia_256_ctr(void);
1136 # endif
1137 # ifndef OPENSSL_NO_CHACHA
1138 const EVP_CIPHER *EVP_chacha20(void);
1139 # ifndef OPENSSL_NO_POLY1305
1140 const EVP_CIPHER *EVP_chacha20_poly1305(void);
1141 # endif
1142 # endif
1143
1144 # ifndef OPENSSL_NO_SEED
1145 const EVP_CIPHER *EVP_seed_ecb(void);
1146 const EVP_CIPHER *EVP_seed_cbc(void);
1147 const EVP_CIPHER *EVP_seed_cfb128(void);
1148 # define EVP_seed_cfb EVP_seed_cfb128
1149 const EVP_CIPHER *EVP_seed_ofb(void);
1150 # endif
1151
1152 # ifndef OPENSSL_NO_SM4
1153 const EVP_CIPHER *EVP_sm4_ecb(void);
1154 const EVP_CIPHER *EVP_sm4_cbc(void);
1155 const EVP_CIPHER *EVP_sm4_cfb128(void);
1156 # define EVP_sm4_cfb EVP_sm4_cfb128
1157 const EVP_CIPHER *EVP_sm4_ofb(void);
1158 const EVP_CIPHER *EVP_sm4_ctr(void);
1159 # endif
1160
1161 # ifndef OPENSSL_NO_DEPRECATED_1_1_0
1162 # define OPENSSL_add_all_algorithms_conf() \
1163 OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \
1164 | OPENSSL_INIT_ADD_ALL_DIGESTS \
1165 | OPENSSL_INIT_LOAD_CONFIG, NULL)
1166 # define OPENSSL_add_all_algorithms_noconf() \
1167 OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \
1168 | OPENSSL_INIT_ADD_ALL_DIGESTS, NULL)
1169
1170 # ifdef OPENSSL_LOAD_CONF
1171 # define OpenSSL_add_all_algorithms() OPENSSL_add_all_algorithms_conf()
1172 # else
1173 # define OpenSSL_add_all_algorithms() OPENSSL_add_all_algorithms_noconf()
1174 # endif
1175
1176 # define OpenSSL_add_all_ciphers() \
1177 OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS, NULL)
1178 # define OpenSSL_add_all_digests() \
1179 OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_DIGESTS, NULL)
1180
1181 # define EVP_cleanup() while(0) continue
1182 # endif
1183
1184 int EVP_add_cipher(const EVP_CIPHER *cipher);
1185 int EVP_add_digest(const EVP_MD *digest);
1186
1187 const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
1188 const EVP_MD *EVP_get_digestbyname(const char *name);
1189
1190 void EVP_CIPHER_do_all(void (*fn) (const EVP_CIPHER *ciph,
1191 const char *from, const char *to, void *x),
1192 void *arg);
1193 void EVP_CIPHER_do_all_sorted(void (*fn)
1194 (const EVP_CIPHER *ciph, const char *from,
1195 const char *to, void *x), void *arg);
1196 void EVP_CIPHER_do_all_provided(OSSL_LIB_CTX *libctx,
1197 void (*fn)(EVP_CIPHER *cipher, void *arg),
1198 void *arg);
1199
1200 void EVP_MD_do_all(void (*fn) (const EVP_MD *ciph,
1201 const char *from, const char *to, void *x),
1202 void *arg);
1203 void EVP_MD_do_all_sorted(void (*fn)
1204 (const EVP_MD *ciph, const char *from,
1205 const char *to, void *x), void *arg);
1206 void EVP_MD_do_all_provided(OSSL_LIB_CTX *libctx,
1207 void (*fn)(EVP_MD *md, void *arg),
1208 void *arg);
1209
1210
1211
1212 EVP_MAC *EVP_MAC_fetch(OSSL_LIB_CTX *libctx, const char *algorithm,
1213 const char *properties);
1214 int EVP_MAC_up_ref(EVP_MAC *mac);
1215 void EVP_MAC_free(EVP_MAC *mac);
1216 const char *EVP_MAC_get0_name(const EVP_MAC *mac);
1217 const char *EVP_MAC_get0_description(const EVP_MAC *mac);
1218 int EVP_MAC_is_a(const EVP_MAC *mac, const char *name);
1219 const OSSL_PROVIDER *EVP_MAC_get0_provider(const EVP_MAC *mac);
1220 int EVP_MAC_get_params(EVP_MAC *mac, OSSL_PARAM params[]);
1221
1222 EVP_MAC_CTX *EVP_MAC_CTX_new(EVP_MAC *mac);
1223 void EVP_MAC_CTX_free(EVP_MAC_CTX *ctx);
1224 EVP_MAC_CTX *EVP_MAC_CTX_dup(const EVP_MAC_CTX *src);
1225 EVP_MAC *EVP_MAC_CTX_get0_mac(EVP_MAC_CTX *ctx);
1226 int EVP_MAC_CTX_get_params(EVP_MAC_CTX *ctx, OSSL_PARAM params[]);
1227 int EVP_MAC_CTX_set_params(EVP_MAC_CTX *ctx, const OSSL_PARAM params[]);
1228
1229 size_t EVP_MAC_CTX_get_mac_size(EVP_MAC_CTX *ctx);
1230 size_t EVP_MAC_CTX_get_block_size(EVP_MAC_CTX *ctx);
1231 unsigned char *EVP_Q_mac(OSSL_LIB_CTX *libctx, const char *name, const char *propq,
1232 const char *subalg, const OSSL_PARAM *params,
1233 const void *key, size_t keylen,
1234 const unsigned char *data, size_t datalen,
1235 unsigned char *out, size_t outsize, size_t *outlen);
1236 int EVP_MAC_init(EVP_MAC_CTX *ctx, const unsigned char *key, size_t keylen,
1237 const OSSL_PARAM params[]);
1238 int EVP_MAC_update(EVP_MAC_CTX *ctx, const unsigned char *data, size_t datalen);
1239 int EVP_MAC_final(EVP_MAC_CTX *ctx,
1240 unsigned char *out, size_t *outl, size_t outsize);
1241 int EVP_MAC_finalXOF(EVP_MAC_CTX *ctx, unsigned char *out, size_t outsize);
1242 const OSSL_PARAM *EVP_MAC_gettable_params(const EVP_MAC *mac);
1243 const OSSL_PARAM *EVP_MAC_gettable_ctx_params(const EVP_MAC *mac);
1244 const OSSL_PARAM *EVP_MAC_settable_ctx_params(const EVP_MAC *mac);
1245 const OSSL_PARAM *EVP_MAC_CTX_gettable_params(EVP_MAC_CTX *ctx);
1246 const OSSL_PARAM *EVP_MAC_CTX_settable_params(EVP_MAC_CTX *ctx);
1247
1248 void EVP_MAC_do_all_provided(OSSL_LIB_CTX *libctx,
1249 void (*fn)(EVP_MAC *mac, void *arg),
1250 void *arg);
1251 int EVP_MAC_names_do_all(const EVP_MAC *mac,
1252 void (*fn)(const char *name, void *data),
1253 void *data);
1254
1255
1256 EVP_RAND *EVP_RAND_fetch(OSSL_LIB_CTX *libctx, const char *algorithm,
1257 const char *properties);
1258 int EVP_RAND_up_ref(EVP_RAND *rand);
1259 void EVP_RAND_free(EVP_RAND *rand);
1260 const char *EVP_RAND_get0_name(const EVP_RAND *rand);
1261 const char *EVP_RAND_get0_description(const EVP_RAND *md);
1262 int EVP_RAND_is_a(const EVP_RAND *rand, const char *name);
1263 const OSSL_PROVIDER *EVP_RAND_get0_provider(const EVP_RAND *rand);
1264 int EVP_RAND_get_params(EVP_RAND *rand, OSSL_PARAM params[]);
1265
1266 EVP_RAND_CTX *EVP_RAND_CTX_new(EVP_RAND *rand, EVP_RAND_CTX *parent);
1267 int EVP_RAND_CTX_up_ref(EVP_RAND_CTX *ctx);
1268 void EVP_RAND_CTX_free(EVP_RAND_CTX *ctx);
1269 EVP_RAND *EVP_RAND_CTX_get0_rand(EVP_RAND_CTX *ctx);
1270 int EVP_RAND_CTX_get_params(EVP_RAND_CTX *ctx, OSSL_PARAM params[]);
1271 int EVP_RAND_CTX_set_params(EVP_RAND_CTX *ctx, const OSSL_PARAM params[]);
1272 const OSSL_PARAM *EVP_RAND_gettable_params(const EVP_RAND *rand);
1273 const OSSL_PARAM *EVP_RAND_gettable_ctx_params(const EVP_RAND *rand);
1274 const OSSL_PARAM *EVP_RAND_settable_ctx_params(const EVP_RAND *rand);
1275 const OSSL_PARAM *EVP_RAND_CTX_gettable_params(EVP_RAND_CTX *ctx);
1276 const OSSL_PARAM *EVP_RAND_CTX_settable_params(EVP_RAND_CTX *ctx);
1277
1278 void EVP_RAND_do_all_provided(OSSL_LIB_CTX *libctx,
1279 void (*fn)(EVP_RAND *rand, void *arg),
1280 void *arg);
1281 int EVP_RAND_names_do_all(const EVP_RAND *rand,
1282 void (*fn)(const char *name, void *data),
1283 void *data);
1284
1285 __owur int EVP_RAND_instantiate(EVP_RAND_CTX *ctx, unsigned int strength,
1286 int prediction_resistance,
1287 const unsigned char *pstr, size_t pstr_len,
1288 const OSSL_PARAM params[]);
1289 int EVP_RAND_uninstantiate(EVP_RAND_CTX *ctx);
1290 __owur int EVP_RAND_generate(EVP_RAND_CTX *ctx, unsigned char *out,
1291 size_t outlen, unsigned int strength,
1292 int prediction_resistance,
1293 const unsigned char *addin, size_t addin_len);
1294 int EVP_RAND_reseed(EVP_RAND_CTX *ctx, int prediction_resistance,
1295 const unsigned char *ent, size_t ent_len,
1296 const unsigned char *addin, size_t addin_len);
1297 __owur int EVP_RAND_nonce(EVP_RAND_CTX *ctx, unsigned char *out, size_t outlen);
1298 __owur int EVP_RAND_enable_locking(EVP_RAND_CTX *ctx);
1299
1300 int EVP_RAND_verify_zeroization(EVP_RAND_CTX *ctx);
1301 unsigned int EVP_RAND_get_strength(EVP_RAND_CTX *ctx);
1302 int EVP_RAND_get_state(EVP_RAND_CTX *ctx);
1303
1304 # define EVP_RAND_STATE_UNINITIALISED 0
1305 # define EVP_RAND_STATE_READY 1
1306 # define EVP_RAND_STATE_ERROR 2
1307
1308
1309 # ifndef OPENSSL_NO_DEPRECATED_3_0
1310 OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_decrypt_old(unsigned char *dec_key,
1311 const unsigned char *enc_key,
1312 int enc_key_len,
1313 EVP_PKEY *private_key);
1314 OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_encrypt_old(unsigned char *enc_key,
1315 const unsigned char *key,
1316 int key_len, EVP_PKEY *pub_key);
1317 # endif
1318 int EVP_PKEY_is_a(const EVP_PKEY *pkey, const char *name);
1319 int EVP_PKEY_type_names_do_all(const EVP_PKEY *pkey,
1320 void (*fn)(const char *name, void *data),
1321 void *data);
1322 int EVP_PKEY_type(int type);
1323 int EVP_PKEY_get_id(const EVP_PKEY *pkey);
1324 # define EVP_PKEY_id EVP_PKEY_get_id
1325 int EVP_PKEY_get_base_id(const EVP_PKEY *pkey);
1326 # define EVP_PKEY_base_id EVP_PKEY_get_base_id
1327 int EVP_PKEY_get_bits(const EVP_PKEY *pkey);
1328 # define EVP_PKEY_bits EVP_PKEY_get_bits
1329 int EVP_PKEY_get_security_bits(const EVP_PKEY *pkey);
1330 # define EVP_PKEY_security_bits EVP_PKEY_get_security_bits
1331 int EVP_PKEY_get_size(const EVP_PKEY *pkey);
1332 # define EVP_PKEY_size EVP_PKEY_get_size
1333 int EVP_PKEY_can_sign(const EVP_PKEY *pkey);
1334 int EVP_PKEY_set_type(EVP_PKEY *pkey, int type);
1335 int EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len);
1336 int EVP_PKEY_set_type_by_keymgmt(EVP_PKEY *pkey, EVP_KEYMGMT *keymgmt);
1337 # ifndef OPENSSL_NO_DEPRECATED_3_0
1338 # ifndef OPENSSL_NO_ENGINE
1339 OSSL_DEPRECATEDIN_3_0
1340 int EVP_PKEY_set1_engine(EVP_PKEY *pkey, ENGINE *e);
1341 OSSL_DEPRECATEDIN_3_0
1342 ENGINE *EVP_PKEY_get0_engine(const EVP_PKEY *pkey);
1343 # endif
1344 OSSL_DEPRECATEDIN_3_0
1345 int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key);
1346 OSSL_DEPRECATEDIN_3_0
1347 void *EVP_PKEY_get0(const EVP_PKEY *pkey);
1348 OSSL_DEPRECATEDIN_3_0
1349 const unsigned char *EVP_PKEY_get0_hmac(const EVP_PKEY *pkey, size_t *len);
1350 # ifndef OPENSSL_NO_POLY1305
1351 OSSL_DEPRECATEDIN_3_0
1352 const unsigned char *EVP_PKEY_get0_poly1305(const EVP_PKEY *pkey, size_t *len);
1353 # endif
1354 # ifndef OPENSSL_NO_SIPHASH
1355 OSSL_DEPRECATEDIN_3_0
1356 const unsigned char *EVP_PKEY_get0_siphash(const EVP_PKEY *pkey, size_t *len);
1357 # endif
1358
1359 struct rsa_st;
1360 OSSL_DEPRECATEDIN_3_0
1361 int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, struct rsa_st *key);
1362 OSSL_DEPRECATEDIN_3_0
1363 const struct rsa_st *EVP_PKEY_get0_RSA(const EVP_PKEY *pkey);
1364 OSSL_DEPRECATEDIN_3_0
1365 struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);
1366
1367 # ifndef OPENSSL_NO_DSA
1368 struct dsa_st;
1369 OSSL_DEPRECATEDIN_3_0
1370 int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, struct dsa_st *key);
1371 OSSL_DEPRECATEDIN_3_0
1372 const struct dsa_st *EVP_PKEY_get0_DSA(const EVP_PKEY *pkey);
1373 OSSL_DEPRECATEDIN_3_0
1374 struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);
1375 # endif
1376
1377 # ifndef OPENSSL_NO_DH
1378 struct dh_st;
1379 OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_set1_DH(EVP_PKEY *pkey, struct dh_st *key);
1380 OSSL_DEPRECATEDIN_3_0 const struct dh_st *EVP_PKEY_get0_DH(const EVP_PKEY *pkey);
1381 OSSL_DEPRECATEDIN_3_0 struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey);
1382 # endif
1383
1384 # ifndef OPENSSL_NO_EC
1385 struct ec_key_st;
1386 OSSL_DEPRECATEDIN_3_0
1387 int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, struct ec_key_st *key);
1388 OSSL_DEPRECATEDIN_3_0
1389 const struct ec_key_st *EVP_PKEY_get0_EC_KEY(const EVP_PKEY *pkey);
1390 OSSL_DEPRECATEDIN_3_0
1391 struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey);
1392 # endif
1393 # endif
1394
1395 EVP_PKEY *EVP_PKEY_new(void);
1396 int EVP_PKEY_up_ref(EVP_PKEY *pkey);
1397 EVP_PKEY *EVP_PKEY_dup(EVP_PKEY *pkey);
1398 void EVP_PKEY_free(EVP_PKEY *pkey);
1399 const char *EVP_PKEY_get0_description(const EVP_PKEY *pkey);
1400 const OSSL_PROVIDER *EVP_PKEY_get0_provider(const EVP_PKEY *key);
1401
1402 EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp,
1403 long length);
1404 int i2d_PublicKey(const EVP_PKEY *a, unsigned char **pp);
1405
1406
1407 EVP_PKEY *d2i_PrivateKey_ex(int type, EVP_PKEY **a, const unsigned char **pp,
1408 long length, OSSL_LIB_CTX *libctx,
1409 const char *propq);
1410 EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,
1411 long length);
1412 EVP_PKEY *d2i_AutoPrivateKey_ex(EVP_PKEY **a, const unsigned char **pp,
1413 long length, OSSL_LIB_CTX *libctx,
1414 const char *propq);
1415 EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp,
1416 long length);
1417 int i2d_PrivateKey(const EVP_PKEY *a, unsigned char **pp);
1418
1419 int i2d_KeyParams(const EVP_PKEY *a, unsigned char **pp);
1420 EVP_PKEY *d2i_KeyParams(int type, EVP_PKEY **a, const unsigned char **pp,
1421 long length);
1422 int i2d_KeyParams_bio(BIO *bp, const EVP_PKEY *pkey);
1423 EVP_PKEY *d2i_KeyParams_bio(int type, EVP_PKEY **a, BIO *in);
1424
1425 int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from);
1426 int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey);
1427 int EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode);
1428 int EVP_PKEY_parameters_eq(const EVP_PKEY *a, const EVP_PKEY *b);
1429 int EVP_PKEY_eq(const EVP_PKEY *a, const EVP_PKEY *b);
1430
1431 # ifndef OPENSSL_NO_DEPRECATED_3_0
1432 OSSL_DEPRECATEDIN_3_0
1433 int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b);
1434 OSSL_DEPRECATEDIN_3_0
1435 int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b);
1436 # endif
1437
1438 int EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey,
1439 int indent, ASN1_PCTX *pctx);
1440 int EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey,
1441 int indent, ASN1_PCTX *pctx);
1442 int EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey,
1443 int indent, ASN1_PCTX *pctx);
1444 # ifndef OPENSSL_NO_STDIO
1445 int EVP_PKEY_print_public_fp(FILE *fp, const EVP_PKEY *pkey,
1446 int indent, ASN1_PCTX *pctx);
1447 int EVP_PKEY_print_private_fp(FILE *fp, const EVP_PKEY *pkey,
1448 int indent, ASN1_PCTX *pctx);
1449 int EVP_PKEY_print_params_fp(FILE *fp, const EVP_PKEY *pkey,
1450 int indent, ASN1_PCTX *pctx);
1451 # endif
1452
1453 int EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid);
1454 int EVP_PKEY_get_default_digest_name(EVP_PKEY *pkey,
1455 char *mdname, size_t mdname_sz);
1456 int EVP_PKEY_digestsign_supports_digest(EVP_PKEY *pkey, OSSL_LIB_CTX *libctx,
1457 const char *name, const char *propq);
1458
1459 # ifndef OPENSSL_NO_DEPRECATED_3_0
1460
1461
1462
1463
1464 # define EVP_PKEY_set1_tls_encodedpoint(pkey, pt, ptlen) \
1465 EVP_PKEY_set1_encoded_public_key((pkey), (pt), (ptlen))
1466 # endif
1467
1468 int EVP_PKEY_set1_encoded_public_key(EVP_PKEY *pkey,
1469 const unsigned char *pub, size_t publen);
1470
1471 # ifndef OPENSSL_NO_DEPRECATED_3_0
1472
1473
1474
1475
1476 # define EVP_PKEY_get1_tls_encodedpoint(pkey, ppt) \
1477 EVP_PKEY_get1_encoded_public_key((pkey), (ppt))
1478 # endif
1479
1480 size_t EVP_PKEY_get1_encoded_public_key(EVP_PKEY *pkey, unsigned char **ppub);
1481
1482
1483 int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
1484 int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
1485
1486
1487 int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
1488 int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
1489
1490
1491 int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
1492 ASN1_TYPE *param, const EVP_CIPHER *cipher,
1493 const EVP_MD *md, int en_de);
1494 int PKCS5_PBE_keyivgen_ex(EVP_CIPHER_CTX *cctx, const char *pass, int passlen,
1495 ASN1_TYPE *param, const EVP_CIPHER *cipher,
1496 const EVP_MD *md, int en_de, OSSL_LIB_CTX *libctx,
1497 const char *propq);
1498 int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
1499 const unsigned char *salt, int saltlen, int iter,
1500 int keylen, unsigned char *out);
1501 int PKCS5_PBKDF2_HMAC(const char *pass, int passlen,
1502 const unsigned char *salt, int saltlen, int iter,
1503 const EVP_MD *digest, int keylen, unsigned char *out);
1504 int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
1505 ASN1_TYPE *param, const EVP_CIPHER *cipher,
1506 const EVP_MD *md, int en_de);
1507 int PKCS5_v2_PBE_keyivgen_ex(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
1508 ASN1_TYPE *param, const EVP_CIPHER *cipher,
1509 const EVP_MD *md, int en_de,
1510 OSSL_LIB_CTX *libctx, const char *propq);
1511
1512 #ifndef OPENSSL_NO_SCRYPT
1513 int EVP_PBE_scrypt(const char *pass, size_t passlen,
1514 const unsigned char *salt, size_t saltlen,
1515 uint64_t N, uint64_t r, uint64_t p, uint64_t maxmem,
1516 unsigned char *key, size_t keylen);
1517 int EVP_PBE_scrypt_ex(const char *pass, size_t passlen,
1518 const unsigned char *salt, size_t saltlen,
1519 uint64_t N, uint64_t r, uint64_t p, uint64_t maxmem,
1520 unsigned char *key, size_t keylen,
1521 OSSL_LIB_CTX *ctx, const char *propq);
1522
1523 int PKCS5_v2_scrypt_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass,
1524 int passlen, ASN1_TYPE *param,
1525 const EVP_CIPHER *c, const EVP_MD *md, int en_de);
1526 int PKCS5_v2_scrypt_keyivgen_ex(EVP_CIPHER_CTX *ctx, const char *pass,
1527 int passlen, ASN1_TYPE *param,
1528 const EVP_CIPHER *c, const EVP_MD *md, int en_de,
1529 OSSL_LIB_CTX *libctx, const char *propq);
1530 #endif
1531
1532 void PKCS5_PBE_add(void);
1533
1534 int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
1535 ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de);
1536
1537 int EVP_PBE_CipherInit_ex(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
1538 ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de,
1539 OSSL_LIB_CTX *libctx, const char *propq);
1540
1541
1542
1543
1544 # define EVP_PBE_TYPE_OUTER 0x0
1545
1546 # define EVP_PBE_TYPE_PRF 0x1
1547
1548 # define EVP_PBE_TYPE_KDF 0x2
1549
1550 int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid,
1551 int md_nid, EVP_PBE_KEYGEN *keygen);
1552 int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
1553 EVP_PBE_KEYGEN *keygen);
1554 int EVP_PBE_find(int type, int pbe_nid, int *pcnid, int *pmnid,
1555 EVP_PBE_KEYGEN **pkeygen);
1556 int EVP_PBE_find_ex(int type, int pbe_nid, int *pcnid, int *pmnid,
1557 EVP_PBE_KEYGEN **pkeygen, EVP_PBE_KEYGEN_EX **pkeygen_ex);
1558 void EVP_PBE_cleanup(void);
1559 int EVP_PBE_get(int *ptype, int *ppbe_nid, size_t num);
1560
1561 # define ASN1_PKEY_ALIAS 0x1
1562 # define ASN1_PKEY_DYNAMIC 0x2
1563 # define ASN1_PKEY_SIGPARAM_NULL 0x4
1564
1565 # define ASN1_PKEY_CTRL_PKCS7_SIGN 0x1
1566 # define ASN1_PKEY_CTRL_PKCS7_ENCRYPT 0x2
1567 # define ASN1_PKEY_CTRL_DEFAULT_MD_NID 0x3
1568 # define ASN1_PKEY_CTRL_CMS_SIGN 0x5
1569 # define ASN1_PKEY_CTRL_CMS_ENVELOPE 0x7
1570 # define ASN1_PKEY_CTRL_CMS_RI_TYPE 0x8
1571
1572 # define ASN1_PKEY_CTRL_SET1_TLS_ENCPT 0x9
1573 # define ASN1_PKEY_CTRL_GET1_TLS_ENCPT 0xa
1574 # define ASN1_PKEY_CTRL_CMS_IS_RI_TYPE_SUPPORTED 0xb
1575
1576 int EVP_PKEY_asn1_get_count(void);
1577 const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx);
1578 const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type);
1579 const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe,
1580 const char *str, int len);
1581 int EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth);
1582 int EVP_PKEY_asn1_add_alias(int to, int from);
1583 int EVP_PKEY_asn1_get0_info(int *ppkey_id, int *pkey_base_id,
1584 int *ppkey_flags, const char **pinfo,
1585 const char **ppem_str,
1586 const EVP_PKEY_ASN1_METHOD *ameth);
1587
1588 const EVP_PKEY_ASN1_METHOD *EVP_PKEY_get0_asn1(const EVP_PKEY *pkey);
1589 EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags,
1590 const char *pem_str,
1591 const char *info);
1592 void EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst,
1593 const EVP_PKEY_ASN1_METHOD *src);
1594 void EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth);
1595 void EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth,
1596 int (*pub_decode) (EVP_PKEY *pk,
1597 const X509_PUBKEY *pub),
1598 int (*pub_encode) (X509_PUBKEY *pub,
1599 const EVP_PKEY *pk),
1600 int (*pub_cmp) (const EVP_PKEY *a,
1601 const EVP_PKEY *b),
1602 int (*pub_print) (BIO *out,
1603 const EVP_PKEY *pkey,
1604 int indent, ASN1_PCTX *pctx),
1605 int (*pkey_size) (const EVP_PKEY *pk),
1606 int (*pkey_bits) (const EVP_PKEY *pk));
1607 void EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth,
1608 int (*priv_decode) (EVP_PKEY *pk,
1609 const PKCS8_PRIV_KEY_INFO
1610 *p8inf),
1611 int (*priv_encode) (PKCS8_PRIV_KEY_INFO *p8,
1612 const EVP_PKEY *pk),
1613 int (*priv_print) (BIO *out,
1614 const EVP_PKEY *pkey,
1615 int indent,
1616 ASN1_PCTX *pctx));
1617 void EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD *ameth,
1618 int (*param_decode) (EVP_PKEY *pkey,
1619 const unsigned char **pder,
1620 int derlen),
1621 int (*param_encode) (const EVP_PKEY *pkey,
1622 unsigned char **pder),
1623 int (*param_missing) (const EVP_PKEY *pk),
1624 int (*param_copy) (EVP_PKEY *to,
1625 const EVP_PKEY *from),
1626 int (*param_cmp) (const EVP_PKEY *a,
1627 const EVP_PKEY *b),
1628 int (*param_print) (BIO *out,
1629 const EVP_PKEY *pkey,
1630 int indent,
1631 ASN1_PCTX *pctx));
1632
1633 void EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth,
1634 void (*pkey_free) (EVP_PKEY *pkey));
1635 void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth,
1636 int (*pkey_ctrl) (EVP_PKEY *pkey, int op,
1637 long arg1, void *arg2));
1638 void EVP_PKEY_asn1_set_item(EVP_PKEY_ASN1_METHOD *ameth,
1639 int (*item_verify) (EVP_MD_CTX *ctx,
1640 const ASN1_ITEM *it,
1641 const void *data,
1642 const X509_ALGOR *a,
1643 const ASN1_BIT_STRING *sig,
1644 EVP_PKEY *pkey),
1645 int (*item_sign) (EVP_MD_CTX *ctx,
1646 const ASN1_ITEM *it,
1647 const void *data,
1648 X509_ALGOR *alg1,
1649 X509_ALGOR *alg2,
1650 ASN1_BIT_STRING *sig));
1651
1652 void EVP_PKEY_asn1_set_siginf(EVP_PKEY_ASN1_METHOD *ameth,
1653 int (*siginf_set) (X509_SIG_INFO *siginf,
1654 const X509_ALGOR *alg,
1655 const ASN1_STRING *sig));
1656
1657 void EVP_PKEY_asn1_set_check(EVP_PKEY_ASN1_METHOD *ameth,
1658 int (*pkey_check) (const EVP_PKEY *pk));
1659
1660 void EVP_PKEY_asn1_set_public_check(EVP_PKEY_ASN1_METHOD *ameth,
1661 int (*pkey_pub_check) (const EVP_PKEY *pk));
1662
1663 void EVP_PKEY_asn1_set_param_check(EVP_PKEY_ASN1_METHOD *ameth,
1664 int (*pkey_param_check) (const EVP_PKEY *pk));
1665
1666 void EVP_PKEY_asn1_set_set_priv_key(EVP_PKEY_ASN1_METHOD *ameth,
1667 int (*set_priv_key) (EVP_PKEY *pk,
1668 const unsigned char
1669 *priv,
1670 size_t len));
1671 void EVP_PKEY_asn1_set_set_pub_key(EVP_PKEY_ASN1_METHOD *ameth,
1672 int (*set_pub_key) (EVP_PKEY *pk,
1673 const unsigned char *pub,
1674 size_t len));
1675 void EVP_PKEY_asn1_set_get_priv_key(EVP_PKEY_ASN1_METHOD *ameth,
1676 int (*get_priv_key) (const EVP_PKEY *pk,
1677 unsigned char *priv,
1678 size_t *len));
1679 void EVP_PKEY_asn1_set_get_pub_key(EVP_PKEY_ASN1_METHOD *ameth,
1680 int (*get_pub_key) (const EVP_PKEY *pk,
1681 unsigned char *pub,
1682 size_t *len));
1683
1684 void EVP_PKEY_asn1_set_security_bits(EVP_PKEY_ASN1_METHOD *ameth,
1685 int (*pkey_security_bits) (const EVP_PKEY
1686 *pk));
1687
1688 int EVP_PKEY_CTX_get_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD **md);
1689 int EVP_PKEY_CTX_set_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
1690
1691 int EVP_PKEY_CTX_set1_id(EVP_PKEY_CTX *ctx, const void *id, int len);
1692 int EVP_PKEY_CTX_get1_id(EVP_PKEY_CTX *ctx, void *id);
1693 int EVP_PKEY_CTX_get1_id_len(EVP_PKEY_CTX *ctx, size_t *id_len);
1694
1695 int EVP_PKEY_CTX_set_kem_op(EVP_PKEY_CTX *ctx, const char *op);
1696
1697 const char *EVP_PKEY_get0_type_name(const EVP_PKEY *key);
1698
1699 # define EVP_PKEY_OP_UNDEFINED 0
1700 # define EVP_PKEY_OP_PARAMGEN (1 << 1)
1701 # define EVP_PKEY_OP_KEYGEN (1 << 2)
1702 # define EVP_PKEY_OP_FROMDATA (1 << 3)
1703 # define EVP_PKEY_OP_SIGN (1 << 4)
1704 # define EVP_PKEY_OP_VERIFY (1 << 5)
1705 # define EVP_PKEY_OP_VERIFYRECOVER (1 << 6)
1706 # define EVP_PKEY_OP_SIGNCTX (1 << 7)
1707 # define EVP_PKEY_OP_VERIFYCTX (1 << 8)
1708 # define EVP_PKEY_OP_ENCRYPT (1 << 9)
1709 # define EVP_PKEY_OP_DECRYPT (1 << 10)
1710 # define EVP_PKEY_OP_DERIVE (1 << 11)
1711 # define EVP_PKEY_OP_ENCAPSULATE (1 << 12)
1712 # define EVP_PKEY_OP_DECAPSULATE (1 << 13)
1713 # define EVP_PKEY_OP_SIGNMSG (1 << 14)
1714 # define EVP_PKEY_OP_VERIFYMSG (1 << 15)
1715
1716 # define EVP_PKEY_OP_ALL ((1 << 16) - 1)
1717
1718 # define EVP_PKEY_OP_TYPE_SIG \
1719 (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_SIGNMSG \
1720 | EVP_PKEY_OP_VERIFY | EVP_PKEY_OP_VERIFYMSG \
1721 | EVP_PKEY_OP_VERIFYRECOVER \
1722 | EVP_PKEY_OP_SIGNCTX | EVP_PKEY_OP_VERIFYCTX)
1723
1724 # define EVP_PKEY_OP_TYPE_CRYPT \
1725 (EVP_PKEY_OP_ENCRYPT | EVP_PKEY_OP_DECRYPT)
1726
1727 # define EVP_PKEY_OP_TYPE_DERIVE \
1728 (EVP_PKEY_OP_DERIVE)
1729
1730 # define EVP_PKEY_OP_TYPE_DATA \
1731 (EVP_PKEY_OP_FROMDATA)
1732
1733 # define EVP_PKEY_OP_TYPE_KEM \
1734 (EVP_PKEY_OP_ENCAPSULATE | EVP_PKEY_OP_DECAPSULATE)
1735
1736 # define EVP_PKEY_OP_TYPE_GEN \
1737 (EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN)
1738
1739 # define EVP_PKEY_OP_TYPE_NOGEN \
1740 (EVP_PKEY_OP_ALL & ~EVP_PKEY_OP_TYPE_GEN)
1741
1742 int EVP_PKEY_CTX_set_mac_key(EVP_PKEY_CTX *ctx, const unsigned char *key,
1743 int keylen);
1744
1745 # define EVP_PKEY_CTRL_MD 1
1746 # define EVP_PKEY_CTRL_PEER_KEY 2
1747 # define EVP_PKEY_CTRL_SET_MAC_KEY 6
1748 # define EVP_PKEY_CTRL_DIGESTINIT 7
1749
1750 # define EVP_PKEY_CTRL_SET_IV 8
1751 # ifndef OPENSSL_NO_DEPRECATED_3_0
1752 # define EVP_PKEY_CTRL_PKCS7_ENCRYPT 3
1753 # define EVP_PKEY_CTRL_PKCS7_DECRYPT 4
1754 # define EVP_PKEY_CTRL_PKCS7_SIGN 5
1755 # define EVP_PKEY_CTRL_CMS_ENCRYPT 9
1756 # define EVP_PKEY_CTRL_CMS_DECRYPT 10
1757 # define EVP_PKEY_CTRL_CMS_SIGN 11
1758 # endif
1759 # define EVP_PKEY_CTRL_CIPHER 12
1760 # define EVP_PKEY_CTRL_GET_MD 13
1761 # define EVP_PKEY_CTRL_SET_DIGEST_SIZE 14
1762 # define EVP_PKEY_CTRL_SET1_ID 15
1763 # define EVP_PKEY_CTRL_GET1_ID 16
1764 # define EVP_PKEY_CTRL_GET1_ID_LEN 17
1765
1766 # define EVP_PKEY_ALG_CTRL 0x1000
1767
1768 # define EVP_PKEY_FLAG_AUTOARGLEN 2
1769
1770
1771
1772 # define EVP_PKEY_FLAG_SIGCTX_CUSTOM 4
1773 # ifndef OPENSSL_NO_DEPRECATED_3_0
1774 OSSL_DEPRECATEDIN_3_0 const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type);
1775 OSSL_DEPRECATEDIN_3_0 EVP_PKEY_METHOD *EVP_PKEY_meth_new(int id, int flags);
1776 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get0_info(int *ppkey_id, int *pflags,
1777 const EVP_PKEY_METHOD *meth);
1778 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst,
1779 const EVP_PKEY_METHOD *src);
1780 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth);
1781 OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth);
1782 OSSL_DEPRECATEDIN_3_0 int EVP_PKEY_meth_remove(const EVP_PKEY_METHOD *pmeth);
1783 OSSL_DEPRECATEDIN_3_0 size_t EVP_PKEY_meth_get_count(void);
1784 OSSL_DEPRECATEDIN_3_0 const EVP_PKEY_METHOD *EVP_PKEY_meth_get0(size_t idx);
1785 # endif
1786
1787 EVP_KEYMGMT *EVP_KEYMGMT_fetch(OSSL_LIB_CTX *ctx, const char *algorithm,
1788 const char *properties);
1789 int EVP_KEYMGMT_up_ref(EVP_KEYMGMT *keymgmt);
1790 void EVP_KEYMGMT_free(EVP_KEYMGMT *keymgmt);
1791 const OSSL_PROVIDER *EVP_KEYMGMT_get0_provider(const EVP_KEYMGMT *keymgmt);
1792 const char *EVP_KEYMGMT_get0_name(const EVP_KEYMGMT *keymgmt);
1793 const char *EVP_KEYMGMT_get0_description(const EVP_KEYMGMT *keymgmt);
1794 int EVP_KEYMGMT_is_a(const EVP_KEYMGMT *keymgmt, const char *name);
1795 void EVP_KEYMGMT_do_all_provided(OSSL_LIB_CTX *libctx,
1796 void (*fn)(EVP_KEYMGMT *keymgmt, void *arg),
1797 void *arg);
1798 int EVP_KEYMGMT_names_do_all(const EVP_KEYMGMT *keymgmt,
1799 void (*fn)(const char *name, void *data),
1800 void *data);
1801 const OSSL_PARAM *EVP_KEYMGMT_gettable_params(const EVP_KEYMGMT *keymgmt);
1802 const OSSL_PARAM *EVP_KEYMGMT_settable_params(const EVP_KEYMGMT *keymgmt);
1803 const OSSL_PARAM *EVP_KEYMGMT_gen_settable_params(const EVP_KEYMGMT *keymgmt);
1804 const OSSL_PARAM *EVP_KEYMGMT_gen_gettable_params(const EVP_KEYMGMT *keymgmt);
1805
1806 EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e);
1807 EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e);
1808 EVP_PKEY_CTX *EVP_PKEY_CTX_new_from_name(OSSL_LIB_CTX *libctx,
1809 const char *name,
1810 const char *propquery);
1811 EVP_PKEY_CTX *EVP_PKEY_CTX_new_from_pkey(OSSL_LIB_CTX *libctx,
1812 EVP_PKEY *pkey, const char *propquery);
1813 EVP_PKEY_CTX *EVP_PKEY_CTX_dup(const EVP_PKEY_CTX *ctx);
1814 void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx);
1815 int EVP_PKEY_CTX_is_a(EVP_PKEY_CTX *ctx, const char *keytype);
1816
1817 int EVP_PKEY_CTX_get_params(EVP_PKEY_CTX *ctx, OSSL_PARAM *params);
1818 const OSSL_PARAM *EVP_PKEY_CTX_gettable_params(const EVP_PKEY_CTX *ctx);
1819 int EVP_PKEY_CTX_set_params(EVP_PKEY_CTX *ctx, const OSSL_PARAM *params);
1820 const OSSL_PARAM *EVP_PKEY_CTX_settable_params(const EVP_PKEY_CTX *ctx);
1821
1822 int EVP_PKEY_CTX_set_algor_params(EVP_PKEY_CTX *ctx, const X509_ALGOR *alg);
1823 int EVP_PKEY_CTX_get_algor_params(EVP_PKEY_CTX *ctx, X509_ALGOR *alg);
1824 int EVP_PKEY_CTX_get_algor(EVP_PKEY_CTX *ctx, X509_ALGOR **alg);
1825
1826 int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,
1827 int cmd, int p1, void *p2);
1828 int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,
1829 const char *value);
1830 int EVP_PKEY_CTX_ctrl_uint64(EVP_PKEY_CTX *ctx, int keytype, int optype,
1831 int cmd, uint64_t value);
1832
1833 int EVP_PKEY_CTX_str2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *str);
1834 int EVP_PKEY_CTX_hex2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *hex);
1835
1836 int EVP_PKEY_CTX_md(EVP_PKEY_CTX *ctx, int optype, int cmd, const char *md);
1837
1838 int EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx);
1839 void EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen);
1840
1841 EVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e,
1842 const unsigned char *key, int keylen);
1843 EVP_PKEY *EVP_PKEY_new_raw_private_key_ex(OSSL_LIB_CTX *libctx,
1844 const char *keytype,
1845 const char *propq,
1846 const unsigned char *priv, size_t len);
1847 EVP_PKEY *EVP_PKEY_new_raw_private_key(int type, ENGINE *e,
1848 const unsigned char *priv,
1849 size_t len);
1850 EVP_PKEY *EVP_PKEY_new_raw_public_key_ex(OSSL_LIB_CTX *libctx,
1851 const char *keytype, const char *propq,
1852 const unsigned char *pub, size_t len);
1853 EVP_PKEY *EVP_PKEY_new_raw_public_key(int type, ENGINE *e,
1854 const unsigned char *pub,
1855 size_t len);
1856 int EVP_PKEY_get_raw_private_key(const EVP_PKEY *pkey, unsigned char *priv,
1857 size_t *len);
1858 int EVP_PKEY_get_raw_public_key(const EVP_PKEY *pkey, unsigned char *pub,
1859 size_t *len);
1860
1861 # ifndef OPENSSL_NO_DEPRECATED_3_0
1862 OSSL_DEPRECATEDIN_3_0
1863 EVP_PKEY *EVP_PKEY_new_CMAC_key(ENGINE *e, const unsigned char *priv,
1864 size_t len, const EVP_CIPHER *cipher);
1865 # endif
1866
1867 void EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data);
1868 void *EVP_PKEY_CTX_get_data(const EVP_PKEY_CTX *ctx);
1869 EVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx);
1870
1871 EVP_PKEY *EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX *ctx);
1872
1873 void EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data);
1874 void *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx);
1875
1876 int EVP_PKEY_CTX_set_signature(EVP_PKEY_CTX *pctx,
1877 const unsigned char *sig, size_t siglen);
1878
1879 void EVP_SIGNATURE_free(EVP_SIGNATURE *signature);
1880 int EVP_SIGNATURE_up_ref(EVP_SIGNATURE *signature);
1881 OSSL_PROVIDER *EVP_SIGNATURE_get0_provider(const EVP_SIGNATURE *signature);
1882 EVP_SIGNATURE *EVP_SIGNATURE_fetch(OSSL_LIB_CTX *ctx, const char *algorithm,
1883 const char *properties);
1884 int EVP_SIGNATURE_is_a(const EVP_SIGNATURE *signature, const char *name);
1885 const char *EVP_SIGNATURE_get0_name(const EVP_SIGNATURE *signature);
1886 const char *EVP_SIGNATURE_get0_description(const EVP_SIGNATURE *signature);
1887 void EVP_SIGNATURE_do_all_provided(OSSL_LIB_CTX *libctx,
1888 void (*fn)(EVP_SIGNATURE *signature,
1889 void *data),
1890 void *data);
1891 int EVP_SIGNATURE_names_do_all(const EVP_SIGNATURE *signature,
1892 void (*fn)(const char *name, void *data),
1893 void *data);
1894 const OSSL_PARAM *EVP_SIGNATURE_gettable_ctx_params(const EVP_SIGNATURE *sig);
1895 const OSSL_PARAM *EVP_SIGNATURE_settable_ctx_params(const EVP_SIGNATURE *sig);
1896
1897 void EVP_ASYM_CIPHER_free(EVP_ASYM_CIPHER *cipher);
1898 int EVP_ASYM_CIPHER_up_ref(EVP_ASYM_CIPHER *cipher);
1899 OSSL_PROVIDER *EVP_ASYM_CIPHER_get0_provider(const EVP_ASYM_CIPHER *cipher);
1900 EVP_ASYM_CIPHER *EVP_ASYM_CIPHER_fetch(OSSL_LIB_CTX *ctx, const char *algorithm,
1901 const char *properties);
1902 int EVP_ASYM_CIPHER_is_a(const EVP_ASYM_CIPHER *cipher, const char *name);
1903 const char *EVP_ASYM_CIPHER_get0_name(const EVP_ASYM_CIPHER *cipher);
1904 const char *EVP_ASYM_CIPHER_get0_description(const EVP_ASYM_CIPHER *cipher);
1905 void EVP_ASYM_CIPHER_do_all_provided(OSSL_LIB_CTX *libctx,
1906 void (*fn)(EVP_ASYM_CIPHER *cipher,
1907 void *arg),
1908 void *arg);
1909 int EVP_ASYM_CIPHER_names_do_all(const EVP_ASYM_CIPHER *cipher,
1910 void (*fn)(const char *name, void *data),
1911 void *data);
1912 const OSSL_PARAM *EVP_ASYM_CIPHER_gettable_ctx_params(const EVP_ASYM_CIPHER *ciph);
1913 const OSSL_PARAM *EVP_ASYM_CIPHER_settable_ctx_params(const EVP_ASYM_CIPHER *ciph);
1914
1915 void EVP_KEM_free(EVP_KEM *wrap);
1916 int EVP_KEM_up_ref(EVP_KEM *wrap);
1917 OSSL_PROVIDER *EVP_KEM_get0_provider(const EVP_KEM *wrap);
1918 EVP_KEM *EVP_KEM_fetch(OSSL_LIB_CTX *ctx, const char *algorithm,
1919 const char *properties);
1920 int EVP_KEM_is_a(const EVP_KEM *wrap, const char *name);
1921 const char *EVP_KEM_get0_name(const EVP_KEM *wrap);
1922 const char *EVP_KEM_get0_description(const EVP_KEM *wrap);
1923 void EVP_KEM_do_all_provided(OSSL_LIB_CTX *libctx,
1924 void (*fn)(EVP_KEM *wrap, void *arg), void *arg);
1925 int EVP_KEM_names_do_all(const EVP_KEM *wrap,
1926 void (*fn)(const char *name, void *data), void *data);
1927 const OSSL_PARAM *EVP_KEM_gettable_ctx_params(const EVP_KEM *kem);
1928 const OSSL_PARAM *EVP_KEM_settable_ctx_params(const EVP_KEM *kem);
1929
1930 int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx);
1931 int EVP_PKEY_sign_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]);
1932 int EVP_PKEY_sign_init_ex2(EVP_PKEY_CTX *ctx,
1933 EVP_SIGNATURE *algo, const OSSL_PARAM params[]);
1934 int EVP_PKEY_sign(EVP_PKEY_CTX *ctx,
1935 unsigned char *sig, size_t *siglen,
1936 const unsigned char *tbs, size_t tbslen);
1937 int EVP_PKEY_sign_message_init(EVP_PKEY_CTX *ctx,
1938 EVP_SIGNATURE *algo, const OSSL_PARAM params[]);
1939 int EVP_PKEY_sign_message_update(EVP_PKEY_CTX *ctx,
1940 const unsigned char *in, size_t inlen);
1941 int EVP_PKEY_sign_message_final(EVP_PKEY_CTX *ctx,
1942 unsigned char *sig, size_t *siglen);
1943 int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx);
1944 int EVP_PKEY_verify_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]);
1945 int EVP_PKEY_verify_init_ex2(EVP_PKEY_CTX *ctx,
1946 EVP_SIGNATURE *algo, const OSSL_PARAM params[]);
1947 int EVP_PKEY_verify(EVP_PKEY_CTX *ctx,
1948 const unsigned char *sig, size_t siglen,
1949 const unsigned char *tbs, size_t tbslen);
1950 int EVP_PKEY_verify_message_init(EVP_PKEY_CTX *ctx,
1951 EVP_SIGNATURE *algo, const OSSL_PARAM params[]);
1952 int EVP_PKEY_verify_message_update(EVP_PKEY_CTX *ctx,
1953 const unsigned char *in, size_t inlen);
1954 int EVP_PKEY_verify_message_final(EVP_PKEY_CTX *ctx);
1955 int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx);
1956 int EVP_PKEY_verify_recover_init_ex(EVP_PKEY_CTX *ctx,
1957 const OSSL_PARAM params[]);
1958 int EVP_PKEY_verify_recover_init_ex2(EVP_PKEY_CTX *ctx,
1959 EVP_SIGNATURE *algo,
1960 const OSSL_PARAM params[]);
1961 int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx,
1962 unsigned char *rout, size_t *routlen,
1963 const unsigned char *sig, size_t siglen);
1964 int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx);
1965 int EVP_PKEY_encrypt_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]);
1966 int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx,
1967 unsigned char *out, size_t *outlen,
1968 const unsigned char *in, size_t inlen);
1969 int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx);
1970 int EVP_PKEY_decrypt_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]);
1971 int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx,
1972 unsigned char *out, size_t *outlen,
1973 const unsigned char *in, size_t inlen);
1974
1975 int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx);
1976 int EVP_PKEY_derive_init_ex(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]);
1977 int EVP_PKEY_derive_set_peer_ex(EVP_PKEY_CTX *ctx, EVP_PKEY *peer,
1978 int validate_peer);
1979 int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer);
1980 int EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);
1981
1982 int EVP_PKEY_encapsulate_init(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]);
1983 int EVP_PKEY_auth_encapsulate_init(EVP_PKEY_CTX *ctx, EVP_PKEY *authpriv,
1984 const OSSL_PARAM params[]);
1985 int EVP_PKEY_encapsulate(EVP_PKEY_CTX *ctx,
1986 unsigned char *wrappedkey, size_t *wrappedkeylen,
1987 unsigned char *genkey, size_t *genkeylen);
1988 int EVP_PKEY_decapsulate_init(EVP_PKEY_CTX *ctx, const OSSL_PARAM params[]);
1989 int EVP_PKEY_auth_decapsulate_init(EVP_PKEY_CTX *ctx, EVP_PKEY *authpub,
1990 const OSSL_PARAM params[]);
1991 int EVP_PKEY_decapsulate(EVP_PKEY_CTX *ctx,
1992 unsigned char *unwrapped, size_t *unwrappedlen,
1993 const unsigned char *wrapped, size_t wrappedlen);
1994 typedef int EVP_PKEY_gen_cb(EVP_PKEY_CTX *ctx);
1995
1996 int EVP_PKEY_fromdata_init(EVP_PKEY_CTX *ctx);
1997 int EVP_PKEY_fromdata(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey, int selection,
1998 OSSL_PARAM param[]);
1999 const OSSL_PARAM *EVP_PKEY_fromdata_settable(EVP_PKEY_CTX *ctx, int selection);
2000
2001 int EVP_PKEY_todata(const EVP_PKEY *pkey, int selection, OSSL_PARAM **params);
2002 int EVP_PKEY_export(const EVP_PKEY *pkey, int selection,
2003 OSSL_CALLBACK *export_cb, void *export_cbarg);
2004
2005 const OSSL_PARAM *EVP_PKEY_gettable_params(const EVP_PKEY *pkey);
2006 int EVP_PKEY_get_params(const EVP_PKEY *pkey, OSSL_PARAM params[]);
2007 int EVP_PKEY_get_int_param(const EVP_PKEY *pkey, const char *key_name,
2008 int *out);
2009 int EVP_PKEY_get_size_t_param(const EVP_PKEY *pkey, const char *key_name,
2010 size_t *out);
2011 int EVP_PKEY_get_bn_param(const EVP_PKEY *pkey, const char *key_name,
2012 BIGNUM **bn);
2013 int EVP_PKEY_get_utf8_string_param(const EVP_PKEY *pkey, const char *key_name,
2014 char *str, size_t max_buf_sz, size_t *out_sz);
2015 int EVP_PKEY_get_octet_string_param(const EVP_PKEY *pkey, const char *key_name,
2016 unsigned char *buf, size_t max_buf_sz,
2017 size_t *out_sz);
2018
2019 const OSSL_PARAM *EVP_PKEY_settable_params(const EVP_PKEY *pkey);
2020 int EVP_PKEY_set_params(EVP_PKEY *pkey, OSSL_PARAM params[]);
2021 int EVP_PKEY_set_int_param(EVP_PKEY *pkey, const char *key_name, int in);
2022 int EVP_PKEY_set_size_t_param(EVP_PKEY *pkey, const char *key_name, size_t in);
2023 int EVP_PKEY_set_bn_param(EVP_PKEY *pkey, const char *key_name,
2024 const BIGNUM *bn);
2025 int EVP_PKEY_set_utf8_string_param(EVP_PKEY *pkey, const char *key_name,
2026 const char *str);
2027 int EVP_PKEY_set_octet_string_param(EVP_PKEY *pkey, const char *key_name,
2028 const unsigned char *buf, size_t bsize);
2029
2030 int EVP_PKEY_get_ec_point_conv_form(const EVP_PKEY *pkey);
2031 int EVP_PKEY_get_field_type(const EVP_PKEY *pkey);
2032
2033 EVP_PKEY *EVP_PKEY_Q_keygen(OSSL_LIB_CTX *libctx, const char *propq,
2034 const char *type, ...);
2035 int EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx);
2036 int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);
2037 int EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx);
2038 int EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);
2039 int EVP_PKEY_generate(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey);
2040 int EVP_PKEY_check(EVP_PKEY_CTX *ctx);
2041 int EVP_PKEY_public_check(EVP_PKEY_CTX *ctx);
2042 int EVP_PKEY_public_check_quick(EVP_PKEY_CTX *ctx);
2043 int EVP_PKEY_param_check(EVP_PKEY_CTX *ctx);
2044 int EVP_PKEY_param_check_quick(EVP_PKEY_CTX *ctx);
2045 int EVP_PKEY_private_check(EVP_PKEY_CTX *ctx);
2046 int EVP_PKEY_pairwise_check(EVP_PKEY_CTX *ctx);
2047
2048 # define EVP_PKEY_get_ex_new_index(l, p, newf, dupf, freef) \
2049 CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EVP_PKEY, l, p, newf, dupf, freef)
2050 int EVP_PKEY_set_ex_data(EVP_PKEY *key, int idx, void *arg);
2051 void *EVP_PKEY_get_ex_data(const EVP_PKEY *key, int idx);
2052
2053 void EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb);
2054 EVP_PKEY_gen_cb *EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx);
2055
2056 int EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx);
2057 # ifndef OPENSSL_NO_DEPRECATED_3_0
2058 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth,
2059 int (*init) (EVP_PKEY_CTX *ctx));
2060 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_copy
2061 (EVP_PKEY_METHOD *pmeth, int (*copy) (EVP_PKEY_CTX *dst,
2062 const EVP_PKEY_CTX *src));
2063 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_cleanup
2064 (EVP_PKEY_METHOD *pmeth, void (*cleanup) (EVP_PKEY_CTX *ctx));
2065 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_paramgen
2066 (EVP_PKEY_METHOD *pmeth, int (*paramgen_init) (EVP_PKEY_CTX *ctx),
2067 int (*paramgen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey));
2068 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_keygen
2069 (EVP_PKEY_METHOD *pmeth, int (*keygen_init) (EVP_PKEY_CTX *ctx),
2070 int (*keygen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey));
2071 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_sign
2072 (EVP_PKEY_METHOD *pmeth, int (*sign_init) (EVP_PKEY_CTX *ctx),
2073 int (*sign) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
2074 const unsigned char *tbs, size_t tbslen));
2075 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_verify
2076 (EVP_PKEY_METHOD *pmeth, int (*verify_init) (EVP_PKEY_CTX *ctx),
2077 int (*verify) (EVP_PKEY_CTX *ctx, const unsigned char *sig, size_t siglen,
2078 const unsigned char *tbs, size_t tbslen));
2079 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_verify_recover
2080 (EVP_PKEY_METHOD *pmeth, int (*verify_recover_init) (EVP_PKEY_CTX *ctx),
2081 int (*verify_recover) (EVP_PKEY_CTX *ctx, unsigned char *sig,
2082 size_t *siglen, const unsigned char *tbs,
2083 size_t tbslen));
2084 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_signctx
2085 (EVP_PKEY_METHOD *pmeth, int (*signctx_init) (EVP_PKEY_CTX *ctx,
2086 EVP_MD_CTX *mctx),
2087 int (*signctx) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
2088 EVP_MD_CTX *mctx));
2089 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_verifyctx
2090 (EVP_PKEY_METHOD *pmeth, int (*verifyctx_init) (EVP_PKEY_CTX *ctx,
2091 EVP_MD_CTX *mctx),
2092 int (*verifyctx) (EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen,
2093 EVP_MD_CTX *mctx));
2094 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_encrypt
2095 (EVP_PKEY_METHOD *pmeth, int (*encrypt_init) (EVP_PKEY_CTX *ctx),
2096 int (*encryptfn) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
2097 const unsigned char *in, size_t inlen));
2098 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_decrypt
2099 (EVP_PKEY_METHOD *pmeth, int (*decrypt_init) (EVP_PKEY_CTX *ctx),
2100 int (*decrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
2101 const unsigned char *in, size_t inlen));
2102 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_derive
2103 (EVP_PKEY_METHOD *pmeth, int (*derive_init) (EVP_PKEY_CTX *ctx),
2104 int (*derive) (EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen));
2105 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_ctrl
2106 (EVP_PKEY_METHOD *pmeth, int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1,
2107 void *p2),
2108 int (*ctrl_str) (EVP_PKEY_CTX *ctx, const char *type, const char *value));
2109 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_digestsign
2110 (EVP_PKEY_METHOD *pmeth,
2111 int (*digestsign) (EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen,
2112 const unsigned char *tbs, size_t tbslen));
2113 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_digestverify
2114 (EVP_PKEY_METHOD *pmeth,
2115 int (*digestverify) (EVP_MD_CTX *ctx, const unsigned char *sig,
2116 size_t siglen, const unsigned char *tbs,
2117 size_t tbslen));
2118 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_check
2119 (EVP_PKEY_METHOD *pmeth, int (*check) (EVP_PKEY *pkey));
2120 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_public_check
2121 (EVP_PKEY_METHOD *pmeth, int (*check) (EVP_PKEY *pkey));
2122 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_param_check
2123 (EVP_PKEY_METHOD *pmeth, int (*check) (EVP_PKEY *pkey));
2124 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_set_digest_custom
2125 (EVP_PKEY_METHOD *pmeth, int (*digest_custom) (EVP_PKEY_CTX *ctx,
2126 EVP_MD_CTX *mctx));
2127 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_init
2128 (const EVP_PKEY_METHOD *pmeth, int (**pinit) (EVP_PKEY_CTX *ctx));
2129 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_copy
2130 (const EVP_PKEY_METHOD *pmeth, int (**pcopy) (EVP_PKEY_CTX *dst,
2131 const EVP_PKEY_CTX *src));
2132 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_cleanup
2133 (const EVP_PKEY_METHOD *pmeth, void (**pcleanup) (EVP_PKEY_CTX *ctx));
2134 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_paramgen
2135 (const EVP_PKEY_METHOD *pmeth, int (**pparamgen_init) (EVP_PKEY_CTX *ctx),
2136 int (**pparamgen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey));
2137 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_keygen
2138 (const EVP_PKEY_METHOD *pmeth, int (**pkeygen_init) (EVP_PKEY_CTX *ctx),
2139 int (**pkeygen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey));
2140 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_sign
2141 (const EVP_PKEY_METHOD *pmeth, int (**psign_init) (EVP_PKEY_CTX *ctx),
2142 int (**psign) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
2143 const unsigned char *tbs, size_t tbslen));
2144 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_verify
2145 (const EVP_PKEY_METHOD *pmeth, int (**pverify_init) (EVP_PKEY_CTX *ctx),
2146 int (**pverify) (EVP_PKEY_CTX *ctx, const unsigned char *sig,
2147 size_t siglen, const unsigned char *tbs, size_t tbslen));
2148 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_verify_recover
2149 (const EVP_PKEY_METHOD *pmeth,
2150 int (**pverify_recover_init) (EVP_PKEY_CTX *ctx),
2151 int (**pverify_recover) (EVP_PKEY_CTX *ctx, unsigned char *sig,
2152 size_t *siglen, const unsigned char *tbs,
2153 size_t tbslen));
2154 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_signctx
2155 (const EVP_PKEY_METHOD *pmeth,
2156 int (**psignctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx),
2157 int (**psignctx) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
2158 EVP_MD_CTX *mctx));
2159 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_verifyctx
2160 (const EVP_PKEY_METHOD *pmeth,
2161 int (**pverifyctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx),
2162 int (**pverifyctx) (EVP_PKEY_CTX *ctx, const unsigned char *sig,
2163 int siglen, EVP_MD_CTX *mctx));
2164 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_encrypt
2165 (const EVP_PKEY_METHOD *pmeth, int (**pencrypt_init) (EVP_PKEY_CTX *ctx),
2166 int (**pencryptfn) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
2167 const unsigned char *in, size_t inlen));
2168 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_decrypt
2169 (const EVP_PKEY_METHOD *pmeth, int (**pdecrypt_init) (EVP_PKEY_CTX *ctx),
2170 int (**pdecrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
2171 const unsigned char *in, size_t inlen));
2172 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_derive
2173 (const EVP_PKEY_METHOD *pmeth, int (**pderive_init) (EVP_PKEY_CTX *ctx),
2174 int (**pderive) (EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen));
2175 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_ctrl
2176 (const EVP_PKEY_METHOD *pmeth,
2177 int (**pctrl) (EVP_PKEY_CTX *ctx, int type, int p1, void *p2),
2178 int (**pctrl_str) (EVP_PKEY_CTX *ctx, const char *type,
2179 const char *value));
2180 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_digestsign
2181 (const EVP_PKEY_METHOD *pmeth,
2182 int (**digestsign) (EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen,
2183 const unsigned char *tbs, size_t tbslen));
2184 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_digestverify
2185 (const EVP_PKEY_METHOD *pmeth,
2186 int (**digestverify) (EVP_MD_CTX *ctx, const unsigned char *sig,
2187 size_t siglen, const unsigned char *tbs,
2188 size_t tbslen));
2189 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_check
2190 (const EVP_PKEY_METHOD *pmeth, int (**pcheck) (EVP_PKEY *pkey));
2191 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_public_check
2192 (const EVP_PKEY_METHOD *pmeth, int (**pcheck) (EVP_PKEY *pkey));
2193 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_param_check
2194 (const EVP_PKEY_METHOD *pmeth, int (**pcheck) (EVP_PKEY *pkey));
2195 OSSL_DEPRECATEDIN_3_0 void EVP_PKEY_meth_get_digest_custom
2196 (const EVP_PKEY_METHOD *pmeth,
2197 int (**pdigest_custom) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx));
2198 # endif
2199
2200 void EVP_KEYEXCH_free(EVP_KEYEXCH *exchange);
2201 int EVP_KEYEXCH_up_ref(EVP_KEYEXCH *exchange);
2202 EVP_KEYEXCH *EVP_KEYEXCH_fetch(OSSL_LIB_CTX *ctx, const char *algorithm,
2203 const char *properties);
2204 OSSL_PROVIDER *EVP_KEYEXCH_get0_provider(const EVP_KEYEXCH *exchange);
2205 int EVP_KEYEXCH_is_a(const EVP_KEYEXCH *keyexch, const char *name);
2206 const char *EVP_KEYEXCH_get0_name(const EVP_KEYEXCH *keyexch);
2207 const char *EVP_KEYEXCH_get0_description(const EVP_KEYEXCH *keyexch);
2208 void EVP_KEYEXCH_do_all_provided(OSSL_LIB_CTX *libctx,
2209 void (*fn)(EVP_KEYEXCH *keyexch, void *data),
2210 void *data);
2211 int EVP_KEYEXCH_names_do_all(const EVP_KEYEXCH *keyexch,
2212 void (*fn)(const char *name, void *data),
2213 void *data);
2214 const OSSL_PARAM *EVP_KEYEXCH_gettable_ctx_params(const EVP_KEYEXCH *keyexch);
2215 const OSSL_PARAM *EVP_KEYEXCH_settable_ctx_params(const EVP_KEYEXCH *keyexch);
2216
2217 void EVP_add_alg_module(void);
2218
2219 int EVP_PKEY_CTX_set_group_name(EVP_PKEY_CTX *ctx, const char *name);
2220 int EVP_PKEY_CTX_get_group_name(EVP_PKEY_CTX *ctx, char *name, size_t namelen);
2221 int EVP_PKEY_get_group_name(const EVP_PKEY *pkey, char *name, size_t name_sz,
2222 size_t *gname_len);
2223
2224 OSSL_LIB_CTX *EVP_PKEY_CTX_get0_libctx(EVP_PKEY_CTX *ctx);
2225 const char *EVP_PKEY_CTX_get0_propq(const EVP_PKEY_CTX *ctx);
2226 const OSSL_PROVIDER *EVP_PKEY_CTX_get0_provider(const EVP_PKEY_CTX *ctx);
2227
2228 # ifdef __cplusplus
2229 }
2230 # endif
2231 #endif