Skip to content

Conversation

@andrewkdinh
Copy link
Contributor

Summary

Adds a CLI tool evp_mac that computes an HMAC of random data using SHA-256 digest.
Runs for 5 seconds and prints the average execution time per encryption.

Fixes openssl/project#1837

Features

  • Four modes of operation:
    • evp_shared (default): Use EVP API and allow shared data between computations
    • evp_isolated: Use EVP API and don't allow shared data between computations
    • deprecated_shared: Use legacy API and allow shared data between computations
    • deprecated_isolated: Use legacy API and don't allow shared data between computations
  • Configurable number of times to update
  • Terse output for easier CI automation (-t)
  • Configurable thread count

TODO: Since freeze functionality hasn't been properly added yet (see openssl/project#1832 & openssl/openssl#29433), support for freezing the context store has not been added yet.

Usage

$ ./evp_mac -h
Usage: evp_mac [-h] [-t] [-o operation] [-u update-times] [-V] thread-count
-h - print this help output
-t - terse output
-o operation - mode of operation. One of [evp_isolated, evp_shared, deprecated_isolated, deprecated_shared] (default: evp_shared)
-u update-times - times to update (default: 1)
-V - print version information and exit
thread-count - number of threads

$ ./evp_mac -o evp_shared 10 # evp_shared operation mode, 10 threads
Average time per computation: 0.207903us

$ ./evp_mac -o evp_isolated 10 # now using evp_isolated mode
Average time per computation: 7.918923us

Findings

Initial results showed that evp_isolated mode generally runs about 30x slower than evp_shared mode.

return;
}

counts[num]++;

Choose a reason for hiding this comment

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

nit: It's better to have size_t count locally, and update it after the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why is it better to do it like that?

Choose a reason for hiding this comment

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

The local counter has less overhead than accessing a global array each iteration.

@andrewkdinh andrewkdinh marked this pull request as ready for review January 27, 2026 16:19
@andrewkdinh andrewkdinh added the approval: done This pull request has the required number of approvals label Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: done This pull request has the required number of approvals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create perftool for EVP_MAC

3 participants