]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/openssl/core_numbers.h
SERIALIZER: New API for serialization of objects through providers
[thirdparty/openssl.git] / include / openssl / core_numbers.h
CommitLineData
4c2883a9
RL
1/*
2 * Copyright 2019 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
ae4186b0
DMSP
10#ifndef OPENSSL_CORE_NUMBERS_H
11# define OPENSSL_CORE_NUMBERS_H
4c2883a9 12
3593266d 13# include <stdarg.h>
4c2883a9
RL
14# include <openssl/core.h>
15
16# ifdef __cplusplus
17extern "C" {
18# endif
19
20/*-
21 * Identities
22 * ----------
23 *
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.
28 *
29 * Names:
30 * for any function base name 'foo' (uppercase form 'FOO'), we will have
31 * the following:
32 * - a macro for the identity with the name OSSL_FUNC_'FOO' or derivates
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'
36 */
37
b60cba3c
RS
38/*
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).
43 */
4c2883a9
RL
44#define OSSL_CORE_MAKE_FUNC(type,name,args) \
45 typedef type (OSSL_##name##_fn)args; \
46 static ossl_inline \
47 OSSL_##name##_fn *OSSL_get_##name(const OSSL_DISPATCH *opf) \
48 { \
49 return (OSSL_##name##_fn *)opf->function; \
50 }
51
52/*
53 * Core function identities, for the two OSSL_DISPATCH tables being passed
54 * in the OSSL_provider_init call.
55 *
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.
58 */
59/* Functions provided by the Core to the provider, reserved numbers 1-1023 */
dca97d00 60# define OSSL_FUNC_CORE_GETTABLE_PARAMS 1
26175013 61OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,
dca97d00 62 core_gettable_params,(const OSSL_PROVIDER *prov))
4c2883a9
RL
63# define OSSL_FUNC_CORE_GET_PARAMS 2
64OSSL_CORE_MAKE_FUNC(int,core_get_params,(const OSSL_PROVIDER *prov,
4e7991b4 65 OSSL_PARAM params[]))
da747958
MC
66# define OSSL_FUNC_CORE_THREAD_START 3
67OSSL_CORE_MAKE_FUNC(int,core_thread_start,(const OSSL_PROVIDER *prov,
68 OSSL_thread_stop_handler_fn handfn))
49c64346 69# define OSSL_FUNC_CORE_GET_LIBRARY_CONTEXT 4
e7706e63
RL
70OSSL_CORE_MAKE_FUNC(OPENSSL_CTX *,core_get_library_context,
71 (const OSSL_PROVIDER *prov))
49c64346
RL
72# define OSSL_FUNC_CORE_NEW_ERROR 5
73OSSL_CORE_MAKE_FUNC(void,core_new_error,(const OSSL_PROVIDER *prov))
74# define OSSL_FUNC_CORE_SET_ERROR_DEBUG 6
75OSSL_CORE_MAKE_FUNC(void,core_set_error_debug,
76 (const OSSL_PROVIDER *prov,
77 const char *file, int line, const char *func))
78# define OSSL_FUNC_CORE_VSET_ERROR 7
79OSSL_CORE_MAKE_FUNC(void,core_vset_error,
80 (const OSSL_PROVIDER *prov,
81 uint32_t reason, const char *fmt, va_list args))
4c2883a9 82
b60cba3c
RS
83/* Memory allocation, freeing, clearing. */
84#define OSSL_FUNC_CRYPTO_MALLOC 10
85OSSL_CORE_MAKE_FUNC(void *,
86 CRYPTO_malloc, (size_t num, const char *file, int line))
87#define OSSL_FUNC_CRYPTO_ZALLOC 11
88OSSL_CORE_MAKE_FUNC(void *,
89 CRYPTO_zalloc, (size_t num, const char *file, int line))
037439c4 90#define OSSL_FUNC_CRYPTO_FREE 12
b60cba3c
RS
91OSSL_CORE_MAKE_FUNC(void,
92 CRYPTO_free, (void *ptr, const char *file, int line))
037439c4 93#define OSSL_FUNC_CRYPTO_CLEAR_FREE 13
b60cba3c
RS
94OSSL_CORE_MAKE_FUNC(void,
95 CRYPTO_clear_free, (void *ptr, size_t num, const char *file, int line))
037439c4 96#define OSSL_FUNC_CRYPTO_REALLOC 14
b60cba3c
RS
97OSSL_CORE_MAKE_FUNC(void *,
98 CRYPTO_realloc, (void *addr, size_t num, const char *file, int line))
037439c4 99#define OSSL_FUNC_CRYPTO_CLEAR_REALLOC 15
b60cba3c 100OSSL_CORE_MAKE_FUNC(void *,
784883fc
SL
101 CRYPTO_clear_realloc, (void *addr, size_t old_num, size_t num,
102 const char *file, int line))
037439c4 103#define OSSL_FUNC_CRYPTO_SECURE_MALLOC 16
b60cba3c
RS
104OSSL_CORE_MAKE_FUNC(void *,
105 CRYPTO_secure_malloc, (size_t num, const char *file, int line))
037439c4 106#define OSSL_FUNC_CRYPTO_SECURE_ZALLOC 17
b60cba3c
RS
107OSSL_CORE_MAKE_FUNC(void *,
108 CRYPTO_secure_zalloc, (size_t num, const char *file, int line))
037439c4 109#define OSSL_FUNC_CRYPTO_SECURE_FREE 18
b60cba3c
RS
110OSSL_CORE_MAKE_FUNC(void,
111 CRYPTO_secure_free, (void *ptr, const char *file, int line))
037439c4 112#define OSSL_FUNC_CRYPTO_SECURE_CLEAR_FREE 19
b60cba3c 113OSSL_CORE_MAKE_FUNC(void,
784883fc
SL
114 CRYPTO_secure_clear_free, (void *ptr, size_t num, const char *file,
115 int line))
037439c4 116#define OSSL_FUNC_CRYPTO_SECURE_ALLOCATED 20
b60cba3c
RS
117OSSL_CORE_MAKE_FUNC(int,
118 CRYPTO_secure_allocated, (const void *ptr))
037439c4 119#define OSSL_FUNC_OPENSSL_CLEANSE 21
b60cba3c
RS
120OSSL_CORE_MAKE_FUNC(void,
121 OPENSSL_cleanse, (void *ptr, size_t len))
cc38e643
MC
122#define OSSL_FUNC_CRYPTO_MEM_CTRL 22
123OSSL_CORE_MAKE_FUNC(int, CRYPTO_mem_ctrl, (int mode))
b60cba3c 124
25e60144 125/* Bio functions provided by the core */
cc38e643
MC
126#define OSSL_FUNC_BIO_NEW_FILE 23
127#define OSSL_FUNC_BIO_NEW_MEMBUF 24
128#define OSSL_FUNC_BIO_READ_EX 25
129#define OSSL_FUNC_BIO_FREE 26
25e60144
SL
130
131OSSL_CORE_MAKE_FUNC(BIO *, BIO_new_file, (const char *filename, const char *mode))
132OSSL_CORE_MAKE_FUNC(BIO *, BIO_new_membuf, (const void *buf, int len))
7bb82f92
SL
133OSSL_CORE_MAKE_FUNC(int, BIO_read_ex, (BIO *bio, void *data, size_t data_len,
134 size_t *bytes_read))
25e60144
SL
135OSSL_CORE_MAKE_FUNC(int, BIO_free, (BIO *bio))
136
4c2883a9
RL
137/* Functions provided by the provider to the Core, reserved numbers 1024-1535 */
138# define OSSL_FUNC_PROVIDER_TEARDOWN 1024
a39eb840 139OSSL_CORE_MAKE_FUNC(void,provider_teardown,(void *provctx))
dca97d00 140# define OSSL_FUNC_PROVIDER_GETTABLE_PARAMS 1025
26175013 141OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *,
dca97d00 142 provider_gettable_params,(void *provctx))
4c2883a9 143# define OSSL_FUNC_PROVIDER_GET_PARAMS 1026
a39eb840 144OSSL_CORE_MAKE_FUNC(int,provider_get_params,(void *provctx,
4e7991b4 145 OSSL_PARAM params[]))
099bd339
RL
146# define OSSL_FUNC_PROVIDER_QUERY_OPERATION 1027
147OSSL_CORE_MAKE_FUNC(const OSSL_ALGORITHM *,provider_query_operation,
a39eb840 148 (void *provctx, int operation_id, const int *no_store))
6ebc2f56
RL
149# define OSSL_FUNC_PROVIDER_GET_REASON_STRINGS 1028
150OSSL_CORE_MAKE_FUNC(const OSSL_ITEM *,provider_get_reason_strings,
151 (void *provctx))
4c2883a9 152
784883fc 153/* Operations */
3653d0c2 154
2893111f 155# define OSSL_OP_DIGEST 1
784883fc
SL
156# define OSSL_OP_CIPHER 2 /* Symmetric Ciphers */
157# define OSSL_OP_MAC 3
ad1700c7 158# define OSSL_OP_KDF 4
784883fc
SL
159# define OSSL_OP_KEYMGMT 10
160# define OSSL_OP_KEYEXCH 11
dfcb5d29 161# define OSSL_OP_SIGNATURE 12
2c938e2e 162# define OSSL_OP_ASYM_CIPHER 13
0d003c52
RL
163/* New section for non-EVP operations */
164# define OSSL_OP_SERIALIZER 20
784883fc 165/* Highest known operation number */
0d003c52 166# define OSSL_OP__HIGHEST 20
784883fc
SL
167
168/* Digests */
2893111f
RL
169
170# define OSSL_FUNC_DIGEST_NEWCTX 1
171# define OSSL_FUNC_DIGEST_INIT 2
172# define OSSL_FUNC_DIGEST_UPDATE 3
173# define OSSL_FUNC_DIGEST_FINAL 4
174# define OSSL_FUNC_DIGEST_DIGEST 5
175# define OSSL_FUNC_DIGEST_FREECTX 6
176# define OSSL_FUNC_DIGEST_DUPCTX 7
177# define OSSL_FUNC_DIGEST_GET_PARAMS 8
92d9d0ae
RL
178# define OSSL_FUNC_DIGEST_SET_CTX_PARAMS 9
179# define OSSL_FUNC_DIGEST_GET_CTX_PARAMS 10
ae3ff60e
RL
180# define OSSL_FUNC_DIGEST_GETTABLE_PARAMS 11
181# define OSSL_FUNC_DIGEST_SETTABLE_CTX_PARAMS 12
182# define OSSL_FUNC_DIGEST_GETTABLE_CTX_PARAMS 13
df05f2ce 183
a39eb840
RL
184OSSL_CORE_MAKE_FUNC(void *, OP_digest_newctx, (void *provctx))
185OSSL_CORE_MAKE_FUNC(int, OP_digest_init, (void *dctx))
3653d0c2 186OSSL_CORE_MAKE_FUNC(int, OP_digest_update,
a39eb840 187 (void *dctx, const unsigned char *in, size_t inl))
3653d0c2 188OSSL_CORE_MAKE_FUNC(int, OP_digest_final,
a39eb840
RL
189 (void *dctx,
190 unsigned char *out, size_t *outl, size_t outsz))
3653d0c2 191OSSL_CORE_MAKE_FUNC(int, OP_digest_digest,
a39eb840 192 (void *provctx, const unsigned char *in, size_t inl,
8ccf2ffb 193 unsigned char *out, size_t *outl, size_t outsz))
df05f2ce 194
a39eb840
RL
195OSSL_CORE_MAKE_FUNC(void, OP_digest_freectx, (void *dctx))
196OSSL_CORE_MAKE_FUNC(void *, OP_digest_dupctx, (void *dctx))
d5e5e2ff 197
2893111f 198OSSL_CORE_MAKE_FUNC(int, OP_digest_get_params, (OSSL_PARAM params[]))
92d9d0ae 199OSSL_CORE_MAKE_FUNC(int, OP_digest_set_ctx_params,
2893111f 200 (void *vctx, const OSSL_PARAM params[]))
92d9d0ae 201OSSL_CORE_MAKE_FUNC(int, OP_digest_get_ctx_params,
2893111f 202 (void *vctx, OSSL_PARAM params[]))
ae3ff60e
RL
203OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_digest_gettable_params, (void))
204OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_digest_settable_ctx_params, (void))
205OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_digest_gettable_ctx_params, (void))
df05f2ce
MC
206
207/* Symmetric Ciphers */
208
df05f2ce
MC
209# define OSSL_FUNC_CIPHER_NEWCTX 1
210# define OSSL_FUNC_CIPHER_ENCRYPT_INIT 2
211# define OSSL_FUNC_CIPHER_DECRYPT_INIT 3
212# define OSSL_FUNC_CIPHER_UPDATE 4
213# define OSSL_FUNC_CIPHER_FINAL 5
718b133a
MC
214# define OSSL_FUNC_CIPHER_CIPHER 6
215# define OSSL_FUNC_CIPHER_FREECTX 7
216# define OSSL_FUNC_CIPHER_DUPCTX 8
80942379 217# define OSSL_FUNC_CIPHER_GET_PARAMS 9
92d9d0ae
RL
218# define OSSL_FUNC_CIPHER_GET_CTX_PARAMS 10
219# define OSSL_FUNC_CIPHER_SET_CTX_PARAMS 11
ae3ff60e
RL
220# define OSSL_FUNC_CIPHER_GETTABLE_PARAMS 12
221# define OSSL_FUNC_CIPHER_GETTABLE_CTX_PARAMS 13
222# define OSSL_FUNC_CIPHER_SETTABLE_CTX_PARAMS 14
df05f2ce 223
a39eb840
RL
224OSSL_CORE_MAKE_FUNC(void *, OP_cipher_newctx, (void *provctx))
225OSSL_CORE_MAKE_FUNC(int, OP_cipher_encrypt_init, (void *cctx,
df05f2ce 226 const unsigned char *key,
344cfa34
MC
227 size_t keylen,
228 const unsigned char *iv,
229 size_t ivlen))
a39eb840 230OSSL_CORE_MAKE_FUNC(int, OP_cipher_decrypt_init, (void *cctx,
df05f2ce 231 const unsigned char *key,
344cfa34
MC
232 size_t keylen,
233 const unsigned char *iv,
234 size_t ivlen))
df05f2ce 235OSSL_CORE_MAKE_FUNC(int, OP_cipher_update,
a39eb840
RL
236 (void *cctx,
237 unsigned char *out, size_t *outl, size_t outsize,
df05f2ce
MC
238 const unsigned char *in, size_t inl))
239OSSL_CORE_MAKE_FUNC(int, OP_cipher_final,
a39eb840
RL
240 (void *cctx,
241 unsigned char *out, size_t *outl, size_t outsize))
df05f2ce 242OSSL_CORE_MAKE_FUNC(int, OP_cipher_cipher,
a39eb840 243 (void *cctx,
f79858ac
RL
244 unsigned char *out, size_t *outl, size_t outsize,
245 const unsigned char *in, size_t inl))
a39eb840
RL
246OSSL_CORE_MAKE_FUNC(void, OP_cipher_freectx, (void *cctx))
247OSSL_CORE_MAKE_FUNC(void *, OP_cipher_dupctx, (void *cctx))
4e7991b4 248OSSL_CORE_MAKE_FUNC(int, OP_cipher_get_params, (OSSL_PARAM params[]))
92d9d0ae 249OSSL_CORE_MAKE_FUNC(int, OP_cipher_get_ctx_params, (void *cctx,
4e7991b4 250 OSSL_PARAM params[]))
92d9d0ae 251OSSL_CORE_MAKE_FUNC(int, OP_cipher_set_ctx_params, (void *cctx,
718b133a 252 const OSSL_PARAM params[]))
784883fc
SL
253OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_cipher_gettable_params, (void))
254OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_cipher_settable_ctx_params, (void))
255OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_cipher_gettable_ctx_params, (void))
df05f2ce 256
e74bd290
RL
257/* MACs */
258
e74bd290
RL
259# define OSSL_FUNC_MAC_NEWCTX 1
260# define OSSL_FUNC_MAC_DUPCTX 2
261# define OSSL_FUNC_MAC_FREECTX 3
262# define OSSL_FUNC_MAC_INIT 4
263# define OSSL_FUNC_MAC_UPDATE 5
264# define OSSL_FUNC_MAC_FINAL 6
784883fc
SL
265# define OSSL_FUNC_MAC_GET_PARAMS 7
266# define OSSL_FUNC_MAC_GET_CTX_PARAMS 8
267# define OSSL_FUNC_MAC_SET_CTX_PARAMS 9
268# define OSSL_FUNC_MAC_GETTABLE_PARAMS 10
269# define OSSL_FUNC_MAC_GETTABLE_CTX_PARAMS 11
270# define OSSL_FUNC_MAC_SETTABLE_CTX_PARAMS 12
e74bd290
RL
271
272OSSL_CORE_MAKE_FUNC(void *, OP_mac_newctx, (void *provctx))
273OSSL_CORE_MAKE_FUNC(void *, OP_mac_dupctx, (void *src))
274OSSL_CORE_MAKE_FUNC(void, OP_mac_freectx, (void *mctx))
275OSSL_CORE_MAKE_FUNC(size_t, OP_mac_size, (void *mctx))
276OSSL_CORE_MAKE_FUNC(int, OP_mac_init, (void *mctx))
277OSSL_CORE_MAKE_FUNC(int, OP_mac_update,
278 (void *mctx, const unsigned char *in, size_t inl))
279OSSL_CORE_MAKE_FUNC(int, OP_mac_final,
280 (void *mctx,
281 unsigned char *out, size_t *outl, size_t outsize))
282OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_mac_gettable_params, (void))
283OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_mac_gettable_ctx_params, (void))
284OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_mac_settable_ctx_params, (void))
285OSSL_CORE_MAKE_FUNC(int, OP_mac_get_params, (OSSL_PARAM params[]))
92d9d0ae 286OSSL_CORE_MAKE_FUNC(int, OP_mac_get_ctx_params,
e74bd290 287 (void *mctx, OSSL_PARAM params[]))
92d9d0ae 288OSSL_CORE_MAKE_FUNC(int, OP_mac_set_ctx_params,
e74bd290
RL
289 (void *mctx, const OSSL_PARAM params[]))
290
2f755701 291/* KDFs and PRFs */
2f755701
P
292
293# define OSSL_FUNC_KDF_NEWCTX 1
294# define OSSL_FUNC_KDF_DUPCTX 2
295# define OSSL_FUNC_KDF_FREECTX 3
296# define OSSL_FUNC_KDF_RESET 4
297# define OSSL_FUNC_KDF_DERIVE 5
298# define OSSL_FUNC_KDF_GETTABLE_PARAMS 6
299# define OSSL_FUNC_KDF_GETTABLE_CTX_PARAMS 7
300# define OSSL_FUNC_KDF_SETTABLE_CTX_PARAMS 8
301# define OSSL_FUNC_KDF_GET_PARAMS 9
302# define OSSL_FUNC_KDF_GET_CTX_PARAMS 10
303# define OSSL_FUNC_KDF_SET_CTX_PARAMS 11
304
305OSSL_CORE_MAKE_FUNC(void *, OP_kdf_newctx, (void *provctx))
306OSSL_CORE_MAKE_FUNC(void *, OP_kdf_dupctx, (void *src))
307OSSL_CORE_MAKE_FUNC(void, OP_kdf_freectx, (void *kctx))
308OSSL_CORE_MAKE_FUNC(void, OP_kdf_reset, (void *kctx))
309OSSL_CORE_MAKE_FUNC(int, OP_kdf_derive, (void *kctx, unsigned char *key,
310 size_t keylen))
311OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_kdf_gettable_params, (void))
312OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_kdf_gettable_ctx_params, (void))
313OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_kdf_settable_ctx_params, (void))
314OSSL_CORE_MAKE_FUNC(int, OP_kdf_get_params, (OSSL_PARAM params[]))
315OSSL_CORE_MAKE_FUNC(int, OP_kdf_get_ctx_params,
316 (void *kctx, OSSL_PARAM params[]))
317OSSL_CORE_MAKE_FUNC(int, OP_kdf_set_ctx_params,
318 (void *kctx, const OSSL_PARAM params[]))
319
a94a3e0d
RL
320/*-
321 * Key management
322 *
323 * Key domain parameter references can be created in several manners:
324 * - by importing the domain parameter material via an OSSL_PARAM array.
325 * - by generating key domain parameters, given input via an OSSL_PARAM
326 * array.
327 *
328 * Key references can be created in several manners:
329 * - by importing the key material via an OSSL_PARAM array.
330 * - by generating a key, given optional domain parameters and
331 * additional keygen parameters.
332 * If domain parameters are given, they must have been generated using
333 * the domain parameter generator functions.
334 * If the domain parameters comes from a different provider, results
335 * are undefined.
336 * THE CALLER MUST ENSURE THAT CORRECT DOMAIN PARAMETERS ARE USED.
337 * - by loading an internal key, given a binary blob that forms an identity.
338 * THE CALLER MUST ENSURE THAT A CORRECT IDENTITY IS USED.
339 */
340
a94a3e0d
RL
341/* Key domain parameter creation and destruction */
342# define OSSL_FUNC_KEYMGMT_IMPORTDOMPARAMS 1
343# define OSSL_FUNC_KEYMGMT_GENDOMPARAMS 2
344# define OSSL_FUNC_KEYMGMT_FREEDOMPARAMS 3
345OSSL_CORE_MAKE_FUNC(void *, OP_keymgmt_importdomparams,
346 (void *provctx, const OSSL_PARAM params[]))
347OSSL_CORE_MAKE_FUNC(void *, OP_keymgmt_gendomparams,
348 (void *provctx, const OSSL_PARAM params[]))
349OSSL_CORE_MAKE_FUNC(void, OP_keymgmt_freedomparams, (void *domparams))
350
351/* Key domain parameter export */
352# define OSSL_FUNC_KEYMGMT_EXPORTDOMPARAMS 4
353OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_exportdomparams,
1640d48c 354 (void *domparams, OSSL_CALLBACK *param_cb, void *cbarg))
a94a3e0d
RL
355
356/* Key domain parameter discovery */
1640d48c
RL
357/*
358 * TODO(v3.0) investigate if we need OP_keymgmt_exportdomparam_types.
359 * 'openssl provider' may be a caller...
360 */
a94a3e0d
RL
361# define OSSL_FUNC_KEYMGMT_IMPORTDOMPARAM_TYPES 5
362# define OSSL_FUNC_KEYMGMT_EXPORTDOMPARAM_TYPES 6
363OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_keymgmt_importdomparam_types,
364 (void))
365OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_keymgmt_exportdomparam_types,
366 (void))
367
368/* Key creation and destruction */
369# define OSSL_FUNC_KEYMGMT_IMPORTKEY 10
370# define OSSL_FUNC_KEYMGMT_GENKEY 11
371# define OSSL_FUNC_KEYMGMT_LOADKEY 12
372# define OSSL_FUNC_KEYMGMT_FREEKEY 13
373OSSL_CORE_MAKE_FUNC(void *, OP_keymgmt_importkey,
374 (void *provctx, const OSSL_PARAM params[]))
375OSSL_CORE_MAKE_FUNC(void *, OP_keymgmt_genkey,
376 (void *provctx,
377 void *domparams, const OSSL_PARAM genkeyparams[]))
378OSSL_CORE_MAKE_FUNC(void *, OP_keymgmt_loadkey,
379 (void *provctx, void *id, size_t idlen))
380OSSL_CORE_MAKE_FUNC(void, OP_keymgmt_freekey, (void *key))
381
382/* Key export */
383# define OSSL_FUNC_KEYMGMT_EXPORTKEY 14
384OSSL_CORE_MAKE_FUNC(int, OP_keymgmt_exportkey,
1640d48c 385 (void *key, OSSL_CALLBACK *param_cb, void *cbarg))
a94a3e0d
RL
386
387/* Key discovery */
1640d48c
RL
388/*
389 * TODO(v3.0) investigate if we need OP_keymgmt_exportkey_types.
390 * 'openssl provider' may be a caller...
391 */
a94a3e0d
RL
392# define OSSL_FUNC_KEYMGMT_IMPORTKEY_TYPES 15
393# define OSSL_FUNC_KEYMGMT_EXPORTKEY_TYPES 16
394OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_keymgmt_importkey_types, (void))
395OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_keymgmt_exportkey_types, (void))
396
ff64702b
MC
397/* Key Exchange */
398
ff64702b
MC
399# define OSSL_FUNC_KEYEXCH_NEWCTX 1
400# define OSSL_FUNC_KEYEXCH_INIT 2
401# define OSSL_FUNC_KEYEXCH_DERIVE 3
402# define OSSL_FUNC_KEYEXCH_SET_PEER 4
403# define OSSL_FUNC_KEYEXCH_FREECTX 5
404# define OSSL_FUNC_KEYEXCH_DUPCTX 6
9c45222d
MC
405# define OSSL_FUNC_KEYEXCH_SET_CTX_PARAMS 7
406# define OSSL_FUNC_KEYEXCH_SETTABLE_CTX_PARAMS 8
ff64702b
MC
407
408OSSL_CORE_MAKE_FUNC(void *, OP_keyexch_newctx, (void *provctx))
8b84b075 409OSSL_CORE_MAKE_FUNC(int, OP_keyexch_init, (void *ctx, void *provkey))
59972370
MC
410OSSL_CORE_MAKE_FUNC(int, OP_keyexch_derive, (void *ctx, unsigned char *secret,
411 size_t *secretlen, size_t outlen))
8b84b075 412OSSL_CORE_MAKE_FUNC(int, OP_keyexch_set_peer, (void *ctx, void *provkey))
ff64702b
MC
413OSSL_CORE_MAKE_FUNC(void, OP_keyexch_freectx, (void *ctx))
414OSSL_CORE_MAKE_FUNC(void *, OP_keyexch_dupctx, (void *ctx))
9c45222d
MC
415OSSL_CORE_MAKE_FUNC(int, OP_keyexch_set_ctx_params, (void *ctx,
416 const OSSL_PARAM params[]))
417OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_keyexch_settable_ctx_params,
418 (void))
ff64702b 419
dfcb5d29
MC
420/* Signature */
421
422# define OSSL_FUNC_SIGNATURE_NEWCTX 1
423# define OSSL_FUNC_SIGNATURE_SIGN_INIT 2
424# define OSSL_FUNC_SIGNATURE_SIGN 3
390acbeb
MC
425# define OSSL_FUNC_SIGNATURE_VERIFY_INIT 4
426# define OSSL_FUNC_SIGNATURE_VERIFY 5
427# define OSSL_FUNC_SIGNATURE_VERIFY_RECOVER_INIT 6
428# define OSSL_FUNC_SIGNATURE_VERIFY_RECOVER 7
d8c98d79
MC
429# define OSSL_FUNC_SIGNATURE_DIGEST_SIGN_INIT 8
430# define OSSL_FUNC_SIGNATURE_DIGEST_SIGN_UPDATE 9
431# define OSSL_FUNC_SIGNATURE_DIGEST_SIGN_FINAL 10
432# define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_INIT 11
433# define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_UPDATE 12
434# define OSSL_FUNC_SIGNATURE_DIGEST_VERIFY_FINAL 13
435# define OSSL_FUNC_SIGNATURE_FREECTX 14
436# define OSSL_FUNC_SIGNATURE_DUPCTX 15
437# define OSSL_FUNC_SIGNATURE_GET_CTX_PARAMS 16
438# define OSSL_FUNC_SIGNATURE_GETTABLE_CTX_PARAMS 17
439# define OSSL_FUNC_SIGNATURE_SET_CTX_PARAMS 18
440# define OSSL_FUNC_SIGNATURE_SETTABLE_CTX_PARAMS 19
441# define OSSL_FUNC_SIGNATURE_GET_CTX_MD_PARAMS 20
442# define OSSL_FUNC_SIGNATURE_GETTABLE_CTX_MD_PARAMS 21
443# define OSSL_FUNC_SIGNATURE_SET_CTX_MD_PARAMS 22
444# define OSSL_FUNC_SIGNATURE_SETTABLE_CTX_MD_PARAMS 23
dfcb5d29
MC
445
446OSSL_CORE_MAKE_FUNC(void *, OP_signature_newctx, (void *provctx))
447OSSL_CORE_MAKE_FUNC(int, OP_signature_sign_init, (void *ctx, void *provkey))
448OSSL_CORE_MAKE_FUNC(int, OP_signature_sign, (void *ctx, unsigned char *sig,
449 size_t *siglen, size_t sigsize,
450 const unsigned char *tbs,
451 size_t tbslen))
390acbeb
MC
452OSSL_CORE_MAKE_FUNC(int, OP_signature_verify_init, (void *ctx, void *provkey))
453OSSL_CORE_MAKE_FUNC(int, OP_signature_verify, (void *ctx,
454 const unsigned char *sig,
455 size_t siglen,
456 const unsigned char *tbs,
457 size_t tbslen))
458OSSL_CORE_MAKE_FUNC(int, OP_signature_verify_recover_init, (void *ctx,
459 void *provkey))
460OSSL_CORE_MAKE_FUNC(int, OP_signature_verify_recover, (void *ctx,
461 unsigned char *rout,
462 size_t *routlen,
463 size_t routsize,
464 const unsigned char *sig,
465 size_t siglen))
d8c98d79
MC
466OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_sign_init,
467 (void *ctx, const char *mdname, const char *props,
468 void *provkey))
469OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_sign_update,
470 (void *ctx, const unsigned char *data, size_t datalen))
471OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_sign_final,
472 (void *ctx, unsigned char *sig, size_t *siglen,
473 size_t sigsize))
474OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_verify_init,
475 (void *ctx, const char *mdname, const char *props,
476 void *provkey))
477OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_verify_update,
478 (void *ctx, const unsigned char *data, size_t datalen))
479OSSL_CORE_MAKE_FUNC(int, OP_signature_digest_verify_final,
480 (void *ctx, const unsigned char *sig, size_t siglen))
dfcb5d29
MC
481OSSL_CORE_MAKE_FUNC(void, OP_signature_freectx, (void *ctx))
482OSSL_CORE_MAKE_FUNC(void *, OP_signature_dupctx, (void *ctx))
9c45222d
MC
483OSSL_CORE_MAKE_FUNC(int, OP_signature_get_ctx_params,
484 (void *ctx, OSSL_PARAM params[]))
485OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_signature_gettable_ctx_params,
486 (void))
487OSSL_CORE_MAKE_FUNC(int, OP_signature_set_ctx_params,
488 (void *ctx, const OSSL_PARAM params[]))
489OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_signature_settable_ctx_params,
490 (void))
d8c98d79
MC
491OSSL_CORE_MAKE_FUNC(int, OP_signature_get_ctx_md_params,
492 (void *ctx, OSSL_PARAM params[]))
493OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_signature_gettable_ctx_md_params,
494 (void *ctx))
495OSSL_CORE_MAKE_FUNC(int, OP_signature_set_ctx_md_params,
496 (void *ctx, const OSSL_PARAM params[]))
497OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_signature_settable_ctx_md_params,
498 (void *ctx))
dfcb5d29 499
2c938e2e
MC
500
501/* Asymmetric Ciphers */
502
503# define OSSL_FUNC_ASYM_CIPHER_NEWCTX 1
504# define OSSL_FUNC_ASYM_CIPHER_ENCRYPT_INIT 2
505# define OSSL_FUNC_ASYM_CIPHER_ENCRYPT 3
506# define OSSL_FUNC_ASYM_CIPHER_DECRYPT_INIT 4
507# define OSSL_FUNC_ASYM_CIPHER_DECRYPT 5
508# define OSSL_FUNC_ASYM_CIPHER_FREECTX 6
509# define OSSL_FUNC_ASYM_CIPHER_DUPCTX 7
510# define OSSL_FUNC_ASYM_CIPHER_GET_CTX_PARAMS 8
511# define OSSL_FUNC_ASYM_CIPHER_GETTABLE_CTX_PARAMS 9
512# define OSSL_FUNC_ASYM_CIPHER_SET_CTX_PARAMS 10
513# define OSSL_FUNC_ASYM_CIPHER_SETTABLE_CTX_PARAMS 11
514
515OSSL_CORE_MAKE_FUNC(void *, OP_asym_cipher_newctx, (void *provctx))
516OSSL_CORE_MAKE_FUNC(int, OP_asym_cipher_encrypt_init, (void *ctx, void *provkey))
517OSSL_CORE_MAKE_FUNC(int, OP_asym_cipher_encrypt, (void *ctx, unsigned char *out,
518 size_t *outlen,
519 size_t outsize,
520 const unsigned char *in,
521 size_t inlen))
522OSSL_CORE_MAKE_FUNC(int, OP_asym_cipher_decrypt_init, (void *ctx, void *provkey))
523OSSL_CORE_MAKE_FUNC(int, OP_asym_cipher_decrypt, (void *ctx, unsigned char *out,
524 size_t *outlen,
525 size_t outsize,
526 const unsigned char *in,
527 size_t inlen))
528OSSL_CORE_MAKE_FUNC(void, OP_asym_cipher_freectx, (void *ctx))
529OSSL_CORE_MAKE_FUNC(void *, OP_asym_cipher_dupctx, (void *ctx))
530OSSL_CORE_MAKE_FUNC(int, OP_asym_cipher_get_ctx_params,
531 (void *ctx, OSSL_PARAM params[]))
532OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_asym_cipher_gettable_ctx_params,
533 (void))
534OSSL_CORE_MAKE_FUNC(int, OP_asym_cipher_set_ctx_params,
535 (void *ctx, const OSSL_PARAM params[]))
536OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_asym_cipher_settable_ctx_params,
537 (void))
538
0d003c52
RL
539/* Serializers */
540# define OSSL_FUNC_SERIALIZER_NEWCTX 1
541# define OSSL_FUNC_SERIALIZER_FREECTX 2
542# define OSSL_FUNC_SERIALIZER_SET_CTX_PARAMS 3
543# define OSSL_FUNC_SERIALIZER_SETTABLE_CTX_PARAMS 4
544# define OSSL_FUNC_SERIALIZER_SERIALIZE_DATA 10
545# define OSSL_FUNC_SERIALIZER_SERIALIZE_OBJECT 11
546OSSL_CORE_MAKE_FUNC(void *, OP_serializer_newctx, (void *provctx))
547OSSL_CORE_MAKE_FUNC(void, OP_serializer_freectx, (void *ctx))
548OSSL_CORE_MAKE_FUNC(int, OP_serializer_set_ctx_params,
549 (void *ctx, const OSSL_PARAM params[]))
550OSSL_CORE_MAKE_FUNC(const OSSL_PARAM *, OP_serializer_settable_ctx_params,
551 (void))
552
553OSSL_CORE_MAKE_FUNC(int, OP_serializer_serialize_data,
554 (void *ctx, const OSSL_PARAM[], BIO *out,
555 OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg))
556OSSL_CORE_MAKE_FUNC(int, OP_serializer_serialize_object,
557 (void *ctx, void *obj, BIO *out,
558 OSSL_PASSPHRASE_CALLBACK *cb, void *cbarg))
559
4c2883a9
RL
560# ifdef __cplusplus
561}
562# endif
563
564#endif