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,
174 # define OSSL_OP_DIGEST 1
175 # define OSSL_OP_CIPHER 2 /* Symmetric Ciphers */
176 # define OSSL_OP_MAC 3
177 # define OSSL_OP_KDF 4
178 # define OSSL_OP_KEYMGMT 10
179 # define OSSL_OP_KEYEXCH 11
180 # define OSSL_OP_SIGNATURE 12
181 # define OSSL_OP_ASYM_CIPHER 13
182 /* New section for non-EVP operations */
183 # define OSSL_OP_SERIALIZER 20
184 /* Highest known operation number */
185 # define OSSL_OP__HIGHEST 20
189 # define OSSL_FUNC_DIGEST_NEWCTX 1
190 # define OSSL_FUNC_DIGEST_INIT 2
191 # define OSSL_FUNC_DIGEST_UPDATE 3
192 # define OSSL_FUNC_DIGEST_FINAL 4
193 # define OSSL_FUNC_DIGEST_DIGEST 5
194 # define OSSL_FUNC_DIGEST_FREECTX 6
195 # define OSSL_FUNC_DIGEST_DUPCTX 7
196 # define OSSL_FUNC_DIGEST_GET_PARAMS 8
197 # define OSSL_FUNC_DIGEST_SET_CTX_PARAMS 9
198 # define OSSL_FUNC_DIGEST_GET_CTX_PARAMS 10
199 # define OSSL_FUNC_DIGEST_GETTABLE_PARAMS 11
200 # define OSSL_FUNC_DIGEST_SETTABLE_CTX_PARAMS 12
201 # define OSSL_FUNC_DIGEST_GETTABLE_CTX_PARAMS 13
203 OSSL_CORE_MAKE_FUNC(void *, OP_digest_newctx, (void *provctx))
204 OSSL_CORE_MAKE_FUNC(int, OP_digest_init, (void *dctx))
205 OSSL_CORE_MAKE_FUNC(int, OP_digest_update,
206 (void *dctx, const unsigned char *in, size_t inl))
207 OSSL_CORE_MAKE_FUNC(int, OP_digest_final,
209 unsigned char *out, size_t *outl, size_t outsz))
210 OSSL_CORE_MAKE_FUNC(int, OP_digest_digest,
211 (void *provctx, const unsigned char *in, size_t inl,
212 unsigned char *out, size_t *outl, size_t outsz))
214 OSSL_CORE_MAKE_FUNC(void, OP_digest_freectx, (void *dctx))
215 OSSL_CORE_MAKE_FUNC(void *, OP_digest_dupctx, (void *dctx))
217 OSSL_CORE_MAKE_FUNC(int, OP_digest_get_params, (OSSL_PARAM params[]))
218 OSSL_CORE_MAKE_FUNC(int, OP_digest_set_ctx_params,
219 (void *vctx, const OSSL_PARAM params[]))
220 OSSL_CORE_MAKE_FUNC(int, OP_digest_get_ctx_params,
221 (void *vctx, OSSL_PARAM params[]))
222 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_digest_gettable_params, (void))
223 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_digest_settable_ctx_params, (void))
224 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_digest_gettable_ctx_params, (void))
226 /* Symmetric Ciphers */
228 # define OSSL_FUNC_CIPHER_NEWCTX 1
229 # define OSSL_FUNC_CIPHER_ENCRYPT_INIT 2
230 # define OSSL_FUNC_CIPHER_DECRYPT_INIT 3
231 # define OSSL_FUNC_CIPHER_UPDATE 4
232 # define OSSL_FUNC_CIPHER_FINAL 5
233 # define OSSL_FUNC_CIPHER_CIPHER 6
234 # define OSSL_FUNC_CIPHER_FREECTX 7
235 # define OSSL_FUNC_CIPHER_DUPCTX 8
236 # define OSSL_FUNC_CIPHER_GET_PARAMS 9
237 # define OSSL_FUNC_CIPHER_GET_CTX_PARAMS 10
238 # define OSSL_FUNC_CIPHER_SET_CTX_PARAMS 11
239 # define OSSL_FUNC_CIPHER_GETTABLE_PARAMS 12
240 # define OSSL_FUNC_CIPHER_GETTABLE_CTX_PARAMS 13
241 # define OSSL_FUNC_CIPHER_SETTABLE_CTX_PARAMS 14
243 OSSL_CORE_MAKE_FUNC(void *, OP_cipher_newctx, (void *provctx))
244 OSSL_CORE_MAKE_FUNC(int, OP_cipher_encrypt_init, (void *cctx,
245 const unsigned char *key,
247 const unsigned char *iv,
249 OSSL_CORE_MAKE_FUNC(int, OP_cipher_decrypt_init, (void *cctx,
250 const unsigned char *key,
252 const unsigned char *iv,
254 OSSL_CORE_MAKE_FUNC(int, OP_cipher_update,
256 unsigned char *out, size_t *outl, size_t outsize,
257 const unsigned char *in, size_t inl))
258 OSSL_CORE_MAKE_FUNC(int, OP_cipher_final,
260 unsigned char *out, size_t *outl, size_t outsize))
261 OSSL_CORE_MAKE_FUNC(int, OP_cipher_cipher,
263 unsigned char *out, size_t *outl, size_t outsize,
264 const unsigned char *in, size_t inl))
265 OSSL_CORE_MAKE_FUNC(void, OP_cipher_freectx, (void *cctx))
266 OSSL_CORE_MAKE_FUNC(void *, OP_cipher_dupctx, (void *cctx))
267 OSSL_CORE_MAKE_FUNC(int, OP_cipher_get_params, (OSSL_PARAM params[]))
268 OSSL_CORE_MAKE_FUNC(int, OP_cipher_get_ctx_params, (void *cctx,
269 OSSL_PARAM params[]))
270 OSSL_CORE_MAKE_FUNC(int, OP_cipher_set_ctx_params, (void *cctx,
271 const OSSL_PARAM params[]))
272 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_cipher_gettable_params, (void))
273 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_cipher_settable_ctx_params, (void))
274 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_cipher_gettable_ctx_params, (void))
278 # define OSSL_FUNC_MAC_NEWCTX 1
279 # define OSSL_FUNC_MAC_DUPCTX 2
280 # define OSSL_FUNC_MAC_FREECTX 3
281 # define OSSL_FUNC_MAC_INIT 4
282 # define OSSL_FUNC_MAC_UPDATE 5
283 # define OSSL_FUNC_MAC_FINAL 6
284 # define OSSL_FUNC_MAC_GET_PARAMS 7
285 # define OSSL_FUNC_MAC_GET_CTX_PARAMS 8
286 # define OSSL_FUNC_MAC_SET_CTX_PARAMS 9
287 # define OSSL_FUNC_MAC_GETTABLE_PARAMS 10
288 # define OSSL_FUNC_MAC_GETTABLE_CTX_PARAMS 11
289 # define OSSL_FUNC_MAC_SETTABLE_CTX_PARAMS 12
291 OSSL_CORE_MAKE_FUNC(void *, OP_mac_newctx, (void *provctx))
292 OSSL_CORE_MAKE_FUNC(void *, OP_mac_dupctx, (void *src))
293 OSSL_CORE_MAKE_FUNC(void, OP_mac_freectx, (void *mctx))
294 OSSL_CORE_MAKE_FUNC(size_t, OP_mac_size, (void *mctx))
295 OSSL_CORE_MAKE_FUNC(int, OP_mac_init, (void *mctx))
296 OSSL_CORE_MAKE_FUNC(int, OP_mac_update,
297 (void *mctx, const unsigned char *in, size_t inl))
298 OSSL_CORE_MAKE_FUNC(int, OP_mac_final,
300 unsigned char *out, size_t *outl, size_t outsize))
301 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_mac_gettable_params, (void))
302 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_mac_gettable_ctx_params, (void))
303 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_mac_settable_ctx_params, (void))
304 OSSL_CORE_MAKE_FUNC(int, OP_mac_get_params, (OSSL_PARAM params[]))
305 OSSL_CORE_MAKE_FUNC(int, OP_mac_get_ctx_params,
306 (void *mctx, OSSL_PARAM params[]))
307 OSSL_CORE_MAKE_FUNC(int, OP_mac_set_ctx_params,
308 (void *mctx, const OSSL_PARAM params[]))
312 # define OSSL_FUNC_KDF_NEWCTX 1
313 # define OSSL_FUNC_KDF_DUPCTX 2
314 # define OSSL_FUNC_KDF_FREECTX 3
315 # define OSSL_FUNC_KDF_RESET 4
316 # define OSSL_FUNC_KDF_DERIVE 5
317 # define OSSL_FUNC_KDF_GETTABLE_PARAMS 6
318 # define OSSL_FUNC_KDF_GETTABLE_CTX_PARAMS 7
319 # define OSSL_FUNC_KDF_SETTABLE_CTX_PARAMS 8
320 # define OSSL_FUNC_KDF_GET_PARAMS 9
321 # define OSSL_FUNC_KDF_GET_CTX_PARAMS 10
322 # define OSSL_FUNC_KDF_SET_CTX_PARAMS 11
324 OSSL_CORE_MAKE_FUNC(void *, OP_kdf_newctx, (void *provctx))
325 OSSL_CORE_MAKE_FUNC(void *, OP_kdf_dupctx, (void *src))
326 OSSL_CORE_MAKE_FUNC(void, OP_kdf_freectx, (void *kctx))
327 OSSL_CORE_MAKE_FUNC(void, OP_kdf_reset, (void *kctx))
328 OSSL_CORE_MAKE_FUNC(int, OP_kdf_derive, (void *kctx, unsigned char *key,
330 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_kdf_gettable_params, (void))
331 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_kdf_gettable_ctx_params, (void))
332 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_kdf_settable_ctx_params, (void))
333 OSSL_CORE_MAKE_FUNC(int, OP_kdf_get_params, (OSSL_PARAM params[]))
334 OSSL_CORE_MAKE_FUNC(int, OP_kdf_get_ctx_params,
335 (void *kctx, OSSL_PARAM params[]))
336 OSSL_CORE_MAKE_FUNC(int, OP_kdf_set_ctx_params,
337 (void *kctx, const OSSL_PARAM params[]))
342 * The Key Management takes care of provider side key objects, and includes
343 * all current functionality to create them, destroy them, set parameters
344 * and key material, etc, essentially everything that manipulates the keys
345 * themselves and their parameters.
347 * The key objects are commonly refered to as |keydata|, and it MUST be able
348 * to contain parameters if the key has any, the public key and the private
349 * key. All parts are optional, but their presence determines what can be
350 * done with the key object in terms of encryption, signature, and so on.
351 * The assumption from libcrypto is that the key object contains any of the
352 * following data combinations:
356 * - public key + private key
357 * - parameters + public key
358 * - parameters + public key + private key
360 * What "parameters", "public key" and "private key" means in detail is left
361 * to the implementation. In the case of DH and DSA, they would typically
362 * include domain parameters, while for certain variants of RSA, they would
363 * typically include PSS or OAEP parameters.
365 * Key objects are created with OP_keymgmt_new() and destroyed with
366 * Op_keymgmt_free(). Key objects can have data filled in with
367 * OP_keymgmt_import().
369 * Three functions are made available to check what selection of data is
370 * present in a key object: OP_keymgmt_has_parameters(),
371 * OP_keymgmt_has_public_key(), and OP_keymgmt_has_private_key(),
374 /* Key data subset selection - individual bits */
375 # define OSSL_KEYMGMT_SELECT_PRIVATE_KEY 0x01
376 # define OSSL_KEYMGMT_SELECT_PUBLIC_KEY 0x02
377 # define OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS 0x04
378 # define OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS 0x80
380 /* Key data subset selection - combinations */
381 # define OSSL_KEYMGMT_SELECT_ALL_PARAMETERS \
382 ( OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS \
383 | OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS)
384 # define OSSL_KEYMGMT_SELECT_KEYPAIR \
385 ( OSSL_KEYMGMT_SELECT_PRIVATE_KEY | OSSL_KEYMGMT_SELECT_PUBLIC_KEY )
386 # define OSSL_KEYMGMT_SELECT_ALL \
387 ( OSSL_KEYMGMT_SELECT_KEYPAIR | OSSL_KEYMGMT_SELECT_ALL_PARAMETERS )
389 /* Basic key object creation */
390 # define OSSL_FUNC_KEYMGMT_NEW 1
391 OSSL_CORE_MAKE_FUNC(void *, OP_keymgmt_new, (void *provctx))
393 /* Generation, a more complex constructor */
394 # define OSSL_FUNC_KEYMGMT_GEN_INIT 2
395 # define OSSL_FUNC_KEYMGMT_GEN_SET_TEMPLATE 3
396 # define OSSL_FUNC_KEYMGMT_GEN_SET_PARAMS 4
397 # define OSSL_FUNC_KEYMGMT_GEN_SETTABLE_PARAMS 5
398 # define OSSL_FUNC_KEYMGMT_GEN 6
399 # define OSSL_FUNC_KEYMGMT_GEN_CLEANUP 7
400 OSSL_CORE_MAKE_FUNC(void *, OP_keymgmt_gen_init,
401 (void *provctx, int selection))
402 OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_gen_set_template,
403 (void *genctx, void *templ))
404 OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_gen_set_params,
405 (void *genctx, const OSSL_PARAM params[]))
406 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,
407 OP_keymgmt_gen_settable_params, (void *provctx))
408 OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_gen_get_params,
409 (void *genctx, OSSL_PARAM params[]))
410 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,
411 OP_keymgmt_gen_gettable_params, (void *provctx))
412 OSSL_CORE_MAKE_FUNC(void *, OP_keymgmt_gen,
413 (void *genctx, OSSL_CALLBACK *cb, void *cbarg))
414 OSSL_CORE_MAKE_FUNC(void, OP_keymgmt_gen_cleanup, (void *genctx))
416 /* Basic key object destruction */
417 # define OSSL_FUNC_KEYMGMT_FREE 10
418 OSSL_CORE_MAKE_FUNC(void, OP_keymgmt_free, (void *keydata))
420 /* Key object information, with discovery */
421 #define OSSL_FUNC_KEYMGMT_GET_PARAMS 11
422 #define OSSL_FUNC_KEYMGMT_GETTABLE_PARAMS 12
423 OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_get_params,
424 (void *keydata, OSSL_PARAM params[]))
425 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_keymgmt_gettable_params, (void))
427 #define OSSL_FUNC_KEYMGMT_SET_PARAMS 13
428 #define OSSL_FUNC_KEYMGMT_SETTABLE_PARAMS 14
429 OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_set_params,
430 (void *keydata, const OSSL_PARAM params[]))
431 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_keymgmt_settable_params, (void))
433 /* Key checks - discovery of supported operations */
434 # define OSSL_FUNC_KEYMGMT_QUERY_OPERATION_NAME 20
435 OSSL_CORE_MAKE_FUNC(const char *, OP_keymgmt_query_operation_name,
438 /* Key checks - key data content checks */
439 # define OSSL_FUNC_KEYMGMT_HAS 21
440 OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_has, (void *keydata, int selection))
442 /* Key checks - validation */
443 # define OSSL_FUNC_KEYMGMT_VALIDATE 22
444 OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_validate, (void *keydata, int selection))
446 /* Key checks - matching */
447 # define OSSL_FUNC_KEYMGMT_MATCH 23
448 OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_match,
449 (const void *keydata1, const void *keydata2,
452 /* Import and export functions, with discovery */
453 # define OSSL_FUNC_KEYMGMT_IMPORT 40
454 # define OSSL_FUNC_KEYMGMT_IMPORT_TYPES 41
455 # define OSSL_FUNC_KEYMGMT_EXPORT 42
456 # define OSSL_FUNC_KEYMGMT_EXPORT_TYPES 43
457 OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_import,
458 (void *keydata, int selection, const OSSL_PARAM params[]))
459 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_keymgmt_import_types,
461 OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_export,
462 (void *keydata, int selection,
463 OSSL_CALLBACK *param_cb, void *cbarg))
464 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_keymgmt_export_types,
467 /* Copy function, only works for matching keymgmt */
468 # define OSSL_FUNC_KEYMGMT_COPY 44
469 OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_copy,
470 ( void *keydata_to, const void *keydata_from,
475 # define OSSL_FUNC_KEYEXCH_NEWCTX 1
476 # define OSSL_FUNC_KEYEXCH_INIT 2
477 # define OSSL_FUNC_KEYEXCH_DERIVE 3
478 # define OSSL_FUNC_KEYEXCH_SET_PEER 4
479 # define OSSL_FUNC_KEYEXCH_FREECTX 5
480 # define OSSL_FUNC_KEYEXCH_DUPCTX 6
481 # define OSSL_FUNC_KEYEXCH_SET_CTX_PARAMS 7
482 # define OSSL_FUNC_KEYEXCH_SETTABLE_CTX_PARAMS 8
483 # define OSSL_FUNC_KEYEXCH_GET_CTX_PARAMS 9
484 # define OSSL_FUNC_KEYEXCH_GETTABLE_CTX_PARAMS 10
486 OSSL_CORE_MAKE_FUNC(void *, OP_keyexch_newctx, (void *provctx))
487 OSSL_CORE_MAKE_FUNC(int, OP_keyexch_init, (void *ctx, void *provkey))
488 OSSL_CORE_MAKE_FUNC(int, OP_keyexch_derive, (void *ctx, unsigned char *secret,
489 size_t *secretlen, size_t outlen))
490 OSSL_CORE_MAKE_FUNC(int, OP_keyexch_set_peer, (void *ctx, void *provkey))
491 OSSL_CORE_MAKE_FUNC(void, OP_keyexch_freectx, (void *ctx))
492 OSSL_CORE_MAKE_FUNC(void *, OP_keyexch_dupctx, (void *ctx))
493 OSSL_CORE_MAKE_FUNC(int, OP_keyexch_set_ctx_params, (void *ctx,
494 const OSSL_PARAM params[]))
495 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_keyexch_settable_ctx_params,
497 OSSL_CORE_MAKE_FUNC(int, OP_keyexch_get_ctx_params, (void *ctx,
498 OSSL_PARAM params[]))
499 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_keyexch_gettable_ctx_params,
504 # define OSSL_FUNC_SIGNATURE_NEWCTX 1
505 # define OSSL_FUNC_SIGNATURE_SIGN_INIT 2
506 # define OSSL_FUNC_SIGNATURE_SIGN 3
507 # define OSSL_FUNC_SIGNATURE_VERIFY_INIT 4
508 # define OSSL_FUNC_SIGNATURE_VERIFY 5
509 # define OSSL_FUNC_SIGNATURE_VERIFY_RECOVER_INIT 6
510 # define OSSL_FUNC_SIGNATURE_VERIFY_RECOVER 7
511 # define OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT 8
512 # define OSSL_FUNC_SIGNATURE_DIGEST_SIGN_UPDATE 9
513 # define OSSL_FUNC_SIGNATURE_DIGEST_SIGN_FINAL 10
514 # define OSSL_FUNC_SIGNATURE_DIGEST_SIGN 11
515 # define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT 12
516 # define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_UPDATE 13
517 # define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_FINAL 14
518 # define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY 15
519 # define OSSL_FUNC_SIGNATURE_FREECTX 16
520 # define OSSL_FUNC_SIGNATURE_DUPCTX 17
521 # define OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS 18
522 # define OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS 19
523 # define OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS 20
524 # define OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS 21
525 # define OSSL_FUNC_SIGNATURE_GET_CTX_MD_PARAMS 22
526 # define OSSL_FUNC_SIGNATURE_GETTABLE_CTX_MD_PARAMS 23
527 # define OSSL_FUNC_SIGNATURE_SET_CTX_MD_PARAMS 24
528 # define OSSL_FUNC_SIGNATURE_SETTABLE_CTX_MD_PARAMS 25
530 OSSL_CORE_MAKE_FUNC(void *, OP_signature_newctx, (void *provctx,
532 OSSL_CORE_MAKE_FUNC(int, OP_signature_sign_init, (void *ctx, void *provkey))
533 OSSL_CORE_MAKE_FUNC(int, OP_signature_sign, (void *ctx, unsigned char *sig,
534 size_t *siglen, size_t sigsize,
535 const unsigned char *tbs,
537 OSSL_CORE_MAKE_FUNC(int, OP_signature_verify_init, (void *ctx, void *provkey))
538 OSSL_CORE_MAKE_FUNC(int, OP_signature_verify, (void *ctx,
539 const unsigned char *sig,
541 const unsigned char *tbs,
543 OSSL_CORE_MAKE_FUNC(int, OP_signature_verify_recover_init, (void *ctx,
545 OSSL_CORE_MAKE_FUNC(int, OP_signature_verify_recover, (void *ctx,
549 const unsigned char *sig,
551 OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_sign_init,
552 (void *ctx, const char *mdname, void *provkey))
553 OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_sign_update,
554 (void *ctx, const unsigned char *data, size_t datalen))
555 OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_sign_final,
556 (void *ctx, unsigned char *sig, size_t *siglen,
558 OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_sign,
559 (void *ctx, unsigned char *sigret, size_t *siglen,
560 size_t sigsize, const unsigned char *tbs, size_t tbslen))
561 OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_verify_init,
562 (void *ctx, const char *mdname, void *provkey))
563 OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_verify_update,
564 (void *ctx, const unsigned char *data, size_t datalen))
565 OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_verify_final,
566 (void *ctx, const unsigned char *sig, size_t siglen))
567 OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_verify,
568 (void *ctx, const unsigned char *sig, size_t siglen,
569 const unsigned char *tbs, size_t tbslen))
570 OSSL_CORE_MAKE_FUNC(void, OP_signature_freectx, (void *ctx))
571 OSSL_CORE_MAKE_FUNC(void *, OP_signature_dupctx, (void *ctx))
572 OSSL_CORE_MAKE_FUNC(int, OP_signature_get_ctx_params,
573 (void *ctx, OSSL_PARAM params[]))
574 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_signature_gettable_ctx_params,
576 OSSL_CORE_MAKE_FUNC(int, OP_signature_set_ctx_params,
577 (void *ctx, const OSSL_PARAM params[]))
578 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_signature_settable_ctx_params,
580 OSSL_CORE_MAKE_FUNC(int, OP_signature_get_ctx_md_params,
581 (void *ctx, OSSL_PARAM params[]))
582 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_signature_gettable_ctx_md_params,
584 OSSL_CORE_MAKE_FUNC(int, OP_signature_set_ctx_md_params,
585 (void *ctx, const OSSL_PARAM params[]))
586 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_signature_settable_ctx_md_params,
590 /* Asymmetric Ciphers */
592 # define OSSL_FUNC_ASYM_CIPHER_NEWCTX 1
593 # define OSSL_FUNC_ASYM_CIPHER_ENCRYPT_INIT 2
594 # define OSSL_FUNC_ASYM_CIPHER_ENCRYPT 3
595 # define OSSL_FUNC_ASYM_CIPHER_DECRYPT_INIT 4
596 # define OSSL_FUNC_ASYM_CIPHER_DECRYPT 5
597 # define OSSL_FUNC_ASYM_CIPHER_FREECTX 6
598 # define OSSL_FUNC_ASYM_CIPHER_DUPCTX 7
599 # define OSSL_FUNC_ASYM_CIPHER_GET_CTX_PARAMS 8
600 # define OSSL_FUNC_ASYM_CIPHER_GETTABLE_CTX_PARAMS 9
601 # define OSSL_FUNC_ASYM_CIPHER_SET_CTX_PARAMS 10
602 # define OSSL_FUNC_ASYM_CIPHER_SETTABLE_CTX_PARAMS 11
604 OSSL_CORE_MAKE_FUNC(void *, OP_asym_cipher_newctx, (void *provctx))
605 OSSL_CORE_MAKE_FUNC(int, OP_asym_cipher_encrypt_init, (void *ctx, void *provkey))
606 OSSL_CORE_MAKE_FUNC(int, OP_asym_cipher_encrypt, (void *ctx, unsigned char *out,
609 const unsigned char *in,
611 OSSL_CORE_MAKE_FUNC(int, OP_asym_cipher_decrypt_init, (void *ctx, void *provkey))
612 OSSL_CORE_MAKE_FUNC(int, OP_asym_cipher_decrypt, (void *ctx, unsigned char *out,
615 const unsigned char *in,
617 OSSL_CORE_MAKE_FUNC(void, OP_asym_cipher_freectx, (void *ctx))
618 OSSL_CORE_MAKE_FUNC(void *, OP_asym_cipher_dupctx, (void *ctx))
619 OSSL_CORE_MAKE_FUNC(int, OP_asym_cipher_get_ctx_params,
620 (void *ctx, OSSL_PARAM params[]))
621 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_asym_cipher_gettable_ctx_params,
623 OSSL_CORE_MAKE_FUNC(int, OP_asym_cipher_set_ctx_params,
624 (void *ctx, const OSSL_PARAM params[]))
625 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_asym_cipher_settable_ctx_params,
629 # define OSSL_FUNC_SERIALIZER_NEWCTX 1
630 # define OSSL_FUNC_SERIALIZER_FREECTX 2
631 # define OSSL_FUNC_SERIALIZER_SET_CTX_PARAMS 3
632 # define OSSL_FUNC_SERIALIZER_SETTABLE_CTX_PARAMS 4
633 # define OSSL_FUNC_SERIALIZER_SERIALIZE_DATA 10
634 # define OSSL_FUNC_SERIALIZER_SERIALIZE_OBJECT 11
635 OSSL_CORE_MAKE_FUNC(void *, OP_serializer_newctx, (void *provctx))
636 OSSL_CORE_MAKE_FUNC(void, OP_serializer_freectx, (void *ctx))
637 OSSL_CORE_MAKE_FUNC(int, OP_serializer_set_ctx_params,
638 (void *ctx, const OSSL_PARAM params[]))
639 OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_serializer_settable_ctx_params,
642 OSSL_CORE_MAKE_FUNC(int, OP_serializer_serialize_data,
643 (void *ctx, const OSSL_PARAM[], OSSL_CORE_BIO *out,
644 OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg))
645 OSSL_CORE_MAKE_FUNC(int, OP_serializer_serialize_object,
646 (void *ctx, void *obj, OSSL_CORE_BIO *out,
647 OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg))