2 * Copyright 2019-2020 The OpenSSL Project Authors. All Rights Reserved.
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
10 #ifndef OPENSSL_CORE_NUMBERS_H
11 # define OPENSSL_CORE_NUMBERS_H
14 # include <openssl/core.h>
24 * All series start with 1, to allow 0 to be an array terminator.
25 * For any FUNC identity, we also provide a function signature typedef
26 * and a static inline function to extract a function pointer from a
27 * OSSL_DISPATCH element in a type safe manner.
30 * for any function base name 'foo' (uppercase form 'FOO'), we will have
32 * - a macro for the identity with the name OSSL_FUNC_'FOO' or derivatives
33 * thereof (to be specified further down)
34 * - a function signature typedef with the name OSSL_'foo'_fn
35 * - a function pointer extractor function with the name OSSL_'foo'
39 * Helper macro to create the function signature typedef and the extractor
40 * |type| is the return-type of the function, |name| is the name of the
41 * function to fetch, and |args| is a parenthesized list of parameters
42 * for the function (that is, it is |name|'s function signature).
44 #define OSSL_CORE_MAKE_FUNC(type,name,args) \
45 typedef type (OSSL_##name##_fn)args; \
47 OSSL_##name##_fn *OSSL_get_##name(const OSSL_DISPATCH *opf) \
49 return (OSSL_##name##_fn *)opf->function; \
53 * Core function identities, for the two OSSL_DISPATCH tables being passed
54 * in the OSSL_provider_init call.
56 * 0 serves as a marker for the end of the OSSL_DISPATCH array, and must
57 * therefore NEVER be used as a function identity.
59 /* Functions provided by the Core to the provider, reserved numbers 1-1023 */
60 # define OSSL_FUNC_CORE_GETTABLE_PARAMS 1
61 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,
62 core_gettable_params,(const OSSL_CORE_HANDLE *prov))
63 # define OSSL_FUNC_CORE_GET_PARAMS 2
64 OSSL_CORE_MAKE_FUNC(int,core_get_params,(const OSSL_CORE_HANDLE *prov,
66 # define OSSL_FUNC_CORE_THREAD_START 3
67 OSSL_CORE_MAKE_FUNC(int,core_thread_start,(const OSSL_CORE_HANDLE *prov,
68 OSSL_thread_stop_handler_fn handfn))
69 # define OSSL_FUNC_CORE_GET_LIBRARY_CONTEXT 4
70 OSSL_CORE_MAKE_FUNC(OPENSSL_CORE_CTX *,core_get_library_context,
71 (const OSSL_CORE_HANDLE *prov))
72 # define OSSL_FUNC_CORE_NEW_ERROR 5
73 OSSL_CORE_MAKE_FUNC(void,core_new_error,(const OSSL_CORE_HANDLE *prov))
74 # define OSSL_FUNC_CORE_SET_ERROR_DEBUG 6
75 OSSL_CORE_MAKE_FUNC(void,core_set_error_debug,
76 (const OSSL_CORE_HANDLE *prov,
77 const char *file, int line, const char *func))
78 # define OSSL_FUNC_CORE_VSET_ERROR 7
79 OSSL_CORE_MAKE_FUNC(void,core_vset_error,
80 (const OSSL_CORE_HANDLE *prov,
81 uint32_t reason, const char *fmt, va_list args))
82 # define OSSL_FUNC_CORE_SET_ERROR_MARK 8
83 OSSL_CORE_MAKE_FUNC(int, core_set_error_mark, (const OSSL_CORE_HANDLE *prov))
84 # define OSSL_FUNC_CORE_CLEAR_LAST_ERROR_MARK 9
85 OSSL_CORE_MAKE_FUNC(int, core_clear_last_error_mark,
86 (const OSSL_CORE_HANDLE *prov))
87 # define OSSL_FUNC_CORE_POP_ERROR_TO_MARK 10
88 OSSL_CORE_MAKE_FUNC(int, core_pop_error_to_mark, (const OSSL_CORE_HANDLE *prov))
90 /* Memory allocation, freeing, clearing. */
91 #define OSSL_FUNC_CRYPTO_MALLOC 20
92 OSSL_CORE_MAKE_FUNC(void *,
93 CRYPTO_malloc, (size_t num, const char *file, int line))
94 #define OSSL_FUNC_CRYPTO_ZALLOC 21
95 OSSL_CORE_MAKE_FUNC(void *,
96 CRYPTO_zalloc, (size_t num, const char *file, int line))
97 #define OSSL_FUNC_CRYPTO_FREE 22
98 OSSL_CORE_MAKE_FUNC(void,
99 CRYPTO_free, (void *ptr, const char *file, int line))
100 #define OSSL_FUNC_CRYPTO_CLEAR_FREE 23
101 OSSL_CORE_MAKE_FUNC(void,
102 CRYPTO_clear_free, (void *ptr, size_t num, const char *file, int line))
103 #define OSSL_FUNC_CRYPTO_REALLOC 24
104 OSSL_CORE_MAKE_FUNC(void *,
105 CRYPTO_realloc, (void *addr, size_t num, const char *file, int line))
106 #define OSSL_FUNC_CRYPTO_CLEAR_REALLOC 25
107 OSSL_CORE_MAKE_FUNC(void *,
108 CRYPTO_clear_realloc, (void *addr, size_t old_num, size_t num,
109 const char *file, int line))
110 #define OSSL_FUNC_CRYPTO_SECURE_MALLOC 26
111 OSSL_CORE_MAKE_FUNC(void *,
112 CRYPTO_secure_malloc, (size_t num, const char *file, int line))
113 #define OSSL_FUNC_CRYPTO_SECURE_ZALLOC 27
114 OSSL_CORE_MAKE_FUNC(void *,
115 CRYPTO_secure_zalloc, (size_t num, const char *file, int line))
116 #define OSSL_FUNC_CRYPTO_SECURE_FREE 28
117 OSSL_CORE_MAKE_FUNC(void,
118 CRYPTO_secure_free, (void *ptr, const char *file, int line))
119 #define OSSL_FUNC_CRYPTO_SECURE_CLEAR_FREE 29
120 OSSL_CORE_MAKE_FUNC(void,
121 CRYPTO_secure_clear_free, (void *ptr, size_t num, const char *file,
123 #define OSSL_FUNC_CRYPTO_SECURE_ALLOCATED 30
124 OSSL_CORE_MAKE_FUNC(int,
125 CRYPTO_secure_allocated, (const void *ptr))
126 #define OSSL_FUNC_OPENSSL_CLEANSE 31
127 OSSL_CORE_MAKE_FUNC(void,
128 OPENSSL_cleanse, (void *ptr, size_t len))
130 /* Bio functions provided by the core */
131 #define OSSL_FUNC_BIO_NEW_FILE 40
132 #define OSSL_FUNC_BIO_NEW_MEMBUF 41
133 #define OSSL_FUNC_BIO_READ_EX 42
134 #define OSSL_FUNC_BIO_WRITE_EX 43
135 #define OSSL_FUNC_BIO_FREE 44
136 #define OSSL_FUNC_BIO_VPRINTF 45
137 #define OSSL_FUNC_BIO_VSNPRINTF 46
139 OSSL_CORE_MAKE_FUNC(OSSL_CORE_BIO *, BIO_new_file, (const char *filename,
141 OSSL_CORE_MAKE_FUNC(OSSL_CORE_BIO *, BIO_new_membuf, (const void *buf, int len))
142 OSSL_CORE_MAKE_FUNC(int, BIO_read_ex, (OSSL_CORE_BIO *bio, void *data,
143 size_t data_len, size_t *bytes_read))
144 OSSL_CORE_MAKE_FUNC(int, BIO_write_ex, (OSSL_CORE_BIO *bio, const void *data,
145 size_t data_len, size_t *written))
146 OSSL_CORE_MAKE_FUNC(int, BIO_free, (OSSL_CORE_BIO *bio))
147 OSSL_CORE_MAKE_FUNC(int, BIO_vprintf, (OSSL_CORE_BIO *bio, const char *format,
149 OSSL_CORE_MAKE_FUNC(int, BIO_vsnprintf,
150 (char *buf, size_t n, const char *fmt, va_list args))
152 #define OSSL_FUNC_SELF_TEST_CB 100
153 OSSL_CORE_MAKE_FUNC(void, self_test_cb, (OPENSSL_CORE_CTX *ctx, OSSL_CALLBACK **cb,
156 /* Functions provided by the provider to the Core, reserved numbers 1024-1535 */
157 # define OSSL_FUNC_PROVIDER_TEARDOWN 1024
158 OSSL_CORE_MAKE_FUNC(void,provider_teardown,(void *provctx))
159 # define OSSL_FUNC_PROVIDER_GETTABLE_PARAMS 1025
160 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,
161 provider_gettable_params,(void *provctx))
162 # define OSSL_FUNC_PROVIDER_GET_PARAMS 1026
163 OSSL_CORE_MAKE_FUNC(int,provider_get_params,(void *provctx,
164 OSSL_PARAM params[]))
165 # define OSSL_FUNC_PROVIDER_QUERY_OPERATION 1027
166 OSSL_CORE_MAKE_FUNC(const OSSL_ALGORITHM *,provider_query_operation,
167 (void *provctx, int operation_id, int *no_store))
168 # define OSSL_FUNC_PROVIDER_GET_REASON_STRINGS 1028
169 OSSL_CORE_MAKE_FUNC(const OSSL_ITEM *,provider_get_reason_strings,
171 # define OSSL_FUNC_PROVIDER_GET_CAPABILITIES 1029
172 OSSL_CORE_MAKE_FUNC(int, provider_get_capabilities, (void *provctx,
173 const char *capability, OSSL_CALLBACK *cb, void *arg))
177 # define OSSL_OP_DIGEST 1
178 # define OSSL_OP_CIPHER 2 /* Symmetric Ciphers */
179 # define OSSL_OP_MAC 3
180 # define OSSL_OP_KDF 4
181 # define OSSL_OP_KEYMGMT 10
182 # define OSSL_OP_KEYEXCH 11
183 # define OSSL_OP_SIGNATURE 12
184 # define OSSL_OP_ASYM_CIPHER 13
185 /* New section for non-EVP operations */
186 # define OSSL_OP_SERIALIZER 20
187 /* Highest known operation number */
188 # define OSSL_OP__HIGHEST 20
192 # define OSSL_FUNC_DIGEST_NEWCTX 1
193 # define OSSL_FUNC_DIGEST_INIT 2
194 # define OSSL_FUNC_DIGEST_UPDATE 3
195 # define OSSL_FUNC_DIGEST_FINAL 4
196 # define OSSL_FUNC_DIGEST_DIGEST 5
197 # define OSSL_FUNC_DIGEST_FREECTX 6
198 # define OSSL_FUNC_DIGEST_DUPCTX 7
199 # define OSSL_FUNC_DIGEST_GET_PARAMS 8
200 # define OSSL_FUNC_DIGEST_SET_CTX_PARAMS 9
201 # define OSSL_FUNC_DIGEST_GET_CTX_PARAMS 10
202 # define OSSL_FUNC_DIGEST_GETTABLE_PARAMS 11
203 # define OSSL_FUNC_DIGEST_SETTABLE_CTX_PARAMS 12
204 # define OSSL_FUNC_DIGEST_GETTABLE_CTX_PARAMS 13
206 OSSL_CORE_MAKE_FUNC(void *, OP_digest_newctx, (void *provctx))
207 OSSL_CORE_MAKE_FUNC(int, OP_digest_init, (void *dctx))
208 OSSL_CORE_MAKE_FUNC(int, OP_digest_update,
209 (void *dctx, const unsigned char *in, size_t inl))
210 OSSL_CORE_MAKE_FUNC(int, OP_digest_final,
212 unsigned char *out, size_t *outl, size_t outsz))
213 OSSL_CORE_MAKE_FUNC(int, OP_digest_digest,
214 (void *provctx, const unsigned char *in, size_t inl,
215 unsigned char *out, size_t *outl, size_t outsz))
217 OSSL_CORE_MAKE_FUNC(void, OP_digest_freectx, (void *dctx))
218 OSSL_CORE_MAKE_FUNC(void *, OP_digest_dupctx, (void *dctx))
220 OSSL_CORE_MAKE_FUNC(int, OP_digest_get_params, (OSSL_PARAM params[]))
221 OSSL_CORE_MAKE_FUNC(int, OP_digest_set_ctx_params,
222 (void *vctx, const OSSL_PARAM params[]))
223 OSSL_CORE_MAKE_FUNC(int, OP_digest_get_ctx_params,
224 (void *vctx, OSSL_PARAM params[]))
225 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_digest_gettable_params, (void))
226 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_digest_settable_ctx_params, (void))
227 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_digest_gettable_ctx_params, (void))
229 /* Symmetric Ciphers */
231 # define OSSL_FUNC_CIPHER_NEWCTX 1
232 # define OSSL_FUNC_CIPHER_ENCRYPT_INIT 2
233 # define OSSL_FUNC_CIPHER_DECRYPT_INIT 3
234 # define OSSL_FUNC_CIPHER_UPDATE 4
235 # define OSSL_FUNC_CIPHER_FINAL 5
236 # define OSSL_FUNC_CIPHER_CIPHER 6
237 # define OSSL_FUNC_CIPHER_FREECTX 7
238 # define OSSL_FUNC_CIPHER_DUPCTX 8
239 # define OSSL_FUNC_CIPHER_GET_PARAMS 9
240 # define OSSL_FUNC_CIPHER_GET_CTX_PARAMS 10
241 # define OSSL_FUNC_CIPHER_SET_CTX_PARAMS 11
242 # define OSSL_FUNC_CIPHER_GETTABLE_PARAMS 12
243 # define OSSL_FUNC_CIPHER_GETTABLE_CTX_PARAMS 13
244 # define OSSL_FUNC_CIPHER_SETTABLE_CTX_PARAMS 14
246 OSSL_CORE_MAKE_FUNC(void *, OP_cipher_newctx, (void *provctx))
247 OSSL_CORE_MAKE_FUNC(int, OP_cipher_encrypt_init, (void *cctx,
248 const unsigned char *key,
250 const unsigned char *iv,
252 OSSL_CORE_MAKE_FUNC(int, OP_cipher_decrypt_init, (void *cctx,
253 const unsigned char *key,
255 const unsigned char *iv,
257 OSSL_CORE_MAKE_FUNC(int, OP_cipher_update,
259 unsigned char *out, size_t *outl, size_t outsize,
260 const unsigned char *in, size_t inl))
261 OSSL_CORE_MAKE_FUNC(int, OP_cipher_final,
263 unsigned char *out, size_t *outl, size_t outsize))
264 OSSL_CORE_MAKE_FUNC(int, OP_cipher_cipher,
266 unsigned char *out, size_t *outl, size_t outsize,
267 const unsigned char *in, size_t inl))
268 OSSL_CORE_MAKE_FUNC(void, OP_cipher_freectx, (void *cctx))
269 OSSL_CORE_MAKE_FUNC(void *, OP_cipher_dupctx, (void *cctx))
270 OSSL_CORE_MAKE_FUNC(int, OP_cipher_get_params, (OSSL_PARAM params[]))
271 OSSL_CORE_MAKE_FUNC(int, OP_cipher_get_ctx_params, (void *cctx,
272 OSSL_PARAM params[]))
273 OSSL_CORE_MAKE_FUNC(int, OP_cipher_set_ctx_params, (void *cctx,
274 const OSSL_PARAM params[]))
275 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_cipher_gettable_params, (void))
276 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_cipher_settable_ctx_params, (void))
277 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_cipher_gettable_ctx_params, (void))
281 # define OSSL_FUNC_MAC_NEWCTX 1
282 # define OSSL_FUNC_MAC_DUPCTX 2
283 # define OSSL_FUNC_MAC_FREECTX 3
284 # define OSSL_FUNC_MAC_INIT 4
285 # define OSSL_FUNC_MAC_UPDATE 5
286 # define OSSL_FUNC_MAC_FINAL 6
287 # define OSSL_FUNC_MAC_GET_PARAMS 7
288 # define OSSL_FUNC_MAC_GET_CTX_PARAMS 8
289 # define OSSL_FUNC_MAC_SET_CTX_PARAMS 9
290 # define OSSL_FUNC_MAC_GETTABLE_PARAMS 10
291 # define OSSL_FUNC_MAC_GETTABLE_CTX_PARAMS 11
292 # define OSSL_FUNC_MAC_SETTABLE_CTX_PARAMS 12
294 OSSL_CORE_MAKE_FUNC(void *, OP_mac_newctx, (void *provctx))
295 OSSL_CORE_MAKE_FUNC(void *, OP_mac_dupctx, (void *src))
296 OSSL_CORE_MAKE_FUNC(void, OP_mac_freectx, (void *mctx))
297 OSSL_CORE_MAKE_FUNC(size_t, OP_mac_size, (void *mctx))
298 OSSL_CORE_MAKE_FUNC(int, OP_mac_init, (void *mctx))
299 OSSL_CORE_MAKE_FUNC(int, OP_mac_update,
300 (void *mctx, const unsigned char *in, size_t inl))
301 OSSL_CORE_MAKE_FUNC(int, OP_mac_final,
303 unsigned char *out, size_t *outl, size_t outsize))
304 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_mac_gettable_params, (void))
305 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_mac_gettable_ctx_params, (void))
306 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_mac_settable_ctx_params, (void))
307 OSSL_CORE_MAKE_FUNC(int, OP_mac_get_params, (OSSL_PARAM params[]))
308 OSSL_CORE_MAKE_FUNC(int, OP_mac_get_ctx_params,
309 (void *mctx, OSSL_PARAM params[]))
310 OSSL_CORE_MAKE_FUNC(int, OP_mac_set_ctx_params,
311 (void *mctx, const OSSL_PARAM params[]))
315 # define OSSL_FUNC_KDF_NEWCTX 1
316 # define OSSL_FUNC_KDF_DUPCTX 2
317 # define OSSL_FUNC_KDF_FREECTX 3
318 # define OSSL_FUNC_KDF_RESET 4
319 # define OSSL_FUNC_KDF_DERIVE 5
320 # define OSSL_FUNC_KDF_GETTABLE_PARAMS 6
321 # define OSSL_FUNC_KDF_GETTABLE_CTX_PARAMS 7
322 # define OSSL_FUNC_KDF_SETTABLE_CTX_PARAMS 8
323 # define OSSL_FUNC_KDF_GET_PARAMS 9
324 # define OSSL_FUNC_KDF_GET_CTX_PARAMS 10
325 # define OSSL_FUNC_KDF_SET_CTX_PARAMS 11
327 OSSL_CORE_MAKE_FUNC(void *, OP_kdf_newctx, (void *provctx))
328 OSSL_CORE_MAKE_FUNC(void *, OP_kdf_dupctx, (void *src))
329 OSSL_CORE_MAKE_FUNC(void, OP_kdf_freectx, (void *kctx))
330 OSSL_CORE_MAKE_FUNC(void, OP_kdf_reset, (void *kctx))
331 OSSL_CORE_MAKE_FUNC(int, OP_kdf_derive, (void *kctx, unsigned char *key,
333 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_kdf_gettable_params, (void))
334 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_kdf_gettable_ctx_params, (void))
335 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_kdf_settable_ctx_params, (void))
336 OSSL_CORE_MAKE_FUNC(int, OP_kdf_get_params, (OSSL_PARAM params[]))
337 OSSL_CORE_MAKE_FUNC(int, OP_kdf_get_ctx_params,
338 (void *kctx, OSSL_PARAM params[]))
339 OSSL_CORE_MAKE_FUNC(int, OP_kdf_set_ctx_params,
340 (void *kctx, const OSSL_PARAM params[]))
345 * The Key Management takes care of provider side key objects, and includes
346 * all current functionality to create them, destroy them, set parameters
347 * and key material, etc, essentially everything that manipulates the keys
348 * themselves and their parameters.
350 * The key objects are commonly refered to as |keydata|, and it MUST be able
351 * to contain parameters if the key has any, the public key and the private
352 * key. All parts are optional, but their presence determines what can be
353 * done with the key object in terms of encryption, signature, and so on.
354 * The assumption from libcrypto is that the key object contains any of the
355 * following data combinations:
359 * - public key + private key
360 * - parameters + public key
361 * - parameters + public key + private key
363 * What "parameters", "public key" and "private key" means in detail is left
364 * to the implementation. In the case of DH and DSA, they would typically
365 * include domain parameters, while for certain variants of RSA, they would
366 * typically include PSS or OAEP parameters.
368 * Key objects are created with OP_keymgmt_new() and destroyed with
369 * Op_keymgmt_free(). Key objects can have data filled in with
370 * OP_keymgmt_import().
372 * Three functions are made available to check what selection of data is
373 * present in a key object: OP_keymgmt_has_parameters(),
374 * OP_keymgmt_has_public_key(), and OP_keymgmt_has_private_key(),
377 /* Key data subset selection - individual bits */
378 # define OSSL_KEYMGMT_SELECT_PRIVATE_KEY 0x01
379 # define OSSL_KEYMGMT_SELECT_PUBLIC_KEY 0x02
380 # define OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS 0x04
381 # define OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS 0x80
383 /* Key data subset selection - combinations */
384 # define OSSL_KEYMGMT_SELECT_ALL_PARAMETERS \
385 ( OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS \
386 | OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS)
387 # define OSSL_KEYMGMT_SELECT_KEYPAIR \
388 ( OSSL_KEYMGMT_SELECT_PRIVATE_KEY | OSSL_KEYMGMT_SELECT_PUBLIC_KEY )
389 # define OSSL_KEYMGMT_SELECT_ALL \
390 ( OSSL_KEYMGMT_SELECT_KEYPAIR | OSSL_KEYMGMT_SELECT_ALL_PARAMETERS )
392 /* Basic key object creation */
393 # define OSSL_FUNC_KEYMGMT_NEW 1
394 OSSL_CORE_MAKE_FUNC(void *, OP_keymgmt_new, (void *provctx))
396 /* Generation, a more complex constructor */
397 # define OSSL_FUNC_KEYMGMT_GEN_INIT 2
398 # define OSSL_FUNC_KEYMGMT_GEN_SET_TEMPLATE 3
399 # define OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS 4
400 # define OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS 5
401 # define OSSL_FUNC_KEYMGMT_GEN 6
402 # define OSSL_FUNC_KEYMGMT_GEN_CLEANUP 7
403 OSSL_CORE_MAKE_FUNC(void *, OP_keymgmt_gen_init,
404 (void *provctx, int selection))
405 OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_gen_set_template,
406 (void *genctx, void *templ))
407 OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_gen_set_params,
408 (void *genctx, const OSSL_PARAM params[]))
409 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,
410 OP_keymgmt_gen_settable_params, (void *provctx))
411 OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_gen_get_params,
412 (void *genctx, OSSL_PARAM params[]))
413 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,
414 OP_keymgmt_gen_gettable_params, (void *provctx))
415 OSSL_CORE_MAKE_FUNC(void *, OP_keymgmt_gen,
416 (void *genctx, OSSL_CALLBACK *cb, void *cbarg))
417 OSSL_CORE_MAKE_FUNC(void, OP_keymgmt_gen_cleanup, (void *genctx))
419 /* Basic key object destruction */
420 # define OSSL_FUNC_KEYMGMT_FREE 10
421 OSSL_CORE_MAKE_FUNC(void, OP_keymgmt_free, (void *keydata))
423 /* Key object information, with discovery */
424 #define OSSL_FUNC_KEYMGMT_GET_PARAMS 11
425 #define OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS 12
426 OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_get_params,
427 (void *keydata, OSSL_PARAM params[]))
428 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_keymgmt_gettable_params, (void))
430 #define OSSL_FUNC_KEYMGMT_SET_PARAMS 13
431 #define OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS 14
432 OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_set_params,
433 (void *keydata, const OSSL_PARAM params[]))
434 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_keymgmt_settable_params, (void))
436 /* Key checks - discovery of supported operations */
437 # define OSSL_FUNC_KEYMGMT_QUERY_OPERATION_NAME 20
438 OSSL_CORE_MAKE_FUNC(const char *, OP_keymgmt_query_operation_name,
441 /* Key checks - key data content checks */
442 # define OSSL_FUNC_KEYMGMT_HAS 21
443 OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_has, (void *keydata, int selection))
445 /* Key checks - validation */
446 # define OSSL_FUNC_KEYMGMT_VALIDATE 22
447 OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_validate, (void *keydata, int selection))
449 /* Key checks - matching */
450 # define OSSL_FUNC_KEYMGMT_MATCH 23
451 OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_match,
452 (const void *keydata1, const void *keydata2,
455 /* Import and export functions, with discovery */
456 # define OSSL_FUNC_KEYMGMT_IMPORT 40
457 # define OSSL_FUNC_KEYMGMT_IMPORT_TYPES 41
458 # define OSSL_FUNC_KEYMGMT_EXPORT 42
459 # define OSSL_FUNC_KEYMGMT_EXPORT_TYPES 43
460 OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_import,
461 (void *keydata, int selection, const OSSL_PARAM params[]))
462 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_keymgmt_import_types,
464 OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_export,
465 (void *keydata, int selection,
466 OSSL_CALLBACK *param_cb, void *cbarg))
467 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_keymgmt_export_types,
470 /* Copy function, only works for matching keymgmt */
471 # define OSSL_FUNC_KEYMGMT_COPY 44
472 OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_copy,
473 ( void *keydata_to, const void *keydata_from,
478 # define OSSL_FUNC_KEYEXCH_NEWCTX 1
479 # define OSSL_FUNC_KEYEXCH_INIT 2
480 # define OSSL_FUNC_KEYEXCH_DERIVE 3
481 # define OSSL_FUNC_KEYEXCH_SET_PEER 4
482 # define OSSL_FUNC_KEYEXCH_FREECTX 5
483 # define OSSL_FUNC_KEYEXCH_DUPCTX 6
484 # define OSSL_FUNC_KEYEXCH_SET_CTX_PARAMS 7
485 # define OSSL_FUNC_KEYEXCH_SETTABLE_CTX_PARAMS 8
486 # define OSSL_FUNC_KEYEXCH_GET_CTX_PARAMS 9
487 # define OSSL_FUNC_KEYEXCH_GETTABLE_CTX_PARAMS 10
489 OSSL_CORE_MAKE_FUNC(void *, OP_keyexch_newctx, (void *provctx))
490 OSSL_CORE_MAKE_FUNC(int, OP_keyexch_init, (void *ctx, void *provkey))
491 OSSL_CORE_MAKE_FUNC(int, OP_keyexch_derive, (void *ctx, unsigned char *secret,
492 size_t *secretlen, size_t outlen))
493 OSSL_CORE_MAKE_FUNC(int, OP_keyexch_set_peer, (void *ctx, void *provkey))
494 OSSL_CORE_MAKE_FUNC(void, OP_keyexch_freectx, (void *ctx))
495 OSSL_CORE_MAKE_FUNC(void *, OP_keyexch_dupctx, (void *ctx))
496 OSSL_CORE_MAKE_FUNC(int, OP_keyexch_set_ctx_params, (void *ctx,
497 const OSSL_PARAM params[]))
498 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_keyexch_settable_ctx_params,
500 OSSL_CORE_MAKE_FUNC(int, OP_keyexch_get_ctx_params, (void *ctx,
501 OSSL_PARAM params[]))
502 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_keyexch_gettable_ctx_params,
507 # define OSSL_FUNC_SIGNATURE_NEWCTX 1
508 # define OSSL_FUNC_SIGNATURE_SIGN_INIT 2
509 # define OSSL_FUNC_SIGNATURE_SIGN 3
510 # define OSSL_FUNC_SIGNATURE_VERIFY_INIT 4
511 # define OSSL_FUNC_SIGNATURE_VERIFY 5
512 # define OSSL_FUNC_SIGNATURE_VERIFY_RECOVER_INIT 6
513 # define OSSL_FUNC_SIGNATURE_VERIFY_RECOVER 7
514 # define OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT 8
515 # define OSSL_FUNC_SIGNATURE_DIGEST_SIGN_UPDATE 9
516 # define OSSL_FUNC_SIGNATURE_DIGEST_SIGN_FINAL 10
517 # define OSSL_FUNC_SIGNATURE_DIGEST_SIGN 11
518 # define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT 12
519 # define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_UPDATE 13
520 # define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_FINAL 14
521 # define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY 15
522 # define OSSL_FUNC_SIGNATURE_FREECTX 16
523 # define OSSL_FUNC_SIGNATURE_DUPCTX 17
524 # define OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS 18
525 # define OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS 19
526 # define OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS 20
527 # define OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS 21
528 # define OSSL_FUNC_SIGNATURE_GET_CTX_MD_PARAMS 22
529 # define OSSL_FUNC_SIGNATURE_GETTABLE_CTX_MD_PARAMS 23
530 # define OSSL_FUNC_SIGNATURE_SET_CTX_MD_PARAMS 24
531 # define OSSL_FUNC_SIGNATURE_SETTABLE_CTX_MD_PARAMS 25
533 OSSL_CORE_MAKE_FUNC(void *, OP_signature_newctx, (void *provctx,
535 OSSL_CORE_MAKE_FUNC(int, OP_signature_sign_init, (void *ctx, void *provkey))
536 OSSL_CORE_MAKE_FUNC(int, OP_signature_sign, (void *ctx, unsigned char *sig,
537 size_t *siglen, size_t sigsize,
538 const unsigned char *tbs,
540 OSSL_CORE_MAKE_FUNC(int, OP_signature_verify_init, (void *ctx, void *provkey))
541 OSSL_CORE_MAKE_FUNC(int, OP_signature_verify, (void *ctx,
542 const unsigned char *sig,
544 const unsigned char *tbs,
546 OSSL_CORE_MAKE_FUNC(int, OP_signature_verify_recover_init, (void *ctx,
548 OSSL_CORE_MAKE_FUNC(int, OP_signature_verify_recover, (void *ctx,
552 const unsigned char *sig,
554 OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_sign_init,
555 (void *ctx, const char *mdname, void *provkey))
556 OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_sign_update,
557 (void *ctx, const unsigned char *data, size_t datalen))
558 OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_sign_final,
559 (void *ctx, unsigned char *sig, size_t *siglen,
561 OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_sign,
562 (void *ctx, unsigned char *sigret, size_t *siglen,
563 size_t sigsize, const unsigned char *tbs, size_t tbslen))
564 OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_verify_init,
565 (void *ctx, const char *mdname, void *provkey))
566 OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_verify_update,
567 (void *ctx, const unsigned char *data, size_t datalen))
568 OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_verify_final,
569 (void *ctx, const unsigned char *sig, size_t siglen))
570 OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_verify,
571 (void *ctx, const unsigned char *sig, size_t siglen,
572 const unsigned char *tbs, size_t tbslen))
573 OSSL_CORE_MAKE_FUNC(void, OP_signature_freectx, (void *ctx))
574 OSSL_CORE_MAKE_FUNC(void *, OP_signature_dupctx, (void *ctx))
575 OSSL_CORE_MAKE_FUNC(int, OP_signature_get_ctx_params,
576 (void *ctx, OSSL_PARAM params[]))
577 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_signature_gettable_ctx_params,
579 OSSL_CORE_MAKE_FUNC(int, OP_signature_set_ctx_params,
580 (void *ctx, const OSSL_PARAM params[]))
581 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_signature_settable_ctx_params,
583 OSSL_CORE_MAKE_FUNC(int, OP_signature_get_ctx_md_params,
584 (void *ctx, OSSL_PARAM params[]))
585 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_signature_gettable_ctx_md_params,
587 OSSL_CORE_MAKE_FUNC(int, OP_signature_set_ctx_md_params,
588 (void *ctx, const OSSL_PARAM params[]))
589 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_signature_settable_ctx_md_params,
593 /* Asymmetric Ciphers */
595 # define OSSL_FUNC_ASYM_CIPHER_NEWCTX 1
596 # define OSSL_FUNC_ASYM_CIPHER_ENCRYPT_INIT 2
597 # define OSSL_FUNC_ASYM_CIPHER_ENCRYPT 3
598 # define OSSL_FUNC_ASYM_CIPHER_DECRYPT_INIT 4
599 # define OSSL_FUNC_ASYM_CIPHER_DECRYPT 5
600 # define OSSL_FUNC_ASYM_CIPHER_FREECTX 6
601 # define OSSL_FUNC_ASYM_CIPHER_DUPCTX 7
602 # define OSSL_FUNC_ASYM_CIPHER_GET_CTX_PARAMS 8
603 # define OSSL_FUNC_ASYM_CIPHER_GETTABLE_CTX_PARAMS 9
604 # define OSSL_FUNC_ASYM_CIPHER_SET_CTX_PARAMS 10
605 # define OSSL_FUNC_ASYM_CIPHER_SETTABLE_CTX_PARAMS 11
607 OSSL_CORE_MAKE_FUNC(void *, OP_asym_cipher_newctx, (void *provctx))
608 OSSL_CORE_MAKE_FUNC(int, OP_asym_cipher_encrypt_init, (void *ctx, void *provkey))
609 OSSL_CORE_MAKE_FUNC(int, OP_asym_cipher_encrypt, (void *ctx, unsigned char *out,
612 const unsigned char *in,
614 OSSL_CORE_MAKE_FUNC(int, OP_asym_cipher_decrypt_init, (void *ctx, void *provkey))
615 OSSL_CORE_MAKE_FUNC(int, OP_asym_cipher_decrypt, (void *ctx, unsigned char *out,
618 const unsigned char *in,
620 OSSL_CORE_MAKE_FUNC(void, OP_asym_cipher_freectx, (void *ctx))
621 OSSL_CORE_MAKE_FUNC(void *, OP_asym_cipher_dupctx, (void *ctx))
622 OSSL_CORE_MAKE_FUNC(int, OP_asym_cipher_get_ctx_params,
623 (void *ctx, OSSL_PARAM params[]))
624 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_asym_cipher_gettable_ctx_params,
626 OSSL_CORE_MAKE_FUNC(int, OP_asym_cipher_set_ctx_params,
627 (void *ctx, const OSSL_PARAM params[]))
628 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_asym_cipher_settable_ctx_params,
632 # define OSSL_FUNC_SERIALIZER_NEWCTX 1
633 # define OSSL_FUNC_SERIALIZER_FREECTX 2
634 # define OSSL_FUNC_SERIALIZER_SET_CTX_PARAMS 3
635 # define OSSL_FUNC_SERIALIZER_SETTABLE_CTX_PARAMS 4
636 # define OSSL_FUNC_SERIALIZER_SERIALIZE_DATA 10
637 # define OSSL_FUNC_SERIALIZER_SERIALIZE_OBJECT 11
638 OSSL_CORE_MAKE_FUNC(void *, OP_serializer_newctx, (void *provctx))
639 OSSL_CORE_MAKE_FUNC(void, OP_serializer_freectx, (void *ctx))
640 OSSL_CORE_MAKE_FUNC(int, OP_serializer_set_ctx_params,
641 (void *ctx, const OSSL_PARAM params[]))
642 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_serializer_settable_ctx_params,
645 OSSL_CORE_MAKE_FUNC(int, OP_serializer_serialize_data,
646 (void *ctx, const OSSL_PARAM[], OSSL_CORE_BIO *out,
647 OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg))
648 OSSL_CORE_MAKE_FUNC(int, OP_serializer_serialize_object,
649 (void *ctx, void *obj, OSSL_CORE_BIO *out,
650 OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg))