Skip to content

Commit

Permalink
add prov load/unload pattern to encode_decode test
Browse files Browse the repository at this point in the history
  • Loading branch information
baentsch committed Mar 6, 2024
1 parent 6c7c9da commit 260f27a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
15 changes: 8 additions & 7 deletions test/oqs_test_endecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);

Expand Down
5 changes: 4 additions & 1 deletion test/oqs_test_groups.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -142,14 +143,16 @@ 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"));

T(OSSL_PROVIDER_do_all(libctx, test_provider_groups, &errcnt));

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;
Expand Down

0 comments on commit 260f27a

Please sign in to comment.