Skip to content
Merged
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,10 @@ Four modes of operation:
- deprecated_isolated: Use legacy API and don't allow shared data between computations

```
Usage: evp_kdf [-h] [-t] [-o operation] [-V] thread-count
Usage: evp_kdf [-h] [-t] [-f] [-o operation] [-V] thread-count
-h - print this help output
-t - terse output
-f - freeze default context (available only with openssl >= 4.x.x)
-o operation - mode of operation. One of [evp_isolated, evp_shared, deprecated_isolated, deprecated_shared] (default: evp_shared)
-V - print version information and exit
thread-count - number of threads
Expand Down
6 changes: 6 additions & 0 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,12 @@ list(APPEND run_opts run_writeread_buffers)
add_executable(evp_hash evp_hash.c)
target_link_libraries(evp_hash PRIVATE perf)
list(APPEND run_tests evp_hash)
if( HAVE_OSSL_LIB_CTX_FREEZE )
set(run_evp_kdf_freeze
evp_kdf "" "" "-f"
CACHE STRING "Freeze LIB_CTX for evp_kdf")
list(APPEND run_opts run_evp_kdf_freeze)
endif()
set(run_evp_hash_operations
evp_hash "" "" "-o deprecated" "-o evp_isolated" "-o evp_shared"
CACHE STRING "Modes of operation for evp_hash")
Expand Down
28 changes: 27 additions & 1 deletion source/evp_kdf.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 @@ -169,9 +170,16 @@ static void do_deprecated_shared(size_t num)

static void print_help(FILE *file)
{
#ifdef HAVE_OSSL_LIB_CTX_FREEZE
fprintf(file, "Usage: evp_kdf [-h] [-t] [-f] [-o operation] [-V] thread-count\n");
#else
fprintf(file, "Usage: evp_kdf [-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
printf("-f - freeze default context\n");
#endif
fprintf(file, "-o operation - mode of operation. One of [evp_isolated, evp_shared, deprecated_isolated, deprecated_shared] (default: evp_shared)\n");
fprintf(file, "-V - print version information and exit\n");
fprintf(file, "thread-count - number of threads\n");
Expand All @@ -184,9 +192,19 @@ int main(int argc, char *argv[])
double av;
int terse = 0, operation = EVP_SHARED;
int j, opt, rc = EXIT_FAILURE;
char *getopt_options = "Vhto:";
#ifdef HAVE_OSSL_LIB_CTX_FREEZE
int freeze = 0;
getopt_options = "Vhto:f";
#endif

while ((opt = getopt(argc, argv, "Vhto:")) != -1) {
while ((opt = getopt(argc, argv, getopt_options)) != -1) {
switch (opt) {
#ifdef HAVE_OSSL_LIB_CTX_FREEZE
case 'f':
freeze = 1;
break;
#endif
case 't':
terse = 1;
break;
Expand Down Expand Up @@ -242,6 +260,14 @@ int main(int argc, char *argv[])

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

#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
switch (operation) {
case EVP_SHARED:
run_err = !perflib_run_multi_thread_test(do_evp_shared, threadcount, &duration) || run_err;
Expand Down