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