When working with security-sensitive applications, it's often important to understand how fast different cryptographic algorithms perform on the system. OpenSSL provides a built-in benchmarking utility that allows you to measure the throughput of hash functions, symmetric ciphers, and more. This can be particularly useful for comparing algorithm choices, or testing hardware acceleration. This tutorial explains how to benchmark cryptographic algorithms performance using OpenSSL.
The openssl speed
command benchmarks cryptographic algorithms. To test a single algorithm, you can specify it with the -evp
option:
openssl speed -evp sha256
This command measures how many bytes per second can be processed using SHA-256 on different block sizes.
You can also benchmark multiple algorithms in a single run. For example, testing both SHA-256 and AES-256-CBC together:
openssl speed -evp sha256 aes-256-cbc
Example output:
Doing aes-256-cbc for 3s on 16 size blocks: 200944226 aes-256-cbc's in 2.99s
Doing aes-256-cbc for 3s on 64 size blocks: 63286821 aes-256-cbc's in 3.00s
Doing aes-256-cbc for 3s on 256 size blocks: 16783157 aes-256-cbc's in 3.00s
Doing aes-256-cbc for 3s on 1024 size blocks: 4274102 aes-256-cbc's in 3.00s
Doing aes-256-cbc for 3s on 8192 size blocks: 535832 aes-256-cbc's in 3.00s
Doing aes-256-cbc for 3s on 16384 size blocks: 272130 aes-256-cbc's in 2.99s
Doing sha256 for 3s on 16 size blocks: 18866770 sha256's in 3.00s
Doing sha256 for 3s on 64 size blocks: 14832864 sha256's in 3.00s
Doing sha256 for 3s on 256 size blocks: 9187455 sha256's in 3.00s
Doing sha256 for 3s on 1024 size blocks: 3706952 sha256's in 3.00s
Doing sha256 for 3s on 8192 size blocks: 557400 sha256's in 3.00s
Doing sha256 for 3s on 16384 size blocks: 282454 sha256's in 3.00s
version: 3.0.13
built on: Wed Feb 5 13:17:43 2025 UTC
options: bn(64,64)
compiler: gcc -fPIC -pthread -m64 -Wa,--noexecstack -Wall ...
CPUINFO: OPENSSL_ia32cap=0x7ffaf3bfffebffff:0x18c05fdef3bfa7eb
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes
aes-256-cbc 1075286.83k 1350118.85k 1432162.73k 1458893.48k 1463178.58k 1491163.18k
sha256 100622.77k 316434.43k 783996.16k 1265306.28k 1522073.60k 1542575.45k
To know which algorithms can be benchmarked, you can list available hash functions and ciphers:
openssl list -digest-algorithms
openssl list -cipher-algorithms
Leave a Comment
Cancel reply