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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,13 @@ Two modes of operation:
- evp_isolated: Use EVP API and don't allow shared data between computations

```
Usage: evp_rand [-h] [-t] [-o operation] [-V] thread-count
Usage: evp_rand [-h] [-t] [-f] [-o operation] [-V] thread-count
-h - print this help output
-t - terse output
-f - freeze default context
-o operation - mode of operation. One of [evp_isolated, evp_shared] (default: evp_shared)
-V - print version information and exit
thread-count - number of thread
thread-count - number of threads
```

```sh
Expand Down
6 changes: 5 additions & 1 deletion source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ set(run_evp_pkey_operations
set(run_evp_pkey_algorithms
evp_pkey "" "" "-a RSA" "-a X25519" "-a X448" "-a ED25519" "-a ED448"
CACHE STRING "Algorithms for evp_pkey")
set(run_evp_rand_freeze
evp_rand "" "" "-f"
CACHE STRING "Freeze LIB_CTX for evp_rand")
set(run_evp_setpeer_keys
evp_setpeer "-k" dh ec256 ec521 x25519 all
CACHE STRING "Key types for evp_setpeer")
Expand Down Expand Up @@ -359,7 +362,8 @@ set(run_opts run_evp_fetch_pqs

if(HAVE_OSSL_LIB_CTX_FREEZE)
list(APPEND run_opts run_evp_hash_freeze
run_evp_cipher_freeze)
run_evp_cipher_freeze
run_evp_rand_freeze)
endif()

# Used across multiple tests
Expand Down
31 changes: 30 additions & 1 deletion source/evp_rand.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#define OPENSSL_SUPPRESS_DEPRECATED

#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#ifndef _WIN32
Expand Down Expand Up @@ -121,9 +122,16 @@ static void do_evp_shared(size_t num)

static void print_help(FILE *file)
{
#ifdef HAVE_OSSL_LIB_CTX_FREEZE
fprintf(file, "Usage: evp_rand [-h] [-t] [-f] [-o operation] [-V] thread-count\n");
#else
fprintf(file, "Usage: evp_rand [-h] [-t] [-o operation] [-V] thread-count\n");
#endif
fprintf(file, "-h - print this help output\n");
fprintf(file, "-t - terse output\n");
#ifdef HAVE_OSSL_LIB_CTX_FREEZE
fprintf(file, "-f - freeze default context\n");
#endif
fprintf(file, "-o operation - mode of operation. One of [evp_isolated, evp_shared] (default: evp_shared)\n");
fprintf(file, "-V - print version information and exit\n");
fprintf(file, "thread-count - number of threads\n");
Expand All @@ -136,12 +144,24 @@ int main(int argc, char *argv[])
double av;
int terse = 0, operation = EVP_SHARED;
int j, opt, rc = EXIT_FAILURE;
#ifdef HAVE_OSSL_LIB_CTX_FREEZE
int freeze = 0;
char *getopt_options = "Vhtfo:";
#else
char *getopt_options = "Vhto:";
#endif

while ((opt = getopt(argc, argv, "Vhto:")) != -1) {

while ((opt = getopt(argc, argv, getopt_options)) != -1) {
switch (opt) {
case 't':
terse = 1;
break;
#ifdef HAVE_OSSL_LIB_CTX_FREEZE
case 'f':
freeze = 1;
break;
#endif
case 'o':
if (strcmp(optarg, "evp_isolated") == 0) {
operation = EVP_ISOLATED;
Expand Down Expand Up @@ -184,6 +204,15 @@ int main(int argc, char *argv[])
goto err;
}

#ifdef HAVE_OSSL_LIB_CTX_FREEZE
if (freeze) {
if (OSSL_LIB_CTX_freeze(NULL, NULL) == 0) {
fprintf(stderr, "Freezing LIB CTX failed\n");
goto err;
}
}
#endif

max_time = ossl_time_add(ossl_time_now(), ossl_seconds2time(RUN_TIME));

switch (operation) {
Expand Down