1 /* 2 * Copyright 2019-2024 The OpenSSL Project Authors. All Rights Reserved. 3 * 4 * Licensed under the Apache License 2.0 (the "License"). You may not use 5 * this file except in compliance with the License. You can obtain a copy 6 * in the file LICENSE in the source distribution or at 7 * https://www.openssl.org/source/license.html 8 */ 9 10 #ifndef OPENSSL_CORE_NUMBERS_H 11 # define OPENSSL_CORE_NUMBERS_H 12 # pragma once 13 14 # include <stdarg.h> 15 # include <openssl/core.h> 16 # include <openssl/indicator.h> 17 18 # ifdef __cplusplus 19 extern "C" { 20 # endif 21 22 /*- 23 * Identities 24 * ---------- 25 * 26 * All series start with 1, to allow 0 to be an array terminator. 27 * For any FUNC identity, we also provide a function signature typedef 28 * and a static inline function to extract a function pointer from a 29 * OSSL_DISPATCH element in a type safe manner. 30 * 31 * Names: 32 * for any function base name 'foo' (uppercase form 'FOO'), we will have 33 * the following: 34 * - a macro for the identity with the name OSSL_FUNC_'FOO' or derivatives 35 * thereof (to be specified further down) 36 * - a function signature typedef with the name OSSL_FUNC_'foo'_fn 37 * - a function pointer extractor function with the name OSSL_FUNC_'foo' 38 */ 39 40 /* 41 * Helper macro to create the function signature typedef and the extractor 42 * |type| is the return-type of the function, |name| is the name of the 43 * function to fetch, and |args| is a parenthesized list of parameters 44 * for the function (that is, it is |name|'s function signature). 45 * Note: This is considered a "reserved" internal macro. Applications should 46 * not use this or assume its existence. 47 */ 48 #define OSSL_CORE_MAKE_FUNC(type,name,args) \ 49 typedef type (OSSL_FUNC_##name##_fn)args; \ 50 static ossl_unused ossl_inline \ 51 OSSL_FUNC_##name##_fn *OSSL_FUNC_##name(const OSSL_DISPATCH *opf) \ 52 { \ 53 return (OSSL_FUNC_##name##_fn *)opf->function; \ 54 } 55 56 /* 57 * Core function identities, for the two OSSL_DISPATCH tables being passed 58 * in the OSSL_provider_init call. 59 * 60 * 0 serves as a marker for the end of the OSSL_DISPATCH array, and must 61 * therefore NEVER be used as a function identity. 62 */ 63 /* Functions provided by the Core to the provider, reserved numbers 1-1023 */ 64 # define OSSL_FUNC_CORE_GETTABLE_PARAMS 1 65 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, 66 core_gettable_params,(const OSSL_CORE_HANDLE *prov)) 67 # define OSSL_FUNC_CORE_GET_PARAMS 2 68 OSSL_CORE_MAKE_FUNC(int,core_get_params,(const OSSL_CORE_HANDLE *prov, 69 OSSL_PARAM params[])) 70 # define OSSL_FUNC_CORE_THREAD_START 3 71 OSSL_CORE_MAKE_FUNC(int,core_thread_start,(const OSSL_CORE_HANDLE *prov, 72 OSSL_thread_stop_handler_fn handfn, 73 void *arg)) 74 # define OSSL_FUNC_CORE_GET_LIBCTX 4 75 OSSL_CORE_MAKE_FUNC(OPENSSL_CORE_CTX *,core_get_libctx, 76 (const OSSL_CORE_HANDLE *prov)) 77 # define OSSL_FUNC_CORE_NEW_ERROR 5 78 OSSL_CORE_MAKE_FUNC(void,core_new_error,(const OSSL_CORE_HANDLE *prov)) 79 # define OSSL_FUNC_CORE_SET_ERROR_DEBUG 6 80 OSSL_CORE_MAKE_FUNC(void,core_set_error_debug, 81 (const OSSL_CORE_HANDLE *prov, 82 const char *file, int line, const char *func)) 83 # define OSSL_FUNC_CORE_VSET_ERROR 7 84 OSSL_CORE_MAKE_FUNC(void,core_vset_error, 85 (const OSSL_CORE_HANDLE *prov, 86 uint32_t reason, const char *fmt, va_list args)) 87 # define OSSL_FUNC_CORE_SET_ERROR_MARK 8 88 OSSL_CORE_MAKE_FUNC(int, core_set_error_mark, (const OSSL_CORE_HANDLE *prov)) 89 # define OSSL_FUNC_CORE_CLEAR_LAST_ERROR_MARK 9 90 OSSL_CORE_MAKE_FUNC(int, core_clear_last_error_mark, 91 (const OSSL_CORE_HANDLE *prov)) 92 # define OSSL_FUNC_CORE_POP_ERROR_TO_MARK 10 93 OSSL_CORE_MAKE_FUNC(int, core_pop_error_to_mark, (const OSSL_CORE_HANDLE *prov)) 94 95 96 /* Functions to access the OBJ database */ 97 98 #define OSSL_FUNC_CORE_OBJ_ADD_SIGID 11 99 #define OSSL_FUNC_CORE_OBJ_CREATE 12 100 101 OSSL_CORE_MAKE_FUNC(int, core_obj_add_sigid, 102 (const OSSL_CORE_HANDLE *prov, const char *sign_name, 103 const char *digest_name, const char *pkey_name)) 104 OSSL_CORE_MAKE_FUNC(int, core_obj_create, 105 (const OSSL_CORE_HANDLE *prov, const char *oid, 106 const char *sn, const char *ln)) 107 108 /* Memory allocation, freeing, clearing. */ 109 #define OSSL_FUNC_CRYPTO_MALLOC 20 110 OSSL_CORE_MAKE_FUNC(void *, 111 CRYPTO_malloc, (size_t num, const char *file, int line)) 112 #define OSSL_FUNC_CRYPTO_ZALLOC 21 113 OSSL_CORE_MAKE_FUNC(void *, 114 CRYPTO_zalloc, (size_t num, const char *file, int line)) 115 #define OSSL_FUNC_CRYPTO_FREE 22 116 OSSL_CORE_MAKE_FUNC(void, 117 CRYPTO_free, (void *ptr, const char *file, int line)) 118 #define OSSL_FUNC_CRYPTO_CLEAR_FREE 23 119 OSSL_CORE_MAKE_FUNC(void, 120 CRYPTO_clear_free, (void *ptr, size_t num, const char *file, int line)) 121 #define OSSL_FUNC_CRYPTO_REALLOC 24 122 OSSL_CORE_MAKE_FUNC(void *, 123 CRYPTO_realloc, (void *addr, size_t num, const char *file, int line)) 124 #define OSSL_FUNC_CRYPTO_CLEAR_REALLOC 25 125 OSSL_CORE_MAKE_FUNC(void *, 126 CRYPTO_clear_realloc, (void *addr, size_t old_num, size_t num, 127 const char *file, int line)) 128 #define OSSL_FUNC_CRYPTO_SECURE_MALLOC 26 129 OSSL_CORE_MAKE_FUNC(void *, 130 CRYPTO_secure_malloc, (size_t num, const char *file, int line)) 131 #define OSSL_FUNC_CRYPTO_SECURE_ZALLOC 27 132 OSSL_CORE_MAKE_FUNC(void *, 133 CRYPTO_secure_zalloc, (size_t num, const char *file, int line)) 134 #define OSSL_FUNC_CRYPTO_SECURE_FREE 28 135 OSSL_CORE_MAKE_FUNC(void, 136 CRYPTO_secure_free, (void *ptr, const char *file, int line)) 137 #define OSSL_FUNC_CRYPTO_SECURE_CLEAR_FREE 29 138 OSSL_CORE_MAKE_FUNC(void, 139 CRYPTO_secure_clear_free, (void *ptr, size_t num, const char *file, 140 int line)) 141 #define OSSL_FUNC_CRYPTO_SECURE_ALLOCATED 30 142 OSSL_CORE_MAKE_FUNC(int, 143 CRYPTO_secure_allocated, (const void *ptr)) 144 #define OSSL_FUNC_OPENSSL_CLEANSE 31 145 OSSL_CORE_MAKE_FUNC(void, 146 OPENSSL_cleanse, (void *ptr, size_t len)) 147 148 /* Bio functions provided by the core */ 149 #define OSSL_FUNC_BIO_NEW_FILE 40 150 #define OSSL_FUNC_BIO_NEW_MEMBUF 41 151 #define OSSL_FUNC_BIO_READ_EX 42 152 #define OSSL_FUNC_BIO_WRITE_EX 43 153 #define OSSL_FUNC_BIO_UP_REF 44 154 #define OSSL_FUNC_BIO_FREE 45 155 #define OSSL_FUNC_BIO_VPRINTF 46 156 #define OSSL_FUNC_BIO_VSNPRINTF 47 157 #define OSSL_FUNC_BIO_PUTS 48 158 #define OSSL_FUNC_BIO_GETS 49 159 #define OSSL_FUNC_BIO_CTRL 50 160 161 162 OSSL_CORE_MAKE_FUNC(OSSL_CORE_BIO *, BIO_new_file, (const char *filename, 163 const char *mode)) 164 OSSL_CORE_MAKE_FUNC(OSSL_CORE_BIO *, BIO_new_membuf, (const void *buf, int len)) 165 OSSL_CORE_MAKE_FUNC(int, BIO_read_ex, (OSSL_CORE_BIO *bio, void *data, 166 size_t data_len, size_t *bytes_read)) 167 OSSL_CORE_MAKE_FUNC(int, BIO_write_ex, (OSSL_CORE_BIO *bio, const void *data, 168 size_t data_len, size_t *written)) 169 OSSL_CORE_MAKE_FUNC(int, BIO_gets, (OSSL_CORE_BIO *bio, char *buf, int size)) 170 OSSL_CORE_MAKE_FUNC(int, BIO_puts, (OSSL_CORE_BIO *bio, const char *str)) 171 OSSL_CORE_MAKE_FUNC(int, BIO_up_ref, (OSSL_CORE_BIO *bio)) 172 OSSL_CORE_MAKE_FUNC(int, BIO_free, (OSSL_CORE_BIO *bio)) 173 OSSL_CORE_MAKE_FUNC(int, BIO_vprintf, (OSSL_CORE_BIO *bio, const char *format, 174 va_list args)) 175 OSSL_CORE_MAKE_FUNC(int, BIO_vsnprintf, 176 (char *buf, size_t n, const char *fmt, va_list args)) 177 OSSL_CORE_MAKE_FUNC(int, BIO_ctrl, (OSSL_CORE_BIO *bio, 178 int cmd, long num, void *ptr)) 179 180 /* New seeding functions prototypes with the 101-104 series */ 181 #define OSSL_FUNC_CLEANUP_USER_ENTROPY 96 182 #define OSSL_FUNC_CLEANUP_USER_NONCE 97 183 #define OSSL_FUNC_GET_USER_ENTROPY 98 184 #define OSSL_FUNC_GET_USER_NONCE 99 185 186 #define OSSL_FUNC_INDICATOR_CB 95 187 OSSL_CORE_MAKE_FUNC(void, indicator_cb, (OPENSSL_CORE_CTX *ctx, 188 OSSL_INDICATOR_CALLBACK **cb)) 189 #define OSSL_FUNC_SELF_TEST_CB 100 190 OSSL_CORE_MAKE_FUNC(void, self_test_cb, (OPENSSL_CORE_CTX *ctx, OSSL_CALLBACK **cb, 191 void **cbarg)) 192 193 /* Functions to get seed material from the operating system */ 194 #define OSSL_FUNC_GET_ENTROPY 101 195 #define OSSL_FUNC_CLEANUP_ENTROPY 102 196 #define OSSL_FUNC_GET_NONCE 103 197 #define OSSL_FUNC_CLEANUP_NONCE 104 198 OSSL_CORE_MAKE_FUNC(size_t, get_entropy, (const OSSL_CORE_HANDLE *handle, 199 unsigned char **pout, int entropy, 200 size_t min_len, size_t max_len)) 201 OSSL_CORE_MAKE_FUNC(size_t, get_user_entropy, (const OSSL_CORE_HANDLE *handle, 202 unsigned char **pout, int entropy, 203 size_t min_len, size_t max_len)) 204 OSSL_CORE_MAKE_FUNC(void, cleanup_entropy, (const OSSL_CORE_HANDLE *handle, 205 unsigned char *buf, size_t len)) 206 OSSL_CORE_MAKE_FUNC(void, cleanup_user_entropy, (const OSSL_CORE_HANDLE *handle, 207 unsigned char *buf, size_t len)) 208 OSSL_CORE_MAKE_FUNC(size_t, get_nonce, (const OSSL_CORE_HANDLE *handle, 209 unsigned char **pout, size_t min_len, 210 size_t max_len, const void *salt, 211 size_t salt_len)) 212 OSSL_CORE_MAKE_FUNC(size_t, get_user_nonce, (const OSSL_CORE_HANDLE *handle, 213 unsigned char **pout, size_t min_len, 214 size_t max_len, const void *salt, 215 size_t salt_len)) 216 OSSL_CORE_MAKE_FUNC(void, cleanup_nonce, (const OSSL_CORE_HANDLE *handle, 217 unsigned char *buf, size_t len)) 218 OSSL_CORE_MAKE_FUNC(void, cleanup_user_nonce, (const OSSL_CORE_HANDLE *handle, 219 unsigned char *buf, size_t len)) 220 221 /* Functions to access the core's providers */ 222 #define OSSL_FUNC_PROVIDER_REGISTER_CHILD_CB 105 223 #define OSSL_FUNC_PROVIDER_DEREGISTER_CHILD_CB 106 224 #define OSSL_FUNC_PROVIDER_NAME 107 225 #define OSSL_FUNC_PROVIDER_GET0_PROVIDER_CTX 108 226 #define OSSL_FUNC_PROVIDER_GET0_DISPATCH 109 227 #define OSSL_FUNC_PROVIDER_UP_REF 110 228 #define OSSL_FUNC_PROVIDER_FREE 111 229 230 OSSL_CORE_MAKE_FUNC(int, provider_register_child_cb, 231 (const OSSL_CORE_HANDLE *handle, 232 int (*create_cb)(const OSSL_CORE_HANDLE *provider, void *cbdata), 233 int (*remove_cb)(const OSSL_CORE_HANDLE *provider, void *cbdata), 234 int (*global_props_cb)(const char *props, void *cbdata), 235 void *cbdata)) 236 OSSL_CORE_MAKE_FUNC(void, provider_deregister_child_cb, 237 (const OSSL_CORE_HANDLE *handle)) 238 OSSL_CORE_MAKE_FUNC(const char *, provider_name, 239 (const OSSL_CORE_HANDLE *prov)) 240 OSSL_CORE_MAKE_FUNC(void *, provider_get0_provider_ctx, 241 (const OSSL_CORE_HANDLE *prov)) 242 OSSL_CORE_MAKE_FUNC(const OSSL_DISPATCH *, provider_get0_dispatch, 243 (const OSSL_CORE_HANDLE *prov)) 244 OSSL_CORE_MAKE_FUNC(int, provider_up_ref, 245 (const OSSL_CORE_HANDLE *prov, int activate)) 246 OSSL_CORE_MAKE_FUNC(int, provider_free, 247 (const OSSL_CORE_HANDLE *prov, int deactivate)) 248 249 /* Functions provided by the provider to the Core, reserved numbers 1024-1535 */ 250 # define OSSL_FUNC_PROVIDER_TEARDOWN 1024 251 OSSL_CORE_MAKE_FUNC(void,provider_teardown,(void *provctx)) 252 # define OSSL_FUNC_PROVIDER_GETTABLE_PARAMS 1025 253 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, 254 provider_gettable_params,(void *provctx)) 255 # define OSSL_FUNC_PROVIDER_GET_PARAMS 1026 256 OSSL_CORE_MAKE_FUNC(int,provider_get_params,(void *provctx, 257 OSSL_PARAM params[])) 258 # define OSSL_FUNC_PROVIDER_QUERY_OPERATION 1027 259 OSSL_CORE_MAKE_FUNC(const OSSL_ALGORITHM *,provider_query_operation, 260 (void *provctx, int operation_id, int *no_store)) 261 # define OSSL_FUNC_PROVIDER_UNQUERY_OPERATION 1028 262 OSSL_CORE_MAKE_FUNC(void, provider_unquery_operation, 263 (void *provctx, int operation_id, const OSSL_ALGORITHM *)) 264 # define OSSL_FUNC_PROVIDER_GET_REASON_STRINGS 1029 265 OSSL_CORE_MAKE_FUNC(const OSSL_ITEM *,provider_get_reason_strings, 266 (void *provctx)) 267 # define OSSL_FUNC_PROVIDER_GET_CAPABILITIES 1030 268 OSSL_CORE_MAKE_FUNC(int, provider_get_capabilities, (void *provctx, 269 const char *capability, OSSL_CALLBACK *cb, void *arg)) 270 # define OSSL_FUNC_PROVIDER_SELF_TEST 1031 271 OSSL_CORE_MAKE_FUNC(int, provider_self_test, (void *provctx)) 272 273 /* Operations */ 274 275 # define OSSL_OP_DIGEST 1 276 # define OSSL_OP_CIPHER 2 /* Symmetric Ciphers */ 277 # define OSSL_OP_MAC 3 278 # define OSSL_OP_KDF 4 279 # define OSSL_OP_RAND 5 280 # define OSSL_OP_KEYMGMT 10 281 # define OSSL_OP_KEYEXCH 11 282 # define OSSL_OP_SIGNATURE 12 283 # define OSSL_OP_ASYM_CIPHER 13 284 # define OSSL_OP_KEM 14 285 /* New section for non-EVP operations */ 286 # define OSSL_OP_ENCODER 20 287 # define OSSL_OP_DECODER 21 288 # define OSSL_OP_STORE 22 289 /* Highest known operation number */ 290 # define OSSL_OP__HIGHEST 22 291 292 /* Digests */ 293 294 # define OSSL_FUNC_DIGEST_NEWCTX 1 295 # define OSSL_FUNC_DIGEST_INIT 2 296 # define OSSL_FUNC_DIGEST_UPDATE 3 297 # define OSSL_FUNC_DIGEST_FINAL 4 298 # define OSSL_FUNC_DIGEST_DIGEST 5 299 # define OSSL_FUNC_DIGEST_FREECTX 6 300 # define OSSL_FUNC_DIGEST_DUPCTX 7 301 # define OSSL_FUNC_DIGEST_GET_PARAMS 8 302 # define OSSL_FUNC_DIGEST_SET_CTX_PARAMS 9 303 # define OSSL_FUNC_DIGEST_GET_CTX_PARAMS 10 304 # define OSSL_FUNC_DIGEST_GETTABLE_PARAMS 11 305 # define OSSL_FUNC_DIGEST_SETTABLE_CTX_PARAMS 12 306 # define OSSL_FUNC_DIGEST_GETTABLE_CTX_PARAMS 13 307 # define OSSL_FUNC_DIGEST_SQUEEZE 14 308 # define OSSL_FUNC_DIGEST_COPYCTX 15 309 310 OSSL_CORE_MAKE_FUNC(void *, digest_newctx, (void *provctx)) 311 OSSL_CORE_MAKE_FUNC(int, digest_init, (void *dctx, const OSSL_PARAM params[])) 312 OSSL_CORE_MAKE_FUNC(int, digest_update, 313 (void *dctx, const unsigned char *in, size_t inl)) 314 OSSL_CORE_MAKE_FUNC(int, digest_final, 315 (void *dctx, 316 unsigned char *out, size_t *outl, size_t outsz)) 317 OSSL_CORE_MAKE_FUNC(int, digest_squeeze, 318 (void *dctx, 319 unsigned char *out, size_t *outl, size_t outsz)) 320 OSSL_CORE_MAKE_FUNC(int, digest_digest, 321 (void *provctx, const unsigned char *in, size_t inl, 322 unsigned char *out, size_t *outl, size_t outsz)) 323 324 OSSL_CORE_MAKE_FUNC(void, digest_freectx, (void *dctx)) 325 OSSL_CORE_MAKE_FUNC(void *, digest_dupctx, (void *dctx)) 326 OSSL_CORE_MAKE_FUNC(void, digest_copyctx, (void *outctx, void *inctx)) 327 328 OSSL_CORE_MAKE_FUNC(int, digest_get_params, (OSSL_PARAM params[])) 329 OSSL_CORE_MAKE_FUNC(int, digest_set_ctx_params, 330 (void *vctx, const OSSL_PARAM params[])) 331 OSSL_CORE_MAKE_FUNC(int, digest_get_ctx_params, 332 (void *vctx, OSSL_PARAM params[])) 333 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, digest_gettable_params, 334 (void *provctx)) 335 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, digest_settable_ctx_params, 336 (void *dctx, void *provctx)) 337 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, digest_gettable_ctx_params, 338 (void *dctx, void *provctx)) 339 340 /* Symmetric Ciphers */ 341 342 # define OSSL_FUNC_CIPHER_NEWCTX 1 343 # define OSSL_FUNC_CIPHER_ENCRYPT_INIT 2 344 # define OSSL_FUNC_CIPHER_DECRYPT_INIT 3 345 # define OSSL_FUNC_CIPHER_UPDATE 4 346 # define OSSL_FUNC_CIPHER_FINAL 5 347 # define OSSL_FUNC_CIPHER_CIPHER 6 348 # define OSSL_FUNC_CIPHER_FREECTX 7 349 # define OSSL_FUNC_CIPHER_DUPCTX 8 350 # define OSSL_FUNC_CIPHER_GET_PARAMS 9 351 # define OSSL_FUNC_CIPHER_GET_CTX_PARAMS 10 352 # define OSSL_FUNC_CIPHER_SET_CTX_PARAMS 11 353 # define OSSL_FUNC_CIPHER_GETTABLE_PARAMS 12 354 # define OSSL_FUNC_CIPHER_GETTABLE_CTX_PARAMS 13 355 # define OSSL_FUNC_CIPHER_SETTABLE_CTX_PARAMS 14 356 # define OSSL_FUNC_CIPHER_PIPELINE_ENCRYPT_INIT 15 357 # define OSSL_FUNC_CIPHER_PIPELINE_DECRYPT_INIT 16 358 # define OSSL_FUNC_CIPHER_PIPELINE_UPDATE 17 359 # define OSSL_FUNC_CIPHER_PIPELINE_FINAL 18 360 361 OSSL_CORE_MAKE_FUNC(void *, cipher_newctx, (void *provctx)) 362 OSSL_CORE_MAKE_FUNC(int, cipher_encrypt_init, (void *cctx, 363 const unsigned char *key, 364 size_t keylen, 365 const unsigned char *iv, 366 size_t ivlen, 367 const OSSL_PARAM params[])) 368 OSSL_CORE_MAKE_FUNC(int, cipher_decrypt_init, (void *cctx, 369 const unsigned char *key, 370 size_t keylen, 371 const unsigned char *iv, 372 size_t ivlen, 373 const OSSL_PARAM params[])) 374 OSSL_CORE_MAKE_FUNC(int, cipher_update, 375 (void *cctx, 376 unsigned char *out, size_t *outl, size_t outsize, 377 const unsigned char *in, size_t inl)) 378 OSSL_CORE_MAKE_FUNC(int, cipher_final, 379 (void *cctx, 380 unsigned char *out, size_t *outl, size_t outsize)) 381 OSSL_CORE_MAKE_FUNC(int, cipher_cipher, 382 (void *cctx, 383 unsigned char *out, size_t *outl, size_t outsize, 384 const unsigned char *in, size_t inl)) 385 OSSL_CORE_MAKE_FUNC(int, cipher_pipeline_encrypt_init, 386 (void *cctx, 387 const unsigned char *key, size_t keylen, 388 size_t numpipes, const unsigned char **iv, size_t ivlen, 389 const OSSL_PARAM params[])) 390 OSSL_CORE_MAKE_FUNC(int, cipher_pipeline_decrypt_init, 391 (void *cctx, 392 const unsigned char *key, size_t keylen, 393 size_t numpipes, const unsigned char **iv, size_t ivlen, 394 const OSSL_PARAM params[])) 395 OSSL_CORE_MAKE_FUNC(int, cipher_pipeline_update, 396 (void *cctx, size_t numpipes, 397 unsigned char **out, size_t *outl, const size_t *outsize, 398 const unsigned char **in, const size_t *inl)) 399 OSSL_CORE_MAKE_FUNC(int, cipher_pipeline_final, 400 (void *cctx, size_t numpipes, 401 unsigned char **out, size_t *outl, const size_t *outsize)) 402 OSSL_CORE_MAKE_FUNC(void, cipher_freectx, (void *cctx)) 403 OSSL_CORE_MAKE_FUNC(void *, cipher_dupctx, (void *cctx)) 404 OSSL_CORE_MAKE_FUNC(int, cipher_get_params, (OSSL_PARAM params[])) 405 OSSL_CORE_MAKE_FUNC(int, cipher_get_ctx_params, (void *cctx, 406 OSSL_PARAM params[])) 407 OSSL_CORE_MAKE_FUNC(int, cipher_set_ctx_params, (void *cctx, 408 const OSSL_PARAM params[])) 409 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, cipher_gettable_params, 410 (void *provctx)) 411 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, cipher_settable_ctx_params, 412 (void *cctx, void *provctx)) 413 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, cipher_gettable_ctx_params, 414 (void *cctx, void *provctx)) 415 416 /* MACs */ 417 418 # define OSSL_FUNC_MAC_NEWCTX 1 419 # define OSSL_FUNC_MAC_DUPCTX 2 420 # define OSSL_FUNC_MAC_FREECTX 3 421 # define OSSL_FUNC_MAC_INIT 4 422 # define OSSL_FUNC_MAC_UPDATE 5 423 # define OSSL_FUNC_MAC_FINAL 6 424 # define OSSL_FUNC_MAC_GET_PARAMS 7 425 # define OSSL_FUNC_MAC_GET_CTX_PARAMS 8 426 # define OSSL_FUNC_MAC_SET_CTX_PARAMS 9 427 # define OSSL_FUNC_MAC_GETTABLE_PARAMS 10 428 # define OSSL_FUNC_MAC_GETTABLE_CTX_PARAMS 11 429 # define OSSL_FUNC_MAC_SETTABLE_CTX_PARAMS 12 430 431 OSSL_CORE_MAKE_FUNC(void *, mac_newctx, (void *provctx)) 432 OSSL_CORE_MAKE_FUNC(void *, mac_dupctx, (void *src)) 433 OSSL_CORE_MAKE_FUNC(void, mac_freectx, (void *mctx)) 434 OSSL_CORE_MAKE_FUNC(int, mac_init, (void *mctx, const unsigned char *key, 435 size_t keylen, const OSSL_PARAM params[])) 436 OSSL_CORE_MAKE_FUNC(int, mac_update, 437 (void *mctx, const unsigned char *in, size_t inl)) 438 OSSL_CORE_MAKE_FUNC(int, mac_final, 439 (void *mctx, 440 unsigned char *out, size_t *outl, size_t outsize)) 441 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, mac_gettable_params, (void *provctx)) 442 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, mac_gettable_ctx_params, 443 (void *mctx, void *provctx)) 444 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, mac_settable_ctx_params, 445 (void *mctx, void *provctx)) 446 OSSL_CORE_MAKE_FUNC(int, mac_get_params, (OSSL_PARAM params[])) 447 OSSL_CORE_MAKE_FUNC(int, mac_get_ctx_params, 448 (void *mctx, OSSL_PARAM params[])) 449 OSSL_CORE_MAKE_FUNC(int, mac_set_ctx_params, 450 (void *mctx, const OSSL_PARAM params[])) 451 452 /* KDFs and PRFs */ 453 454 # define OSSL_FUNC_KDF_NEWCTX 1 455 # define OSSL_FUNC_KDF_DUPCTX 2 456 # define OSSL_FUNC_KDF_FREECTX 3 457 # define OSSL_FUNC_KDF_RESET 4 458 # define OSSL_FUNC_KDF_DERIVE 5 459 # define OSSL_FUNC_KDF_GETTABLE_PARAMS 6 460 # define OSSL_FUNC_KDF_GETTABLE_CTX_PARAMS 7 461 # define OSSL_FUNC_KDF_SETTABLE_CTX_PARAMS 8 462 # define OSSL_FUNC_KDF_GET_PARAMS 9 463 # define OSSL_FUNC_KDF_GET_CTX_PARAMS 10 464 # define OSSL_FUNC_KDF_SET_CTX_PARAMS 11 465 466 OSSL_CORE_MAKE_FUNC(void *, kdf_newctx, (void *provctx)) 467 OSSL_CORE_MAKE_FUNC(void *, kdf_dupctx, (void *src)) 468 OSSL_CORE_MAKE_FUNC(void, kdf_freectx, (void *kctx)) 469 OSSL_CORE_MAKE_FUNC(void, kdf_reset, (void *kctx)) 470 OSSL_CORE_MAKE_FUNC(int, kdf_derive, (void *kctx, unsigned char *key, 471 size_t keylen, const OSSL_PARAM params[])) 472 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kdf_gettable_params, (void *provctx)) 473 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kdf_gettable_ctx_params, 474 (void *kctx, void *provctx)) 475 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kdf_settable_ctx_params, 476 (void *kctx, void *provctx)) 477 OSSL_CORE_MAKE_FUNC(int, kdf_get_params, (OSSL_PARAM params[])) 478 OSSL_CORE_MAKE_FUNC(int, kdf_get_ctx_params, 479 (void *kctx, OSSL_PARAM params[])) 480 OSSL_CORE_MAKE_FUNC(int, kdf_set_ctx_params, 481 (void *kctx, const OSSL_PARAM params[])) 482 483 /* RAND */ 484 485 # define OSSL_FUNC_RAND_NEWCTX 1 486 # define OSSL_FUNC_RAND_FREECTX 2 487 # define OSSL_FUNC_RAND_INSTANTIATE 3 488 # define OSSL_FUNC_RAND_UNINSTANTIATE 4 489 # define OSSL_FUNC_RAND_GENERATE 5 490 # define OSSL_FUNC_RAND_RESEED 6 491 # define OSSL_FUNC_RAND_NONCE 7 492 # define OSSL_FUNC_RAND_ENABLE_LOCKING 8 493 # define OSSL_FUNC_RAND_LOCK 9 494 # define OSSL_FUNC_RAND_UNLOCK 10 495 # define OSSL_FUNC_RAND_GETTABLE_PARAMS 11 496 # define OSSL_FUNC_RAND_GETTABLE_CTX_PARAMS 12 497 # define OSSL_FUNC_RAND_SETTABLE_CTX_PARAMS 13 498 # define OSSL_FUNC_RAND_GET_PARAMS 14 499 # define OSSL_FUNC_RAND_GET_CTX_PARAMS 15 500 # define OSSL_FUNC_RAND_SET_CTX_PARAMS 16 501 # define OSSL_FUNC_RAND_VERIFY_ZEROIZATION 17 502 # define OSSL_FUNC_RAND_GET_SEED 18 503 # define OSSL_FUNC_RAND_CLEAR_SEED 19 504 505 OSSL_CORE_MAKE_FUNC(void *,rand_newctx, 506 (void *provctx, void *parent, 507 const OSSL_DISPATCH *parent_calls)) 508 OSSL_CORE_MAKE_FUNC(void,rand_freectx, (void *vctx)) 509 OSSL_CORE_MAKE_FUNC(int,rand_instantiate, 510 (void *vdrbg, unsigned int strength, 511 int prediction_resistance, 512 const unsigned char *pstr, size_t pstr_len, 513 const OSSL_PARAM params[])) 514 OSSL_CORE_MAKE_FUNC(int,rand_uninstantiate, (void *vdrbg)) 515 OSSL_CORE_MAKE_FUNC(int,rand_generate, 516 (void *vctx, unsigned char *out, size_t outlen, 517 unsigned int strength, int prediction_resistance, 518 const unsigned char *addin, size_t addin_len)) 519 OSSL_CORE_MAKE_FUNC(int,rand_reseed, 520 (void *vctx, int prediction_resistance, 521 const unsigned char *ent, size_t ent_len, 522 const unsigned char *addin, size_t addin_len)) 523 OSSL_CORE_MAKE_FUNC(size_t,rand_nonce, 524 (void *vctx, unsigned char *out, unsigned int strength, 525 size_t min_noncelen, size_t max_noncelen)) 526 OSSL_CORE_MAKE_FUNC(int,rand_enable_locking, (void *vctx)) 527 OSSL_CORE_MAKE_FUNC(int,rand_lock, (void *vctx)) 528 OSSL_CORE_MAKE_FUNC(void,rand_unlock, (void *vctx)) 529 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,rand_gettable_params, (void *provctx)) 530 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,rand_gettable_ctx_params, 531 (void *vctx, void *provctx)) 532 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,rand_settable_ctx_params, 533 (void *vctx, void *provctx)) 534 OSSL_CORE_MAKE_FUNC(int,rand_get_params, (OSSL_PARAM params[])) 535 OSSL_CORE_MAKE_FUNC(int,rand_get_ctx_params, 536 (void *vctx, OSSL_PARAM params[])) 537 OSSL_CORE_MAKE_FUNC(int,rand_set_ctx_params, 538 (void *vctx, const OSSL_PARAM params[])) 539 OSSL_CORE_MAKE_FUNC(void,rand_set_callbacks, 540 (void *vctx, OSSL_INOUT_CALLBACK *get_entropy, 541 OSSL_CALLBACK *cleanup_entropy, 542 OSSL_INOUT_CALLBACK *get_nonce, 543 OSSL_CALLBACK *cleanup_nonce, void *arg)) 544 OSSL_CORE_MAKE_FUNC(int,rand_verify_zeroization, 545 (void *vctx)) 546 OSSL_CORE_MAKE_FUNC(size_t,rand_get_seed, 547 (void *vctx, unsigned char **buffer, 548 int entropy, size_t min_len, size_t max_len, 549 int prediction_resistance, 550 const unsigned char *adin, size_t adin_len)) 551 OSSL_CORE_MAKE_FUNC(void,rand_clear_seed, 552 (void *vctx, unsigned char *buffer, size_t b_len)) 553 554 /*- 555 * Key management 556 * 557 * The Key Management takes care of provider side key objects, and includes 558 * all current functionality to create them, destroy them, set parameters 559 * and key material, etc, essentially everything that manipulates the keys 560 * themselves and their parameters. 561 * 562 * The key objects are commonly referred to as |keydata|, and it MUST be able 563 * to contain parameters if the key has any, the public key and the private 564 * key. All parts are optional, but their presence determines what can be 565 * done with the key object in terms of encryption, signature, and so on. 566 * The assumption from libcrypto is that the key object contains any of the 567 * following data combinations: 568 * 569 * - parameters only 570 * - public key only 571 * - public key + private key 572 * - parameters + public key 573 * - parameters + public key + private key 574 * 575 * What "parameters", "public key" and "private key" means in detail is left 576 * to the implementation. In the case of DH and DSA, they would typically 577 * include domain parameters, while for certain variants of RSA, they would 578 * typically include PSS or OAEP parameters. 579 * 580 * Key objects are created with OSSL_FUNC_keymgmt_new() and destroyed with 581 * OSSL_FUNC_keymgmt_free(). Key objects can have data filled in with 582 * OSSL_FUNC_keymgmt_import(). 583 * 584 * Three functions are made available to check what selection of data is 585 * present in a key object: OSSL_FUNC_keymgmt_has_parameters(), 586 * OSSL_FUNC_keymgmt_has_public_key(), and OSSL_FUNC_keymgmt_has_private_key(), 587 */ 588 589 /* Key data subset selection - individual bits */ 590 # define OSSL_KEYMGMT_SELECT_PRIVATE_KEY 0x01 591 # define OSSL_KEYMGMT_SELECT_PUBLIC_KEY 0x02 592 # define OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS 0x04 593 # define OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS 0x80 594 595 /* Key data subset selection - combinations */ 596 # define OSSL_KEYMGMT_SELECT_ALL_PARAMETERS \ 597 ( OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS \ 598 | OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS) 599 # define OSSL_KEYMGMT_SELECT_KEYPAIR \ 600 ( OSSL_KEYMGMT_SELECT_PRIVATE_KEY | OSSL_KEYMGMT_SELECT_PUBLIC_KEY ) 601 # define OSSL_KEYMGMT_SELECT_ALL \ 602 ( OSSL_KEYMGMT_SELECT_KEYPAIR | OSSL_KEYMGMT_SELECT_ALL_PARAMETERS ) 603 604 # define OSSL_KEYMGMT_VALIDATE_FULL_CHECK 0 605 # define OSSL_KEYMGMT_VALIDATE_QUICK_CHECK 1 606 607 /* Basic key object creation */ 608 # define OSSL_FUNC_KEYMGMT_NEW 1 609 OSSL_CORE_MAKE_FUNC(void *, keymgmt_new, (void *provctx)) 610 611 /* Generation, a more complex constructor */ 612 # define OSSL_FUNC_KEYMGMT_GEN_INIT 2 613 # define OSSL_FUNC_KEYMGMT_GEN_SET_TEMPLATE 3 614 # define OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS 4 615 # define OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS 5 616 # define OSSL_FUNC_KEYMGMT_GEN 6 617 # define OSSL_FUNC_KEYMGMT_GEN_CLEANUP 7 618 # define OSSL_FUNC_KEYMGMT_GEN_GET_PARAMS 15 619 # define OSSL_FUNC_KEYMGMT_GEN_GETTABLE_PARAMS 16 620 621 OSSL_CORE_MAKE_FUNC(void *, keymgmt_gen_init, 622 (void *provctx, int selection, const OSSL_PARAM params[])) 623 OSSL_CORE_MAKE_FUNC(int, keymgmt_gen_set_template, 624 (void *genctx, void *templ)) 625 OSSL_CORE_MAKE_FUNC(int, keymgmt_gen_set_params, 626 (void *genctx, const OSSL_PARAM params[])) 627 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, 628 keymgmt_gen_settable_params, 629 (void *genctx, void *provctx)) 630 OSSL_CORE_MAKE_FUNC(int, keymgmt_gen_get_params, 631 (void *genctx, OSSL_PARAM params[])) 632 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_gen_gettable_params, 633 (void *genctx, void *provctx)) 634 OSSL_CORE_MAKE_FUNC(void *, keymgmt_gen, 635 (void *genctx, OSSL_CALLBACK *cb, void *cbarg)) 636 OSSL_CORE_MAKE_FUNC(void, keymgmt_gen_cleanup, (void *genctx)) 637 638 /* Key loading by object reference */ 639 # define OSSL_FUNC_KEYMGMT_LOAD 8 640 OSSL_CORE_MAKE_FUNC(void *, keymgmt_load, 641 (const void *reference, size_t reference_sz)) 642 643 /* Basic key object destruction */ 644 # define OSSL_FUNC_KEYMGMT_FREE 10 645 OSSL_CORE_MAKE_FUNC(void, keymgmt_free, (void *keydata)) 646 647 /* Key object information, with discovery */ 648 #define OSSL_FUNC_KEYMGMT_GET_PARAMS 11 649 #define OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS 12 650 OSSL_CORE_MAKE_FUNC(int, keymgmt_get_params, 651 (void *keydata, OSSL_PARAM params[])) 652 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_gettable_params, 653 (void *provctx)) 654 655 #define OSSL_FUNC_KEYMGMT_SET_PARAMS 13 656 #define OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS 14 657 OSSL_CORE_MAKE_FUNC(int, keymgmt_set_params, 658 (void *keydata, const OSSL_PARAM params[])) 659 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_settable_params, 660 (void *provctx)) 661 662 /* Key checks - discovery of supported operations */ 663 # define OSSL_FUNC_KEYMGMT_QUERY_OPERATION_NAME 20 664 OSSL_CORE_MAKE_FUNC(const char *, keymgmt_query_operation_name, 665 (int operation_id)) 666 667 /* Key checks - key data content checks */ 668 # define OSSL_FUNC_KEYMGMT_HAS 21 669 OSSL_CORE_MAKE_FUNC(int, keymgmt_has, (const void *keydata, int selection)) 670 671 /* Key checks - validation */ 672 # define OSSL_FUNC_KEYMGMT_VALIDATE 22 673 OSSL_CORE_MAKE_FUNC(int, keymgmt_validate, (const void *keydata, int selection, 674 int checktype)) 675 676 /* Key checks - matching */ 677 # define OSSL_FUNC_KEYMGMT_MATCH 23 678 OSSL_CORE_MAKE_FUNC(int, keymgmt_match, 679 (const void *keydata1, const void *keydata2, 680 int selection)) 681 682 /* Import and export functions, with discovery */ 683 # define OSSL_FUNC_KEYMGMT_IMPORT 40 684 # define OSSL_FUNC_KEYMGMT_IMPORT_TYPES 41 685 # define OSSL_FUNC_KEYMGMT_EXPORT 42 686 # define OSSL_FUNC_KEYMGMT_EXPORT_TYPES 43 687 OSSL_CORE_MAKE_FUNC(int, keymgmt_import, 688 (void *keydata, int selection, const OSSL_PARAM params[])) 689 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_import_types, 690 (int selection)) 691 OSSL_CORE_MAKE_FUNC(int, keymgmt_export, 692 (void *keydata, int selection, 693 OSSL_CALLBACK *param_cb, void *cbarg)) 694 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_export_types, 695 (int selection)) 696 697 /* Dup function, constructor */ 698 # define OSSL_FUNC_KEYMGMT_DUP 44 699 OSSL_CORE_MAKE_FUNC(void *, keymgmt_dup, 700 (const void *keydata_from, int selection)) 701 702 /* Extended import and export functions */ 703 # define OSSL_FUNC_KEYMGMT_IMPORT_TYPES_EX 45 704 # define OSSL_FUNC_KEYMGMT_EXPORT_TYPES_EX 46 705 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_import_types_ex, 706 (void *provctx, int selection)) 707 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keymgmt_export_types_ex, 708 (void *provctx, int selection)) 709 710 /* Key Exchange */ 711 712 # define OSSL_FUNC_KEYEXCH_NEWCTX 1 713 # define OSSL_FUNC_KEYEXCH_INIT 2 714 # define OSSL_FUNC_KEYEXCH_DERIVE 3 715 # define OSSL_FUNC_KEYEXCH_SET_PEER 4 716 # define OSSL_FUNC_KEYEXCH_FREECTX 5 717 # define OSSL_FUNC_KEYEXCH_DUPCTX 6 718 # define OSSL_FUNC_KEYEXCH_SET_CTX_PARAMS 7 719 # define OSSL_FUNC_KEYEXCH_SETTABLE_CTX_PARAMS 8 720 # define OSSL_FUNC_KEYEXCH_GET_CTX_PARAMS 9 721 # define OSSL_FUNC_KEYEXCH_GETTABLE_CTX_PARAMS 10 722 723 OSSL_CORE_MAKE_FUNC(void *, keyexch_newctx, (void *provctx)) 724 OSSL_CORE_MAKE_FUNC(int, keyexch_init, (void *ctx, void *provkey, 725 const OSSL_PARAM params[])) 726 OSSL_CORE_MAKE_FUNC(int, keyexch_derive, (void *ctx, unsigned char *secret, 727 size_t *secretlen, size_t outlen)) 728 OSSL_CORE_MAKE_FUNC(int, keyexch_set_peer, (void *ctx, void *provkey)) 729 OSSL_CORE_MAKE_FUNC(void, keyexch_freectx, (void *ctx)) 730 OSSL_CORE_MAKE_FUNC(void *, keyexch_dupctx, (void *ctx)) 731 OSSL_CORE_MAKE_FUNC(int, keyexch_set_ctx_params, (void *ctx, 732 const OSSL_PARAM params[])) 733 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keyexch_settable_ctx_params, 734 (void *ctx, void *provctx)) 735 OSSL_CORE_MAKE_FUNC(int, keyexch_get_ctx_params, (void *ctx, 736 OSSL_PARAM params[])) 737 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, keyexch_gettable_ctx_params, 738 (void *ctx, void *provctx)) 739 740 /* Signature */ 741 742 # define OSSL_FUNC_SIGNATURE_NEWCTX 1 743 # define OSSL_FUNC_SIGNATURE_SIGN_INIT 2 744 # define OSSL_FUNC_SIGNATURE_SIGN 3 745 # define OSSL_FUNC_SIGNATURE_VERIFY_INIT 4 746 # define OSSL_FUNC_SIGNATURE_VERIFY 5 747 # define OSSL_FUNC_SIGNATURE_VERIFY_RECOVER_INIT 6 748 # define OSSL_FUNC_SIGNATURE_VERIFY_RECOVER 7 749 # define OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT 8 750 # define OSSL_FUNC_SIGNATURE_DIGEST_SIGN_UPDATE 9 751 # define OSSL_FUNC_SIGNATURE_DIGEST_SIGN_FINAL 10 752 # define OSSL_FUNC_SIGNATURE_DIGEST_SIGN 11 753 # define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT 12 754 # define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_UPDATE 13 755 # define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_FINAL 14 756 # define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY 15 757 # define OSSL_FUNC_SIGNATURE_FREECTX 16 758 # define OSSL_FUNC_SIGNATURE_DUPCTX 17 759 # define OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS 18 760 # define OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS 19 761 # define OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS 20 762 # define OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS 21 763 # define OSSL_FUNC_SIGNATURE_GET_CTX_MD_PARAMS 22 764 # define OSSL_FUNC_SIGNATURE_GETTABLE_CTX_MD_PARAMS 23 765 # define OSSL_FUNC_SIGNATURE_SET_CTX_MD_PARAMS 24 766 # define OSSL_FUNC_SIGNATURE_SETTABLE_CTX_MD_PARAMS 25 767 # define OSSL_FUNC_SIGNATURE_QUERY_KEY_TYPES 26 768 # define OSSL_FUNC_SIGNATURE_SIGN_MESSAGE_INIT 27 769 # define OSSL_FUNC_SIGNATURE_SIGN_MESSAGE_UPDATE 28 770 # define OSSL_FUNC_SIGNATURE_SIGN_MESSAGE_FINAL 29 771 # define OSSL_FUNC_SIGNATURE_VERIFY_MESSAGE_INIT 30 772 # define OSSL_FUNC_SIGNATURE_VERIFY_MESSAGE_UPDATE 31 773 # define OSSL_FUNC_SIGNATURE_VERIFY_MESSAGE_FINAL 32 774 775 OSSL_CORE_MAKE_FUNC(void *, signature_newctx, (void *provctx, 776 const char *propq)) 777 OSSL_CORE_MAKE_FUNC(int, signature_sign_init, (void *ctx, void *provkey, 778 const OSSL_PARAM params[])) 779 OSSL_CORE_MAKE_FUNC(int, signature_sign, (void *ctx, unsigned char *sig, 780 size_t *siglen, size_t sigsize, 781 const unsigned char *tbs, 782 size_t tbslen)) 783 OSSL_CORE_MAKE_FUNC(int, signature_sign_message_init, 784 (void *ctx, void *provkey, const OSSL_PARAM params[])) 785 OSSL_CORE_MAKE_FUNC(int, signature_sign_message_update, 786 (void *ctx, const unsigned char *in, size_t inlen)) 787 OSSL_CORE_MAKE_FUNC(int, signature_sign_message_final, 788 (void *ctx, unsigned char *sig, 789 size_t *siglen, size_t sigsize)) 790 OSSL_CORE_MAKE_FUNC(int, signature_verify_init, (void *ctx, void *provkey, 791 const OSSL_PARAM params[])) 792 OSSL_CORE_MAKE_FUNC(int, signature_verify, (void *ctx, 793 const unsigned char *sig, 794 size_t siglen, 795 const unsigned char *tbs, 796 size_t tbslen)) 797 OSSL_CORE_MAKE_FUNC(int, signature_verify_message_init, 798 (void *ctx, void *provkey, const OSSL_PARAM params[])) 799 OSSL_CORE_MAKE_FUNC(int, signature_verify_message_update, 800 (void *ctx, const unsigned char *in, size_t inlen)) 801 /* 802 * signature_verify_final requires that the signature to be verified against 803 * is specified via an OSSL_PARAM. 804 */ 805 OSSL_CORE_MAKE_FUNC(int, signature_verify_message_final, (void *ctx)) 806 OSSL_CORE_MAKE_FUNC(int, signature_verify_recover_init, 807 (void *ctx, void *provkey, const OSSL_PARAM params[])) 808 OSSL_CORE_MAKE_FUNC(int, signature_verify_recover, 809 (void *ctx, unsigned char *rout, size_t *routlen, 810 size_t routsize, const unsigned char *sig, size_t siglen)) 811 OSSL_CORE_MAKE_FUNC(int, signature_digest_sign_init, 812 (void *ctx, const char *mdname, void *provkey, 813 const OSSL_PARAM params[])) 814 OSSL_CORE_MAKE_FUNC(int, signature_digest_sign_update, 815 (void *ctx, const unsigned char *data, size_t datalen)) 816 OSSL_CORE_MAKE_FUNC(int, signature_digest_sign_final, 817 (void *ctx, unsigned char *sig, size_t *siglen, 818 size_t sigsize)) 819 OSSL_CORE_MAKE_FUNC(int, signature_digest_sign, 820 (void *ctx, unsigned char *sigret, size_t *siglen, 821 size_t sigsize, const unsigned char *tbs, size_t tbslen)) 822 OSSL_CORE_MAKE_FUNC(int, signature_digest_verify_init, 823 (void *ctx, const char *mdname, void *provkey, 824 const OSSL_PARAM params[])) 825 OSSL_CORE_MAKE_FUNC(int, signature_digest_verify_update, 826 (void *ctx, const unsigned char *data, size_t datalen)) 827 OSSL_CORE_MAKE_FUNC(int, signature_digest_verify_final, 828 (void *ctx, const unsigned char *sig, size_t siglen)) 829 OSSL_CORE_MAKE_FUNC(int, signature_digest_verify, 830 (void *ctx, const unsigned char *sig, size_t siglen, 831 const unsigned char *tbs, size_t tbslen)) 832 OSSL_CORE_MAKE_FUNC(void, signature_freectx, (void *ctx)) 833 OSSL_CORE_MAKE_FUNC(void *, signature_dupctx, (void *ctx)) 834 OSSL_CORE_MAKE_FUNC(int, signature_get_ctx_params, 835 (void *ctx, OSSL_PARAM params[])) 836 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, signature_gettable_ctx_params, 837 (void *ctx, void *provctx)) 838 OSSL_CORE_MAKE_FUNC(int, signature_set_ctx_params, 839 (void *ctx, const OSSL_PARAM params[])) 840 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, signature_settable_ctx_params, 841 (void *ctx, void *provctx)) 842 OSSL_CORE_MAKE_FUNC(int, signature_get_ctx_md_params, 843 (void *ctx, OSSL_PARAM params[])) 844 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, signature_gettable_ctx_md_params, 845 (void *ctx)) 846 OSSL_CORE_MAKE_FUNC(int, signature_set_ctx_md_params, 847 (void *ctx, const OSSL_PARAM params[])) 848 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, signature_settable_ctx_md_params, 849 (void *ctx)) 850 OSSL_CORE_MAKE_FUNC(const char **, signature_query_key_types, (void)) 851 852 /* Asymmetric Ciphers */ 853 854 # define OSSL_FUNC_ASYM_CIPHER_NEWCTX 1 855 # define OSSL_FUNC_ASYM_CIPHER_ENCRYPT_INIT 2 856 # define OSSL_FUNC_ASYM_CIPHER_ENCRYPT 3 857 # define OSSL_FUNC_ASYM_CIPHER_DECRYPT_INIT 4 858 # define OSSL_FUNC_ASYM_CIPHER_DECRYPT 5 859 # define OSSL_FUNC_ASYM_CIPHER_FREECTX 6 860 # define OSSL_FUNC_ASYM_CIPHER_DUPCTX 7 861 # define OSSL_FUNC_ASYM_CIPHER_GET_CTX_PARAMS 8 862 # define OSSL_FUNC_ASYM_CIPHER_GETTABLE_CTX_PARAMS 9 863 # define OSSL_FUNC_ASYM_CIPHER_SET_CTX_PARAMS 10 864 # define OSSL_FUNC_ASYM_CIPHER_SETTABLE_CTX_PARAMS 11 865 866 OSSL_CORE_MAKE_FUNC(void *, asym_cipher_newctx, (void *provctx)) 867 OSSL_CORE_MAKE_FUNC(int, asym_cipher_encrypt_init, (void *ctx, void *provkey, 868 const OSSL_PARAM params[])) 869 OSSL_CORE_MAKE_FUNC(int, asym_cipher_encrypt, (void *ctx, unsigned char *out, 870 size_t *outlen, 871 size_t outsize, 872 const unsigned char *in, 873 size_t inlen)) 874 OSSL_CORE_MAKE_FUNC(int, asym_cipher_decrypt_init, (void *ctx, void *provkey, 875 const OSSL_PARAM params[])) 876 OSSL_CORE_MAKE_FUNC(int, asym_cipher_decrypt, (void *ctx, unsigned char *out, 877 size_t *outlen, 878 size_t outsize, 879 const unsigned char *in, 880 size_t inlen)) 881 OSSL_CORE_MAKE_FUNC(void, asym_cipher_freectx, (void *ctx)) 882 OSSL_CORE_MAKE_FUNC(void *, asym_cipher_dupctx, (void *ctx)) 883 OSSL_CORE_MAKE_FUNC(int, asym_cipher_get_ctx_params, 884 (void *ctx, OSSL_PARAM params[])) 885 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, asym_cipher_gettable_ctx_params, 886 (void *ctx, void *provctx)) 887 OSSL_CORE_MAKE_FUNC(int, asym_cipher_set_ctx_params, 888 (void *ctx, const OSSL_PARAM params[])) 889 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, asym_cipher_settable_ctx_params, 890 (void *ctx, void *provctx)) 891 892 /* Asymmetric Key encapsulation */ 893 # define OSSL_FUNC_KEM_NEWCTX 1 894 # define OSSL_FUNC_KEM_ENCAPSULATE_INIT 2 895 # define OSSL_FUNC_KEM_ENCAPSULATE 3 896 # define OSSL_FUNC_KEM_DECAPSULATE_INIT 4 897 # define OSSL_FUNC_KEM_DECAPSULATE 5 898 # define OSSL_FUNC_KEM_FREECTX 6 899 # define OSSL_FUNC_KEM_DUPCTX 7 900 # define OSSL_FUNC_KEM_GET_CTX_PARAMS 8 901 # define OSSL_FUNC_KEM_GETTABLE_CTX_PARAMS 9 902 # define OSSL_FUNC_KEM_SET_CTX_PARAMS 10 903 # define OSSL_FUNC_KEM_SETTABLE_CTX_PARAMS 11 904 # define OSSL_FUNC_KEM_AUTH_ENCAPSULATE_INIT 12 905 # define OSSL_FUNC_KEM_AUTH_DECAPSULATE_INIT 13 906 907 OSSL_CORE_MAKE_FUNC(void *, kem_newctx, (void *provctx)) 908 OSSL_CORE_MAKE_FUNC(int, kem_encapsulate_init, (void *ctx, void *provkey, 909 const OSSL_PARAM params[])) 910 OSSL_CORE_MAKE_FUNC(int, kem_auth_encapsulate_init, (void *ctx, void *provkey, 911 void *authprivkey, 912 const OSSL_PARAM params[])) 913 OSSL_CORE_MAKE_FUNC(int, kem_encapsulate, (void *ctx, 914 unsigned char *out, size_t *outlen, 915 unsigned char *secret, 916 size_t *secretlen)) 917 OSSL_CORE_MAKE_FUNC(int, kem_decapsulate_init, (void *ctx, void *provkey, 918 const OSSL_PARAM params[])) 919 OSSL_CORE_MAKE_FUNC(int, kem_auth_decapsulate_init, (void *ctx, void *provkey, 920 void *authpubkey, 921 const OSSL_PARAM params[])) 922 OSSL_CORE_MAKE_FUNC(int, kem_decapsulate, (void *ctx, 923 unsigned char *out, size_t *outlen, 924 const unsigned char *in, size_t inlen)) 925 OSSL_CORE_MAKE_FUNC(void, kem_freectx, (void *ctx)) 926 OSSL_CORE_MAKE_FUNC(void *, kem_dupctx, (void *ctx)) 927 OSSL_CORE_MAKE_FUNC(int, kem_get_ctx_params, (void *ctx, OSSL_PARAM params[])) 928 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kem_gettable_ctx_params, 929 (void *ctx, void *provctx)) 930 OSSL_CORE_MAKE_FUNC(int, kem_set_ctx_params, 931 (void *ctx, const OSSL_PARAM params[])) 932 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, kem_settable_ctx_params, 933 (void *ctx, void *provctx)) 934 935 /* Encoders and decoders */ 936 # define OSSL_FUNC_ENCODER_NEWCTX 1 937 # define OSSL_FUNC_ENCODER_FREECTX 2 938 # define OSSL_FUNC_ENCODER_GET_PARAMS 3 939 # define OSSL_FUNC_ENCODER_GETTABLE_PARAMS 4 940 # define OSSL_FUNC_ENCODER_SET_CTX_PARAMS 5 941 # define OSSL_FUNC_ENCODER_SETTABLE_CTX_PARAMS 6 942 # define OSSL_FUNC_ENCODER_DOES_SELECTION 10 943 # define OSSL_FUNC_ENCODER_ENCODE 11 944 # define OSSL_FUNC_ENCODER_IMPORT_OBJECT 20 945 # define OSSL_FUNC_ENCODER_FREE_OBJECT 21 946 OSSL_CORE_MAKE_FUNC(void *, encoder_newctx, (void *provctx)) 947 OSSL_CORE_MAKE_FUNC(void, encoder_freectx, (void *ctx)) 948 OSSL_CORE_MAKE_FUNC(int, encoder_get_params, (OSSL_PARAM params[])) 949 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, encoder_gettable_params, 950 (void *provctx)) 951 OSSL_CORE_MAKE_FUNC(int, encoder_set_ctx_params, 952 (void *ctx, const OSSL_PARAM params[])) 953 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, encoder_settable_ctx_params, 954 (void *provctx)) 955 956 OSSL_CORE_MAKE_FUNC(int, encoder_does_selection, 957 (void *provctx, int selection)) 958 OSSL_CORE_MAKE_FUNC(int, encoder_encode, 959 (void *ctx, OSSL_CORE_BIO *out, 960 const void *obj_raw, const OSSL_PARAM obj_abstract[], 961 int selection, 962 OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg)) 963 964 OSSL_CORE_MAKE_FUNC(void *, encoder_import_object, 965 (void *ctx, int selection, const OSSL_PARAM params[])) 966 OSSL_CORE_MAKE_FUNC(void, encoder_free_object, (void *obj)) 967 968 # define OSSL_FUNC_DECODER_NEWCTX 1 969 # define OSSL_FUNC_DECODER_FREECTX 2 970 # define OSSL_FUNC_DECODER_GET_PARAMS 3 971 # define OSSL_FUNC_DECODER_GETTABLE_PARAMS 4 972 # define OSSL_FUNC_DECODER_SET_CTX_PARAMS 5 973 # define OSSL_FUNC_DECODER_SETTABLE_CTX_PARAMS 6 974 # define OSSL_FUNC_DECODER_DOES_SELECTION 10 975 # define OSSL_FUNC_DECODER_DECODE 11 976 # define OSSL_FUNC_DECODER_EXPORT_OBJECT 20 977 OSSL_CORE_MAKE_FUNC(void *, decoder_newctx, (void *provctx)) 978 OSSL_CORE_MAKE_FUNC(void, decoder_freectx, (void *ctx)) 979 OSSL_CORE_MAKE_FUNC(int, decoder_get_params, (OSSL_PARAM params[])) 980 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, decoder_gettable_params, 981 (void *provctx)) 982 OSSL_CORE_MAKE_FUNC(int, decoder_set_ctx_params, 983 (void *ctx, const OSSL_PARAM params[])) 984 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, decoder_settable_ctx_params, 985 (void *provctx)) 986 987 OSSL_CORE_MAKE_FUNC(int, decoder_does_selection, 988 (void *provctx, int selection)) 989 OSSL_CORE_MAKE_FUNC(int, decoder_decode, 990 (void *ctx, OSSL_CORE_BIO *in, int selection, 991 OSSL_CALLBACK *data_cb, void *data_cbarg, 992 OSSL_PASSPHRASE_CALLBACK *pw_cb, void *pw_cbarg)) 993 OSSL_CORE_MAKE_FUNC(int, decoder_export_object, 994 (void *ctx, const void *objref, size_t objref_sz, 995 OSSL_CALLBACK *export_cb, void *export_cbarg)) 996 997 /*- 998 * Store 999 * 1000 * Objects are scanned by using the 'open', 'load', 'eof' and 'close' 1001 * functions, which implement an OSSL_STORE loader. 1002 * 1003 * store_load() works in a way that's very similar to the decoders, in 1004 * that they pass an abstract object through a callback, either as a DER 1005 * octet string or as an object reference, which libcrypto will have to 1006 * deal with. 1007 */ 1008 1009 #define OSSL_FUNC_STORE_OPEN 1 1010 #define OSSL_FUNC_STORE_ATTACH 2 1011 #define OSSL_FUNC_STORE_SETTABLE_CTX_PARAMS 3 1012 #define OSSL_FUNC_STORE_SET_CTX_PARAMS 4 1013 #define OSSL_FUNC_STORE_LOAD 5 1014 #define OSSL_FUNC_STORE_EOF 6 1015 #define OSSL_FUNC_STORE_CLOSE 7 1016 #define OSSL_FUNC_STORE_EXPORT_OBJECT 8 1017 #define OSSL_FUNC_STORE_DELETE 9 1018 #define OSSL_FUNC_STORE_OPEN_EX 10 1019 OSSL_CORE_MAKE_FUNC(void *, store_open, (void *provctx, const char *uri)) 1020 OSSL_CORE_MAKE_FUNC(void *, store_attach, (void *provctx, OSSL_CORE_BIO *in)) 1021 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, store_settable_ctx_params, 1022 (void *provctx)) 1023 OSSL_CORE_MAKE_FUNC(int, store_set_ctx_params, 1024 (void *loaderctx, const OSSL_PARAM params[])) 1025 OSSL_CORE_MAKE_FUNC(int, store_load, 1026 (void *loaderctx, 1027 OSSL_CALLBACK *object_cb, void *object_cbarg, 1028 OSSL_PASSPHRASE_CALLBACK *pw_cb, void *pw_cbarg)) 1029 OSSL_CORE_MAKE_FUNC(int, store_eof, (void *loaderctx)) 1030 OSSL_CORE_MAKE_FUNC(int, store_close, (void *loaderctx)) 1031 OSSL_CORE_MAKE_FUNC(int, store_export_object, 1032 (void *loaderctx, const void *objref, size_t objref_sz, 1033 OSSL_CALLBACK *export_cb, void *export_cbarg)) 1034 OSSL_CORE_MAKE_FUNC(int, store_delete, 1035 (void *provctx, const char *uri, const OSSL_PARAM params[], 1036 OSSL_PASSPHRASE_CALLBACK *pw_cb, void *pw_cbarg)) 1037 OSSL_CORE_MAKE_FUNC(void *, store_open_ex, 1038 (void *provctx, const char *uri, const OSSL_PARAM params[], 1039 OSSL_PASSPHRASE_CALLBACK *pw_cb, void *pw_cbarg)) 1040 1041 # ifdef __cplusplus 1042 } 1043 # endif 1044 1045 #endif 1046