How do you benchmark cryptography?

There are many different metrics that can be used when benchmarking cryptography. The common metrics are; average time per operation, average amount of data processed per unit of time, and number of clock cycles taken per data processed.

The first metric of average time per operation, is used with asymmetric key algorithms. These are algorithms that have a public and a private key pair and are doing operations such as signing, verifying, or creating a shared secret key where the input and output data of the operation is a constant size. In wolfSSL, the signature creation and verification operations for RSA and ECC can be benchmarked with the bundled benchmark application using the following command:

`./wolfcrypt/benchmark/benchmark -rsa -ecc`

The last two metrics of average amount of data processed per unit of time (often MB/s, megabytes per second) and number of clock cycles per byte processed are used with symmetric key algorithms. These are algorithms such as AES or ChaCha20 where the key used for encryption should be the same as decryption and the input / output sizes are dependent on the amount of data passed in by the user. When using hardware acceleration created specifically for crypto operations the cycles per byte can even dip below 1. That is – more than one byte of input data processed (encrypted or decrypted) in the time it took for one clock cycle with the CPU! An example of benchmarking AES and ChaCha20 would be the following command:

`./wolfcrypt/benchmark/benchmark -aes-gcm -chacha20`

There are many options available with the wolfSSL benchmark application. All of the options can be seen by using the flag -h `./wolfcrypt/benchmark/benchmark -h`. A couple of the flags that are of note are -base10 and -csv. The flag -base10 uses 1000 bytes as a kilobyte (instead of 1024 which is the default with wolfSSL, aka KiB) and can be used when comparing performance with OpenSSL which defaults to treating 1000 bytes as a kilobyte. Benchmark performance also is very dependent on the hardware that it is run on. The wolfSSL benchmarks page has performance of wolfSSL crypto operations on various hardware platforms.

For questions about setting up wolfSSL to be as fast as possible on your platform, or for inquiries about any of the above, please contact us at facts@wolfssl.com or +1 425 245 8247.

Download wolfSSL Now