summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2019-04-30 13:41:51 +0200
committerRichard Levitte <levitte@openssl.org>2019-04-30 15:34:23 +0200
commita39eb84006ca68d38d1c7204a6135647d06b5d01 (patch)
treea39170c4d6ece3fc94ae7fc4e09a97d4b090f00f /test
parentf79858ac4d90a450d0620d1ecb713bc35d7d9f8d (diff)
downloadopenssl-new-a39eb84006ca68d38d1c7204a6135647d06b5d01.tar.gz
Replumbing: give the possibility for the provider to create a context
OSSL_provider_init() gets another output parameter, holding a pointer to a provider side context. It's entirely up to the provider to define the context and what it's being used for. This pointer is passed back to other provider functions, typically the provider global get_params and set_params functions, and also the diverse algorithm context creators, and of course, the teardown function. With this, a provider can be instantiated more than once, or be re-loaded as the case may be, while maintaining instance state. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/8848)
Diffstat (limited to 'test')
-rw-r--r--test/p_test.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/test/p_test.c b/test/p_test.c
index bf13a0a070..93196f74c4 100644
--- a/test/p_test.c
+++ b/test/p_test.c
@@ -38,13 +38,18 @@ static const OSSL_ITEM p_param_types[] = {
{ 0, NULL }
};
-static const OSSL_ITEM *p_get_param_types(const OSSL_PROVIDER *_)
+/* This is a trick to ensure we define the provider functions correctly */
+static OSSL_provider_get_param_types_fn p_get_param_types;
+static OSSL_provider_get_params_fn p_get_params;
+
+static const OSSL_ITEM *p_get_param_types(void *_)
{
return p_param_types;
}
-static int p_get_params(const OSSL_PROVIDER *prov, OSSL_PARAM params[])
+static int p_get_params(void *vprov, const OSSL_PARAM params[])
{
+ const OSSL_PROVIDER *prov = vprov;
const OSSL_PARAM *p = params;
int ok = 1;
@@ -101,7 +106,8 @@ static const OSSL_DISPATCH p_test_table[] = {
int OSSL_provider_init(const OSSL_PROVIDER *provider,
const OSSL_DISPATCH *in,
- const OSSL_DISPATCH **out)
+ const OSSL_DISPATCH **out,
+ void **provctx)
{
for (; in->function_id != 0; in++) {
switch (in->function_id) {
@@ -117,6 +123,9 @@ int OSSL_provider_init(const OSSL_PROVIDER *provider,
}
}
+ /* Because we use this in get_params, we need to pass it back */
+ *provctx = (void *)provider;
+
*out = p_test_table;
return 1;
}