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?
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?
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
Results are fairy similar for hmac(md5)
vs md5
.
So I guess to benchmark hmac(sha256)
you just need to take results of sha256
hash function.
% openssl speed hmac md5 sha256 sha512
Doing md5 for 3s on 16 size blocks: 13715628 md5's in 2.99s
Doing md5 for 3s on 64 size blocks: 10361234 md5's in 2.99s
Doing md5 for 3s on 256 size blocks: 5689195 md5's in 2.99s
Doing md5 for 3s on 1024 size blocks: 1990236 md5's in 2.99s
Doing md5 for 3s on 8192 size blocks: 293475 md5's in 2.99s
Doing hmac(md5) for 3s on 16 size blocks: 13368283 hmac(md5)'s in 2.99s
Doing hmac(md5) for 3s on 64 size blocks: 9924043 hmac(md5)'s in 2.99s
Doing hmac(md5) for 3s on 256 size blocks: 5593989 hmac(md5)'s in 2.99s
Doing hmac(md5) for 3s on 1024 size blocks: 1964644 hmac(md5)'s in 2.99s
Doing hmac(md5) for 3s on 8192 size blocks: 292363 hmac(md5)'s in 2.99s
Doing sha256 for 3s on 16 size blocks: 14201213 sha256's in 2.99s
Doing sha256 for 3s on 64 size blocks: 7570892 sha256's in 2.99s
Doing sha256 for 3s on 256 size blocks: 3138350 sha256's in 2.99s
Doing sha256 for 3s on 1024 size blocks: 939177 sha256's in 2.99s
Doing sha256 for 3s on 8192 size blocks: 126911 sha256's in 2.99s
Doing sha512 for 3s on 16 size blocks: 11391648 sha512's in 2.99s
Doing sha512 for 3s on 64 size blocks: 11011678 sha512's in 2.98s
Doing sha512 for 3s on 256 size blocks: 3895326 sha512's in 2.98s
Doing sha512 for 3s on 1024 size blocks: 1303197 sha512's in 2.98s
Doing sha512 for 3s on 8192 size blocks: 189750 sha512's in 2.98s
LibreSSL 2.8.3
built on: date not available
options:bn(64,64) rc4(16x,int) des(idx,cisc,16,int) aes(partial) blowfish(idx)
compiler: information not available
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
md5 73410.89k 221714.56k 486819.65k 681496.50k 803485.66k
hmac(md5) 71518.45k 212298.15k 478869.83k 672032.15k 800279.37k
sha256 75974.89k 162043.05k 268412.75k 321679.74k 347906.04k
sha512 60963.26k 236450.99k 335184.41k 447599.24k 521495.30k