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