b7397e89db
Make fips140.ko run a suite of known answer self-tests at load time to demonstrate the correct operation of cryptographic functionality, as required by FIPS 140-2/3 and NIAP FPT_TST_EXT.1.1. Bug: 153614920 Bug: 173104584 Bug: 188620248 Test: Built and loaded fips140.ko on a HiKey960, and on a Pixel device. Change-Id: I38e5c8052ff57ddfe44624beb626d38b7706b0a4 Co-developed-by: Elena Petrova <lenaptr@google.com> Signed-off-by: Elena Petrova <lenaptr@google.com> [ebiggers: Rewrote most of lenaptr@'s original patch. Added some missing tests, removed some unnecessary tests in accordance with the FIPS 140-2 IG, changed most test vectors and added a script to generate them, removed an unnecessary kconfig option, changed implementation of error injection, and many other improvements.] Signed-off-by: Eric Biggers <ebiggers@google.com> [ardb: add generation of AES-CTR test vector and the associated runtime selftest] Signed-off-by: Ard Biesheuvel <ardb@google.com>
66 lines
2.6 KiB
C
66 lines
2.6 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/* Copyright 2021 Google LLC */
|
|
|
|
/*
|
|
* This header was automatically generated by gen_fips140_testvecs.py.
|
|
* Don't edit it directly.
|
|
*/
|
|
|
|
static const u8 fips_message[32] __initconst =
|
|
"This is a 32-byte test message.";
|
|
|
|
static const u8 fips_aes_key[16] __initconst = "128-bit AES key";
|
|
|
|
static const u8 fips_aes_iv[16] __initconst = "ABCDEFGHIJKL";
|
|
|
|
static const u8 fips_aes_cbc_ciphertext[32] __initconst =
|
|
"\xc4\x6d\xad\xa4\x04\x52\x11\x5a\x7a\xb3\x7c\x68\x85\x8d\x90\xf0"
|
|
"\x55\xc3\xd3\x35\xc1\x75\x31\x90\xdf\x90\x4b\x5a\x56\xfd\xa7\x89";
|
|
|
|
static const u8 fips_aes_ecb_ciphertext[32] __initconst =
|
|
"\xc1\x9d\xe6\xb8\xb2\x90\xff\xfe\xf2\x77\x18\xb0\x55\xd3\xee\xa9"
|
|
"\xe2\x6f\x4a\x32\x67\xfd\xb7\xa5\x2f\x4b\x6e\x1a\x86\x2b\x6e\x3a";
|
|
|
|
static const u8 fips_aes_ctr_ciphertext[32] __initconst =
|
|
"\x92\xbe\x23\xa1\x80\x88\x5d\x31\x27\xb3\x9c\x40\x58\x57\x1d\xde"
|
|
"\xc1\x8d\x5b\xe7\x42\x93\x09\xf8\xd4\xf7\x49\x42\xcf\x40\x62\x7e";
|
|
|
|
static const u8 fips_aes_gcm_assoc[22] __initconst = "associated data string";
|
|
|
|
static const u8 fips_aes_gcm_ciphertext[48] __initconst =
|
|
"\x37\x88\x3e\x1d\x58\x50\xda\x10\x07\xeb\x52\xdf\xea\x0a\x54\xd4"
|
|
"\x44\xbf\x88\x2a\xf3\x03\x03\x84\xaf\x8b\x96\xbd\xea\x65\x60\x6f"
|
|
"\x82\xfa\x51\xf4\x28\xad\x0c\xf1\xce\x0f\x91\xdd\x1a\x4c\x77\x5f";
|
|
|
|
static const u8 fips_aes_xts_key[32] __initconst =
|
|
"This is an AES-128-XTS key.";
|
|
|
|
static const u8 fips_aes_xts_ciphertext[32] __initconst =
|
|
"\x5e\xb9\x98\xd6\x26\xb3\x55\xbf\x44\xab\x3e\xae\x73\xc0\x81\xc9"
|
|
"\xf4\x29\x0e\x17\x1e\xc5\xc8\x90\x79\x99\xf1\x43\x3a\x23\x08\x5a";
|
|
|
|
static const u8 fips_hmac_key[16] __initconst = "128-bit HMAC key";
|
|
|
|
static const u8 fips_sha1_digest[20] __initconst =
|
|
"\x1b\x78\xc7\x4b\xd5\xd4\x83\xb1\x58\xc5\x96\x83\x4f\x16\x8d\x15"
|
|
"\xb4\xaa\x22\x8c";
|
|
|
|
static const u8 fips_sha256_digest[32] __initconst =
|
|
"\x4e\x11\x83\x0c\x53\x80\x1e\x5f\x9b\x38\x33\x38\xe8\x74\x43\xb0"
|
|
"\xc1\x3a\xbe\xbf\x75\xf0\x12\x0f\x21\x33\xf5\x16\x33\xf1\xb0\x81";
|
|
|
|
static const u8 fips_hmac_sha256_digest[32] __initconst =
|
|
"\x63\x0e\xb5\x73\x79\xfc\xaf\x5f\x86\xe3\xaf\xf0\xc8\x36\xef\xd5"
|
|
"\x35\x8d\x40\x25\x38\xb3\x65\x72\x98\xf3\x59\xd8\x1e\x54\x4c\xa1";
|
|
|
|
static const u8 fips_sha512_digest[64] __initconst =
|
|
"\x32\xe0\x44\x23\xbd\xe3\xec\x28\xbf\xf1\x34\x11\xd5\xae\xbf\xd5"
|
|
"\xc0\x8e\xb5\xa1\x04\xef\x2f\x07\x84\xf1\xd9\x83\x0f\x6c\x31\xab"
|
|
"\xf7\xe7\x57\xfa\xf7\xae\xf0\x6f\xb2\x16\x08\x32\xcf\xc7\xef\x35"
|
|
"\xb3\x3b\x51\xb9\xfd\xe7\xff\x5e\xb2\x8b\xc6\x79\xe6\x14\x04\xb4";
|
|
|
|
/*
|
|
* This header was automatically generated by gen_fips140_testvecs.py.
|
|
* Don't edit it directly.
|
|
*/
|