I would like to know how to calculate the encryption time for AES-CCM.
The Crypto++ wiki provides an article Benchmarks. It provides a lot of details regarding library performance, how throughput is calculated, and it even references the source code where the actual throughput is measured. Believe it or not, a simple call to clock works just fine to measure bulk encryption. Also see Benchmarks | Timing Loop in the same wiki article.
To benchmark AES/CCM, do something like the following. It is based on the Crypto++ benchmarking code, but it uses a ThreadUserTimer instead of a direct call to clock. ThreadUserTimer works across all OSes and all versions of C++.
You need to dial-in your processor speed at cpuFreq. You should also run ./governor.sh perf to move the CPU from an idle or C-level sleep state, but you can't because it is a Linux script. You can find it in the TestScript/ folder.
Running it on a Core i5-6400 at 2.7 GHz results in:
$ g++ bench.cxx ./libcryptopp.a -o bench.exe
$ ./bench.exe
AES/CCM benchmarks...
2.7 GHz cpu frequency
3.00491 cycles per byte (cpb)
856.904 MiB per second (MiB)
Usually you benchmark a library with CTR mode. For example, all of the SUPERCOP benchmarks are performed using the mode. You can switch to CTR mode by including "modes.h", and then:
The Crypto++ wiki provides an article Benchmarks. It provides a lot of details regarding library performance, how throughput is calculated, and it even references the source code where the actual throughput is measured. Believe it or not, a simple call to
clock
works just fine to measure bulk encryption. Also see Benchmarks | Timing Loop in the same wiki article.To benchmark AES/CCM, do something like the following. It is based on the Crypto++ benchmarking code, but it uses a
ThreadUserTimer
instead of a direct call toclock
.ThreadUserTimer
works across all OSes and all versions of C++.You need to dial-in your processor speed at
cpuFreq
. You should also run./governor.sh perf
to move the CPU from an idle or C-level sleep state, but you can't because it is a Linux script. You can find it in theTestScript/
folder.Running it on a Core i5-6400 at 2.7 GHz results in:
Usually you benchmark a library with CTR mode. For example, all of the SUPERCOP benchmarks are performed using the mode. You can switch to CTR mode by including
"modes.h"
, and then:Finally, the same test using CTR mode: