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

Holger Dengler posted 1 patch 2 weeks, 5 days ago
lib/crypto/tests/Kconfig        |  12 +++
lib/crypto/tests/Makefile       |   1 +
lib/crypto/tests/aes-testvecs.h |  77 ++++++++++++++++
lib/crypto/tests/aes_kunit.c    | 150 ++++++++++++++++++++++++++++++++
4 files changed, 240 insertions(+)
create mode 100644 lib/crypto/tests/aes-testvecs.h
create mode 100644 lib/crypto/tests/aes_kunit.c
[PATCH v2 0/1] lib/crypto: tests: KUnit test-suite for AES
Posted by Holger Dengler 2 weeks, 5 days ago
The following patch adds a kunit tests for the aes library.

Changes since v1 [1]:
- move information from cover-letter to commit message
- remove unused struct buf
- add reference to the KAT source
- restructure the benchmark
  - reduce the number of iterations for warm-up and benchmark
  - measure each aes operation and take the minimal measurement for the
    bandwidth calculation
  - normalize bandwidth to MB (power of 10) instead of MiB (power of 2)

Changes since RFC [2]:
- 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/20260115183831.72010-1-dengler@linux.ibm.com
[2] https://lore.kernel.org/linux-crypto/20260114153138.4896-1-dengler@linux.ibm.com

Example output of the aes_kunit test-suite:

[  316.380919] KTAP version 1
[  316.380923] 1..1
[  316.380964]     KTAP version 1
[  316.380965]     # Subtest: aes
[  316.380966]     # module: aes_kunit
[  316.380968]     1..9
[  316.381071]     ok 1 test_aes128_encrypt
[  316.381129]     ok 2 test_aes128_decrypt
[  316.381186]     ok 3 test_aes192_encrypt
[  316.381248]     ok 4 test_aes192_decrypt
[  316.381309]     ok 5 test_aes256_encrypt
[  316.381367]     ok 6 test_aes256_decrypt
[  316.381411]     # benchmark_aes128: enc (len=16): 500 MB/s
[  316.381414]     # benchmark_aes128: dec (len=16): 500 MB/s
[  316.381447]     ok 7 benchmark_aes128
[  316.381491]     # benchmark_aes192: enc (len=16): 500 MB/s
[  316.381494]     # benchmark_aes192: dec (len=16): 484 MB/s
[  316.381529]     ok 8 benchmark_aes192
[  316.381572]     # benchmark_aes256: enc (len=16): 484 MB/s
[  316.381574]     # benchmark_aes256: dec (len=16): 484 MB/s
[  316.381608]     ok 9 benchmark_aes256
[  316.381610] # aes: pass:9 fail:0 skip:0 total:9
[  316.381612] # Totals: pass:9 fail:0 skip:0 total:9
[  316.381614] 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 |  77 ++++++++++++++++
 lib/crypto/tests/aes_kunit.c    | 150 ++++++++++++++++++++++++++++++++
 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