[PATCH v1 0/1] lib/crypto: tests: KUnit test-suite for AES

Holger Dengler posted 1 patch 3 weeks, 1 day ago
There is a newer version of this series
lib/crypto/tests/Kconfig        |  12 +++
lib/crypto/tests/Makefile       |   1 +
lib/crypto/tests/aes-testvecs.h |  78 +++++++++++++++++
lib/crypto/tests/aes_kunit.c    | 149 ++++++++++++++++++++++++++++++++
4 files changed, 240 insertions(+)
create mode 100644 lib/crypto/tests/aes-testvecs.h
create mode 100644 lib/crypto/tests/aes_kunit.c
[PATCH v1 0/1] lib/crypto: tests: KUnit test-suite for AES
Posted by Holger Dengler 3 weeks, 1 day ago
The following patch adds a kunit tests for the aes library. It does a very
minimal verification of the aes operation for all key-sizes. The benchmarks,
which are also part of the test-suite, can be used to get some rough
performance measurements of the aes encrypt and decrypt functions. The
aes_prepare*key() APIs are not covered by the benchmarks.

Changes since RFC [1]:
- reorder entries in Kconfig/Makefile alphabetically
- fail (instead of skip) in case of failures in key preparation
- replace local constant definitions
- replace macros with helper functions

[1] https://lore.kernel.org/linux-crypto/20260114153138.4896-1-dengler@linux.ibm.com

Example output of the aes_kunit test-suite:

[  178.640161] KTAP version 1
[  178.640167] 1..1
[  178.642268]     KTAP version 1
[  178.642269]     # Subtest: aes
[  178.642270]     # module: aes_kunit
[  178.642272]     1..9
[  178.642330]     ok 1 test_aes128_encrypt
[  178.642378]     ok 2 test_aes128_decrypt
[  178.642427]     ok 3 test_aes192_encrypt
[  178.642477]     ok 4 test_aes192_decrypt
[  178.642531]     ok 5 test_aes256_encrypt
[  178.642584]     ok 6 test_aes256_decrypt
[  179.345355]     # benchmark_aes128: enc (iter. 10000000, duration 351128093ns)
[  179.345359]     # benchmark_aes128: enc (len=16): 434 MB/s
[  179.345361]     # benchmark_aes128: dec (iter. 10000000, duration 351541596ns)
[  179.345363]     # benchmark_aes128: dec (len=16): 434 MB/s
[  179.345398]     ok 7 benchmark_aes128
[  180.082939]     # benchmark_aes192: enc (iter. 10000000, duration 370559483ns)
[  180.082942]     # benchmark_aes192: enc (len=16): 411 MB/s
[  180.082944]     # benchmark_aes192: dec (iter. 10000000, duration 366888529ns)
[  180.082946]     # benchmark_aes192: dec (len=16): 415 MB/s
[  180.082982]     ok 8 benchmark_aes192
[  180.810447]     # benchmark_aes256: enc (iter. 10000000, duration 363703684ns)
[  180.810450]     # benchmark_aes256: enc (len=16): 419 MB/s
[  180.810452]     # benchmark_aes256: dec (iter. 10000000, duration 363671689ns)
[  180.810454]     # benchmark_aes256: dec (len=16): 419 MB/s
[  180.810490]     ok 9 benchmark_aes256
[  180.810495] # aes: pass:9 fail:0 skip:0 total:9
[  180.810498] # Totals: pass:9 fail:0 skip:0 total:9
[  180.810500] ok 1 aes

Holger Dengler (1):
  lib/crypto: tests: Add KUnit tests for AES

 lib/crypto/tests/Kconfig        |  12 +++
 lib/crypto/tests/Makefile       |   1 +
 lib/crypto/tests/aes-testvecs.h |  78 +++++++++++++++++
 lib/crypto/tests/aes_kunit.c    | 149 ++++++++++++++++++++++++++++++++
 4 files changed, 240 insertions(+)
 create mode 100644 lib/crypto/tests/aes-testvecs.h
 create mode 100644 lib/crypto/tests/aes_kunit.c


base-commit: 47753e09a15d9fd7cdf114550510f4f2af9333ec
-- 
2.51.0