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