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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,10 @@ Two modes of operation:
- evp_shared (default): Use EVP API and allow shared data between threads

```
Usage: evp_cipher [-h] [-t] [-o operation] [-u update-times] [-a algorithm] thread-count
Usage: evp_cipher [-h] [-t] [-f] [-o operation] [-u update-times] [-a algorithm] 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] (default: evp_shared)
-u update-times - times to update (default: 1)
-a algorithm - One of: [AES-128-CBC, AES-256-CBC] (default: AES-128-CBC)
Expand Down
6 changes: 5 additions & 1 deletion source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,9 @@ set(run_evp_cipher_operations
set(run_evp_cipher_algorithms
evp_cipher "" "" "-a AES-128-CBC" "-a AES-256-CBC"
CACHE STRING "Encryption algorithms for evp_cipher")
set(run_evp_cipher_freeze
evp_cipher "" "" "-f"
CACHE STRING "Freeze LIB_CTX for evp_cipher")
set(run_evp_mac_operations
evp_mac "" "" "-o deprecated_isolated" "-o deprecated_shared" "-o evp_isolated" "-o evp_shared"
CACHE STRING "Modes of operation for evp_mac")
Expand Down Expand Up @@ -341,7 +344,8 @@ set(run_opts run_evp_fetch_pqs
CACHE STRING "List of per-text options")

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

# Used across multiple tests
Expand Down
33 changes: 30 additions & 3 deletions source/evp_cipher.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_cipher_shared(size_t num)

static void print_help(FILE *file)
{
#ifdef HAVE_OSSL_LIB_CTX_FREEZE
fprintf(file, "Usage: evp_cipher [-h] [-f] [-t] [-o operation] [-u update-times] [-a algorithm] [-V] thread-count\n");
#else
fprintf(file, "Usage: evp_cipher [-h] [-t] [-o operation] [-u update-times] [-a algorithm] [-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, "-u update-times - times to update (default: 1)\n");
fprintf(file, "-a algorithm - One of: [AES-128-CBC, AES-256-CBC] (default: AES-128-CBC)\n");
Expand All @@ -139,9 +147,19 @@ int main(int argc, char *argv[])
int terse = 0, operation = EVP_SHARED;
int j, opt, rc = EXIT_FAILURE;
int key_len, iv_len;

while ((opt = getopt(argc, argv, "Vhto:u:a:")) != -1) {
switch (opt) {
char *getopt_options = "Vhto:u:a:";
#ifdef HAVE_OSSL_LIB_CTX_FREEZE
int freeze = 0;
getopt_options = "Vhto:u:a:f";
#endif

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 @@ -228,6 +246,15 @@ 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_ISOLATED:
err = !perflib_run_multi_thread_test(do_cipher_isolated, threadcount, &duration) || err;
Expand Down
Loading