Browse Source

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
205e7de000
1 changed files with 33 additions and 1 deletions
  1. 33
    1
      src/tests/aes_test.c

+ 33
- 1
src/tests/aes_test.c View File

@@ -50,6 +50,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
50 50
 	KEY ( 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab,	\
51 51
 	      0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c )
52 52
 
53
+/** Key used for NIST 192-bit test vectors */
54
+#define AES_KEY_NIST_192						\
55
+	KEY ( 0x8e, 0x73, 0xb0, 0xf7, 0xda, 0x0e, 0x64, 0x52, 0xc8,	\
56
+	      0x10, 0xf3, 0x2b, 0x80, 0x90, 0x79, 0xe5, 0x62, 0xf8,	\
57
+	      0xea, 0xd2, 0x52, 0x2c, 0x6b, 0x7b )
58
+
53 59
 /** Key used for NIST 256-bit test vectors */
54 60
 #define AES_KEY_NIST_256						\
55 61
 	KEY ( 0x60, 0x3d, 0xeb, 0x10, 0x15, 0xca, 0x71, 0xbe, 0x2b,	\
@@ -102,6 +108,30 @@ CIPHER_TEST ( aes_128_cbc, &aes_cbc_algorithm,
102 108
 		     0x3f, 0xf1, 0xca, 0xa1, 0x68, 0x1f, 0xac, 0x09,
103 109
 		     0x12, 0x0e, 0xca, 0x30, 0x75, 0x86, 0xe1, 0xa7 ) );
104 110
 
111
+/** AES-192-ECB (same test as AES-192-Core) */
112
+CIPHER_TEST ( aes_192_ecb, &aes_ecb_algorithm,
113
+	AES_KEY_NIST_192, AES_IV_NIST_DUMMY, AES_PLAINTEXT_NIST,
114
+	CIPHERTEXT ( 0xbd, 0x33, 0x4f, 0x1d, 0x6e, 0x45, 0xf2, 0x5f,
115
+		     0xf7, 0x12, 0xa2, 0x14, 0x57, 0x1f, 0xa5, 0xcc,
116
+		     0x97, 0x41, 0x04, 0x84, 0x6d, 0x0a, 0xd3, 0xad,
117
+		     0x77, 0x34, 0xec, 0xb3, 0xec, 0xee, 0x4e, 0xef,
118
+		     0xef, 0x7a, 0xfd, 0x22, 0x70, 0xe2, 0xe6, 0x0a,
119
+		     0xdc, 0xe0, 0xba, 0x2f, 0xac, 0xe6, 0x44, 0x4e,
120
+		     0x9a, 0x4b, 0x41, 0xba, 0x73, 0x8d, 0x6c, 0x72,
121
+		     0xfb, 0x16, 0x69, 0x16, 0x03, 0xc1, 0x8e, 0x0e ) );
122
+
123
+/** AES-192-CBC */
124
+CIPHER_TEST ( aes_192_cbc, &aes_cbc_algorithm,
125
+	AES_KEY_NIST_192, AES_IV_NIST_CBC, AES_PLAINTEXT_NIST,
126
+	CIPHERTEXT ( 0x4f, 0x02, 0x1d, 0xb2, 0x43, 0xbc, 0x63, 0x3d,
127
+		     0x71, 0x78, 0x18, 0x3a, 0x9f, 0xa0, 0x71, 0xe8,
128
+		     0xb4, 0xd9, 0xad, 0xa9, 0xad, 0x7d, 0xed, 0xf4,
129
+		     0xe5, 0xe7, 0x38, 0x76, 0x3f, 0x69, 0x14, 0x5a,
130
+		     0x57, 0x1b, 0x24, 0x20, 0x12, 0xfb, 0x7a, 0xe0,
131
+		     0x7f, 0xa9, 0xba, 0xac, 0x3d, 0xf1, 0x02, 0xe0,
132
+		     0x08, 0xb0, 0xe2, 0x79, 0x88, 0x59, 0x88, 0x81,
133
+		     0xd9, 0x20, 0xa9, 0xe6, 0x4f, 0x56, 0x15, 0xcd ) );
134
+
105 135
 /** AES-256-ECB (same test as AES-256-Core) */
106 136
 CIPHER_TEST ( aes_256_ecb, &aes_ecb_algorithm,
107 137
 	AES_KEY_NIST_256, AES_IV_NIST_DUMMY, AES_PLAINTEXT_NIST,
@@ -138,11 +168,13 @@ static void aes_test_exec ( void ) {
138 168
 	/* Correctness tests */
139 169
 	cipher_ok ( &aes_128_ecb );
140 170
 	cipher_ok ( &aes_128_cbc );
171
+	cipher_ok ( &aes_192_ecb );
172
+	cipher_ok ( &aes_192_cbc );
141 173
 	cipher_ok ( &aes_256_ecb );
142 174
 	cipher_ok ( &aes_256_cbc );
143 175
 
144 176
 	/* Speed tests */
145
-	for ( keylen = 128 ; keylen <= 256 ; keylen += 128 ) {
177
+	for ( keylen = 128 ; keylen <= 256 ; keylen += 64 ) {
146 178
 		DBG ( "AES-%d-ECB encryption required %ld cycles per byte\n",
147 179
 		      keylen, cipher_cost_encrypt ( ecb, ( keylen / 8 ) ) );
148 180
 		DBG ( "AES-%d-ECB decryption required %ld cycles per byte\n",

Loading…
Cancel
Save