Skip to content

Commit

Permalink
Cleanup threading resources when OpenSSL is used.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashman-p committed Oct 23, 2024
1 parent 90030a4 commit ac3dfd0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
6 changes: 6 additions & 0 deletions tests/test_kem.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

#if OQS_USE_PTHREADS
#include <pthread.h>
# if OQS_USE_OPENSSL
#include <openssl/crypto.h>
# endif
#endif

#ifdef OQS_ENABLE_TEST_CONSTANT_TIME
Expand Down Expand Up @@ -206,6 +209,9 @@ struct thread_data {
void *test_wrapper(void *arg) {
struct thread_data *td = arg;
td->rc = kem_test_correctness(td->alg_name);
#if defined(OQS_USE_OPENSSL) && !defined(OQS_DLOPEN_OPENSSL)
OPENSSL_thread_stop();
#endif
return NULL;
}
#endif
Expand Down
6 changes: 6 additions & 0 deletions tests/test_sig.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

#if OQS_USE_PTHREADS
#include <pthread.h>
# if OQS_USE_OPENSSL
#include <openssl/crypto.h>
# endif
#endif

#ifdef OQS_ENABLE_TEST_CONSTANT_TIME
Expand Down Expand Up @@ -183,6 +186,9 @@ struct thread_data {
void *test_wrapper(void *arg) {
struct thread_data *td = arg;
td->rc = sig_test_correctness(td->alg_name);
#if defined(OQS_USE_OPENSSL) && !defined(OQS_DLOPEN_OPENSSL)
OPENSSL_thread_stop();
#endif
return NULL;
}
#endif
Expand Down
19 changes: 18 additions & 1 deletion tests/test_sig_stfl.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@

#if OQS_USE_PTHREADS_IN_TESTS
#include <pthread.h>

# if OQS_USE_OPENSSL
#include <openssl/crypto.h>
# endif
static pthread_mutex_t *test_sk_lock = NULL;
static pthread_mutex_t *sk_lock = NULL;
#endif
Expand Down Expand Up @@ -990,6 +992,9 @@ void *test_query_key(void *arg) {
struct lock_test_data *td = arg;
printf("\n%s: Start Query Stateful Key info\n", __func__);
td->rc = sig_stfl_test_query_key(td->alg_name);
#if defined(OQS_USE_OPENSSL) && !defined(OQS_DLOPEN_OPENSSL)
OPENSSL_thread_stop();
#endif
printf("%s: End Query Stateful Key info\n\n", __func__);
return NULL;
}
Expand All @@ -998,6 +1003,9 @@ void *test_sig_gen(void *arg) {
struct lock_test_data *td = arg;
printf("\n%s: Start Generate Stateful Signature\n", __func__);
td->rc = sig_stfl_test_sig_gen(td->alg_name);
#if defined(OQS_USE_OPENSSL) && !defined(OQS_DLOPEN_OPENSSL)
OPENSSL_thread_stop();
#endif
printf("%s: End Generate Stateful Signature\n\n", __func__);
return NULL;
}
Expand All @@ -1006,19 +1014,28 @@ void *test_create_keys(void *arg) {
struct lock_test_data *td = arg;
printf("\n%s: Start Generate Keys\n", __func__);
td->rc = sig_stfl_test_secret_key_lock(td->alg_name, td->katfile);
#if defined(OQS_USE_OPENSSL) && !defined(OQS_DLOPEN_OPENSSL)
OPENSSL_thread_stop();
#endif
printf("%s: End Generate Stateful Keys\n\n", __func__);
return NULL;
}

void *test_correctness_wrapper(void *arg) {
struct thread_data *td = arg;
td->rc = sig_stfl_test_correctness(td->alg_name, td->katfile);
#if defined(OQS_USE_OPENSSL) && !defined(OQS_DLOPEN_OPENSSL)
OPENSSL_thread_stop();
#endif
return NULL;
}

void *test_secret_key_wrapper(void *arg) {
struct thread_data *td = arg;
td->rc = sig_stfl_test_secret_key(td->alg_name, td->katfile);
#if defined(OQS_USE_OPENSSL) && !defined(OQS_DLOPEN_OPENSSL)
OPENSSL_thread_stop();
#endif
return NULL;
}
#endif
Expand Down

0 comments on commit ac3dfd0

Please sign in to comment.