Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions source/evp_cipher.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,26 @@ static int cipher_isolated()
static void do_cipher_isolated(size_t num)
{
OSSL_TIME time;
size_t count = 0;

do {
if (!cipher_isolated()) {
err = 1;
return;
}

counts[num]++;
count++;
time = ossl_time_now();
} while (time.t < max_time.t);

counts[num] = count;
}

static void do_cipher_shared(size_t num)
{
OSSL_TIME time;
EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();
size_t count = 0;

if (ctx == NULL || !EVP_CipherInit_ex2(ctx, evp_cipher, key, iv, 1, NULL)) {
err = 1;
Expand All @@ -111,11 +115,12 @@ static void do_cipher_shared(size_t num)
goto err;
}

counts[num]++;
count++;
time = ossl_time_now();
} while (time.t < max_time.t);

err:
counts[num] = count;
EVP_CIPHER_CTX_free(ctx);
}

Expand Down
5 changes: 4 additions & 1 deletion source/evp_fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ void do_fetch(size_t num)
{
OSSL_TIME time;
size_t i, j;
size_t count = 0;
const char *fetch_alg = NULL;
int array_size = ARRAY_SIZE(fetch_entries);

Expand Down Expand Up @@ -282,9 +283,11 @@ void do_fetch(size_t num)
err = 1;
return;
}
counts[num]++;
count++;
time = ossl_time_now();
} while (time.t < max_time.t);

counts[num] = count;
}

static void
Expand Down
9 changes: 7 additions & 2 deletions source/evp_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,19 @@ static int hash_evp_sha512()
static void do_hash_isolated(size_t num)
{
OSSL_TIME time;
size_t count = 0;

do {
if (!hash_func_isolated()) {
err = 1;
return;
}

counts[num]++;
count++;
time = ossl_time_now();
} while (time.t < max_time.t);

counts[num] = count;
}

/*
Expand All @@ -226,6 +229,7 @@ static void do_hash_evp_shared(size_t num)
{
OSSL_TIME time;
EVP_MD_CTX *mctx = EVP_MD_CTX_new();
size_t count = 0;

if (mctx == NULL || !EVP_DigestInit_ex(mctx, evp_md, NULL)) {
err = 1;
Expand All @@ -238,11 +242,12 @@ static void do_hash_evp_shared(size_t num)
goto err;
}

counts[num]++;
count++;
time = ossl_time_now();
} while (time.t < max_time.t);

err:
counts[num] = count;
EVP_MD_CTX_free(mctx);
}

Expand Down
18 changes: 14 additions & 4 deletions source/evp_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,26 @@ static int evp_isolated()
static void do_evp_isolated(size_t num)
{
OSSL_TIME time;
size_t count = 0;

do {
if (!evp_isolated()) {
run_err = 1;
return;
}

counts[num]++;
count++;
time = ossl_time_now();
} while (time.t < max_time.t);

counts[num] = count;
}

static void do_evp_shared(size_t num)
{
OSSL_TIME time;
EVP_MAC *mac = NULL;
size_t count = 0;
EVP_MAC_CTX *ctx = NULL;
OSSL_PARAM params[] = {
OSSL_PARAM_construct_utf8_string("digest", "SHA256", 0),
Expand All @@ -129,11 +133,12 @@ static void do_evp_shared(size_t num)
goto err;
}

counts[num]++;
count++;
time = ossl_time_now();
} while (time.t < max_time.t);

err:
counts[num] = count;
EVP_MAC_CTX_free(ctx);
EVP_MAC_free(mac);
}
Expand Down Expand Up @@ -173,22 +178,26 @@ static int hmac_isolated()
static void do_deprecated_isolated(size_t num)
{
OSSL_TIME time;
size_t count = 0;

do {
if (!hmac_isolated()) {
run_err = 1;
return;
}

counts[num]++;
count++;
time = ossl_time_now();
} while (time.t < max_time.t);

counts[num] = count;
}

static void do_deprecated_shared(size_t num)
{
OSSL_TIME time;
HMAC_CTX *ctx = HMAC_CTX_new();
size_t count = 0;

if (ctx == NULL
|| !HMAC_Init_ex(ctx, key, KEY_SIZE, EVP_sha256(), NULL))
Expand All @@ -199,10 +208,11 @@ static void do_deprecated_shared(size_t num)
|| !HMAC_Init_ex(ctx, NULL, 0, NULL, NULL))
goto err;

counts[num]++;
count++;
time = ossl_time_now();
} while (time.t < max_time.t);

counts[num] = count;
return;

err:
Expand Down
8 changes: 4 additions & 4 deletions source/evp_setpeer.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ OSSL_TIME max_time;
void do_setpeer(size_t num)
{
OSSL_TIME time;
size_t count = 0;

EVP_PKEY_CTX *pkey_ctx = NULL;

Expand All @@ -56,17 +57,16 @@ void do_setpeer(size_t num)
return;
}

counts[num] = 0;

do {
if (EVP_PKEY_derive_set_peer(pkey_ctx, pkey) <= 0) {
err = 1;
break;
}
counts[num]++;
count++;
time = ossl_time_now();
} while (time.t < max_time.t);

counts[num] = count;
EVP_PKEY_CTX_free(pkey_ctx);
}

Expand Down Expand Up @@ -183,7 +183,7 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
}

counts = OPENSSL_malloc(sizeof(OSSL_TIME) * threadcount);
counts = OPENSSL_malloc(sizeof(size_t) * threadcount);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a separate commit, ideally.

if (counts == NULL) {
printf("Failed to create counts array\n");
return EXIT_FAILURE;
Expand Down
15 changes: 12 additions & 3 deletions source/handshake.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ static void do_handshake(size_t num)
SSL *clientssl = NULL, *serverssl = NULL;
int ret = 1;
OSSL_TIME time;
size_t count = 0;
SSL_CTX *lsctx = NULL;
SSL_CTX *lcctx = NULL;

Expand Down Expand Up @@ -102,10 +103,12 @@ static void do_handshake(size_t num)
SSL_CTX_free(lcctx);
lsctx = lcctx = NULL;
}
counts[num]++;
count++;
time = ossl_time_now();
} while (time.t < max_time.t);

counts[num] = count;

if (!ret)
err = 1;
}
Expand All @@ -117,6 +120,7 @@ static void do_handshake_ossl_lib_ctx_per_thread(size_t num)
SSL *clientssl = NULL, *serverssl = NULL;
int ret = 1;
OSSL_TIME time;
size_t count = 0;
OSSL_LIB_CTX *libctx = NULL;
SSL_CTX *lsctx = NULL;
SSL_CTX *lcctx = NULL;
Expand Down Expand Up @@ -156,10 +160,12 @@ static void do_handshake_ossl_lib_ctx_per_thread(size_t num)
SSL_CTX_free(lcctx);
lsctx = lcctx = NULL;
}
counts[num]++;
count++;
time = ossl_time_now();
} while (time.t < max_time.t);

counts[num] = count;

SSL_CTX_free(lsctx);
SSL_CTX_free(lcctx);

Expand All @@ -174,6 +180,7 @@ static void do_handshake_ctx_pool(size_t num)
SSL *clientssl = NULL, *serverssl = NULL;
int ret = 1;
OSSL_TIME time;
size_t count = 0;
SSL_CTX *lsctx = NULL;
SSL_CTX *lcctx = NULL;
struct ctxs *ctx = NULL;
Expand Down Expand Up @@ -226,11 +233,13 @@ static void do_handshake_ctx_pool(size_t num)
SSL_CTX_free(lcctx);
lsctx = lcctx = NULL;
}
counts[num]++;
count++;
time = ossl_time_now();
}
while (time.t < max_time.t);

counts[num] = count;

if (share_ctx == 1 && test_case == TC_OSSL_LIB_CTX_POOL) {
SSL_CTX_free(lsctx);
SSL_CTX_free(lcctx);
Expand Down
7 changes: 4 additions & 3 deletions source/newrawkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ void do_newrawkey(size_t num)
{
EVP_PKEY *pkey;
OSSL_TIME time;
size_t count = 0;
const unsigned char *key_data = key_x25519;
size_t key_len = sizeof(key_x25519);

Expand All @@ -362,8 +363,6 @@ void do_newrawkey(size_t num)
break;
}

counts[num] = 0;

do {
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
pkey = EVP_PKEY_new_raw_public_key_ex(NULL, alg_name, NULL, key_data,
Expand All @@ -379,9 +378,11 @@ void do_newrawkey(size_t num)
err = 1;
else
EVP_PKEY_free(pkey);
counts[num]++;
count++;
time = ossl_time_now();
} while (time.t < max_time.t);

counts[num] = count;
}

int main(int argc, char *argv[])
Expand Down
7 changes: 4 additions & 3 deletions source/pkeyread.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,14 @@ static void do_derread(size_t num)
size_t keydata_sz;
EVP_PKEY *pkey = NULL;
OSSL_TIME time;
size_t count = 0;

if (sample_id >= SAMPLE_ALL) {
fprintf(stderr, "%s no sample key set for test\n", __func__);
err = 1;
return;
}

counts[num] = 0;

do {
keydata = (const unsigned char *)sample_keys[sample_id][FORMAT_DER];
keydata_sz = sample_key_sizes[sample_id][FORMAT_DER];
Expand All @@ -151,9 +150,11 @@ static void do_derread(size_t num)
error:
EVP_PKEY_free(pkey);
pkey = NULL;
counts[num]++;
count++;
time = ossl_time_now();
} while (time.t < max_time.t);

counts[num] = count;
}

static int sample_name_to_id(const char *sample_name)
Expand Down
7 changes: 4 additions & 3 deletions source/providerdoall.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,19 @@ static void do_providerdoall(size_t num)
{
int count;
OSSL_TIME time;

counts[num] = 0;
size_t iters = 0;

do {
count = 0;
if (!OSSL_PROVIDER_do_all(NULL, doit, &count) || count != 1) {
err = 1;
break;
}
counts[num]++;
iters++;
time = ossl_time_now();
} while (time.t < max_time.t);

counts[num] = iters;
}

int main(int argc, char *argv[])
Expand Down
7 changes: 4 additions & 3 deletions source/randbytes.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,16 @@ void do_randbytes(size_t num)
{
unsigned char buf[32];
OSSL_TIME time;

counts[num] = 0;
size_t count = 0;

do {
if (!RAND_bytes(buf, sizeof(buf)))
err = 1;
counts[num]++;
count++;
time = ossl_time_now();
} while (time.t < max_time.t);

counts[num] = count;
}

int main(int argc, char *argv[])
Expand Down
Loading
Loading