|
@@ -35,6 +35,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
35
|
35
|
#include <assert.h>
|
36
|
36
|
#include <string.h>
|
37
|
37
|
#include <ipxe/hmac_drbg.h>
|
|
38
|
+#include <ipxe/sha1.h>
|
38
|
39
|
#include <ipxe/test.h>
|
39
|
40
|
|
40
|
41
|
/** Define inline expected data */
|
|
@@ -42,10 +43,18 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
42
|
43
|
|
43
|
44
|
/** An HMAC_DRBG instantiation test */
|
44
|
45
|
struct hmac_drbg_test_instantiate {
|
45
|
|
- /** Entropy (including nonce) */
|
|
46
|
+ /** Underlying hash algorithm */
|
|
47
|
+ struct digest_algorithm *hash;
|
|
48
|
+ /** Output block length */
|
|
49
|
+ size_t out_len;
|
|
50
|
+ /** Entropy */
|
46
|
51
|
const void *entropy;
|
47
|
|
- /** Length of entropy (including nonce) */
|
|
52
|
+ /** Length of entropy */
|
48
|
53
|
size_t entropy_len;
|
|
54
|
+ /** Nonce */
|
|
55
|
+ const void *nonce;
|
|
56
|
+ /** Length of nonce */
|
|
57
|
+ size_t nonce_len;
|
49
|
58
|
/** Personalisation string */
|
50
|
59
|
const void *personal;
|
51
|
60
|
/** Length of personalisation string */
|
|
@@ -64,19 +73,26 @@ struct hmac_drbg_test_instantiate {
|
64
|
73
|
* Define an HMAC_DRBG instantiation test
|
65
|
74
|
*
|
66
|
75
|
* @v name Test name
|
67
|
|
- * @v entropy_array Entropy input (including nonce)
|
|
76
|
+ * @v hmac_drbg HMAC_DRBG algorithm
|
|
77
|
+ * @v entropy_array Entropy input
|
|
78
|
+ * @v nonce_array Nonce
|
68
|
79
|
* @v personal_array Personalisation string
|
69
|
80
|
* @v key Expected key
|
70
|
81
|
* @v value Expected value
|
71
|
82
|
* @ret test Instantiation test
|
72
|
83
|
*/
|
73
|
|
-#define HMAC_DRBG_TEST_INSTANTIATE( name, entropy_array, \
|
74
|
|
- personal_array, key, value ) \
|
|
84
|
+#define HMAC_DRBG_TEST_INSTANTIATE( name, hmac_drbg, entropy_array, \
|
|
85
|
+ nonce_array, personal_array, \
|
|
86
|
+ key, value ) \
|
75
|
87
|
static const uint8_t name ## _key [] = key; \
|
76
|
88
|
static const uint8_t name ## _value [] = value; \
|
77
|
89
|
static const struct hmac_drbg_test_instantiate name = { \
|
|
90
|
+ .hash = HMAC_DRBG_HASH ( hmac_drbg ), \
|
|
91
|
+ .out_len = HMAC_DRBG_OUTLEN_BYTES ( hmac_drbg ), \
|
78
|
92
|
.entropy = entropy_array, \
|
79
|
93
|
.entropy_len = sizeof ( entropy_array ), \
|
|
94
|
+ .nonce = nonce_array, \
|
|
95
|
+ .nonce_len = sizeof ( nonce_array ), \
|
80
|
96
|
.personal = personal_array, \
|
81
|
97
|
.personal_len = sizeof ( personal_array ), \
|
82
|
98
|
.expected_key = name ## _key, \
|
|
@@ -92,19 +108,33 @@ struct hmac_drbg_test_instantiate {
|
92
|
108
|
* @v test Instantiation test
|
93
|
109
|
*/
|
94
|
110
|
#define instantiate_ok( state, test ) do { \
|
95
|
|
- assert ( (test)->expected_key_len == HMAC_DRBG_OUTLEN_BYTES ); \
|
96
|
|
- assert ( (test)->expected_value_len == HMAC_DRBG_OUTLEN_BYTES ); \
|
97
|
|
- hmac_drbg_instantiate ( (state), (test)->entropy, \
|
98
|
|
- (test)->entropy_len, (test)->personal, \
|
|
111
|
+ struct { \
|
|
112
|
+ uint8_t entropy[(test)->entropy_len]; \
|
|
113
|
+ uint8_t nonce[(test)->nonce_len]; \
|
|
114
|
+ } __attribute__ (( packed )) entropy_nonce; \
|
|
115
|
+ \
|
|
116
|
+ assert ( (test)->expected_key_len == (test)->out_len ); \
|
|
117
|
+ assert ( (test)->expected_value_len == (test)->out_len ); \
|
|
118
|
+ memcpy ( entropy_nonce.entropy, (test)->entropy, \
|
|
119
|
+ sizeof ( entropy_nonce.entropy ) ); \
|
|
120
|
+ memcpy ( entropy_nonce.nonce, (test)->nonce, \
|
|
121
|
+ sizeof ( entropy_nonce.nonce ) ); \
|
|
122
|
+ hmac_drbg_instantiate ( (test)->hash, (state), &entropy_nonce, \
|
|
123
|
+ sizeof ( entropy_nonce ), \
|
|
124
|
+ (test)->personal, \
|
99
|
125
|
(test)->personal_len ); \
|
100
|
126
|
ok ( memcmp ( (state)->key, (test)->expected_key, \
|
101
|
|
- sizeof ( (state)->key ) ) == 0 ); \
|
|
127
|
+ (test)->expected_key_len ) == 0 ); \
|
102
|
128
|
ok ( memcmp ( (state)->value, (test)->expected_value, \
|
103
|
|
- sizeof ( (state)->value ) ) == 0 ); \
|
|
129
|
+ (test)->expected_value_len ) == 0 ); \
|
104
|
130
|
} while ( 0 )
|
105
|
131
|
|
106
|
132
|
/** An HMAC_DRBG reseed test */
|
107
|
133
|
struct hmac_drbg_test_reseed {
|
|
134
|
+ /** Underlying hash algorithm */
|
|
135
|
+ struct digest_algorithm *hash;
|
|
136
|
+ /** Output block length */
|
|
137
|
+ size_t out_len;
|
108
|
138
|
/** Entropy */
|
109
|
139
|
const void *entropy;
|
110
|
140
|
/** Length of entropy */
|
|
@@ -127,17 +157,20 @@ struct hmac_drbg_test_reseed {
|
127
|
157
|
* Define an HMAC_DRBG reseed test
|
128
|
158
|
*
|
129
|
159
|
* @v name Test name
|
|
160
|
+ * @v hmac_drbg HMAC_DRBG algorithm
|
130
|
161
|
* @v entropy_array Entropy input
|
131
|
162
|
* @v additional_array Additional input
|
132
|
163
|
* @v key Expected key
|
133
|
164
|
* @v value Expected value
|
134
|
165
|
* @ret test Reseed test
|
135
|
166
|
*/
|
136
|
|
-#define HMAC_DRBG_TEST_RESEED( name, entropy_array, additional_array, \
|
137
|
|
- key, value ) \
|
|
167
|
+#define HMAC_DRBG_TEST_RESEED( name, hmac_drbg, entropy_array, \
|
|
168
|
+ additional_array, key, value ) \
|
138
|
169
|
static const uint8_t name ## _key [] = key; \
|
139
|
170
|
static const uint8_t name ## _value [] = value; \
|
140
|
171
|
static const struct hmac_drbg_test_reseed name = { \
|
|
172
|
+ .hash = HMAC_DRBG_HASH ( hmac_drbg ), \
|
|
173
|
+ .out_len = HMAC_DRBG_OUTLEN_BYTES ( hmac_drbg ), \
|
141
|
174
|
.entropy = entropy_array, \
|
142
|
175
|
.entropy_len = sizeof ( entropy_array ), \
|
143
|
176
|
.additional = additional_array, \
|
|
@@ -155,19 +188,23 @@ struct hmac_drbg_test_reseed {
|
155
|
188
|
* @v test Reseed test
|
156
|
189
|
*/
|
157
|
190
|
#define reseed_ok( state, test ) do { \
|
158
|
|
- assert ( (test)->expected_key_len == HMAC_DRBG_OUTLEN_BYTES ); \
|
159
|
|
- assert ( (test)->expected_value_len == HMAC_DRBG_OUTLEN_BYTES ); \
|
160
|
|
- hmac_drbg_reseed ( (state), (test)->entropy, \
|
|
191
|
+ assert ( (test)->expected_key_len == (test)->out_len ); \
|
|
192
|
+ assert ( (test)->expected_value_len == (test)->out_len ); \
|
|
193
|
+ hmac_drbg_reseed ( (test)->hash, (state), (test)->entropy, \
|
161
|
194
|
(test)->entropy_len, (test)->additional, \
|
162
|
195
|
(test)->additional_len ); \
|
163
|
196
|
ok ( memcmp ( (state)->key, (test)->expected_key, \
|
164
|
|
- sizeof ( (state)->key ) ) == 0 ); \
|
|
197
|
+ (test)->expected_key_len ) == 0 ); \
|
165
|
198
|
ok ( memcmp ( (state)->value, (test)->expected_value, \
|
166
|
|
- sizeof ( (state)->value ) ) == 0 ); \
|
|
199
|
+ (test)->expected_value_len ) == 0 ); \
|
167
|
200
|
} while ( 0 )
|
168
|
201
|
|
169
|
202
|
/** An HMAC_DRBG generation test */
|
170
|
203
|
struct hmac_drbg_test_generate {
|
|
204
|
+ /** Underlying hash algorithm */
|
|
205
|
+ struct digest_algorithm *hash;
|
|
206
|
+ /** Output block length */
|
|
207
|
+ size_t out_len;
|
171
|
208
|
/** Additional input */
|
172
|
209
|
const void *additional;
|
173
|
210
|
/** Length of additional_input */
|
|
@@ -183,25 +220,28 @@ struct hmac_drbg_test_generate {
|
183
|
220
|
/** Expected pseudorandom data */
|
184
|
221
|
const void *expected_data;
|
185
|
222
|
/** Length of data */
|
186
|
|
- size_t len;
|
|
223
|
+ size_t expected_data_len;
|
187
|
224
|
};
|
188
|
225
|
|
189
|
226
|
/**
|
190
|
227
|
* Define an HMAC_DRBG generation test
|
191
|
228
|
*
|
192
|
229
|
* @v name Test name
|
|
230
|
+ * @v hmac_drbg HMAC_DRBG algorithm
|
193
|
231
|
* @v additional_array Additional input
|
194
|
232
|
* @v key Expected key
|
195
|
233
|
* @v value Expected value
|
196
|
234
|
* @v data Expected pseudorandom data
|
197
|
235
|
* @ret test Generation test
|
198
|
236
|
*/
|
199
|
|
-#define HMAC_DRBG_TEST_GENERATE( name, additional_array, key, value, \
|
200
|
|
- data ) \
|
|
237
|
+#define HMAC_DRBG_TEST_GENERATE( name, hmac_drbg, additional_array, \
|
|
238
|
+ key, value, data ) \
|
201
|
239
|
static const uint8_t name ## _key [] = key; \
|
202
|
240
|
static const uint8_t name ## _value [] = value; \
|
203
|
241
|
static const uint8_t name ## _data [] = data; \
|
204
|
242
|
static const struct hmac_drbg_test_generate name = { \
|
|
243
|
+ .hash = HMAC_DRBG_HASH ( hmac_drbg ), \
|
|
244
|
+ .out_len = HMAC_DRBG_OUTLEN_BYTES ( hmac_drbg ), \
|
205
|
245
|
.additional = additional_array, \
|
206
|
246
|
.additional_len = sizeof ( additional_array ), \
|
207
|
247
|
.expected_key = name ## _key, \
|
|
@@ -209,7 +249,7 @@ struct hmac_drbg_test_generate {
|
209
|
249
|
.expected_value = name ## _value, \
|
210
|
250
|
.expected_value_len = sizeof ( name ## _value ), \
|
211
|
251
|
.expected_data = name ## _data, \
|
212
|
|
- .len = sizeof ( name ## _data ), \
|
|
252
|
+ .expected_data_len = sizeof ( name ## _data ), \
|
213
|
253
|
}
|
214
|
254
|
|
215
|
255
|
/**
|
|
@@ -219,25 +259,28 @@ struct hmac_drbg_test_generate {
|
219
|
259
|
* @v test Generation test
|
220
|
260
|
*/
|
221
|
261
|
#define generate_ok( state, test ) do { \
|
222
|
|
- uint8_t data[ (test)->len ]; \
|
|
262
|
+ uint8_t data[ (test)->expected_data_len ]; \
|
223
|
263
|
int rc; \
|
224
|
264
|
\
|
225
|
|
- assert ( (test)->expected_key_len == HMAC_DRBG_OUTLEN_BYTES ); \
|
226
|
|
- assert ( (test)->expected_value_len == HMAC_DRBG_OUTLEN_BYTES );\
|
227
|
|
- rc = hmac_drbg_generate ( (state), (test)->additional, \
|
228
|
|
- (test)->additional_len, data, \
|
229
|
|
- sizeof ( data ) ); \
|
|
265
|
+ assert ( (test)->expected_key_len == (test)->out_len ); \
|
|
266
|
+ assert ( (test)->expected_value_len == (test)->out_len ); \
|
|
267
|
+ rc = hmac_drbg_generate ( (test)->hash, (state), \
|
|
268
|
+ (test)->additional, \
|
|
269
|
+ (test)->additional_len, \
|
|
270
|
+ data, sizeof ( data ) ); \
|
230
|
271
|
ok ( rc == 0 ); \
|
231
|
272
|
ok ( memcmp ( (state)->key, (test)->expected_key, \
|
232
|
|
- sizeof ( (state)->key ) ) == 0 ); \
|
|
273
|
+ (test)->expected_key_len ) == 0 ); \
|
233
|
274
|
ok ( memcmp ( (state)->value, (test)->expected_value, \
|
234
|
|
- sizeof ( (state)->value ) ) == 0 ); \
|
|
275
|
+ (test)->expected_value_len ) == 0 ); \
|
235
|
276
|
ok ( memcmp ( data, (test)->expected_data, \
|
236
|
|
- sizeof ( data ) ) == 0 ); \
|
|
277
|
+ (test)->expected_data_len ) == 0 ); \
|
237
|
278
|
} while ( 0 )
|
238
|
279
|
|
239
|
280
|
/** An HMAC_DRBG generation failure test */
|
240
|
281
|
struct hmac_drbg_test_generate_fail {
|
|
282
|
+ /** Underlying hash algorithm */
|
|
283
|
+ struct digest_algorithm *hash;
|
241
|
284
|
/** Additional input */
|
242
|
285
|
const void *additional;
|
243
|
286
|
/** Length of additional_input */
|
|
@@ -250,11 +293,14 @@ struct hmac_drbg_test_generate_fail {
|
250
|
293
|
* Define an HMAC_DRBG generation failure test
|
251
|
294
|
*
|
252
|
295
|
* @v name Test name
|
|
296
|
+ * @v hmac_drbg HMAC_DRBG algorithm
|
253
|
297
|
* @v additional_array Additional input
|
254
|
298
|
* @ret test Generation failure test
|
255
|
299
|
*/
|
256
|
|
-#define HMAC_DRBG_TEST_GENERATE_FAIL( name, additional_array, len ) \
|
|
300
|
+#define HMAC_DRBG_TEST_GENERATE_FAIL( name, hmac_drbg, \
|
|
301
|
+ additional_array, len ) \
|
257
|
302
|
static const struct hmac_drbg_test_generate_fail name = { \
|
|
303
|
+ .hash = HMAC_DRBG_HASH ( hmac_drbg ), \
|
258
|
304
|
.additional = additional_array, \
|
259
|
305
|
.additional_len = sizeof ( additional_array ), \
|
260
|
306
|
.requested_len = len, \
|
|
@@ -270,25 +316,24 @@ struct hmac_drbg_test_generate_fail {
|
270
|
316
|
uint8_t data[ (test)->requested_len ]; \
|
271
|
317
|
int rc; \
|
272
|
318
|
\
|
273
|
|
- rc = hmac_drbg_generate ( (state), (test)->additional, \
|
|
319
|
+ rc = hmac_drbg_generate ( (test)->hash, (state), \
|
|
320
|
+ (test)->additional, \
|
274
|
321
|
(test)->additional_len, data, \
|
275
|
322
|
sizeof ( data ) ); \
|
276
|
323
|
ok ( rc != 0 ); \
|
277
|
324
|
} while ( 0 )
|
278
|
325
|
|
279
|
|
-/** "EntropyInput" and "Nonce"
|
280
|
|
- *
|
281
|
|
- * These are pre-concatenated since our implementation expects to
|
282
|
|
- * receive the nonce in the form of additional entropy.
|
283
|
|
- */
|
|
326
|
+/** "EntropyInput" */
|
284
|
327
|
static const uint8_t entropy_input[] = {
|
285
|
|
- /* "EntropyInput" */
|
286
|
328
|
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
|
287
|
329
|
0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
|
288
|
330
|
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
|
289
|
331
|
0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
|
290
|
|
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,
|
291
|
|
- /* "Nonce" */
|
|
332
|
+ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36
|
|
333
|
+};
|
|
334
|
+
|
|
335
|
+/** "Nonce" for SHA-1 */
|
|
336
|
+static const uint8_t nonce_sha1[] = {
|
292
|
337
|
0x20, 0x21, 0x22, 0x23, 0x24
|
293
|
338
|
};
|
294
|
339
|
|
|
@@ -343,16 +388,16 @@ static const uint8_t additional_input_2[] = {
|
343
|
388
|
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6
|
344
|
389
|
};
|
345
|
390
|
|
346
|
|
-/** Test 1 : Instantiation */
|
347
|
|
-HMAC_DRBG_TEST_INSTANTIATE ( instantiate_1,
|
348
|
|
- entropy_input, personalisation_string_empty,
|
|
391
|
+/** SHA-1 Test 1 : Instantiation */
|
|
392
|
+HMAC_DRBG_TEST_INSTANTIATE ( sha1_instantiate_1, HMAC_DRBG_SHA1,
|
|
393
|
+ entropy_input, nonce_sha1, personalisation_string_empty,
|
349
|
394
|
EXPECT ( 0xab, 0x16, 0x0d, 0xd2, 0x1c, 0x30, 0x98, 0x0c, 0xa3, 0xca,
|
350
|
395
|
0x5a, 0x9c, 0x77, 0xb7, 0xbd, 0xf0, 0x50, 0xe6, 0x4e, 0xe9 ),
|
351
|
396
|
EXPECT ( 0x61, 0x44, 0x99, 0xea, 0x98, 0x0c, 0xfb, 0x3d, 0xaa, 0x2c,
|
352
|
397
|
0xa8, 0x6d, 0x65, 0xa4, 0x6b, 0xf4, 0x48, 0x8d, 0x8c, 0xc5 ) );
|
353
|
398
|
|
354
|
|
-/** Test 1.1 : First call to Generate */
|
355
|
|
-HMAC_DRBG_TEST_GENERATE ( generate_1_1,
|
|
399
|
+/** SHA-1 Test 1.1 : First call to Generate */
|
|
400
|
+HMAC_DRBG_TEST_GENERATE ( sha1_generate_1_1, HMAC_DRBG_SHA1,
|
356
|
401
|
additional_input_empty,
|
357
|
402
|
EXPECT ( 0x7b, 0xb1, 0x80, 0x28, 0xe0, 0x1d, 0x03, 0x42, 0xdf, 0x4f,
|
358
|
403
|
0x54, 0xda, 0x51, 0x22, 0xfa, 0x5f, 0x2c, 0x3a, 0x05, 0xe4 ),
|
|
@@ -363,8 +408,8 @@ HMAC_DRBG_TEST_GENERATE ( generate_1_1,
|
363
|
408
|
0x8c, 0x0b, 0x22, 0xcd, 0x06, 0x30, 0xbf, 0xb0, 0x12, 0x7f,
|
364
|
409
|
0xb5, 0x40, 0x8c, 0x8e, 0xfc, 0x17, 0xa9, 0x29, 0x89, 0x6e ) );
|
365
|
410
|
|
366
|
|
-/** Test 1.2 : Second call to Generate */
|
367
|
|
-HMAC_DRBG_TEST_GENERATE ( generate_1_2,
|
|
411
|
+/** SHA-1 Test 1.2 : Second call to Generate */
|
|
412
|
+HMAC_DRBG_TEST_GENERATE ( sha1_generate_1_2, HMAC_DRBG_SHA1,
|
368
|
413
|
additional_input_empty,
|
369
|
414
|
EXPECT ( 0x3d, 0x4d, 0x73, 0x77, 0xe9, 0x17, 0x2a, 0xaf, 0xa7, 0x76,
|
370
|
415
|
0xb0, 0xdd, 0xcb, 0x89, 0x42, 0x00, 0x4a, 0x44, 0xb7, 0xfd ),
|
|
@@ -375,11 +420,11 @@ HMAC_DRBG_TEST_GENERATE ( generate_1_2,
|
375
|
420
|
0x9c, 0xe3, 0x67, 0xd0, 0x3a, 0xea, 0xde, 0x37, 0x82, 0x7f,
|
376
|
421
|
0xa8, 0xe9, 0xcb, 0x6a, 0x08, 0x19, 0x61, 0x15, 0xd9, 0x48 ) );
|
377
|
422
|
|
378
|
|
-/** Test 2 : Instantiation */
|
379
|
|
-#define instantiate_2 instantiate_1
|
|
423
|
+/** SHA-1 Test 2 : Instantiation */
|
|
424
|
+#define sha1_instantiate_2 sha1_instantiate_1
|
380
|
425
|
|
381
|
|
-/** Test 2.1 : First call to Generate */
|
382
|
|
-HMAC_DRBG_TEST_GENERATE ( generate_2_1,
|
|
426
|
+/** SHA-1 Test 2.1 : First call to Generate */
|
|
427
|
+HMAC_DRBG_TEST_GENERATE ( sha1_generate_2_1, HMAC_DRBG_SHA1,
|
383
|
428
|
additional_input_1,
|
384
|
429
|
EXPECT ( 0x3a, 0x06, 0x2e, 0x6b, 0x79, 0xfe, 0x70, 0xdb, 0xff, 0xeb,
|
385
|
430
|
0x3a, 0x2b, 0x6b, 0xe8, 0x03, 0x23, 0xf7, 0xd6, 0x74, 0xc5 ),
|
|
@@ -390,8 +435,8 @@ HMAC_DRBG_TEST_GENERATE ( generate_2_1,
|
390
|
435
|
0x9a, 0xd0, 0xbb, 0x26, 0xfa, 0xc0, 0x49, 0x7b, 0x5c, 0x57,
|
391
|
436
|
0xe1, 0x61, 0xe3, 0x66, 0x81, 0xbc, 0xc9, 0x30, 0xce, 0x80 ) );
|
392
|
437
|
|
393
|
|
-/** Test 2.2 : Second call to Generate */
|
394
|
|
-HMAC_DRBG_TEST_GENERATE ( generate_2_2,
|
|
438
|
+/** SHA-1 Test 2.2 : Second call to Generate */
|
|
439
|
+HMAC_DRBG_TEST_GENERATE ( sha1_generate_2_2, HMAC_DRBG_SHA1,
|
395
|
440
|
additional_input_2,
|
396
|
441
|
EXPECT ( 0x8a, 0xd7, 0xe3, 0x47, 0x72, 0xb5, 0xfc, 0x7c, 0x3b, 0x3b,
|
397
|
442
|
0x27, 0x62, 0x4f, 0x0b, 0x91, 0x77, 0x6a, 0x8a, 0x71, 0x12 ),
|
|
@@ -402,16 +447,16 @@ HMAC_DRBG_TEST_GENERATE ( generate_2_2,
|
402
|
447
|
0xb9, 0xc3, 0x7b, 0x7f, 0xe8, 0x1b, 0xa9, 0x40, 0x45, 0xa1,
|
403
|
448
|
0x4a, 0x7c, 0xb5, 0x14, 0xb4, 0x46, 0x66, 0x6e, 0xa5, 0xa7 ) );
|
404
|
449
|
|
405
|
|
-/** Test 3 : Instantiation */
|
406
|
|
-HMAC_DRBG_TEST_INSTANTIATE ( instantiate_3,
|
407
|
|
- entropy_input, personalisation_string,
|
|
450
|
+/** SHA-1 Test 3 : Instantiation */
|
|
451
|
+HMAC_DRBG_TEST_INSTANTIATE ( sha1_instantiate_3, HMAC_DRBG_SHA1,
|
|
452
|
+ entropy_input, nonce_sha1, personalisation_string,
|
408
|
453
|
EXPECT ( 0xb7, 0xd9, 0x66, 0xd7, 0x0d, 0x4e, 0x27, 0xa7, 0xfa, 0x83,
|
409
|
454
|
0x8f, 0x7d, 0x61, 0x12, 0x6c, 0x0e, 0xdc, 0x84, 0x76, 0x1c ),
|
410
|
455
|
EXPECT ( 0xda, 0xb2, 0xa7, 0x18, 0x83, 0xf1, 0x00, 0x5c, 0x5d, 0xd0,
|
411
|
456
|
0x39, 0x32, 0x4d, 0x3c, 0x36, 0x4d, 0x6e, 0x18, 0xf9, 0x54 ) );
|
412
|
457
|
|
413
|
|
-/** Test 3.1 : First call to Generate */
|
414
|
|
-HMAC_DRBG_TEST_GENERATE ( generate_3_1,
|
|
458
|
+/** SHA-1 Test 3.1 : First call to Generate */
|
|
459
|
+HMAC_DRBG_TEST_GENERATE ( sha1_generate_3_1, HMAC_DRBG_SHA1,
|
415
|
460
|
additional_input_empty,
|
416
|
461
|
EXPECT ( 0x87, 0xd3, 0x82, 0x8b, 0xe0, 0x3a, 0x80, 0x7d, 0xd3, 0x40,
|
417
|
462
|
0x29, 0x41, 0xbe, 0xd6, 0xde, 0x98, 0x6e, 0xe7, 0xa2, 0x86 ),
|
|
@@ -422,8 +467,8 @@ HMAC_DRBG_TEST_GENERATE ( generate_3_1,
|
422
|
467
|
0x9b, 0xd0, 0x60, 0x20, 0x8e, 0xea, 0x7d, 0x71, 0xf9, 0xd1,
|
423
|
468
|
0x23, 0xdf, 0x47, 0xb3, 0xce, 0x06, 0x9d, 0x98, 0xed, 0xe6 ) );
|
424
|
469
|
|
425
|
|
-/** Test 3.2 : Second call to Generate */
|
426
|
|
-HMAC_DRBG_TEST_GENERATE ( generate_3_2,
|
|
470
|
+/** SHA-1 Test 3.2 : Second call to Generate */
|
|
471
|
+HMAC_DRBG_TEST_GENERATE ( sha1_generate_3_2, HMAC_DRBG_SHA1,
|
427
|
472
|
additional_input_empty,
|
428
|
473
|
EXPECT ( 0x26, 0xab, 0xbf, 0x54, 0xb2, 0x8b, 0x93, 0xff, 0x90, 0x08,
|
429
|
474
|
0x67, 0x0e, 0xbf, 0xee, 0x86, 0xcd, 0xd7, 0x22, 0x8e, 0xd5 ),
|
|
@@ -434,11 +479,11 @@ HMAC_DRBG_TEST_GENERATE ( generate_3_2,
|
434
|
479
|
0x63, 0x97, 0x65, 0x47, 0x2b, 0x71, 0xac, 0xeb, 0xe2, 0xea,
|
435
|
480
|
0x8b, 0x1b, 0x6b, 0x49, 0x62, 0x9c, 0xb6, 0x73, 0x17, 0xe0 ) );
|
436
|
481
|
|
437
|
|
-/** Test 4 : Instantiation */
|
438
|
|
-#define instantiate_4 instantiate_3
|
|
482
|
+/** SHA-1 Test 4 : Instantiation */
|
|
483
|
+#define sha1_instantiate_4 sha1_instantiate_3
|
439
|
484
|
|
440
|
|
-/** Test 4.1 : First call to Generate */
|
441
|
|
-HMAC_DRBG_TEST_GENERATE ( generate_4_1,
|
|
485
|
+/** SHA-1 Test 4.1 : First call to Generate */
|
|
486
|
+HMAC_DRBG_TEST_GENERATE ( sha1_generate_4_1, HMAC_DRBG_SHA1,
|
442
|
487
|
additional_input_1,
|
443
|
488
|
EXPECT ( 0x17, 0xa5, 0xd7, 0x9f, 0x07, 0x67, 0x87, 0x6f, 0x3a, 0x45,
|
444
|
489
|
0xe0, 0xc9, 0xc3, 0x3e, 0xc8, 0x8b, 0x03, 0xce, 0xea, 0x13 ),
|
|
@@ -449,8 +494,8 @@ HMAC_DRBG_TEST_GENERATE ( generate_4_1,
|
449
|
494
|
0x6d, 0xfc, 0x30, 0x2e, 0xad, 0x4c, 0xe3, 0xf5, 0x54, 0xc7,
|
450
|
495
|
0x9b, 0x0d, 0x44, 0x23, 0x9e, 0xba, 0x56, 0xa7, 0xea, 0x2d ) );
|
451
|
496
|
|
452
|
|
-/** Test 4.2 : Second call to Generate */
|
453
|
|
-HMAC_DRBG_TEST_GENERATE ( generate_4_2,
|
|
497
|
+/** SHA-1 Test 4.2 : Second call to Generate */
|
|
498
|
+HMAC_DRBG_TEST_GENERATE ( sha1_generate_4_2, HMAC_DRBG_SHA1,
|
454
|
499
|
additional_input_2,
|
455
|
500
|
EXPECT ( 0x07, 0x9b, 0x57, 0xd9, 0x40, 0x6e, 0x11, 0xc2, 0xf8, 0x7c,
|
456
|
501
|
0x8c, 0x82, 0x8c, 0x8c, 0x6f, 0xa7, 0x6e, 0x40, 0xea, 0x01 ),
|
|
@@ -461,23 +506,23 @@ HMAC_DRBG_TEST_GENERATE ( generate_4_2,
|
461
|
506
|
0xdc, 0x91, 0x21, 0x5d, 0x44, 0xb1, 0x07, 0xb4, 0xd5, 0xa7,
|
462
|
507
|
0x79, 0x01, 0x59, 0x25, 0x09, 0x76, 0x52, 0x80, 0xf9, 0x69 ) );
|
463
|
508
|
|
464
|
|
-/** Test 5 : Instantiation */
|
465
|
|
-#define instantiate_5 instantiate_1
|
|
509
|
+/** SHA-1 Test 5 : Instantiation */
|
|
510
|
+#define sha1_instantiate_5 sha1_instantiate_1
|
466
|
511
|
|
467
|
|
-/** Test 5.1 : First call to Generate */
|
468
|
|
-HMAC_DRBG_TEST_GENERATE_FAIL ( generate_fail_5_1,
|
|
512
|
+/** SHA-1 Test 5.1 : First call to Generate */
|
|
513
|
+HMAC_DRBG_TEST_GENERATE_FAIL ( sha1_generate_fail_5_1, HMAC_DRBG_SHA1,
|
469
|
514
|
additional_input_empty, ( 320 / 8 ) );
|
470
|
515
|
|
471
|
|
-/** Test 5.2 : Reseed */
|
472
|
|
-HMAC_DRBG_TEST_RESEED ( reseed_5_2,
|
|
516
|
+/** SHA-1 Test 5.2 : Reseed */
|
|
517
|
+HMAC_DRBG_TEST_RESEED ( sha1_reseed_5_2, HMAC_DRBG_SHA1,
|
473
|
518
|
entropy_input_1, additional_input_empty,
|
474
|
519
|
EXPECT ( 0xcd, 0x4c, 0xab, 0x38, 0xc8, 0xad, 0x65, 0x71, 0x22, 0xbf,
|
475
|
520
|
0x5d, 0x3d, 0x00, 0xd0, 0xac, 0x9b, 0x13, 0xd6, 0x29, 0xbb ),
|
476
|
521
|
EXPECT ( 0xf6, 0x60, 0xe2, 0x3e, 0x91, 0x00, 0x6b, 0x62, 0xc6, 0x54,
|
477
|
522
|
0x3a, 0xb1, 0x34, 0x4d, 0x23, 0xa3, 0x1a, 0xb4, 0xcf, 0x2c ) );
|
478
|
523
|
|
479
|
|
-/** Test 5.3 : Retried first call to Generate */
|
480
|
|
-HMAC_DRBG_TEST_GENERATE ( generate_5_3,
|
|
524
|
+/** SHA-1 Test 5.3 : Retried first call to Generate */
|
|
525
|
+HMAC_DRBG_TEST_GENERATE ( sha1_generate_5_3, HMAC_DRBG_SHA1,
|
481
|
526
|
additional_input_empty,
|
482
|
527
|
EXPECT ( 0x58, 0x7f, 0xd8, 0x21, 0xef, 0x6c, 0x9d, 0xa4, 0xa8, 0x3c,
|
483
|
528
|
0x19, 0x21, 0x1f, 0x10, 0x56, 0xca, 0xcd, 0x23, 0xfc, 0x1a ),
|
|
@@ -488,20 +533,20 @@ HMAC_DRBG_TEST_GENERATE ( generate_5_3,
|
488
|
533
|
0xbc, 0x0e, 0xfc, 0x28, 0x2a, 0xbd, 0x87, 0x60, 0x5c, 0xc9,
|
489
|
534
|
0x0c, 0xba, 0x9b, 0x86, 0x33, 0xdc, 0xb1, 0xda, 0xe0, 0x2e ) );
|
490
|
535
|
|
491
|
|
-/** Test 5.4 : Second call to Generate */
|
492
|
|
-HMAC_DRBG_TEST_GENERATE_FAIL ( generate_fail_5_4,
|
|
536
|
+/** SHA-1 Test 5.4 : Second call to Generate */
|
|
537
|
+HMAC_DRBG_TEST_GENERATE_FAIL ( sha1_generate_fail_5_4, HMAC_DRBG_SHA1,
|
493
|
538
|
additional_input_empty, ( 320 / 8 ) );
|
494
|
539
|
|
495
|
|
-/** Test 5.5 : Reseed */
|
496
|
|
-HMAC_DRBG_TEST_RESEED ( reseed_5_5,
|
|
540
|
+/** SHA-1 Test 5.5 : Reseed */
|
|
541
|
+HMAC_DRBG_TEST_RESEED ( sha1_reseed_5_5, HMAC_DRBG_SHA1,
|
497
|
542
|
entropy_input_2, additional_input_empty,
|
498
|
543
|
EXPECT ( 0xdb, 0xa1, 0xcf, 0xf4, 0x87, 0x95, 0x46, 0xa0, 0x38, 0xa5,
|
499
|
544
|
0x59, 0xb2, 0xa2, 0x4d, 0xf2, 0xc0, 0x30, 0x08, 0x9a, 0x41 ),
|
500
|
545
|
EXPECT ( 0x2f, 0x88, 0x3c, 0x46, 0x48, 0xe1, 0x31, 0xe8, 0x6d, 0xdf,
|
501
|
546
|
0x9d, 0xca, 0x0d, 0x74, 0xf3, 0x0c, 0xa1, 0xce, 0x6e, 0xfb ) );
|
502
|
547
|
|
503
|
|
-/** Test 5.6 : Retried second call to Generate */
|
504
|
|
-HMAC_DRBG_TEST_GENERATE ( generate_5_6,
|
|
548
|
+/** SHA-1 Test 5.6 : Retried second call to Generate */
|
|
549
|
+HMAC_DRBG_TEST_GENERATE ( sha1_generate_5_6, HMAC_DRBG_SHA1,
|
505
|
550
|
additional_input_empty,
|
506
|
551
|
EXPECT ( 0xf9, 0x39, 0xa5, 0xab, 0x08, 0xa3, 0x9f, 0x23, 0x10, 0x70,
|
507
|
552
|
0xb0, 0xd4, 0xc9, 0x6d, 0xc2, 0x37, 0x90, 0xba, 0x01, 0x53 ),
|
|
@@ -512,23 +557,23 @@ HMAC_DRBG_TEST_GENERATE ( generate_5_6,
|
512
|
557
|
0x1a, 0x0a, 0xd3, 0x9b, 0xd1, 0x5e, 0x86, 0x2e, 0x64, 0x4f,
|
513
|
558
|
0x31, 0xe4, 0xa2, 0xd7, 0xd8, 0x43, 0xe5, 0x7c, 0x59, 0x68 ) );
|
514
|
559
|
|
515
|
|
-/** Test 6 : Instantiate */
|
516
|
|
-#define instantiate_6 instantiate_1
|
|
560
|
+/** SHA-1 Test 6 : Instantiate */
|
|
561
|
+#define sha1_instantiate_6 sha1_instantiate_1
|
517
|
562
|
|
518
|
|
-/** Test 6.1 : First call to Generate */
|
519
|
|
-HMAC_DRBG_TEST_GENERATE_FAIL ( generate_fail_6_1,
|
|
563
|
+/** SHA-1 Test 6.1 : First call to Generate */
|
|
564
|
+HMAC_DRBG_TEST_GENERATE_FAIL ( sha1_generate_fail_6_1, HMAC_DRBG_SHA1,
|
520
|
565
|
additional_input_1, ( 320 / 8 ) );
|
521
|
566
|
|
522
|
|
-/** Test 6.2 : Reseed */
|
523
|
|
-HMAC_DRBG_TEST_RESEED ( reseed_6_2,
|
|
567
|
+/** SHA-1 Test 6.2 : Reseed */
|
|
568
|
+HMAC_DRBG_TEST_RESEED ( sha1_reseed_6_2, HMAC_DRBG_SHA1,
|
524
|
569
|
entropy_input_1, additional_input_1,
|
525
|
570
|
EXPECT ( 0x52, 0x28, 0xa4, 0xb6, 0xa4, 0x46, 0x92, 0x90, 0x5e, 0xc0,
|
526
|
571
|
0x44, 0xbf, 0xf0, 0xbb, 0x4e, 0x25, 0xa3, 0x87, 0xca, 0xc1 ),
|
527
|
572
|
EXPECT ( 0x24, 0x77, 0x32, 0xd0, 0x4c, 0xb8, 0x4e, 0xd4, 0x1a, 0xdd,
|
528
|
573
|
0x95, 0xa4, 0xb7, 0x8b, 0x50, 0xcd, 0x9b, 0x3d, 0x3f, 0x32 ) );
|
529
|
574
|
|
530
|
|
-/** Test 6.3 : Retried first call to Generate */
|
531
|
|
-HMAC_DRBG_TEST_GENERATE ( generate_6_3,
|
|
575
|
+/** SHA-1 Test 6.3 : Retried first call to Generate */
|
|
576
|
+HMAC_DRBG_TEST_GENERATE ( sha1_generate_6_3, HMAC_DRBG_SHA1,
|
532
|
577
|
additional_input_empty,
|
533
|
578
|
EXPECT ( 0xab, 0x3d, 0xd4, 0x89, 0x5b, 0xc8, 0xcd, 0x22, 0x71, 0xde,
|
534
|
579
|
0xba, 0x5f, 0x3c, 0x13, 0x63, 0x52, 0x6b, 0x8b, 0x74, 0x52 ),
|
|
@@ -539,20 +584,20 @@ HMAC_DRBG_TEST_GENERATE ( generate_6_3,
|
539
|
584
|
0x57, 0xae, 0xe8, 0x15, 0xb9, 0xc0, 0x70, 0x04, 0xc7, 0xe9,
|
540
|
585
|
0x92, 0xeb, 0x8c, 0x7e, 0x59, 0x19, 0x64, 0xaf, 0xee, 0xa2 ) );
|
541
|
586
|
|
542
|
|
-/** Test 6.4 : Second call to Generate */
|
543
|
|
-HMAC_DRBG_TEST_GENERATE_FAIL ( generate_fail_6_4,
|
|
587
|
+/** SHA-1 Test 6.4 : Second call to Generate */
|
|
588
|
+HMAC_DRBG_TEST_GENERATE_FAIL ( sha1_generate_fail_6_4, HMAC_DRBG_SHA1,
|
544
|
589
|
additional_input_2, ( 320 / 8 ) );
|
545
|
590
|
|
546
|
|
-/** Test 6.5 : Reseed */
|
547
|
|
-HMAC_DRBG_TEST_RESEED ( reseed_6_5,
|
|
591
|
+/** SHA-1 Test 6.5 : Reseed */
|
|
592
|
+HMAC_DRBG_TEST_RESEED ( sha1_reseed_6_5, HMAC_DRBG_SHA1,
|
548
|
593
|
entropy_input_2, additional_input_2,
|
549
|
594
|
EXPECT ( 0xe5, 0x73, 0x9f, 0x9c, 0xf7, 0xff, 0x43, 0x84, 0xd1, 0x27,
|
550
|
595
|
0x3e, 0x02, 0x6b, 0x45, 0x31, 0x21, 0x36, 0x49, 0x4f, 0x41 ),
|
551
|
596
|
EXPECT ( 0x30, 0xc3, 0x43, 0x05, 0xc2, 0xc6, 0x48, 0xb0, 0x57, 0xa6,
|
552
|
597
|
0x40, 0x22, 0x1b, 0x5c, 0x56, 0x57, 0x26, 0xcd, 0x32, 0xb2 ) );
|
553
|
598
|
|
554
|
|
-/** Test 6.6 : Retried second call to Generate */
|
555
|
|
-HMAC_DRBG_TEST_GENERATE ( generate_6_6,
|
|
599
|
+/** SHA-1 Test 6.6 : Retried second call to Generate */
|
|
600
|
+HMAC_DRBG_TEST_GENERATE ( sha1_generate_6_6, HMAC_DRBG_SHA1,
|
556
|
601
|
additional_input_empty,
|
557
|
602
|
EXPECT ( 0x61, 0x91, 0xca, 0x9b, 0xf0, 0x00, 0xd1, 0x0a, 0x71, 0x69,
|
558
|
603
|
0x0a, 0xc1, 0x0e, 0x09, 0xff, 0xc8, 0x92, 0xab, 0xde, 0x9a ),
|
|
@@ -563,23 +608,23 @@ HMAC_DRBG_TEST_GENERATE ( generate_6_6,
|
563
|
608
|
0x2d, 0xc6, 0x4a, 0x16, 0x42, 0x11, 0x88, 0x9a, 0x01, 0x0f,
|
564
|
609
|
0x24, 0x71, 0xa0, 0x91, 0x2f, 0xfe, 0xa1, 0xbf, 0x01, 0x95 ) );
|
565
|
610
|
|
566
|
|
-/** Test 7 : Instantiation */
|
567
|
|
-#define instantiate_7 instantiate_3
|
|
611
|
+/** SHA-1 Test 7 : Instantiation */
|
|
612
|
+#define sha1_instantiate_7 sha1_instantiate_3
|
568
|
613
|
|
569
|
|
-/** Test 7.1 : First call to Generate */
|
570
|
|
-HMAC_DRBG_TEST_GENERATE_FAIL ( generate_fail_7_1,
|
|
614
|
+/** SHA-1 Test 7.1 : First call to Generate */
|
|
615
|
+HMAC_DRBG_TEST_GENERATE_FAIL ( sha1_generate_fail_7_1, HMAC_DRBG_SHA1,
|
571
|
616
|
additional_input_empty, ( 320 / 8 ) );
|
572
|
617
|
|
573
|
|
-/** Test 7.2 : Reseed */
|
574
|
|
-HMAC_DRBG_TEST_RESEED ( reseed_7_2,
|
|
618
|
+/** SHA-1 Test 7.2 : Reseed */
|
|
619
|
+HMAC_DRBG_TEST_RESEED ( sha1_reseed_7_2, HMAC_DRBG_SHA1,
|
575
|
620
|
entropy_input_1, additional_input_empty,
|
576
|
621
|
EXPECT ( 0xb9, 0x25, 0x4d, 0x8a, 0xac, 0xba, 0x43, 0xfb, 0xda, 0xe6,
|
577
|
622
|
0x39, 0x4f, 0x2b, 0x3a, 0xfc, 0x5d, 0x58, 0x08, 0x00, 0xbf ),
|
578
|
623
|
EXPECT ( 0x28, 0x40, 0x3b, 0x60, 0x36, 0x38, 0xd0, 0x7d, 0x79, 0x66,
|
579
|
624
|
0x66, 0x1e, 0xf6, 0x7b, 0x9d, 0x39, 0x05, 0xf4, 0x6d, 0xb9 ) );
|
580
|
625
|
|
581
|
|
-/** Test 7.3 : Retried first call to Generate */
|
582
|
|
-HMAC_DRBG_TEST_GENERATE ( generate_7_3,
|
|
626
|
+/** SHA-1 Test 7.3 : Retried first call to Generate */
|
|
627
|
+HMAC_DRBG_TEST_GENERATE ( sha1_generate_7_3, HMAC_DRBG_SHA1,
|
583
|
628
|
additional_input_empty,
|
584
|
629
|
EXPECT ( 0x64, 0xfe, 0x07, 0x4a, 0x6e, 0x77, 0x97, 0xd1, 0xa4, 0x35,
|
585
|
630
|
0xda, 0x89, 0x64, 0x48, 0x4d, 0x6c, 0xf8, 0xbd, 0xc0, 0x1b ),
|
|
@@ -590,20 +635,20 @@ HMAC_DRBG_TEST_GENERATE ( generate_7_3,
|
590
|
635
|
0xb5, 0x70, 0x81, 0xe4, 0x22, 0x0f, 0x22, 0xc5, 0xc2, 0x83,
|
591
|
636
|
0xe2, 0xc9, 0x1b, 0x8e, 0x30, 0x5a, 0xb8, 0x69, 0xc6, 0x25 ) );
|
592
|
637
|
|
593
|
|
-/** Test 7.4 : Second call to Generate */
|
594
|
|
-HMAC_DRBG_TEST_GENERATE_FAIL ( generate_fail_7_4,
|
|
638
|
+/** SHA-1 Test 7.4 : Second call to Generate */
|
|
639
|
+HMAC_DRBG_TEST_GENERATE_FAIL ( sha1_generate_fail_7_4, HMAC_DRBG_SHA1,
|
595
|
640
|
additional_input_empty, ( 320 / 8 ) );
|
596
|
641
|
|
597
|
|
-/** Test 7.5 : Reseed */
|
598
|
|
-HMAC_DRBG_TEST_RESEED ( reseed_7_5,
|
|
642
|
+/** SHA-1 Test 7.5 : Reseed */
|
|
643
|
+HMAC_DRBG_TEST_RESEED ( sha1_reseed_7_5, HMAC_DRBG_SHA1,
|
599
|
644
|
entropy_input_2, additional_input_empty,
|
600
|
645
|
EXPECT ( 0x02, 0xbc, 0x57, 0x7f, 0xd1, 0x0e, 0xf7, 0x19, 0x3c, 0x1d,
|
601
|
646
|
0xb0, 0x98, 0xbd, 0x5b, 0x75, 0xc7, 0xc4, 0xb6, 0x79, 0x59 ),
|
602
|
647
|
EXPECT ( 0xbc, 0xbd, 0xf0, 0x52, 0xe0, 0xe0, 0x2a, 0xe8, 0x9a, 0x77,
|
603
|
648
|
0x67, 0x94, 0x3f, 0x98, 0x65, 0xb8, 0xb7, 0x22, 0x90, 0x2d ) );
|
604
|
649
|
|
605
|
|
-/** Test 7.6 : Retried second call to Generate */
|
606
|
|
-HMAC_DRBG_TEST_GENERATE ( generate_7_6,
|
|
650
|
+/** SHA-1 Test 7.6 : Retried second call to Generate */
|
|
651
|
+HMAC_DRBG_TEST_GENERATE ( sha1_generate_7_6, HMAC_DRBG_SHA1,
|
607
|
652
|
additional_input_empty,
|
608
|
653
|
EXPECT ( 0x1a, 0xa4, 0x24, 0x1c, 0x69, 0x5e, 0x29, 0xc0, 0xa5, 0x9a,
|
609
|
654
|
0xd1, 0x8a, 0x60, 0x70, 0xe3, 0x38, 0xa5, 0x48, 0xbe, 0x92 ),
|
|
@@ -614,23 +659,23 @@ HMAC_DRBG_TEST_GENERATE ( generate_7_6,
|
614
|
659
|
0x61, 0x48, 0x2c, 0xa5, 0x4d, 0x5f, 0xa7, 0x23, 0xf4, 0xc8,
|
615
|
660
|
0x8b, 0x4f, 0xa5, 0x04, 0xbf, 0x03, 0x27, 0x7f, 0xa7, 0x83 ) );
|
616
|
661
|
|
617
|
|
-/** Test 8 : Instantiate */
|
618
|
|
-#define instantiate_8 instantiate_3
|
|
662
|
+/** SHA-1 Test 8 : Instantiate */
|
|
663
|
+#define sha1_instantiate_8 sha1_instantiate_3
|
619
|
664
|
|
620
|
|
-/** Test 8.1 : First call to Generate */
|
621
|
|
-HMAC_DRBG_TEST_GENERATE_FAIL ( generate_fail_8_1,
|
|
665
|
+/** SHA-1 Test 8.1 : First call to Generate */
|
|
666
|
+HMAC_DRBG_TEST_GENERATE_FAIL ( sha1_generate_fail_8_1, HMAC_DRBG_SHA1,
|
622
|
667
|
additional_input_1, ( 320 / 8 ) );
|
623
|
668
|
|
624
|
|
-/** Test 8.2 : Reseed */
|
625
|
|
-HMAC_DRBG_TEST_RESEED ( reseed_8_2,
|
|
669
|
+/** SHA-1 Test 8.2 : Reseed */
|
|
670
|
+HMAC_DRBG_TEST_RESEED ( sha1_reseed_8_2, HMAC_DRBG_SHA1,
|
626
|
671
|
entropy_input_1, additional_input_1,
|
627
|
672
|
EXPECT ( 0xc0, 0x95, 0x48, 0xc0, 0xd3, 0xc8, 0x61, 0xd7, 0x40, 0xf2,
|
628
|
673
|
0x83, 0x7d, 0x72, 0xb5, 0x07, 0x23, 0x5c, 0x26, 0xdb, 0x82 ),
|
629
|
674
|
EXPECT ( 0x17, 0x4b, 0x3f, 0x84, 0xc3, 0x53, 0x1f, 0x7c, 0x0a, 0x2e,
|
630
|
675
|
0x54, 0x21, 0x23, 0x4e, 0xa1, 0x6b, 0x70, 0x8d, 0xdf, 0x0d ) );
|
631
|
676
|
|
632
|
|
-/** Test 8.3 : Retried first call to Generate */
|
633
|
|
-HMAC_DRBG_TEST_GENERATE ( generate_8_3,
|
|
677
|
+/** SHA-1 Test 8.3 : Retried first call to Generate */
|
|
678
|
+HMAC_DRBG_TEST_GENERATE ( sha1_generate_8_3, HMAC_DRBG_SHA1,
|
634
|
679
|
additional_input_empty,
|
635
|
680
|
EXPECT ( 0x60, 0x3f, 0x09, 0x49, 0x27, 0x9c, 0x70, 0xe8, 0xc6, 0x6c,
|
636
|
681
|
0x0f, 0x56, 0x37, 0xc0, 0xf3, 0x75, 0x60, 0x07, 0xe5, 0xac ),
|
|
@@ -641,20 +686,20 @@ HMAC_DRBG_TEST_GENERATE ( generate_8_3,
|
641
|
686
|
0x34, 0x71, 0xfd, 0xa5, 0x5c, 0x6d, 0xdd, 0x2c, 0x03, 0xef,
|
642
|
687
|
0xa3, 0xb9, 0x64, 0x3a, 0xb3, 0xbb, 0x22, 0xf6, 0xc9, 0xf2 ) );
|
643
|
688
|
|
644
|
|
-/** Test 8.4 : Second call to Generate */
|
645
|
|
-HMAC_DRBG_TEST_GENERATE_FAIL ( generate_fail_8_4,
|
|
689
|
+/** SHA-1 Test 8.4 : Second call to Generate */
|
|
690
|
+HMAC_DRBG_TEST_GENERATE_FAIL ( sha1_generate_fail_8_4, HMAC_DRBG_SHA1,
|
646
|
691
|
additional_input_2, ( 320 / 8 ) );
|
647
|
692
|
|
648
|
|
-/** Test 8.5 : Reseed */
|
649
|
|
-HMAC_DRBG_TEST_RESEED ( reseed_8_5,
|
|
693
|
+/** SHA-1 Test 8.5 : Reseed */
|
|
694
|
+HMAC_DRBG_TEST_RESEED ( sha1_reseed_8_5, HMAC_DRBG_SHA1,
|
650
|
695
|
entropy_input_2, additional_input_2,
|
651
|
696
|
EXPECT ( 0x89, 0x42, 0xa5, 0x4f, 0x34, 0x9e, 0x28, 0x1b, 0x84, 0xaa,
|
652
|
697
|
0x46, 0x95, 0x87, 0xfb, 0xdd, 0xaf, 0x9d, 0x11, 0x40, 0x82 ),
|
653
|
698
|
EXPECT ( 0x07, 0x73, 0x0e, 0x3c, 0xbf, 0xfd, 0x3c, 0xaf, 0xd7, 0xa8,
|
654
|
699
|
0xaa, 0xe2, 0xbf, 0x01, 0xd6, 0x01, 0x43, 0x01, 0xe2, 0x4d ) );
|
655
|
700
|
|
656
|
|
-/** Test 8.6 : Retried second call to Generate */
|
657
|
|
-HMAC_DRBG_TEST_GENERATE ( generate_8_6,
|
|
701
|
+/** SHA-1 Test 8.6 : Retried second call to Generate */
|
|
702
|
+HMAC_DRBG_TEST_GENERATE ( sha1_generate_8_6, HMAC_DRBG_SHA1,
|
658
|
703
|
additional_input_empty,
|
659
|
704
|
EXPECT ( 0xbd, 0xe1, 0xb4, 0x6c, 0xdc, 0x54, 0x13, 0xb3, 0xd9, 0xf7,
|
660
|
705
|
0x35, 0xac, 0xdb, 0x80, 0xb1, 0x3c, 0x57, 0xbf, 0xe4, 0x73 ),
|
|
@@ -724,69 +769,69 @@ static void hmac_drbg_test_exec ( void ) {
|
724
|
769
|
* greater than the reseed_interval.
|
725
|
770
|
*/
|
726
|
771
|
|
727
|
|
- /* Test 1 */
|
728
|
|
- instantiate_ok ( &state, &instantiate_1 );
|
729
|
|
- generate_ok ( &state, &generate_1_1 );
|
730
|
|
- generate_ok ( &state, &generate_1_2 );
|
|
772
|
+ /* SHA-1 Test 1 */
|
|
773
|
+ instantiate_ok ( &state, &sha1_instantiate_1 );
|
|
774
|
+ generate_ok ( &state, &sha1_generate_1_1 );
|
|
775
|
+ generate_ok ( &state, &sha1_generate_1_2 );
|
731
|
776
|
|
732
|
|
- /* Test 2 */
|
733
|
|
- instantiate_ok ( &state, &instantiate_2 );
|
734
|
|
- generate_ok ( &state, &generate_2_1 );
|
735
|
|
- generate_ok ( &state, &generate_2_2 );
|
|
777
|
+ /* SHA-1 Test 2 */
|
|
778
|
+ instantiate_ok ( &state, &sha1_instantiate_2 );
|
|
779
|
+ generate_ok ( &state, &sha1_generate_2_1 );
|
|
780
|
+ generate_ok ( &state, &sha1_generate_2_2 );
|
736
|
781
|
|
737
|
|
- /* Test 3 */
|
738
|
|
- instantiate_ok ( &state, &instantiate_3 );
|
739
|
|
- generate_ok ( &state, &generate_3_1 );
|
740
|
|
- generate_ok ( &state, &generate_3_2 );
|
|
782
|
+ /* SHA-1 Test 3 */
|
|
783
|
+ instantiate_ok ( &state, &sha1_instantiate_3 );
|
|
784
|
+ generate_ok ( &state, &sha1_generate_3_1 );
|
|
785
|
+ generate_ok ( &state, &sha1_generate_3_2 );
|
741
|
786
|
|
742
|
|
- /* Test 4 */
|
743
|
|
- instantiate_ok ( &state, &instantiate_4 );
|
744
|
|
- generate_ok ( &state, &generate_4_1 );
|
745
|
|
- generate_ok ( &state, &generate_4_2 );
|
|
787
|
+ /* SHA-1 Test 4 */
|
|
788
|
+ instantiate_ok ( &state, &sha1_instantiate_4 );
|
|
789
|
+ generate_ok ( &state, &sha1_generate_4_1 );
|
|
790
|
+ generate_ok ( &state, &sha1_generate_4_2 );
|
746
|
791
|
|
747
|
|
- /* Test 5 */
|
748
|
|
- instantiate_ok ( &state, &instantiate_5 );
|
|
792
|
+ /* SHA-1 Test 5 */
|
|
793
|
+ instantiate_ok ( &state, &sha1_instantiate_5 );
|
749
|
794
|
force_reseed_required ( &state ); /* See above comments */
|
750
|
|
- generate_fail_ok ( &state, &generate_fail_5_1 );
|
751
|
|
- reseed_ok ( &state, &reseed_5_2 );
|
752
|
|
- generate_ok ( &state, &generate_5_3 );
|
|
795
|
+ generate_fail_ok ( &state, &sha1_generate_fail_5_1 );
|
|
796
|
+ reseed_ok ( &state, &sha1_reseed_5_2 );
|
|
797
|
+ generate_ok ( &state, &sha1_generate_5_3 );
|
753
|
798
|
force_reseed_required ( &state ); /* See above comments */
|
754
|
|
- generate_fail_ok ( &state, &generate_fail_5_4 );
|
755
|
|
- reseed_ok ( &state, &reseed_5_5 );
|
756
|
|
- generate_ok ( &state, &generate_5_6 );
|
|
799
|
+ generate_fail_ok ( &state, &sha1_generate_fail_5_4 );
|
|
800
|
+ reseed_ok ( &state, &sha1_reseed_5_5 );
|
|
801
|
+ generate_ok ( &state, &sha1_generate_5_6 );
|
757
|
802
|
|
758
|
|
- /* Test 6 */
|
759
|
|
- instantiate_ok ( &state, &instantiate_6 );
|
|
803
|
+ /* SHA-1 Test 6 */
|
|
804
|
+ instantiate_ok ( &state, &sha1_instantiate_6 );
|
760
|
805
|
force_reseed_required ( &state ); /* See above comments */
|
761
|
|
- generate_fail_ok ( &state, &generate_fail_6_1 );
|
762
|
|
- reseed_ok ( &state, &reseed_6_2 );
|
763
|
|
- generate_ok ( &state, &generate_6_3 );
|
|
806
|
+ generate_fail_ok ( &state, &sha1_generate_fail_6_1 );
|
|
807
|
+ reseed_ok ( &state, &sha1_reseed_6_2 );
|
|
808
|
+ generate_ok ( &state, &sha1_generate_6_3 );
|
764
|
809
|
force_reseed_required ( &state ); /* See above comments */
|
765
|
|
- generate_fail_ok ( &state, &generate_fail_6_4 );
|
766
|
|
- reseed_ok ( &state, &reseed_6_5 );
|
767
|
|
- generate_ok ( &state, &generate_6_6 );
|
|
810
|
+ generate_fail_ok ( &state, &sha1_generate_fail_6_4 );
|
|
811
|
+ reseed_ok ( &state, &sha1_reseed_6_5 );
|
|
812
|
+ generate_ok ( &state, &sha1_generate_6_6 );
|
768
|
813
|
|
769
|
|
- /* Test 7 */
|
770
|
|
- instantiate_ok ( &state, &instantiate_7 );
|
|
814
|
+ /* SHA-1 Test 7 */
|
|
815
|
+ instantiate_ok ( &state, &sha1_instantiate_7 );
|
771
|
816
|
force_reseed_required ( &state ); /* See above comments */
|
772
|
|
- generate_fail_ok ( &state, &generate_fail_7_1 );
|
773
|
|
- reseed_ok ( &state, &reseed_7_2 );
|
774
|
|
- generate_ok ( &state, &generate_7_3 );
|
|
817
|
+ generate_fail_ok ( &state, &sha1_generate_fail_7_1 );
|
|
818
|
+ reseed_ok ( &state, &sha1_reseed_7_2 );
|
|
819
|
+ generate_ok ( &state, &sha1_generate_7_3 );
|
775
|
820
|
force_reseed_required ( &state ); /* See above comments */
|
776
|
|
- generate_fail_ok ( &state, &generate_fail_7_4 );
|
777
|
|
- reseed_ok ( &state, &reseed_7_5 );
|
778
|
|
- generate_ok ( &state, &generate_7_6 );
|
|
821
|
+ generate_fail_ok ( &state, &sha1_generate_fail_7_4 );
|
|
822
|
+ reseed_ok ( &state, &sha1_reseed_7_5 );
|
|
823
|
+ generate_ok ( &state, &sha1_generate_7_6 );
|
779
|
824
|
|
780
|
|
- /* Test 8 */
|
781
|
|
- instantiate_ok ( &state, &instantiate_8 );
|
|
825
|
+ /* SHA-1 Test 8 */
|
|
826
|
+ instantiate_ok ( &state, &sha1_instantiate_8 );
|
782
|
827
|
force_reseed_required ( &state ); /* See above comments */
|
783
|
|
- generate_fail_ok ( &state, &generate_fail_8_1 );
|
784
|
|
- reseed_ok ( &state, &reseed_8_2 );
|
785
|
|
- generate_ok ( &state, &generate_8_3 );
|
|
828
|
+ generate_fail_ok ( &state, &sha1_generate_fail_8_1 );
|
|
829
|
+ reseed_ok ( &state, &sha1_reseed_8_2 );
|
|
830
|
+ generate_ok ( &state, &sha1_generate_8_3 );
|
786
|
831
|
force_reseed_required ( &state ); /* See above comments */
|
787
|
|
- generate_fail_ok ( &state, &generate_fail_8_4 );
|
788
|
|
- reseed_ok ( &state, &reseed_8_5 );
|
789
|
|
- generate_ok ( &state, &generate_8_6 );
|
|
832
|
+ generate_fail_ok ( &state, &sha1_generate_fail_8_4 );
|
|
833
|
+ reseed_ok ( &state, &sha1_reseed_8_5 );
|
|
834
|
+ generate_ok ( &state, &sha1_generate_8_6 );
|
790
|
835
|
}
|
791
|
836
|
|
792
|
837
|
/** HMAC_DRBG self-test */
|