-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy pathtest_common.c
61 lines (47 loc) · 1.66 KB
/
test_common.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// SPDX-License-Identifier: Apache-2.0 AND MIT
#include "test_common.h"
#include <string.h>
void hexdump(const void *ptr, size_t len)
{
const unsigned char *p = ptr;
size_t i, j;
for (i = 0; i < len; i += j) {
for (j = 0; j < 16 && i + j < len; j++)
printf("%s%02x", j? "" : " ", p[i + j]);
}
printf("\n");
}
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
int alg_is_enabled(const char *algname) {
char *alglist = getenv("OQS_SKIP_TESTS");
char *comma = NULL;
char totest[200];
if (alglist == NULL) return 1;
while((comma = strchr(alglist, ','))) {
memcpy(totest, alglist, MIN(200,comma-alglist));
totest[comma-alglist]='\0';
if (strstr(algname, totest)) return 0;
alglist = comma+1;
}
return strstr(algname, alglist) == NULL;
}
#ifdef OQS_PROVIDER_STATIC
#define OQS_PROVIDER_ENTRYPOINT_NAME oqs_provider_init
#else
#define OQS_PROVIDER_ENTRYPOINT_NAME OSSL_provider_init
#endif // ifdef OQS_PROVIDER_STATIC
#ifndef OQS_PROVIDER_STATIC
/* Loads the oqs-provider from a shared module (.so). */
void load_oqs_provider(OSSL_LIB_CTX *libctx, const char *modulename, const char *configfile) {
T(OSSL_LIB_CTX_load_config(libctx, configfile));
T(OSSL_PROVIDER_available(libctx, modulename));
}
#else
extern OSSL_provider_init_fn OQS_PROVIDER_ENTRYPOINT_NAME;
/* Loads the statically linked oqs-provider. */
void load_oqs_provider(OSSL_LIB_CTX *libctx, const char *modulename, const char *configfile) {
(void)configfile;
T(OSSL_PROVIDER_add_builtin(libctx, modulename, OQS_PROVIDER_ENTRYPOINT_NAME));
T(OSSL_PROVIDER_load(libctx, "default"));
}
# endif // ifndef OQS_PROVIDER_STATIC