Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenSSL speed command for HMAC

OpenSSL provides a convenient command for benchmarking algorithms.

From what I understood, it only allows benchmarking encryption and hash functions. Is there a way to benchmark HMAC as well (say, hmac-sha256) from command line?

like image 832
M.S. Dousti Avatar asked Oct 15 '25 13:10

M.S. Dousti


1 Answers

Posting an updated answer as I was just looking at this myself!

From OpenSSL 3.0.0 the speed utility has been updated to include the -hmac option, so you can benchmark hmac with a digest of choice:

% openssl speed -hmac sha256
Doing hmac(sha256) for 3s on 16 size blocks: 8128050 hmac(sha256)'s in 2.99s
Doing hmac(sha256) for 3s on 64 size blocks: 6008552 hmac(sha256)'s in 2.99s
Doing hmac(sha256) for 3s on 256 size blocks: 3546506 hmac(sha256)'s in 2.99s
Doing hmac(sha256) for 3s on 1024 size blocks: 1278147 hmac(sha256)'s in 2.99s
Doing hmac(sha256) for 3s on 8192 size blocks: 192561 hmac(sha256)'s in 2.99s
Doing hmac(sha256) for 3s on 16384 size blocks: 96923 hmac(sha256)'s in 2.99s
version: 3.0.0-beta2
built on: built on: Mon Aug  2 17:30:29 2021 UTC
options:bn(64,64)
compiler: clang -fPIC -pthread -m64 -Wa,--noexecstack -Qunused-arguments -Wall -O3 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_BUILDING_OPENSSL -DNDEBUG
CPUINFO: ...
The 'numbers' are in 1000s of bytes per second processed.
type             16 bytes     64 bytes    256 bytes   1024 bytes   8192 bytes  16384 bytes
hmac(sha256)     43494.58k   128611.15k   303647.34k   437733.29k   527578.50k   531099.14k
like image 185
Samuel Lee Avatar answered Oct 18 '25 08:10

Samuel Lee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!