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