2 * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
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
10 #include <openssl/core.h>
11 #include <openssl/core_numbers.h>
12 #include <openssl/params.h>
13 #include <openssl/opensslv.h>
14 #include "internal/cryptlib_int.h"
15 #include "internal/nelem.h"
16 #include "internal/thread_once.h"
17 #include "internal/provider.h"
18 #include "internal/refcount.h"
19 #include "provider_local.h"
21 static OSSL_PROVIDER
*provider_new(const char *name
,
22 OSSL_provider_init_fn
*init_function
);
25 * Provider Object structure
26 * =========================
33 DEFINE_STACK_OF(INFOPAIR
)
35 struct provider_store_st
; /* Forward declaration */
37 struct ossl_provider_st
{
39 unsigned int flag_initialized
:1;
40 unsigned int flag_fallback
:1;
42 /* OpenSSL library side data */
43 CRYPTO_REF_COUNT refcnt
;
44 CRYPTO_RWLOCK
*refcnt_lock
; /* For the ref counter */
48 OSSL_provider_init_fn
*init_function
;
49 STACK_OF(INFOPAIR
) *parameters
;
50 OPENSSL_CTX
*libctx
; /* The library context this instance is in */
51 struct provider_store_st
*store
; /* The store this instance belongs to */
54 * In the FIPS module inner provider, this isn't needed, since the
55 * error upcalls are always direct calls to the outer provider.
57 int error_lib
; /* ERR library number, one for each provider */
58 # ifndef OPENSSL_NO_ERR
59 ERR_STRING_DATA
*error_strings
; /* Copy of what the provider gives us */
63 /* Provider side functions */
64 OSSL_provider_teardown_fn
*teardown
;
65 OSSL_provider_gettable_params_fn
*gettable_params
;
66 OSSL_provider_get_params_fn
*get_params
;
67 OSSL_provider_query_operation_fn
*query_operation
;
69 /* Provider side data */
72 DEFINE_STACK_OF(OSSL_PROVIDER
)
74 static int ossl_provider_cmp(const OSSL_PROVIDER
* const *a
,
75 const OSSL_PROVIDER
* const *b
)
77 return strcmp((*a
)->name
, (*b
)->name
);
81 * Provider Object store
82 * =====================
84 * The Provider Object store is a library context object, and therefore needs
88 struct provider_store_st
{
89 STACK_OF(OSSL_PROVIDER
) *providers
;
91 unsigned int use_fallbacks
:1;
94 static void provider_store_free(void *vstore
)
96 struct provider_store_st
*store
= vstore
;
100 sk_OSSL_PROVIDER_pop_free(store
->providers
, ossl_provider_free
);
101 CRYPTO_THREAD_lock_free(store
->lock
);
105 static void *provider_store_new(OPENSSL_CTX
*ctx
)
107 struct provider_store_st
*store
= OPENSSL_zalloc(sizeof(*store
));
108 const struct predefined_providers_st
*p
= NULL
;
111 || (store
->providers
= sk_OSSL_PROVIDER_new(ossl_provider_cmp
)) == NULL
112 || (store
->lock
= CRYPTO_THREAD_lock_new()) == NULL
) {
113 provider_store_free(store
);
116 store
->use_fallbacks
= 1;
118 for (p
= predefined_providers
; p
->name
!= NULL
; p
++) {
119 OSSL_PROVIDER
*prov
= NULL
;
122 * We use the internal constructor directly here,
123 * otherwise we get a call loop
125 prov
= provider_new(p
->name
, p
->init
);
128 || sk_OSSL_PROVIDER_push(store
->providers
, prov
) == 0) {
129 ossl_provider_free(prov
);
130 provider_store_free(store
);
131 CRYPTOerr(CRYPTO_F_PROVIDER_STORE_NEW
, ERR_R_INTERNAL_ERROR
);
137 prov
->error_lib
= ERR_get_next_error_library();
140 ossl_provider_set_fallback(prov
);
146 static const OPENSSL_CTX_METHOD provider_store_method
= {
151 static struct provider_store_st
*get_provider_store(OPENSSL_CTX
*libctx
)
153 struct provider_store_st
*store
= NULL
;
155 store
= openssl_ctx_get_data(libctx
, OPENSSL_CTX_PROVIDER_STORE_INDEX
,
156 &provider_store_method
);
158 CRYPTOerr(CRYPTO_F_GET_PROVIDER_STORE
, ERR_R_INTERNAL_ERROR
);
162 OSSL_PROVIDER
*ossl_provider_find(OPENSSL_CTX
*libctx
, const char *name
,
165 struct provider_store_st
*store
= NULL
;
166 OSSL_PROVIDER
*prov
= NULL
;
168 if ((store
= get_provider_store(libctx
)) != NULL
) {
169 OSSL_PROVIDER tmpl
= { 0, };
174 * Make sure any providers are loaded from config before we try to find
178 OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG
, NULL
);
181 tmpl
.name
= (char *)name
;
182 CRYPTO_THREAD_write_lock(store
->lock
);
183 if ((i
= sk_OSSL_PROVIDER_find(store
->providers
, &tmpl
)) == -1
184 || (prov
= sk_OSSL_PROVIDER_value(store
->providers
, i
)) == NULL
185 || !ossl_provider_up_ref(prov
))
187 CRYPTO_THREAD_unlock(store
->lock
);
194 * Provider Object methods
195 * =======================
198 static OSSL_PROVIDER
*provider_new(const char *name
,
199 OSSL_provider_init_fn
*init_function
)
201 OSSL_PROVIDER
*prov
= NULL
;
203 if ((prov
= OPENSSL_zalloc(sizeof(*prov
))) == NULL
205 || (prov
->refcnt_lock
= CRYPTO_THREAD_lock_new()) == NULL
207 || !ossl_provider_up_ref(prov
) /* +1 One reference to be returned */
208 || (prov
->name
= OPENSSL_strdup(name
)) == NULL
) {
209 ossl_provider_free(prov
);
210 CRYPTOerr(CRYPTO_F_PROVIDER_NEW
, ERR_R_MALLOC_FAILURE
);
214 prov
->init_function
= init_function
;
218 int ossl_provider_up_ref(OSSL_PROVIDER
*prov
)
222 if (CRYPTO_UP_REF(&prov
->refcnt
, &ref
, prov
->refcnt_lock
) <= 0)
227 OSSL_PROVIDER
*ossl_provider_new(OPENSSL_CTX
*libctx
, const char *name
,
228 OSSL_provider_init_fn
*init_function
,
231 struct provider_store_st
*store
= NULL
;
232 OSSL_PROVIDER
*prov
= NULL
;
234 if ((store
= get_provider_store(libctx
)) == NULL
)
237 if ((prov
= ossl_provider_find(libctx
, name
,
238 noconfig
)) != NULL
) { /* refcount +1 */
239 ossl_provider_free(prov
); /* refcount -1 */
240 ERR_raise_data(ERR_LIB_CRYPTO
, CRYPTO_R_PROVIDER_ALREADY_EXISTS
, NULL
,
245 /* provider_new() generates an error, so no need here */
246 if ((prov
= provider_new(name
, init_function
)) == NULL
)
249 CRYPTO_THREAD_write_lock(store
->lock
);
250 if (!ossl_provider_up_ref(prov
)) { /* +1 One reference for the store */
251 ossl_provider_free(prov
); /* -1 Reference that was to be returned */
253 } else if (sk_OSSL_PROVIDER_push(store
->providers
, prov
) == 0) {
254 ossl_provider_free(prov
); /* -1 Store reference */
255 ossl_provider_free(prov
); /* -1 Reference that was to be returned */
258 prov
->libctx
= libctx
;
261 prov
->error_lib
= ERR_get_next_error_library();
264 CRYPTO_THREAD_unlock(store
->lock
);
267 CRYPTOerr(CRYPTO_F_OSSL_PROVIDER_NEW
, ERR_R_MALLOC_FAILURE
);
270 * At this point, the provider is only partially "loaded". To be
271 * fully "loaded", ossl_provider_activate() must also be called.
277 static void free_infopair(INFOPAIR
*pair
)
279 OPENSSL_free(pair
->name
);
280 OPENSSL_free(pair
->value
);
284 void ossl_provider_free(OSSL_PROVIDER
*prov
)
289 CRYPTO_DOWN_REF(&prov
->refcnt
, &ref
, prov
->refcnt_lock
);
292 * When the refcount drops below two, the store is the only
293 * possible reference, or it has already been taken away from
294 * the store (this may happen if a provider was activated
295 * because it's a fallback, but isn't currently used)
296 * When that happens, the provider is inactivated.
298 if (ref
< 2 && prov
->flag_initialized
) {
300 ossl_init_thread_deregister(prov
);
302 if (prov
->teardown
!= NULL
)
303 prov
->teardown(prov
->provctx
);
304 #ifndef OPENSSL_NO_ERR
306 if (prov
->error_strings
!= NULL
) {
307 ERR_unload_strings(prov
->error_lib
, prov
->error_strings
);
308 OPENSSL_free(prov
->error_strings
);
309 prov
->error_strings
= NULL
;
313 prov
->flag_initialized
= 0;
317 * When the refcount drops to zero, it has been taken out of
318 * the store. All we have to do here is clean it out.
322 DSO_free(prov
->module
);
324 OPENSSL_free(prov
->name
);
325 OPENSSL_free(prov
->path
);
326 sk_INFOPAIR_pop_free(prov
->parameters
, free_infopair
);
328 CRYPTO_THREAD_lock_free(prov
->refcnt_lock
);
336 int ossl_provider_set_module_path(OSSL_PROVIDER
*prov
, const char *module_path
)
338 OPENSSL_free(prov
->path
);
339 if (module_path
== NULL
)
341 if ((prov
->path
= OPENSSL_strdup(module_path
)) != NULL
)
343 CRYPTOerr(CRYPTO_F_OSSL_PROVIDER_SET_MODULE_PATH
, ERR_R_MALLOC_FAILURE
);
347 int ossl_provider_add_parameter(OSSL_PROVIDER
*prov
,
348 const char *name
, const char *value
)
350 INFOPAIR
*pair
= NULL
;
352 if ((pair
= OPENSSL_zalloc(sizeof(*pair
))) != NULL
353 && (prov
->parameters
!= NULL
354 || (prov
->parameters
= sk_INFOPAIR_new_null()) != NULL
)
355 && (pair
->name
= OPENSSL_strdup(name
)) != NULL
356 && (pair
->value
= OPENSSL_strdup(value
)) != NULL
357 && sk_INFOPAIR_push(prov
->parameters
, pair
) > 0)
361 OPENSSL_free(pair
->name
);
362 OPENSSL_free(pair
->value
);
365 CRYPTOerr(CRYPTO_F_OSSL_PROVIDER_ADD_PARAMETER
, ERR_R_MALLOC_FAILURE
);
370 * Provider activation.
372 * What "activation" means depends on the provider form; for built in
373 * providers (in the library or the application alike), the provider
374 * can already be considered to be loaded, all that's needed is to
375 * initialize it. However, for dynamically loadable provider modules,
376 * we must first load that module.
378 * Built in modules are distinguished from dynamically loaded modules
379 * with an already assigned init function.
381 static const OSSL_DISPATCH
*core_dispatch
; /* Define further down */
384 * Internal version that doesn't affect the store flags, and thereby avoid
385 * locking. Direct callers must remember to set the store flags when
388 static int provider_activate(OSSL_PROVIDER
*prov
)
390 const OSSL_DISPATCH
*provider_dispatch
= NULL
;
391 #ifndef OPENSSL_NO_ERR
393 OSSL_provider_get_reason_strings_fn
*p_get_reason_strings
= NULL
;
397 if (prov
->flag_initialized
)
401 * If the init function isn't set, it indicates that this provider is
404 if (prov
->init_function
== NULL
) {
408 if (prov
->module
== NULL
) {
409 char *allocated_path
= NULL
;
410 const char *module_path
= NULL
;
411 char *merged_path
= NULL
;
412 const char *load_dir
= ossl_safe_getenv("OPENSSL_MODULES");
414 if ((prov
->module
= DSO_new()) == NULL
) {
415 /* DSO_new() generates an error already */
419 if (load_dir
== NULL
)
420 load_dir
= MODULESDIR
;
422 DSO_ctrl(prov
->module
, DSO_CTRL_SET_FLAGS
,
423 DSO_FLAG_NAME_TRANSLATION_EXT_ONLY
, NULL
);
425 module_path
= prov
->path
;
426 if (module_path
== NULL
)
427 module_path
= allocated_path
=
428 DSO_convert_filename(prov
->module
, prov
->name
);
429 if (module_path
!= NULL
)
430 merged_path
= DSO_merge(prov
->module
, module_path
, load_dir
);
432 if (merged_path
== NULL
433 || (DSO_load(prov
->module
, merged_path
, NULL
, 0)) == NULL
) {
434 DSO_free(prov
->module
);
438 OPENSSL_free(merged_path
);
439 OPENSSL_free(allocated_path
);
442 if (prov
->module
!= NULL
)
443 prov
->init_function
= (OSSL_provider_init_fn
*)
444 DSO_bind_func(prov
->module
, "OSSL_provider_init");
448 /* Call the initialise function for the provider. */
449 if (prov
->init_function
== NULL
450 || !prov
->init_function(prov
, core_dispatch
, &provider_dispatch
,
452 ERR_raise_data(ERR_LIB_CRYPTO
, ERR_R_INIT_FAIL
, NULL
,
453 "name=%s", prov
->name
);
455 DSO_free(prov
->module
);
461 for (; provider_dispatch
->function_id
!= 0; provider_dispatch
++) {
462 switch (provider_dispatch
->function_id
) {
463 case OSSL_FUNC_PROVIDER_TEARDOWN
:
465 OSSL_get_provider_teardown(provider_dispatch
);
467 case OSSL_FUNC_PROVIDER_GETTABLE_PARAMS
:
468 prov
->gettable_params
=
469 OSSL_get_provider_gettable_params(provider_dispatch
);
471 case OSSL_FUNC_PROVIDER_GET_PARAMS
:
473 OSSL_get_provider_get_params(provider_dispatch
);
475 case OSSL_FUNC_PROVIDER_QUERY_OPERATION
:
476 prov
->query_operation
=
477 OSSL_get_provider_query_operation(provider_dispatch
);
479 #ifndef OPENSSL_NO_ERR
481 case OSSL_FUNC_PROVIDER_GET_REASON_STRINGS
:
482 p_get_reason_strings
=
483 OSSL_get_provider_get_reason_strings(provider_dispatch
);
490 #ifndef OPENSSL_NO_ERR
492 if (p_get_reason_strings
!= NULL
) {
493 const OSSL_ITEM
*reasonstrings
= p_get_reason_strings(prov
->provctx
);
497 * ERR_load_strings() handles ERR_STRING_DATA rather than OSSL_ITEM,
498 * although they are essentially the same type.
499 * Furthermore, ERR_load_strings() patches the array's error number
500 * with the error library number, so we need to make a copy of that
503 cnt
= 1; /* One for the terminating item */
504 while (reasonstrings
[cnt
].id
!= 0) {
505 if (ERR_GET_LIB(reasonstrings
[cnt
].id
) != 0)
510 /* Allocate one extra item for the "library" name */
511 prov
->error_strings
=
512 OPENSSL_zalloc(sizeof(ERR_STRING_DATA
) * (cnt
+ 1));
513 if (prov
->error_strings
== NULL
)
517 * Set the "library" name.
519 prov
->error_strings
[0].error
= ERR_PACK(prov
->error_lib
, 0, 0);
520 prov
->error_strings
[0].string
= prov
->name
;
522 * Copy reasonstrings item 0..cnt-1 to prov->error_trings positions
525 for (cnt2
= 1; cnt2
<= cnt
; cnt2
++) {
526 prov
->error_strings
[cnt2
].error
= (int)reasonstrings
[cnt2
-1].id
;
527 prov
->error_strings
[cnt2
].string
= reasonstrings
[cnt2
-1].ptr
;
530 ERR_load_strings(prov
->error_lib
, prov
->error_strings
);
535 /* With this flag set, this provider has become fully "loaded". */
536 prov
->flag_initialized
= 1;
541 int ossl_provider_activate(OSSL_PROVIDER
*prov
)
543 if (provider_activate(prov
)) {
544 CRYPTO_THREAD_write_lock(prov
->store
->lock
);
545 prov
->store
->use_fallbacks
= 0;
546 CRYPTO_THREAD_unlock(prov
->store
->lock
);
553 void *ossl_provider_ctx(const OSSL_PROVIDER
*prov
)
555 return prov
->provctx
;
559 static int provider_forall_loaded(struct provider_store_st
*store
,
560 int *found_activated
,
561 int (*cb
)(OSSL_PROVIDER
*provider
,
569 num_provs
= sk_OSSL_PROVIDER_num(store
->providers
);
571 if (found_activated
!= NULL
)
572 *found_activated
= 0;
573 for (i
= 0; i
< num_provs
; i
++) {
574 OSSL_PROVIDER
*prov
=
575 sk_OSSL_PROVIDER_value(store
->providers
, i
);
577 if (prov
->flag_initialized
) {
578 if (found_activated
!= NULL
)
579 *found_activated
= 1;
580 if (!(ret
= cb(prov
, cbdata
)))
589 * This function only does something once when store->use_fallbacks == 1,
590 * and then sets store->use_fallbacks = 0, so the second call and so on is
591 * effectively a no-op.
593 static void provider_activate_fallbacks(struct provider_store_st
*store
)
595 if (store
->use_fallbacks
) {
596 int num_provs
= sk_OSSL_PROVIDER_num(store
->providers
);
597 int activated_fallback_count
= 0;
600 for (i
= 0; i
< num_provs
; i
++) {
601 OSSL_PROVIDER
*prov
= sk_OSSL_PROVIDER_value(store
->providers
, i
);
604 * Note that we don't care if the activation succeeds or not.
605 * If it doesn't succeed, then any attempt to use any of the
606 * fallback providers will fail anyway.
608 if (prov
->flag_fallback
) {
609 activated_fallback_count
++;
610 provider_activate(prov
);
615 * We assume that all fallbacks have been added to the store before
616 * any fallback is activated.
617 * TODO: We may have to reconsider this, IF we find ourselves adding
618 * fallbacks after any previous fallback has been activated.
620 if (activated_fallback_count
> 0)
621 store
->use_fallbacks
= 0;
625 int ossl_provider_forall_loaded(OPENSSL_CTX
*ctx
,
626 int (*cb
)(OSSL_PROVIDER
*provider
,
631 struct provider_store_st
*store
= get_provider_store(ctx
);
635 * Make sure any providers are loaded from config before we try to use
638 OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG
, NULL
);
642 CRYPTO_THREAD_read_lock(store
->lock
);
644 provider_activate_fallbacks(store
);
647 * Now, we sweep through all providers
649 ret
= provider_forall_loaded(store
, NULL
, cb
, cbdata
);
651 CRYPTO_THREAD_unlock(store
->lock
);
657 int ossl_provider_available(OSSL_PROVIDER
*prov
)
660 CRYPTO_THREAD_read_lock(prov
->store
->lock
);
661 provider_activate_fallbacks(prov
->store
);
662 CRYPTO_THREAD_unlock(prov
->store
->lock
);
664 return prov
->flag_initialized
;
669 /* Setters of Provider Object data */
670 int ossl_provider_set_fallback(OSSL_PROVIDER
*prov
)
675 prov
->flag_fallback
= 1;
679 /* Getters of Provider Object data */
680 const char *ossl_provider_name(const OSSL_PROVIDER
*prov
)
685 const DSO
*ossl_provider_dso(const OSSL_PROVIDER
*prov
)
690 const char *ossl_provider_module_name(const OSSL_PROVIDER
*prov
)
695 return DSO_get_filename(prov
->module
);
699 const char *ossl_provider_module_path(const OSSL_PROVIDER
*prov
)
704 /* FIXME: Ensure it's a full path */
705 return DSO_get_filename(prov
->module
);
709 OPENSSL_CTX
*ossl_provider_library_context(const OSSL_PROVIDER
*prov
)
714 /* Wrappers around calls to the provider */
715 void ossl_provider_teardown(const OSSL_PROVIDER
*prov
)
717 if (prov
->teardown
!= NULL
)
718 prov
->teardown(prov
->provctx
);
721 const OSSL_PARAM
*ossl_provider_gettable_params(const OSSL_PROVIDER
*prov
)
723 return prov
->gettable_params
== NULL
724 ? NULL
: prov
->gettable_params(prov
->provctx
);
727 int ossl_provider_get_params(const OSSL_PROVIDER
*prov
, OSSL_PARAM params
[])
729 return prov
->get_params
== NULL
730 ? 0 : prov
->get_params(prov
->provctx
, params
);
734 const OSSL_ALGORITHM
*ossl_provider_query_operation(const OSSL_PROVIDER
*prov
,
738 return prov
->query_operation(prov
->provctx
, operation_id
, no_cache
);
742 * Core functions for the provider
743 * ===============================
745 * This is the set of functions that the core makes available to the provider
749 * This returns a list of Provider Object parameters with their types, for
750 * discovery. We do not expect that many providers will use this, but one
753 static const OSSL_PARAM param_types
[] = {
754 OSSL_PARAM_DEFN("openssl-verstion", OSSL_PARAM_UTF8_PTR
, NULL
, 0),
755 OSSL_PARAM_DEFN("provider-name", OSSL_PARAM_UTF8_PTR
, NULL
, 0),
760 * Forward declare all the functions that are provided aa dispatch.
761 * This ensures that the compiler will complain if they aren't defined
762 * with the correct signature.
764 static OSSL_core_gettable_params_fn core_gettable_params
;
765 static OSSL_core_get_params_fn core_get_params
;
766 static OSSL_core_thread_start_fn core_thread_start
;
767 static OSSL_core_get_library_context_fn core_get_libctx
;
769 static OSSL_core_new_error_fn core_new_error
;
770 static OSSL_core_set_error_debug_fn core_set_error_debug
;
771 static OSSL_core_vset_error_fn core_vset_error
;
774 static const OSSL_PARAM
*core_gettable_params(const OSSL_PROVIDER
*prov
)
779 static int core_get_params(const OSSL_PROVIDER
*prov
, OSSL_PARAM params
[])
785 /* Load config before we attempt to read any provider parameters */
786 OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CONFIG
, NULL
);
789 if ((p
= OSSL_PARAM_locate(params
, "openssl-version")) != NULL
)
790 OSSL_PARAM_set_utf8_ptr(p
, OPENSSL_VERSION_STR
);
791 if ((p
= OSSL_PARAM_locate(params
, "provider-name")) != NULL
)
792 OSSL_PARAM_set_utf8_ptr(p
, prov
->name
);
794 if (prov
->parameters
== NULL
)
797 for (i
= 0; i
< sk_INFOPAIR_num(prov
->parameters
); i
++) {
798 INFOPAIR
*pair
= sk_INFOPAIR_value(prov
->parameters
, i
);
800 if ((p
= OSSL_PARAM_locate(params
, pair
->name
)) != NULL
)
801 OSSL_PARAM_set_utf8_ptr(p
, pair
->value
);
807 static OPENSSL_CTX
*core_get_libctx(const OSSL_PROVIDER
*prov
)
809 return ossl_provider_library_context(prov
);
812 static int core_thread_start(const OSSL_PROVIDER
*prov
,
813 OSSL_thread_stop_handler_fn handfn
)
815 return ossl_init_thread_start(prov
, prov
->provctx
, handfn
);
819 * The FIPS module inner provider doesn't implement these. They aren't
820 * needed there, since the FIPS module upcalls are always the outer provider
825 * TODO(3.0) These error functions should use |prov| to select the proper
826 * library context to report in the correct error stack, at least if error
827 * stacks become tied to the library context.
828 * We cannot currently do that since there's no support for it in the
831 static void core_new_error(const OSSL_PROVIDER
*prov
)
836 static void core_set_error_debug(const OSSL_PROVIDER
*prov
,
837 const char *file
, int line
, const char *func
)
839 ERR_set_debug(file
, line
, func
);
842 static void core_vset_error(const OSSL_PROVIDER
*prov
,
843 uint32_t reason
, const char *fmt
, va_list args
)
846 * If the uppermost 8 bits are non-zero, it's an OpenSSL library
847 * error and will be treated as such. Otherwise, it's a new style
848 * provider error and will be treated as such.
850 if (ERR_GET_LIB(reason
) != 0) {
851 ERR_vset_error(ERR_GET_LIB(reason
), ERR_GET_REASON(reason
), fmt
, args
);
853 ERR_vset_error(prov
->error_lib
, (int)reason
, fmt
, args
);
859 * Functions provided by the core. Blank line separates "families" of related
862 static const OSSL_DISPATCH core_dispatch_
[] = {
863 { OSSL_FUNC_CORE_GETTABLE_PARAMS
, (void (*)(void))core_gettable_params
},
864 { OSSL_FUNC_CORE_GET_PARAMS
, (void (*)(void))core_get_params
},
865 { OSSL_FUNC_CORE_GET_LIBRARY_CONTEXT
, (void (*)(void))core_get_libctx
},
866 { OSSL_FUNC_CORE_THREAD_START
, (void (*)(void))core_thread_start
},
868 { OSSL_FUNC_CORE_NEW_ERROR
, (void (*)(void))core_new_error
},
869 { OSSL_FUNC_CORE_SET_ERROR_DEBUG
, (void (*)(void))core_set_error_debug
},
870 { OSSL_FUNC_CORE_VSET_ERROR
, (void (*)(void))core_vset_error
},
873 { OSSL_FUNC_CRYPTO_MALLOC
, (void (*)(void))CRYPTO_malloc
},
874 { OSSL_FUNC_CRYPTO_ZALLOC
, (void (*)(void))CRYPTO_zalloc
},
875 { OSSL_FUNC_CRYPTO_FREE
, (void (*)(void))CRYPTO_free
},
876 { OSSL_FUNC_CRYPTO_CLEAR_FREE
, (void (*)(void))CRYPTO_clear_free
},
877 { OSSL_FUNC_CRYPTO_REALLOC
, (void (*)(void))CRYPTO_realloc
},
878 { OSSL_FUNC_CRYPTO_CLEAR_REALLOC
, (void (*)(void))CRYPTO_clear_realloc
},
879 { OSSL_FUNC_CRYPTO_SECURE_MALLOC
, (void (*)(void))CRYPTO_secure_malloc
},
880 { OSSL_FUNC_CRYPTO_SECURE_ZALLOC
, (void (*)(void))CRYPTO_secure_zalloc
},
881 { OSSL_FUNC_CRYPTO_SECURE_FREE
, (void (*)(void))CRYPTO_secure_free
},
882 { OSSL_FUNC_CRYPTO_SECURE_CLEAR_FREE
,
883 (void (*)(void))CRYPTO_secure_clear_free
},
884 { OSSL_FUNC_CRYPTO_SECURE_ALLOCATED
,
885 (void (*)(void))CRYPTO_secure_allocated
},
886 { OSSL_FUNC_OPENSSL_CLEANSE
, (void (*)(void))OPENSSL_cleanse
},
890 static const OSSL_DISPATCH
*core_dispatch
= core_dispatch_
;