From 260f27a531c1f8d23cce420d27e7c748ae379613 Mon Sep 17 00:00:00 2001 From: Michael Baentsch <57787676+baentsch@users.noreply.github.com> Date: Wed, 6 Mar 2024 16:21:53 +0100 Subject: [PATCH] add prov load/unload pattern to encode_decode test --- test/oqs_test_endecode.c | 15 ++++++++------- test/oqs_test_groups.c | 5 ++++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/test/oqs_test_endecode.c b/test/oqs_test_endecode.c index 8f20e78f..21e13c34 100644 --- a/test/oqs_test_endecode.c +++ b/test/oqs_test_endecode.c @@ -244,13 +244,13 @@ int main(int argc, char *argv[]) modulename = argv[1]; configfile = argv[2]; - load_oqs_provider(libctx, modulename, configfile); + oqsprov = load_oqs_provider(libctx, modulename, configfile); keyctx = OSSL_LIB_CTX_new(); - oqsprov = load_oqs_provider(keyctx, modulename, configfile); - dfltprov = OSSL_PROVIDER_load(keyctx, "default"); + + // possible as oqs_provider init (static or dynamic) has already been done: keyprov = OSSL_PROVIDER_load(keyctx, modulename); algs = OSSL_PROVIDER_query_operation(oqsprov, OSSL_OP_SIGNATURE, @@ -276,10 +276,11 @@ int main(int argc, char *argv[]) } #endif /* OQS_KEM_ENCODERS */ - OSSL_PROVIDER_unload(dfltprov); - OSSL_PROVIDER_unload(keyprov); - if (OPENSSL_VERSION_PREREQ(3, 1)) - OSSL_PROVIDER_unload(oqsprov); // avoid crash in 3.0.x + if (OPENSSL_VERSION_PREREQ(3, 1)) { // avoid crash in 3.0.x + OSSL_PROVIDER_unload(dfltprov); + OSSL_PROVIDER_unload(keyprov); + OSSL_PROVIDER_unload(oqsprov); + } OSSL_LIB_CTX_free(libctx); OSSL_LIB_CTX_free(keyctx); diff --git a/test/oqs_test_groups.c b/test/oqs_test_groups.c index 171d2b44..eb31b38a 100644 --- a/test/oqs_test_groups.c +++ b/test/oqs_test_groups.c @@ -132,6 +132,7 @@ int main(int argc, char *argv[]) { size_t i; int errcnt = 0, test = 0; + OSSL_PROVIDER *oqsprov = NULL; T((libctx = OSSL_LIB_CTX_new()) != NULL); T(argc == 4); @@ -142,7 +143,7 @@ int main(int argc, char *argv[]) T(cert = test_mk_file_path(certsdir, "servercert.pem")); T(privkey = test_mk_file_path(certsdir, "serverkey.pem")); - load_oqs_provider(libctx, modulename, configfile); + oqsprov = load_oqs_provider(libctx, modulename, configfile); T(OSSL_PROVIDER_available(libctx, "default")); @@ -150,6 +151,8 @@ int main(int argc, char *argv[]) OPENSSL_free(cert); OPENSSL_free(privkey); + if (OPENSSL_VERSION_PREREQ(3, 1)) + OSSL_PROVIDER_unload(oqsprov); // avoid crash in 3.0.x OSSL_LIB_CTX_free(libctx); TEST_ASSERT(errcnt == 0) return !test;