summaryrefslogtreecommitdiffstats
path: root/providers/nullprov.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2020-05-06 12:29:57 +0100
committerMatt Caswell <matt@openssl.org>2020-05-16 17:10:03 +0100
commitd40b42ab4c8a88740a2cc2a20c709fe869c4dd1e (patch)
tree0dfa4439f3de544d7e52abf56c578e10e5346458 /providers/nullprov.c
parent827f04d5105e9bec0af214c42b8ad799fba5bb0d (diff)
Maintain strict type discipline between the core and providers
A provider could be linked against a different version of libcrypto than the version of libcrypto that loaded the provider. Different versions of libcrypto could define opaque types differently. It must never occur that a type created in one libcrypto is used directly by the other libcrypto. This will cause crashes. We can "cheat" for "built-in" providers that are part of libcrypto itself, because we know that the two libcrypto versions are the same - but not for other providers. To ensure this does not occur we use different types names for the handful of opaque types that are passed between the core and providers. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/11758)
Diffstat (limited to 'providers/nullprov.c')
-rw-r--r--providers/nullprov.c36
1 files changed, 3 insertions, 33 deletions
diff --git a/providers/nullprov.c b/providers/nullprov.c
index a1a2681173..945ec2fbb6 100644
--- a/providers/nullprov.c
+++ b/providers/nullprov.c
@@ -17,10 +17,6 @@
OSSL_provider_init_fn ossl_null_provider_init;
-/* Functions provided by the core */
-static OSSL_core_gettable_params_fn *c_gettable_params = NULL;
-static OSSL_core_get_params_fn *c_get_params = NULL;
-
/* Parameters we provide to the core */
static const OSSL_ITEM null_param_types[] = {
{ OSSL_PARAM_UTF8_PTR, OSSL_PROV_PARAM_NAME },
@@ -67,40 +63,14 @@ static const OSSL_DISPATCH null_dispatch_table[] = {
{ 0, NULL }
};
-int ossl_null_provider_init(const OSSL_PROVIDER *provider,
+int ossl_null_provider_init(const OSSL_CORE_HANDLE *handle,
const OSSL_DISPATCH *in,
const OSSL_DISPATCH **out,
void **provctx)
{
- OSSL_core_get_library_context_fn *c_get_libctx = NULL;
-
- for (; in->function_id != 0; in++) {
- switch (in->function_id) {
- case OSSL_FUNC_CORE_GETTABLE_PARAMS:
- c_gettable_params = OSSL_get_core_gettable_params(in);
- break;
- case OSSL_FUNC_CORE_GET_PARAMS:
- c_get_params = OSSL_get_core_get_params(in);
- break;
- case OSSL_FUNC_CORE_GET_LIBRARY_CONTEXT:
- c_get_libctx = OSSL_get_core_get_library_context(in);
- break;
- /* Just ignore anything we don't understand */
- default:
- break;
- }
- }
-
- if (c_get_libctx == NULL)
- return 0;
-
*out = null_dispatch_table;
- /*
- * We want to make sure that all calls from this provider that requires
- * a library context use the same context as the one used to call our
- * functions. We do that by passing it along as the provider context.
- */
- *provctx = c_get_libctx(provider);
+ /* Could be anything - we don't use it */
+ *provctx = (void *)handle;
return 1;
}