david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[test] Add NIST self-tests for AES192 in ECB and CBC modes

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2015-07-25 14:54:57 +01:00
parent 09824eca31
commit 205e7de000
1 changed files with 33 additions and 1 deletions

View File

@ -50,6 +50,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
KEY ( 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, \
0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c )
/** Key used for NIST 192-bit test vectors */
#define AES_KEY_NIST_192 \
KEY ( 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, 0xc8, \
0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5, 0x62, 0xf8, \
0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b )
/** Key used for NIST 256-bit test vectors */
#define AES_KEY_NIST_256 \
KEY ( 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, 0x2b, \
@ -102,6 +108,30 @@ CIPHER_TEST ( aes_128_cbc, &aes_cbc_algorithm,
0x3f, 0xf1, 0xca, 0xa1, 0x68, 0x1f, 0xac, 0x09,
0x12, 0x0e, 0xca, 0x30, 0x75, 0x86, 0xe1, 0xa7 ) );
/** AES-192-ECB (same test as AES-192-Core) */
CIPHER_TEST ( aes_192_ecb, &aes_ecb_algorithm,
AES_KEY_NIST_192, AES_IV_NIST_DUMMY, AES_PLAINTEXT_NIST,
CIPHERTEXT ( 0xbd, 0x33, 0x4f, 0x1d, 0x6e, 0x45, 0xf2, 0x5f,
0xf7, 0x12, 0xa2, 0x14, 0x57, 0x1f, 0xa5, 0xcc,
0x97, 0x41, 0x04, 0x84, 0x6d, 0x0a, 0xd3, 0xad,
0x77, 0x34, 0xec, 0xb3, 0xec, 0xee, 0x4e, 0xef,
0xef, 0x7a, 0xfd, 0x22, 0x70, 0xe2, 0xe6, 0x0a,
0xdc, 0xe0, 0xba, 0x2f, 0xac, 0xe6, 0x44, 0x4e,
0x9a, 0x4b, 0x41, 0xba, 0x73, 0x8d, 0x6c, 0x72,
0xfb, 0x16, 0x69, 0x16, 0x03, 0xc1, 0x8e, 0x0e ) );
/** AES-192-CBC */
CIPHER_TEST ( aes_192_cbc, &aes_cbc_algorithm,
AES_KEY_NIST_192, AES_IV_NIST_CBC, AES_PLAINTEXT_NIST,
CIPHERTEXT ( 0x4f, 0x02, 0x1d, 0xb2, 0x43, 0xbc, 0x63, 0x3d,
0x71, 0x78, 0x18, 0x3a, 0x9f, 0xa0, 0x71, 0xe8,
0xb4, 0xd9, 0xad, 0xa9, 0xad, 0x7d, 0xed, 0xf4,
0xe5, 0xe7, 0x38, 0x76, 0x3f, 0x69, 0x14, 0x5a,
0x57, 0x1b, 0x24, 0x20, 0x12, 0xfb, 0x7a, 0xe0,
0x7f, 0xa9, 0xba, 0xac, 0x3d, 0xf1, 0x02, 0xe0,
0x08, 0xb0, 0xe2, 0x79, 0x88, 0x59, 0x88, 0x81,
0xd9, 0x20, 0xa9, 0xe6, 0x4f, 0x56, 0x15, 0xcd ) );
/** AES-256-ECB (same test as AES-256-Core) */
CIPHER_TEST ( aes_256_ecb, &aes_ecb_algorithm,
AES_KEY_NIST_256, AES_IV_NIST_DUMMY, AES_PLAINTEXT_NIST,
@ -138,11 +168,13 @@ static void aes_test_exec ( void ) {
/* Correctness tests */
cipher_ok ( &aes_128_ecb );
cipher_ok ( &aes_128_cbc );
cipher_ok ( &aes_192_ecb );
cipher_ok ( &aes_192_cbc );
cipher_ok ( &aes_256_ecb );
cipher_ok ( &aes_256_cbc );
/* Speed tests */
for ( keylen = 128 ; keylen <= 256 ; keylen += 128 ) {
for ( keylen = 128 ; keylen <= 256 ; keylen += 64 ) {
DBG ( "AES-%d-ECB encryption required %ld cycles per byte\n",
keylen, cipher_cost_encrypt ( ecb, ( keylen / 8 ) ) );
DBG ( "AES-%d-ECB decryption required %ld cycles per byte\n",