summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@kernel.org>2026-02-18 13:34:53 -0800
committerEric Biggers <ebiggers@kernel.org>2026-03-09 13:27:20 -0700
commit2505f9157ebf2bbdb7b1c0ff1cb7274e651ab028 (patch)
tree76e2b18a0f4bcbe24dd774991de614468db5f51b /scripts
parenta348fd1f6eee5b8f5bf159c9d95d35cc54d17699 (diff)
lib/crypto: aes: Add FIPS self-test for CMAC
Add a FIPS cryptographic algorithm self-test for AES-CMAC to fulfill the self-test requirement when this code is built into a FIPS 140 cryptographic module. This provides parity with the traditional crypto API, which uses crypto/testmgr.c to meet the FIPS self-test requirement. Reviewed-by: Ard Biesheuvel <ardb@kernel.org> Link: https://lore.kernel.org/r/20260218213501.136844-8-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/crypto/gen-fips-testvecs.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/scripts/crypto/gen-fips-testvecs.py b/scripts/crypto/gen-fips-testvecs.py
index db873f88619a..9f18bcb97412 100755
--- a/scripts/crypto/gen-fips-testvecs.py
+++ b/scripts/crypto/gen-fips-testvecs.py
@@ -3,8 +3,12 @@
#
# Script that generates lib/crypto/fips.h
#
+# Requires that python-cryptography be installed.
+#
# Copyright 2025 Google LLC
+import cryptography.hazmat.primitives.ciphers
+import cryptography.hazmat.primitives.cmac
import hashlib
import hmac
@@ -34,3 +38,9 @@ for alg in 'sha1', 'sha256', 'sha512':
print_static_u8_array_definition(f'fips_test_sha3_256_value',
hashlib.sha3_256(fips_test_data).digest())
+
+aes = cryptography.hazmat.primitives.ciphers.algorithms.AES(fips_test_key)
+aes_cmac = cryptography.hazmat.primitives.cmac.CMAC(aes)
+aes_cmac.update(fips_test_data)
+print_static_u8_array_definition('fips_test_aes_cmac_value',
+ aes_cmac.finalize())