-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See #272. This commit checks that if `c_obj_create` fails, the error code is `OBJ_R_OID_EXISTS` and the OID has been successfully added (using `OBJ_txt2nid`). If it's the case, then the error is skipped.
- Loading branch information
thb-sb
authored and
Thomas Bailleux
committed
Nov 2, 2023
1 parent
4dac252
commit 564ee11
Showing
5 changed files
with
162 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// SPDX-License-Identifier: Apache-2.0 AND MIT | ||
|
||
#ifndef _WIN32 | ||
# include <pthread.h> | ||
#endif | ||
|
||
#include <openssl/crypto.h> | ||
#include <openssl/provider.h> | ||
|
||
#include "test_common.h" | ||
|
||
static const size_t N_THREADS = 16; | ||
|
||
static const char *kModuleName = NULL; | ||
static const char *kConfigFile = NULL; | ||
|
||
/** \brief Loads the oqs-provider in an `OSSL_LIB_CTX` object. */ | ||
static int load_oqs_provider_thread(OSSL_LIB_CTX *lib_ctx) | ||
{ | ||
OSSL_PROVIDER *default_provider = NULL; | ||
OSSL_PROVIDER *oqs_provider = NULL; | ||
int ret = -1; | ||
|
||
#ifdef OQS_PROVIDER_STATIC | ||
if ((default_provider = OSSL_PROVIDER_load(lib_ctx, "default")) == NULL) { | ||
goto end; | ||
} | ||
if (OSSL_PROVIDER_add_builtin(lib_ctx, kModuleName, | ||
OQS_PROVIDER_ENTRYPOINT_NAME) | ||
!= 1) { | ||
goto unload_default_provider; | ||
} | ||
if ((oqs_provider = OSSL_PROVIDER_load(lib_ctx, kModuleName)) == NULL) { | ||
goto unload_default_provider; | ||
} | ||
ret = 0; | ||
OSSL_PROVIDER_unload(oqs_provider); | ||
|
||
#else | ||
|
||
if (OSSL_LIB_CTX_load_config(lib_ctx, kConfigFile) == 1 | ||
&& OSSL_PROVIDER_available(lib_ctx, kModuleName)) { | ||
ret = 0; | ||
} | ||
goto end; | ||
|
||
#endif // ifdef OQS_PROVIDER_STATIC | ||
|
||
unload_default_provider: | ||
OSSL_PROVIDER_unload(default_provider); | ||
|
||
end: | ||
return ret; | ||
} | ||
|
||
/** \brief Creates an OSSL_LIB_CTX object and loads oqs-provider. */ | ||
static void *thread_create_ossl_lib_ctx(void *arg) | ||
{ | ||
OSSL_LIB_CTX *lib_ctx = NULL; | ||
int ret = -1; | ||
|
||
(void)arg; | ||
|
||
if ((lib_ctx = OSSL_LIB_CTX_new()) == NULL) { | ||
goto end; | ||
} | ||
ret = load_oqs_provider_thread(lib_ctx); | ||
OSSL_LIB_CTX_free(lib_ctx); | ||
|
||
end: | ||
return (void *)(size_t)ret; | ||
} | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
size_t i; | ||
pthread_t threads[N_THREADS]; | ||
void *result; | ||
int ret = 0; | ||
|
||
T(argc == 3); | ||
|
||
kModuleName = argv[1]; | ||
kConfigFile = argv[2]; | ||
|
||
for (i = 0; i < N_THREADS; ++i) { | ||
pthread_create(threads + i, NULL, thread_create_ossl_lib_ctx, NULL); | ||
} | ||
|
||
for (i = 0; i < N_THREADS; ++i) { | ||
result = NULL; | ||
pthread_join(threads[i], &result); | ||
ret |= (int)(size_t)result; | ||
} | ||
|
||
return ret; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters