33f31a6fe24fe4435fc64ab07232ef52530410d4
[BearSSL] / test / test_crypto.c
1 /*
2 * Copyright (c) 2016 Thomas Pornin <pornin@bolet.org>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include "bearssl.h"
29 #include "inner.h"
30
31 /*
32 * Decode an hexadecimal string. Returned value is the number of decoded
33 * bytes.
34 */
35 static size_t
36 hextobin(unsigned char *dst, const char *src)
37 {
38 size_t num;
39 unsigned acc;
40 int z;
41
42 num = 0;
43 z = 0;
44 acc = 0;
45 while (*src != 0) {
46 int c = *src ++;
47 if (c >= '0' && c <= '9') {
48 c -= '0';
49 } else if (c >= 'A' && c <= 'F') {
50 c -= ('A' - 10); \
51 } else if (c >= 'a' && c <= 'f') {
52 c -= ('a' - 10); \
53 } else {
54 continue;
55 }
56 if (z) {
57 *dst ++ = (acc << 4) + c;
58 num ++;
59 } else {
60 acc = c;
61 }
62 z = !z;
63 }
64 return num;
65 }
66
67 static void
68 check_equals(const char *banner, const void *v1, const void *v2, size_t len)
69 {
70 size_t u;
71 const unsigned char *b;
72
73 if (memcmp(v1, v2, len) == 0) {
74 return;
75 }
76 fprintf(stderr, "\n%s failed\n", banner);
77 fprintf(stderr, "v1: ");
78 for (u = 0, b = v1; u < len; u ++) {
79 fprintf(stderr, "%02X", b[u]);
80 }
81 fprintf(stderr, "\nv2: ");
82 for (u = 0, b = v2; u < len; u ++) {
83 fprintf(stderr, "%02X", b[u]);
84 }
85 fprintf(stderr, "\n");
86 exit(EXIT_FAILURE);
87 }
88
89 #define HASH_SIZE(cname) br_ ## cname ## _SIZE
90
91 #define TEST_HASH(Name, cname) \
92 static void \
93 test_ ## cname ## _internal(char *data, char *refres) \
94 { \
95 br_ ## cname ## _context mc; \
96 unsigned char res[HASH_SIZE(cname)], ref[HASH_SIZE(cname)]; \
97 size_t u, n; \
98 \
99 hextobin(ref, refres); \
100 n = strlen(data); \
101 br_ ## cname ## _init(&mc); \
102 br_ ## cname ## _update(&mc, data, n); \
103 br_ ## cname ## _out(&mc, res); \
104 check_equals("KAT " #Name " 1", res, ref, HASH_SIZE(cname)); \
105 br_ ## cname ## _init(&mc); \
106 for (u = 0; u < n; u ++) { \
107 br_ ## cname ## _update(&mc, data + u, 1); \
108 } \
109 br_ ## cname ## _out(&mc, res); \
110 check_equals("KAT " #Name " 2", res, ref, HASH_SIZE(cname)); \
111 for (u = 0; u < n; u ++) { \
112 br_ ## cname ## _context mc2; \
113 br_ ## cname ## _init(&mc); \
114 br_ ## cname ## _update(&mc, data, u); \
115 mc2 = mc; \
116 br_ ## cname ## _update(&mc, data + u, n - u); \
117 br_ ## cname ## _out(&mc, res); \
118 check_equals("KAT " #Name " 3", res, ref, HASH_SIZE(cname)); \
119 br_ ## cname ## _update(&mc2, data + u, n - u); \
120 br_ ## cname ## _out(&mc2, res); \
121 check_equals("KAT " #Name " 4", res, ref, HASH_SIZE(cname)); \
122 } \
123 memset(&mc, 0, sizeof mc); \
124 memset(res, 0, sizeof res); \
125 br_ ## cname ## _vtable.init(&mc.vtable); \
126 mc.vtable->update(&mc.vtable, data, n); \
127 mc.vtable->out(&mc.vtable, res); \
128 check_equals("KAT " #Name " 5", res, ref, HASH_SIZE(cname)); \
129 memset(res, 0, sizeof res); \
130 mc.vtable->init(&mc.vtable); \
131 mc.vtable->update(&mc.vtable, data, n); \
132 mc.vtable->out(&mc.vtable, res); \
133 check_equals("KAT " #Name " 6", res, ref, HASH_SIZE(cname)); \
134 }
135
136 #define KAT_MILLION_A(Name, cname, refres) do { \
137 br_ ## cname ## _context mc; \
138 unsigned char buf[1000]; \
139 unsigned char res[HASH_SIZE(cname)], ref[HASH_SIZE(cname)]; \
140 int i; \
141 \
142 hextobin(ref, refres); \
143 memset(buf, 'a', sizeof buf); \
144 br_ ## cname ## _init(&mc); \
145 for (i = 0; i < 1000; i ++) { \
146 br_ ## cname ## _update(&mc, buf, sizeof buf); \
147 } \
148 br_ ## cname ## _out(&mc, res); \
149 check_equals("KAT " #Name " 5", res, ref, HASH_SIZE(cname)); \
150 } while (0)
151
152 TEST_HASH(MD5, md5)
153 TEST_HASH(SHA-1, sha1)
154 TEST_HASH(SHA-224, sha224)
155 TEST_HASH(SHA-256, sha256)
156 TEST_HASH(SHA-384, sha384)
157 TEST_HASH(SHA-512, sha512)
158
159 static void
160 test_MD5(void)
161 {
162 printf("Test MD5: ");
163 fflush(stdout);
164 test_md5_internal("", "d41d8cd98f00b204e9800998ecf8427e");
165 test_md5_internal("a", "0cc175b9c0f1b6a831c399e269772661");
166 test_md5_internal("abc", "900150983cd24fb0d6963f7d28e17f72");
167 test_md5_internal("message digest", "f96b697d7cb7938d525a2f31aaf161d0");
168 test_md5_internal("abcdefghijklmnopqrstuvwxyz",
169 "c3fcd3d76192e4007dfb496cca67e13b");
170 test_md5_internal("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstu"
171 "vwxyz0123456789", "d174ab98d277d9f5a5611c2c9f419d9f");
172 test_md5_internal("1234567890123456789012345678901234567890123456789"
173 "0123456789012345678901234567890",
174 "57edf4a22be3c955ac49da2e2107b67a");
175 KAT_MILLION_A(MD5, md5,
176 "7707d6ae4e027c70eea2a935c2296f21");
177 printf("done.\n");
178 fflush(stdout);
179 }
180
181 static void
182 test_SHA1(void)
183 {
184 printf("Test SHA-1: ");
185 fflush(stdout);
186 test_sha1_internal("abc", "a9993e364706816aba3e25717850c26c9cd0d89d");
187 test_sha1_internal("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlm"
188 "nomnopnopq", "84983e441c3bd26ebaae4aa1f95129e5e54670f1");
189
190 KAT_MILLION_A(SHA-1, sha1,
191 "34aa973cd4c4daa4f61eeb2bdbad27316534016f");
192 printf("done.\n");
193 fflush(stdout);
194 }
195
196 static void
197 test_SHA224(void)
198 {
199 printf("Test SHA-224: ");
200 fflush(stdout);
201 test_sha224_internal("abc",
202 "23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7");
203 test_sha224_internal("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlm"
204 "nomnopnopq",
205 "75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525");
206
207 KAT_MILLION_A(SHA-224, sha224,
208 "20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67");
209 printf("done.\n");
210 fflush(stdout);
211 }
212
213 static void
214 test_SHA256(void)
215 {
216 printf("Test SHA-256: ");
217 fflush(stdout);
218 test_sha256_internal("abc",
219 "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad");
220 test_sha256_internal("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlm"
221 "nomnopnopq",
222 "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1");
223
224 KAT_MILLION_A(SHA-256, sha256,
225 "cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0");
226 printf("done.\n");
227 fflush(stdout);
228 }
229
230 static void
231 test_SHA384(void)
232 {
233 printf("Test SHA-384: ");
234 fflush(stdout);
235 test_sha384_internal("abc",
236 "cb00753f45a35e8bb5a03d699ac65007272c32ab0eded163"
237 "1a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7");
238 test_sha384_internal(
239 "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
240 "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
241 "09330c33f71147e83d192fc782cd1b4753111b173b3b05d2"
242 "2fa08086e3b0f712fcc7c71a557e2db966c3e9fa91746039");
243
244 KAT_MILLION_A(SHA-384, sha384,
245 "9d0e1809716474cb086e834e310a4a1ced149e9c00f24852"
246 "7972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985");
247 printf("done.\n");
248 fflush(stdout);
249 }
250
251 static void
252 test_SHA512(void)
253 {
254 printf("Test SHA-512: ");
255 fflush(stdout);
256 test_sha512_internal("abc",
257 "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a"
258 "2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f");
259 test_sha512_internal(
260 "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
261 "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
262 "8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018"
263 "501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909");
264
265 KAT_MILLION_A(SHA-512, sha512,
266 "e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973eb"
267 "de0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b");
268 printf("done.\n");
269 fflush(stdout);
270 }
271
272 static void
273 test_MD5_SHA1(void)
274 {
275 unsigned char buf[500], out[36], outM[16], outS[20];
276 unsigned char seed[1];
277 br_hmac_drbg_context rc;
278 br_md5_context mc;
279 br_sha1_context sc;
280 br_md5sha1_context cc;
281 size_t u;
282
283 printf("Test MD5+SHA-1: ");
284 fflush(stdout);
285
286 seed[0] = 0;
287 br_hmac_drbg_init(&rc, &br_sha256_vtable, seed, sizeof seed);
288 for (u = 0; u < sizeof buf; u ++) {
289 size_t v;
290
291 br_hmac_drbg_generate(&rc, buf, u);
292 br_md5_init(&mc);
293 br_md5_update(&mc, buf, u);
294 br_md5_out(&mc, outM);
295 br_sha1_init(&sc);
296 br_sha1_update(&sc, buf, u);
297 br_sha1_out(&sc, outS);
298 br_md5sha1_init(&cc);
299 br_md5sha1_update(&cc, buf, u);
300 br_md5sha1_out(&cc, out);
301 check_equals("MD5+SHA-1 [1]", out, outM, 16);
302 check_equals("MD5+SHA-1 [2]", out + 16, outS, 20);
303 br_md5sha1_init(&cc);
304 for (v = 0; v < u; v ++) {
305 br_md5sha1_update(&cc, buf + v, 1);
306 }
307 br_md5sha1_out(&cc, out);
308 check_equals("MD5+SHA-1 [3]", out, outM, 16);
309 check_equals("MD5+SHA-1 [4]", out + 16, outS, 20);
310 }
311
312 printf("done.\n");
313 fflush(stdout);
314 }
315
316 /*
317 * Compute a hash function, on some data, by ID. Returned value is
318 * hash output length.
319 */
320 static size_t
321 do_hash(int id, const void *data, size_t len, void *out)
322 {
323 br_md5_context cmd5;
324 br_sha1_context csha1;
325 br_sha224_context csha224;
326 br_sha256_context csha256;
327 br_sha384_context csha384;
328 br_sha512_context csha512;
329
330 switch (id) {
331 case br_md5_ID:
332 br_md5_init(&cmd5);
333 br_md5_update(&cmd5, data, len);
334 br_md5_out(&cmd5, out);
335 return 16;
336 case br_sha1_ID:
337 br_sha1_init(&csha1);
338 br_sha1_update(&csha1, data, len);
339 br_sha1_out(&csha1, out);
340 return 20;
341 case br_sha224_ID:
342 br_sha224_init(&csha224);
343 br_sha224_update(&csha224, data, len);
344 br_sha224_out(&csha224, out);
345 return 28;
346 case br_sha256_ID:
347 br_sha256_init(&csha256);
348 br_sha256_update(&csha256, data, len);
349 br_sha256_out(&csha256, out);
350 return 32;
351 case br_sha384_ID:
352 br_sha384_init(&csha384);
353 br_sha384_update(&csha384, data, len);
354 br_sha384_out(&csha384, out);
355 return 48;
356 case br_sha512_ID:
357 br_sha512_init(&csha512);
358 br_sha512_update(&csha512, data, len);
359 br_sha512_out(&csha512, out);
360 return 64;
361 default:
362 fprintf(stderr, "Uknown hash function: %d\n", id);
363 exit(EXIT_FAILURE);
364 return 0;
365 }
366 }
367
368 /*
369 * Tests for a multihash. Returned value should be 258 multiplied by the
370 * number of hash functions implemented by the context.
371 */
372 static int
373 test_multihash_inner(br_multihash_context *mc)
374 {
375 /*
376 * Try hashing messages for all lengths from 0 to 257 bytes
377 * (inclusive). Each attempt is done twice, with data input
378 * either in one go, or byte by byte. In the byte by byte
379 * test, intermediate result are obtained and checked.
380 */
381 size_t len;
382 unsigned char buf[258];
383 int i;
384 int tcount;
385
386 tcount = 0;
387 for (len = 0; len < sizeof buf; len ++) {
388 br_sha1_context sc;
389 unsigned char tmp[20];
390
391 br_sha1_init(&sc);
392 br_sha1_update(&sc, buf, len);
393 br_sha1_out(&sc, tmp);
394 buf[len] = tmp[0];
395 }
396 for (len = 0; len <= 257; len ++) {
397 size_t u;
398
399 br_multihash_init(mc);
400 br_multihash_update(mc, buf, len);
401 for (i = 1; i <= 6; i ++) {
402 unsigned char tmp[64], tmp2[64];
403 size_t olen, olen2;
404
405 olen = br_multihash_out(mc, i, tmp);
406 if (olen == 0) {
407 continue;
408 }
409 olen2 = do_hash(i, buf, len, tmp2);
410 if (olen != olen2) {
411 fprintf(stderr,
412 "Bad hash output length: %u / %u\n",
413 (unsigned)olen, (unsigned)olen2);
414 exit(EXIT_FAILURE);
415 }
416 check_equals("Hash output", tmp, tmp2, olen);
417 tcount ++;
418 }
419
420 br_multihash_init(mc);
421 for (u = 0; u < len; u ++) {
422 br_multihash_update(mc, buf + u, 1);
423 for (i = 1; i <= 6; i ++) {
424 unsigned char tmp[64], tmp2[64];
425 size_t olen, olen2;
426
427 olen = br_multihash_out(mc, i, tmp);
428 if (olen == 0) {
429 continue;
430 }
431 olen2 = do_hash(i, buf, u + 1, tmp2);
432 if (olen != olen2) {
433 fprintf(stderr, "Bad hash output"
434 " length: %u / %u\n",
435 (unsigned)olen,
436 (unsigned)olen2);
437 exit(EXIT_FAILURE);
438 }
439 check_equals("Hash output", tmp, tmp2, olen);
440 }
441 }
442 }
443 return tcount;
444 }
445
446 static void
447 test_multihash(void)
448 {
449 br_multihash_context mc;
450
451 printf("Test MultiHash: ");
452 fflush(stdout);
453
454 br_multihash_zero(&mc);
455 br_multihash_setimpl(&mc, br_md5_ID, &br_md5_vtable);
456 if (test_multihash_inner(&mc) != 258) {
457 fprintf(stderr, "Failed test count\n");
458 }
459 printf(".");
460 fflush(stdout);
461
462 br_multihash_zero(&mc);
463 br_multihash_setimpl(&mc, br_sha1_ID, &br_sha1_vtable);
464 if (test_multihash_inner(&mc) != 258) {
465 fprintf(stderr, "Failed test count\n");
466 }
467 printf(".");
468 fflush(stdout);
469
470 br_multihash_zero(&mc);
471 br_multihash_setimpl(&mc, br_sha224_ID, &br_sha224_vtable);
472 if (test_multihash_inner(&mc) != 258) {
473 fprintf(stderr, "Failed test count\n");
474 }
475 printf(".");
476 fflush(stdout);
477
478 br_multihash_zero(&mc);
479 br_multihash_setimpl(&mc, br_sha256_ID, &br_sha256_vtable);
480 if (test_multihash_inner(&mc) != 258) {
481 fprintf(stderr, "Failed test count\n");
482 }
483 printf(".");
484 fflush(stdout);
485
486 br_multihash_zero(&mc);
487 br_multihash_setimpl(&mc, br_sha384_ID, &br_sha384_vtable);
488 if (test_multihash_inner(&mc) != 258) {
489 fprintf(stderr, "Failed test count\n");
490 }
491 printf(".");
492 fflush(stdout);
493
494 br_multihash_zero(&mc);
495 br_multihash_setimpl(&mc, br_sha512_ID, &br_sha512_vtable);
496 if (test_multihash_inner(&mc) != 258) {
497 fprintf(stderr, "Failed test count\n");
498 }
499 printf(".");
500 fflush(stdout);
501
502 br_multihash_zero(&mc);
503 br_multihash_setimpl(&mc, br_md5_ID, &br_md5_vtable);
504 br_multihash_setimpl(&mc, br_sha1_ID, &br_sha1_vtable);
505 br_multihash_setimpl(&mc, br_sha224_ID, &br_sha224_vtable);
506 br_multihash_setimpl(&mc, br_sha256_ID, &br_sha256_vtable);
507 br_multihash_setimpl(&mc, br_sha384_ID, &br_sha384_vtable);
508 br_multihash_setimpl(&mc, br_sha512_ID, &br_sha512_vtable);
509 if (test_multihash_inner(&mc) != 258 * 6) {
510 fprintf(stderr, "Failed test count\n");
511 }
512 printf(".");
513 fflush(stdout);
514
515 printf("done.\n");
516 fflush(stdout);
517 }
518
519 static void
520 do_KAT_HMAC_bin_bin(const br_hash_class *digest_class,
521 const void *key, size_t key_len,
522 const void *data, size_t data_len, const char *href)
523 {
524 br_hmac_key_context kc;
525 br_hmac_context ctx;
526 unsigned char tmp[64], ref[64];
527 size_t u, len;
528
529 len = hextobin(ref, href);
530 br_hmac_key_init(&kc, digest_class, key, key_len);
531 br_hmac_init(&ctx, &kc, 0);
532 br_hmac_update(&ctx, data, data_len);
533 br_hmac_out(&ctx, tmp);
534 check_equals("KAT HMAC 1", tmp, ref, len);
535
536 br_hmac_init(&ctx, &kc, 0);
537 for (u = 0; u < data_len; u ++) {
538 br_hmac_update(&ctx, (const unsigned char *)data + u, 1);
539 }
540 br_hmac_out(&ctx, tmp);
541 check_equals("KAT HMAC 2", tmp, ref, len);
542
543 for (u = 0; u < data_len; u ++) {
544 br_hmac_init(&ctx, &kc, 0);
545 br_hmac_update(&ctx, data, u);
546 br_hmac_out(&ctx, tmp);
547 br_hmac_update(&ctx,
548 (const unsigned char *)data + u, data_len - u);
549 br_hmac_out(&ctx, tmp);
550 check_equals("KAT HMAC 3", tmp, ref, len);
551 }
552 }
553
554 static void
555 do_KAT_HMAC_str_str(const br_hash_class *digest_class, const char *key,
556 const char *data, const char *href)
557 {
558 do_KAT_HMAC_bin_bin(digest_class, key, strlen(key),
559 data, strlen(data), href);
560 }
561
562 static void
563 do_KAT_HMAC_hex_hex(const br_hash_class *digest_class, const char *skey,
564 const char *sdata, const char *href)
565 {
566 unsigned char key[1024];
567 unsigned char data[1024];
568
569 do_KAT_HMAC_bin_bin(digest_class, key, hextobin(key, skey),
570 data, hextobin(data, sdata), href);
571 }
572
573 static void
574 do_KAT_HMAC_hex_str(const br_hash_class *digest_class,
575 const char *skey, const char *data, const char *href)
576 {
577 unsigned char key[1024];
578
579 do_KAT_HMAC_bin_bin(digest_class, key, hextobin(key, skey),
580 data, strlen(data), href);
581 }
582
583 static void
584 test_HMAC_CT(const br_hash_class *digest_class,
585 const void *key, size_t key_len, const void *data)
586 {
587 br_hmac_key_context kc;
588 br_hmac_context hc1, hc2;
589 unsigned char buf1[64], buf2[64];
590 size_t u, v;
591
592 br_hmac_key_init(&kc, digest_class, key, key_len);
593
594 for (u = 0; u < 130; u ++) {
595 for (v = 0; v < 130; v ++) {
596 size_t min_len, max_len;
597 size_t w;
598
599 min_len = v;
600 max_len = v + 256;
601 for (w = min_len; w <= max_len; w ++) {
602 char tmp[30];
603 size_t hlen1, hlen2;
604
605 br_hmac_init(&hc1, &kc, 0);
606 br_hmac_update(&hc1, data, u + w);
607 hlen1 = br_hmac_out(&hc1, buf1);
608 br_hmac_init(&hc2, &kc, 0);
609 br_hmac_update(&hc2, data, u);
610 hlen2 = br_hmac_outCT(&hc2,
611 (const unsigned char *)data + u, w,
612 min_len, max_len, buf2);
613 if (hlen1 != hlen2) {
614 fprintf(stderr, "HMAC length mismatch:"
615 " %u / %u\n", (unsigned)hlen1,
616 (unsigned)hlen2);
617 exit(EXIT_FAILURE);
618 }
619 sprintf(tmp, "HMAC CT %u,%u,%u",
620 (unsigned)u, (unsigned)v, (unsigned)w);
621 check_equals(tmp, buf1, buf2, hlen1);
622 }
623 }
624 printf(".");
625 fflush(stdout);
626 }
627 printf(" ");
628 fflush(stdout);
629 }
630
631 static void
632 test_HMAC(void)
633 {
634 unsigned char data[1000];
635 unsigned x;
636 size_t u;
637 const char key[] = "test HMAC key";
638
639 printf("Test HMAC: ");
640 fflush(stdout);
641 do_KAT_HMAC_hex_str(&br_md5_vtable,
642 "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b",
643 "Hi There",
644 "9294727a3638bb1c13f48ef8158bfc9d");
645 do_KAT_HMAC_str_str(&br_md5_vtable,
646 "Jefe",
647 "what do ya want for nothing?",
648 "750c783e6ab0b503eaa86e310a5db738");
649 do_KAT_HMAC_hex_hex(&br_md5_vtable,
650 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
651 "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD",
652 "56be34521d144c88dbb8c733f0e8b3f6");
653 do_KAT_HMAC_hex_hex(&br_md5_vtable,
654 "0102030405060708090a0b0c0d0e0f10111213141516171819",
655 "CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD",
656 "697eaf0aca3a3aea3a75164746ffaa79");
657 do_KAT_HMAC_hex_str(&br_md5_vtable,
658 "0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c",
659 "Test With Truncation",
660 "56461ef2342edc00f9bab995690efd4c");
661 do_KAT_HMAC_hex_str(&br_md5_vtable,
662 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
663 "Test Using Larger Than Block-Size Key - Hash Key First",
664 "6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd");
665 do_KAT_HMAC_hex_str(&br_md5_vtable,
666 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
667 "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data",
668 "6f630fad67cda0ee1fb1f562db3aa53e");
669
670 do_KAT_HMAC_hex_str(&br_sha1_vtable,
671 "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b",
672 "Hi There",
673 "b617318655057264e28bc0b6fb378c8ef146be00");
674 do_KAT_HMAC_str_str(&br_sha1_vtable,
675 "Jefe",
676 "what do ya want for nothing?",
677 "effcdf6ae5eb2fa2d27416d5f184df9c259a7c79");
678 do_KAT_HMAC_hex_hex(&br_sha1_vtable,
679 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
680 "DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD",
681 "125d7342b9ac11cd91a39af48aa17b4f63f175d3");
682 do_KAT_HMAC_hex_hex(&br_sha1_vtable,
683 "0102030405060708090a0b0c0d0e0f10111213141516171819",
684 "CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD",
685 "4c9007f4026250c6bc8414f9bf50c86c2d7235da");
686 do_KAT_HMAC_hex_str(&br_sha1_vtable,
687 "0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c",
688 "Test With Truncation",
689 "4c1a03424b55e07fe7f27be1d58bb9324a9a5a04");
690 do_KAT_HMAC_hex_str(&br_sha1_vtable,
691 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
692 "Test Using Larger Than Block-Size Key - Hash Key First",
693 "aa4ae5e15272d00e95705637ce8a3b55ed402112");
694 do_KAT_HMAC_hex_str(&br_sha1_vtable,
695 "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
696 "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data",
697 "e8e99d0f45237d786d6bbaa7965c7808bbff1a91");
698
699 /* From RFC 4231 */
700
701 do_KAT_HMAC_hex_hex(&br_sha224_vtable,
702 "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b",
703 "4869205468657265",
704 "896fb1128abbdf196832107cd49df33f"
705 "47b4b1169912ba4f53684b22");
706
707 do_KAT_HMAC_hex_hex(&br_sha256_vtable,
708 "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b",
709 "4869205468657265",
710 "b0344c61d8db38535ca8afceaf0bf12b"
711 "881dc200c9833da726e9376c2e32cff7");
712
713 do_KAT_HMAC_hex_hex(&br_sha384_vtable,
714 "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b",
715 "4869205468657265",
716 "afd03944d84895626b0825f4ab46907f"
717 "15f9dadbe4101ec682aa034c7cebc59c"
718 "faea9ea9076ede7f4af152e8b2fa9cb6");
719
720 do_KAT_HMAC_hex_hex(&br_sha512_vtable,
721 "0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b",
722 "4869205468657265",
723 "87aa7cdea5ef619d4ff0b4241a1d6cb0"
724 "2379f4e2ce4ec2787ad0b30545e17cde"
725 "daa833b7d6b8a702038b274eaea3f4e4"
726 "be9d914eeb61f1702e696c203a126854");
727
728 do_KAT_HMAC_hex_hex(&br_sha224_vtable,
729 "4a656665",
730 "7768617420646f2079612077616e7420"
731 "666f72206e6f7468696e673f",
732 "a30e01098bc6dbbf45690f3a7e9e6d0f"
733 "8bbea2a39e6148008fd05e44");
734
735 do_KAT_HMAC_hex_hex(&br_sha256_vtable,
736 "4a656665",
737 "7768617420646f2079612077616e7420"
738 "666f72206e6f7468696e673f",
739 "5bdcc146bf60754e6a042426089575c7"
740 "5a003f089d2739839dec58b964ec3843");
741
742 do_KAT_HMAC_hex_hex(&br_sha384_vtable,
743 "4a656665",
744 "7768617420646f2079612077616e7420"
745 "666f72206e6f7468696e673f",
746 "af45d2e376484031617f78d2b58a6b1b"
747 "9c7ef464f5a01b47e42ec3736322445e"
748 "8e2240ca5e69e2c78b3239ecfab21649");
749
750 do_KAT_HMAC_hex_hex(&br_sha512_vtable,
751 "4a656665",
752 "7768617420646f2079612077616e7420"
753 "666f72206e6f7468696e673f",
754 "164b7a7bfcf819e2e395fbe73b56e0a3"
755 "87bd64222e831fd610270cd7ea250554"
756 "9758bf75c05a994a6d034f65f8f0e6fd"
757 "caeab1a34d4a6b4b636e070a38bce737");
758
759 do_KAT_HMAC_hex_hex(&br_sha224_vtable,
760 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
761 "aaaaaaaa",
762 "dddddddddddddddddddddddddddddddd"
763 "dddddddddddddddddddddddddddddddd"
764 "dddddddddddddddddddddddddddddddd"
765 "dddd",
766 "7fb3cb3588c6c1f6ffa9694d7d6ad264"
767 "9365b0c1f65d69d1ec8333ea");
768
769 do_KAT_HMAC_hex_hex(&br_sha256_vtable,
770 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
771 "aaaaaaaa",
772 "dddddddddddddddddddddddddddddddd"
773 "dddddddddddddddddddddddddddddddd"
774 "dddddddddddddddddddddddddddddddd"
775 "dddd",
776 "773ea91e36800e46854db8ebd09181a7"
777 "2959098b3ef8c122d9635514ced565fe");
778
779 do_KAT_HMAC_hex_hex(&br_sha384_vtable,
780 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
781 "aaaaaaaa",
782 "dddddddddddddddddddddddddddddddd"
783 "dddddddddddddddddddddddddddddddd"
784 "dddddddddddddddddddddddddddddddd"
785 "dddd",
786 "88062608d3e6ad8a0aa2ace014c8a86f"
787 "0aa635d947ac9febe83ef4e55966144b"
788 "2a5ab39dc13814b94e3ab6e101a34f27");
789
790 do_KAT_HMAC_hex_hex(&br_sha512_vtable,
791 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
792 "aaaaaaaa",
793 "dddddddddddddddddddddddddddddddd"
794 "dddddddddddddddddddddddddddddddd"
795 "dddddddddddddddddddddddddddddddd"
796 "dddd",
797 "fa73b0089d56a284efb0f0756c890be9"
798 "b1b5dbdd8ee81a3655f83e33b2279d39"
799 "bf3e848279a722c806b485a47e67c807"
800 "b946a337bee8942674278859e13292fb");
801
802 do_KAT_HMAC_hex_hex(&br_sha224_vtable,
803 "0102030405060708090a0b0c0d0e0f10"
804 "111213141516171819",
805 "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
806 "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
807 "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
808 "cdcd",
809 "6c11506874013cac6a2abc1bb382627c"
810 "ec6a90d86efc012de7afec5a");
811
812 do_KAT_HMAC_hex_hex(&br_sha256_vtable,
813 "0102030405060708090a0b0c0d0e0f10"
814 "111213141516171819",
815 "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
816 "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
817 "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
818 "cdcd",
819 "82558a389a443c0ea4cc819899f2083a"
820 "85f0faa3e578f8077a2e3ff46729665b");
821
822 do_KAT_HMAC_hex_hex(&br_sha384_vtable,
823 "0102030405060708090a0b0c0d0e0f10"
824 "111213141516171819",
825 "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
826 "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
827 "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
828 "cdcd",
829 "3e8a69b7783c25851933ab6290af6ca7"
830 "7a9981480850009cc5577c6e1f573b4e"
831 "6801dd23c4a7d679ccf8a386c674cffb");
832
833 do_KAT_HMAC_hex_hex(&br_sha512_vtable,
834 "0102030405060708090a0b0c0d0e0f10"
835 "111213141516171819",
836 "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
837 "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
838 "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd"
839 "cdcd",
840 "b0ba465637458c6990e5a8c5f61d4af7"
841 "e576d97ff94b872de76f8050361ee3db"
842 "a91ca5c11aa25eb4d679275cc5788063"
843 "a5f19741120c4f2de2adebeb10a298dd");
844
845 do_KAT_HMAC_hex_hex(&br_sha224_vtable,
846 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
847 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
848 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
849 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
850 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
851 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
852 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
853 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
854 "aaaaaa",
855 "54657374205573696e67204c61726765"
856 "72205468616e20426c6f636b2d53697a"
857 "65204b6579202d2048617368204b6579"
858 "204669727374",
859 "95e9a0db962095adaebe9b2d6f0dbce2"
860 "d499f112f2d2b7273fa6870e");
861
862 do_KAT_HMAC_hex_hex(&br_sha256_vtable,
863 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
864 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
865 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
866 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
867 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
868 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
869 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
870 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
871 "aaaaaa",
872 "54657374205573696e67204c61726765"
873 "72205468616e20426c6f636b2d53697a"
874 "65204b6579202d2048617368204b6579"
875 "204669727374",
876 "60e431591ee0b67f0d8a26aacbf5b77f"
877 "8e0bc6213728c5140546040f0ee37f54");
878
879 do_KAT_HMAC_hex_hex(&br_sha384_vtable,
880 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
881 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
882 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
883 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
884 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
885 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
886 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
887 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
888 "aaaaaa",
889 "54657374205573696e67204c61726765"
890 "72205468616e20426c6f636b2d53697a"
891 "65204b6579202d2048617368204b6579"
892 "204669727374",
893 "4ece084485813e9088d2c63a041bc5b4"
894 "4f9ef1012a2b588f3cd11f05033ac4c6"
895 "0c2ef6ab4030fe8296248df163f44952");
896
897 do_KAT_HMAC_hex_hex(&br_sha512_vtable,
898 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
899 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
900 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
901 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
902 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
903 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
904 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
905 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
906 "aaaaaa",
907 "54657374205573696e67204c61726765"
908 "72205468616e20426c6f636b2d53697a"
909 "65204b6579202d2048617368204b6579"
910 "204669727374",
911 "80b24263c7c1a3ebb71493c1dd7be8b4"
912 "9b46d1f41b4aeec1121b013783f8f352"
913 "6b56d037e05f2598bd0fd2215d6a1e52"
914 "95e64f73f63f0aec8b915a985d786598");
915
916 do_KAT_HMAC_hex_hex(&br_sha224_vtable,
917 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
918 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
919 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
920 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
921 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
922 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
923 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
924 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
925 "aaaaaa",
926 "54686973206973206120746573742075"
927 "73696e672061206c6172676572207468"
928 "616e20626c6f636b2d73697a65206b65"
929 "7920616e642061206c61726765722074"
930 "68616e20626c6f636b2d73697a652064"
931 "6174612e20546865206b6579206e6565"
932 "647320746f2062652068617368656420"
933 "6265666f7265206265696e6720757365"
934 "642062792074686520484d414320616c"
935 "676f726974686d2e",
936 "3a854166ac5d9f023f54d517d0b39dbd"
937 "946770db9c2b95c9f6f565d1");
938
939 do_KAT_HMAC_hex_hex(&br_sha256_vtable,
940 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
941 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
942 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
943 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
944 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
945 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
946 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
947 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
948 "aaaaaa",
949 "54686973206973206120746573742075"
950 "73696e672061206c6172676572207468"
951 "616e20626c6f636b2d73697a65206b65"
952 "7920616e642061206c61726765722074"
953 "68616e20626c6f636b2d73697a652064"
954 "6174612e20546865206b6579206e6565"
955 "647320746f2062652068617368656420"
956 "6265666f7265206265696e6720757365"
957 "642062792074686520484d414320616c"
958 "676f726974686d2e",
959 "9b09ffa71b942fcb27635fbcd5b0e944"
960 "bfdc63644f0713938a7f51535c3a35e2");
961
962 do_KAT_HMAC_hex_hex(&br_sha384_vtable,
963 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
964 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
965 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
966 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
967 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
968 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
969 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
970 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
971 "aaaaaa",
972 "54686973206973206120746573742075"
973 "73696e672061206c6172676572207468"
974 "616e20626c6f636b2d73697a65206b65"
975 "7920616e642061206c61726765722074"
976 "68616e20626c6f636b2d73697a652064"
977 "6174612e20546865206b6579206e6565"
978 "647320746f2062652068617368656420"
979 "6265666f7265206265696e6720757365"
980 "642062792074686520484d414320616c"
981 "676f726974686d2e",
982 "6617178e941f020d351e2f254e8fd32c"
983 "602420feb0b8fb9adccebb82461e99c5"
984 "a678cc31e799176d3860e6110c46523e");
985
986 do_KAT_HMAC_hex_hex(&br_sha512_vtable,
987 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
988 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
989 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
990 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
991 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
992 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
993 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
994 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
995 "aaaaaa",
996 "54686973206973206120746573742075"
997 "73696e672061206c6172676572207468"
998 "616e20626c6f636b2d73697a65206b65"
999 "7920616e642061206c61726765722074"
1000 "68616e20626c6f636b2d73697a652064"
1001 "6174612e20546865206b6579206e6565"
1002 "647320746f2062652068617368656420"
1003 "6265666f7265206265696e6720757365"
1004 "642062792074686520484d414320616c"
1005 "676f726974686d2e",
1006 "e37b6a775dc87dbaa4dfa9f96e5e3ffd"
1007 "debd71f8867289865df5a32d20cdc944"
1008 "b6022cac3c4982b10d5eeb55c3e4de15"
1009 "134676fb6de0446065c97440fa8c6a58");
1010
1011 for (x = 1, u = 0; u < sizeof data; u ++) {
1012 data[u] = x;
1013 x = (x * 45) % 257;
1014 }
1015 printf("(MD5) ");
1016 test_HMAC_CT(&br_md5_vtable, key, sizeof key, data);
1017 printf("(SHA-1) ");
1018 test_HMAC_CT(&br_sha1_vtable, key, sizeof key, data);
1019 printf("(SHA-224) ");
1020 test_HMAC_CT(&br_sha224_vtable, key, sizeof key, data);
1021 printf("(SHA-256) ");
1022 test_HMAC_CT(&br_sha256_vtable, key, sizeof key, data);
1023 printf("(SHA-384) ");
1024 test_HMAC_CT(&br_sha384_vtable, key, sizeof key, data);
1025 printf("(SHA-512) ");
1026 test_HMAC_CT(&br_sha512_vtable, key, sizeof key, data);
1027
1028 printf("done.\n");
1029 fflush(stdout);
1030 }
1031
1032 static void
1033 test_HMAC_DRBG(void)
1034 {
1035 br_hmac_drbg_context ctx;
1036 unsigned char seed[42], tmp[30];
1037 unsigned char ref1[30], ref2[30], ref3[30];
1038 size_t seed_len;
1039
1040 printf("Test HMAC_DRBG: ");
1041 fflush(stdout);
1042
1043 seed_len = hextobin(seed,
1044 "009A4D6792295A7F730FC3F2B49CBC0F62E862272F"
1045 "01795EDF0D54DB760F156D0DAC04C0322B3A204224");
1046 hextobin(ref1,
1047 "9305A46DE7FF8EB107194DEBD3FD48AA"
1048 "20D5E7656CBE0EA69D2A8D4E7C67");
1049 hextobin(ref2,
1050 "C70C78608A3B5BE9289BE90EF6E81A9E"
1051 "2C1516D5751D2F75F50033E45F73");
1052 hextobin(ref3,
1053 "475E80E992140567FCC3A50DAB90FE84"
1054 "BCD7BB03638E9C4656A06F37F650");
1055 br_hmac_drbg_init(&ctx, &br_sha256_vtable, seed, seed_len);
1056 br_hmac_drbg_generate(&ctx, tmp, sizeof tmp);
1057 check_equals("KAT HMAC_DRBG 1", tmp, ref1, sizeof tmp);
1058 br_hmac_drbg_generate(&ctx, tmp, sizeof tmp);
1059 check_equals("KAT HMAC_DRBG 2", tmp, ref2, sizeof tmp);
1060 br_hmac_drbg_generate(&ctx, tmp, sizeof tmp);
1061 check_equals("KAT HMAC_DRBG 3", tmp, ref3, sizeof tmp);
1062
1063 memset(&ctx, 0, sizeof ctx);
1064 br_hmac_drbg_vtable.init(&ctx.vtable,
1065 &br_sha256_vtable, seed, seed_len);
1066 ctx.vtable->generate(&ctx.vtable, tmp, sizeof tmp);
1067 check_equals("KAT HMAC_DRBG 4", tmp, ref1, sizeof tmp);
1068 ctx.vtable->generate(&ctx.vtable, tmp, sizeof tmp);
1069 check_equals("KAT HMAC_DRBG 5", tmp, ref2, sizeof tmp);
1070 ctx.vtable->generate(&ctx.vtable, tmp, sizeof tmp);
1071 check_equals("KAT HMAC_DRBG 6", tmp, ref3, sizeof tmp);
1072
1073 printf("done.\n");
1074 fflush(stdout);
1075 }
1076
1077 static void
1078 do_KAT_PRF(
1079 void (*prf)(void *dst, size_t len,
1080 const void *secret, size_t secret_len,
1081 const char *label, const void *seed, size_t seed_len),
1082 const char *ssecret, const char *label, const char *sseed,
1083 const char *sref)
1084 {
1085 unsigned char secret[100], seed[100], ref[500], out[500];
1086 size_t secret_len, seed_len, ref_len;
1087
1088 secret_len = hextobin(secret, ssecret);
1089 seed_len = hextobin(seed, sseed);
1090 ref_len = hextobin(ref, sref);
1091 prf(out, ref_len, secret, secret_len, label, seed, seed_len);
1092 check_equals("TLS PRF KAT", out, ref, ref_len);
1093 }
1094
1095 static void
1096 test_PRF(void)
1097 {
1098 printf("Test TLS PRF: ");
1099 fflush(stdout);
1100
1101 /*
1102 * Test vector taken from an email that was on:
1103 * http://www.imc.org/ietf-tls/mail-archive/msg01589.html
1104 * but no longer exists there; a version archived in 2008
1105 * can be found on http://www.archive.org/
1106 */
1107 do_KAT_PRF(&br_tls10_prf,
1108 "abababababababababababababababababababababababababababababababababababababababababababababababab",
1109 "PRF Testvector",
1110 "cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd",
1111 "d3d4d1e349b5d515044666d51de32bab258cb521b6b053463e354832fd976754443bcf9a296519bc289abcbc1187e4ebd31e602353776c408aafb74cbc85eff69255f9788faa184cbb957a9819d84a5d7eb006eb459d3ae8de9810454b8b2d8f1afbc655a8c9a013");
1112
1113 /*
1114 * Test vectors are taken from:
1115 * https://www.ietf.org/mail-archive/web/tls/current/msg03416.html
1116 */
1117 do_KAT_PRF(&br_tls12_sha256_prf,
1118 "9bbe436ba940f017b17652849a71db35",
1119 "test label",
1120 "a0ba9f936cda311827a6f796ffd5198c",
1121 "e3f229ba727be17b8d122620557cd453c2aab21d07c3d495329b52d4e61edb5a6b301791e90d35c9c9a46b4e14baf9af0fa022f7077def17abfd3797c0564bab4fbc91666e9def9b97fce34f796789baa48082d122ee42c5a72e5a5110fff70187347b66");
1122 do_KAT_PRF(&br_tls12_sha384_prf,
1123 "b80b733d6ceefcdc71566ea48e5567df",
1124 "test label",
1125 "cd665cf6a8447dd6ff8b27555edb7465",
1126 "7b0c18e9ced410ed1804f2cfa34a336a1c14dffb4900bb5fd7942107e81c83cde9ca0faa60be9fe34f82b1233c9146a0e534cb400fed2700884f9dc236f80edd8bfa961144c9e8d792eca722a7b32fc3d416d473ebc2c5fd4abfdad05d9184259b5bf8cd4d90fa0d31e2dec479e4f1a26066f2eea9a69236a3e52655c9e9aee691c8f3a26854308d5eaa3be85e0990703d73e56f");
1127
1128 printf("done.\n");
1129 fflush(stdout);
1130 }
1131
1132 /*
1133 * AES known-answer tests. Order: key, plaintext, ciphertext.
1134 */
1135 static const char *const KAT_AES[] = {
1136 /*
1137 * From FIPS-197.
1138 */
1139 "000102030405060708090a0b0c0d0e0f",
1140 "00112233445566778899aabbccddeeff",
1141 "69c4e0d86a7b0430d8cdb78070b4c55a",
1142
1143 "000102030405060708090a0b0c0d0e0f1011121314151617",
1144 "00112233445566778899aabbccddeeff",
1145 "dda97ca4864cdfe06eaf70a0ec0d7191",
1146
1147 "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
1148 "00112233445566778899aabbccddeeff",
1149 "8ea2b7ca516745bfeafc49904b496089",
1150
1151 /*
1152 * From NIST validation suite (ECBVarTxt128.rsp).
1153 */
1154 "00000000000000000000000000000000",
1155 "80000000000000000000000000000000",
1156 "3ad78e726c1ec02b7ebfe92b23d9ec34",
1157
1158 "00000000000000000000000000000000",
1159 "c0000000000000000000000000000000",
1160 "aae5939c8efdf2f04e60b9fe7117b2c2",
1161
1162 "00000000000000000000000000000000",
1163 "e0000000000000000000000000000000",
1164 "f031d4d74f5dcbf39daaf8ca3af6e527",
1165
1166 "00000000000000000000000000000000",
1167 "f0000000000000000000000000000000",
1168 "96d9fd5cc4f07441727df0f33e401a36",
1169
1170 "00000000000000000000000000000000",
1171 "f8000000000000000000000000000000",
1172 "30ccdb044646d7e1f3ccea3dca08b8c0",
1173
1174 "00000000000000000000000000000000",
1175 "fc000000000000000000000000000000",
1176 "16ae4ce5042a67ee8e177b7c587ecc82",
1177
1178 "00000000000000000000000000000000",
1179 "fe000000000000000000000000000000",
1180 "b6da0bb11a23855d9c5cb1b4c6412e0a",
1181
1182 "00000000000000000000000000000000",
1183 "ff000000000000000000000000000000",
1184 "db4f1aa530967d6732ce4715eb0ee24b",
1185
1186 "00000000000000000000000000000000",
1187 "ff800000000000000000000000000000",
1188 "a81738252621dd180a34f3455b4baa2f",
1189
1190 "00000000000000000000000000000000",
1191 "ffc00000000000000000000000000000",
1192 "77e2b508db7fd89234caf7939ee5621a",
1193
1194 "00000000000000000000000000000000",
1195 "ffe00000000000000000000000000000",
1196 "b8499c251f8442ee13f0933b688fcd19",
1197
1198 "00000000000000000000000000000000",
1199 "fff00000000000000000000000000000",
1200 "965135f8a81f25c9d630b17502f68e53",
1201
1202 "00000000000000000000000000000000",
1203 "fff80000000000000000000000000000",
1204 "8b87145a01ad1c6cede995ea3670454f",
1205
1206 "00000000000000000000000000000000",
1207 "fffc0000000000000000000000000000",
1208 "8eae3b10a0c8ca6d1d3b0fa61e56b0b2",
1209
1210 "00000000000000000000000000000000",
1211 "fffe0000000000000000000000000000",
1212 "64b4d629810fda6bafdf08f3b0d8d2c5",
1213
1214 "00000000000000000000000000000000",
1215 "ffff0000000000000000000000000000",
1216 "d7e5dbd3324595f8fdc7d7c571da6c2a",
1217
1218 "00000000000000000000000000000000",
1219 "ffff8000000000000000000000000000",
1220 "f3f72375264e167fca9de2c1527d9606",
1221
1222 "00000000000000000000000000000000",
1223 "ffffc000000000000000000000000000",
1224 "8ee79dd4f401ff9b7ea945d86666c13b",
1225
1226 "00000000000000000000000000000000",
1227 "ffffe000000000000000000000000000",
1228 "dd35cea2799940b40db3f819cb94c08b",
1229
1230 "00000000000000000000000000000000",
1231 "fffff000000000000000000000000000",
1232 "6941cb6b3e08c2b7afa581ebdd607b87",
1233
1234 "00000000000000000000000000000000",
1235 "fffff800000000000000000000000000",
1236 "2c20f439f6bb097b29b8bd6d99aad799",
1237
1238 "00000000000000000000000000000000",
1239 "fffffc00000000000000000000000000",
1240 "625d01f058e565f77ae86378bd2c49b3",
1241
1242 "00000000000000000000000000000000",
1243 "fffffe00000000000000000000000000",
1244 "c0b5fd98190ef45fbb4301438d095950",
1245
1246 "00000000000000000000000000000000",
1247 "ffffff00000000000000000000000000",
1248 "13001ff5d99806efd25da34f56be854b",
1249
1250 "00000000000000000000000000000000",
1251 "ffffff80000000000000000000000000",
1252 "3b594c60f5c8277a5113677f94208d82",
1253
1254 "00000000000000000000000000000000",
1255 "ffffffc0000000000000000000000000",
1256 "e9c0fc1818e4aa46bd2e39d638f89e05",
1257
1258 "00000000000000000000000000000000",
1259 "ffffffe0000000000000000000000000",
1260 "f8023ee9c3fdc45a019b4e985c7e1a54",
1261
1262 "00000000000000000000000000000000",
1263 "fffffff0000000000000000000000000",
1264 "35f40182ab4662f3023baec1ee796b57",
1265
1266 "00000000000000000000000000000000",
1267 "fffffff8000000000000000000000000",
1268 "3aebbad7303649b4194a6945c6cc3694",
1269
1270 "00000000000000000000000000000000",
1271 "fffffffc000000000000000000000000",
1272 "a2124bea53ec2834279bed7f7eb0f938",
1273
1274 "00000000000000000000000000000000",
1275 "fffffffe000000000000000000000000",
1276 "b9fb4399fa4facc7309e14ec98360b0a",
1277
1278 "00000000000000000000000000000000",
1279 "ffffffff000000000000000000000000",
1280 "c26277437420c5d634f715aea81a9132",
1281
1282 "00000000000000000000000000000000",
1283 "ffffffff800000000000000000000000",
1284 "171a0e1b2dd424f0e089af2c4c10f32f",
1285
1286 "00000000000000000000000000000000",
1287 "ffffffffc00000000000000000000000",
1288 "7cadbe402d1b208fe735edce00aee7ce",
1289
1290 "00000000000000000000000000000000",
1291 "ffffffffe00000000000000000000000",
1292 "43b02ff929a1485af6f5c6d6558baa0f",
1293
1294 "00000000000000000000000000000000",
1295 "fffffffff00000000000000000000000",
1296 "092faacc9bf43508bf8fa8613ca75dea",
1297
1298 "00000000000000000000000000000000",
1299 "fffffffff80000000000000000000000",
1300 "cb2bf8280f3f9742c7ed513fe802629c",
1301
1302 "00000000000000000000000000000000",
1303 "fffffffffc0000000000000000000000",
1304 "215a41ee442fa992a6e323986ded3f68",
1305
1306 "00000000000000000000000000000000",
1307 "fffffffffe0000000000000000000000",
1308 "f21e99cf4f0f77cea836e11a2fe75fb1",
1309
1310 "00000000000000000000000000000000",
1311 "ffffffffff0000000000000000000000",
1312 "95e3a0ca9079e646331df8b4e70d2cd6",
1313
1314 "00000000000000000000000000000000",
1315 "ffffffffff8000000000000000000000",
1316 "4afe7f120ce7613f74fc12a01a828073",
1317
1318 "00000000000000000000000000000000",
1319 "ffffffffffc000000000000000000000",
1320 "827f000e75e2c8b9d479beed913fe678",
1321
1322 "00000000000000000000000000000000",
1323 "ffffffffffe000000000000000000000",
1324 "35830c8e7aaefe2d30310ef381cbf691",
1325
1326 "00000000000000000000000000000000",
1327 "fffffffffff000000000000000000000",
1328 "191aa0f2c8570144f38657ea4085ebe5",
1329
1330 "00000000000000000000000000000000",
1331 "fffffffffff800000000000000000000",
1332 "85062c2c909f15d9269b6c18ce99c4f0",
1333
1334 "00000000000000000000000000000000",
1335 "fffffffffffc00000000000000000000",
1336 "678034dc9e41b5a560ed239eeab1bc78",
1337
1338 "00000000000000000000000000000000",
1339 "fffffffffffe00000000000000000000",
1340 "c2f93a4ce5ab6d5d56f1b93cf19911c1",
1341
1342 "00000000000000000000000000000000",
1343 "ffffffffffff00000000000000000000",
1344 "1c3112bcb0c1dcc749d799743691bf82",
1345
1346 "00000000000000000000000000000000",
1347 "ffffffffffff80000000000000000000",
1348 "00c55bd75c7f9c881989d3ec1911c0d4",
1349
1350 "00000000000000000000000000000000",
1351 "ffffffffffffc0000000000000000000",
1352 "ea2e6b5ef182b7dff3629abd6a12045f",
1353
1354 "00000000000000000000000000000000",
1355 "ffffffffffffe0000000000000000000",
1356 "22322327e01780b17397f24087f8cc6f",
1357
1358 "00000000000000000000000000000000",
1359 "fffffffffffff0000000000000000000",
1360 "c9cacb5cd11692c373b2411768149ee7",
1361
1362 "00000000000000000000000000000000",
1363 "fffffffffffff8000000000000000000",
1364 "a18e3dbbca577860dab6b80da3139256",
1365
1366 "00000000000000000000000000000000",
1367 "fffffffffffffc000000000000000000",
1368 "79b61c37bf328ecca8d743265a3d425c",
1369
1370 "00000000000000000000000000000000",
1371 "fffffffffffffe000000000000000000",
1372 "d2d99c6bcc1f06fda8e27e8ae3f1ccc7",
1373
1374 "00000000000000000000000000000000",
1375 "ffffffffffffff000000000000000000",
1376 "1bfd4b91c701fd6b61b7f997829d663b",
1377
1378 "00000000000000000000000000000000",
1379 "ffffffffffffff800000000000000000",
1380 "11005d52f25f16bdc9545a876a63490a",
1381
1382 "00000000000000000000000000000000",
1383 "ffffffffffffffc00000000000000000",
1384 "3a4d354f02bb5a5e47d39666867f246a",
1385
1386 "00000000000000000000000000000000",
1387 "ffffffffffffffe00000000000000000",
1388 "d451b8d6e1e1a0ebb155fbbf6e7b7dc3",
1389
1390 "00000000000000000000000000000000",
1391 "fffffffffffffff00000000000000000",
1392 "6898d4f42fa7ba6a10ac05e87b9f2080",
1393
1394 "00000000000000000000000000000000",
1395 "fffffffffffffff80000000000000000",
1396 "b611295e739ca7d9b50f8e4c0e754a3f",
1397
1398 "00000000000000000000000000000000",
1399 "fffffffffffffffc0000000000000000",
1400 "7d33fc7d8abe3ca1936759f8f5deaf20",
1401
1402 "00000000000000000000000000000000",
1403 "fffffffffffffffe0000000000000000",
1404 "3b5e0f566dc96c298f0c12637539b25c",
1405
1406 "00000000000000000000000000000000",
1407 "ffffffffffffffff0000000000000000",
1408 "f807c3e7985fe0f5a50e2cdb25c5109e",
1409
1410 "00000000000000000000000000000000",
1411 "ffffffffffffffff8000000000000000",
1412 "41f992a856fb278b389a62f5d274d7e9",
1413
1414 "00000000000000000000000000000000",
1415 "ffffffffffffffffc000000000000000",
1416 "10d3ed7a6fe15ab4d91acbc7d0767ab1",
1417
1418 "00000000000000000000000000000000",
1419 "ffffffffffffffffe000000000000000",
1420 "21feecd45b2e675973ac33bf0c5424fc",
1421
1422 "00000000000000000000000000000000",
1423 "fffffffffffffffff000000000000000",
1424 "1480cb3955ba62d09eea668f7c708817",
1425
1426 "00000000000000000000000000000000",
1427 "fffffffffffffffff800000000000000",
1428 "66404033d6b72b609354d5496e7eb511",
1429
1430 "00000000000000000000000000000000",
1431 "fffffffffffffffffc00000000000000",
1432 "1c317a220a7d700da2b1e075b00266e1",
1433
1434 "00000000000000000000000000000000",
1435 "fffffffffffffffffe00000000000000",
1436 "ab3b89542233f1271bf8fd0c0f403545",
1437
1438 "00000000000000000000000000000000",
1439 "ffffffffffffffffff00000000000000",
1440 "d93eae966fac46dca927d6b114fa3f9e",
1441
1442 "00000000000000000000000000000000",
1443 "ffffffffffffffffff80000000000000",
1444 "1bdec521316503d9d5ee65df3ea94ddf",
1445
1446 "00000000000000000000000000000000",
1447 "ffffffffffffffffffc0000000000000",
1448 "eef456431dea8b4acf83bdae3717f75f",
1449
1450 "00000000000000000000000000000000",
1451 "ffffffffffffffffffe0000000000000",
1452 "06f2519a2fafaa596bfef5cfa15c21b9",
1453
1454 "00000000000000000000000000000000",
1455 "fffffffffffffffffff0000000000000",
1456 "251a7eac7e2fe809e4aa8d0d7012531a",
1457
1458 "00000000000000000000000000000000",
1459 "fffffffffffffffffff8000000000000",
1460 "3bffc16e4c49b268a20f8d96a60b4058",
1461
1462 "00000000000000000000000000000000",
1463 "fffffffffffffffffffc000000000000",
1464 "e886f9281999c5bb3b3e8862e2f7c988",
1465
1466 "00000000000000000000000000000000",
1467 "fffffffffffffffffffe000000000000",
1468 "563bf90d61beef39f48dd625fcef1361",
1469
1470 "00000000000000000000000000000000",
1471 "ffffffffffffffffffff000000000000",
1472 "4d37c850644563c69fd0acd9a049325b",
1473
1474 "00000000000000000000000000000000",
1475 "ffffffffffffffffffff800000000000",
1476 "b87c921b91829ef3b13ca541ee1130a6",
1477
1478 "00000000000000000000000000000000",
1479 "ffffffffffffffffffffc00000000000",
1480 "2e65eb6b6ea383e109accce8326b0393",
1481
1482 "00000000000000000000000000000000",
1483 "ffffffffffffffffffffe00000000000",
1484 "9ca547f7439edc3e255c0f4d49aa8990",
1485
1486 "00000000000000000000000000000000",
1487 "fffffffffffffffffffff00000000000",
1488 "a5e652614c9300f37816b1f9fd0c87f9",
1489
1490 "00000000000000000000000000000000",
1491 "fffffffffffffffffffff80000000000",
1492 "14954f0b4697776f44494fe458d814ed",
1493
1494 "00000000000000000000000000000000",
1495 "fffffffffffffffffffffc0000000000",
1496 "7c8d9ab6c2761723fe42f8bb506cbcf7",
1497
1498 "00000000000000000000000000000000",
1499 "fffffffffffffffffffffe0000000000",
1500 "db7e1932679fdd99742aab04aa0d5a80",
1501
1502 "00000000000000000000000000000000",
1503 "ffffffffffffffffffffff0000000000",
1504 "4c6a1c83e568cd10f27c2d73ded19c28",
1505
1506 "00000000000000000000000000000000",
1507 "ffffffffffffffffffffff8000000000",
1508 "90ecbe6177e674c98de412413f7ac915",
1509
1510 "00000000000000000000000000000000",
1511 "ffffffffffffffffffffffc000000000",
1512 "90684a2ac55fe1ec2b8ebd5622520b73",
1513
1514 "00000000000000000000000000000000",
1515 "ffffffffffffffffffffffe000000000",
1516 "7472f9a7988607ca79707795991035e6",
1517
1518 "00000000000000000000000000000000",
1519 "fffffffffffffffffffffff000000000",
1520 "56aff089878bf3352f8df172a3ae47d8",
1521
1522 "00000000000000000000000000000000",
1523 "fffffffffffffffffffffff800000000",
1524 "65c0526cbe40161b8019a2a3171abd23",
1525
1526 "00000000000000000000000000000000",
1527 "fffffffffffffffffffffffc00000000",
1528 "377be0be33b4e3e310b4aabda173f84f",
1529
1530 "00000000000000000000000000000000",
1531 "fffffffffffffffffffffffe00000000",
1532 "9402e9aa6f69de6504da8d20c4fcaa2f",
1533
1534 "00000000000000000000000000000000",
1535 "ffffffffffffffffffffffff00000000",
1536 "123c1f4af313ad8c2ce648b2e71fb6e1",
1537
1538 "00000000000000000000000000000000",
1539 "ffffffffffffffffffffffff80000000",
1540 "1ffc626d30203dcdb0019fb80f726cf4",
1541
1542 "00000000000000000000000000000000",
1543 "ffffffffffffffffffffffffc0000000",
1544 "76da1fbe3a50728c50fd2e621b5ad885",
1545
1546 "00000000000000000000000000000000",
1547 "ffffffffffffffffffffffffe0000000",
1548 "082eb8be35f442fb52668e16a591d1d6",
1549
1550 "00000000000000000000000000000000",
1551 "fffffffffffffffffffffffff0000000",
1552 "e656f9ecf5fe27ec3e4a73d00c282fb3",
1553
1554 "00000000000000000000000000000000",
1555 "fffffffffffffffffffffffff8000000",
1556 "2ca8209d63274cd9a29bb74bcd77683a",
1557
1558 "00000000000000000000000000000000",
1559 "fffffffffffffffffffffffffc000000",
1560 "79bf5dce14bb7dd73a8e3611de7ce026",
1561
1562 "00000000000000000000000000000000",
1563 "fffffffffffffffffffffffffe000000",
1564 "3c849939a5d29399f344c4a0eca8a576",
1565
1566 "00000000000000000000000000000000",
1567 "ffffffffffffffffffffffffff000000",
1568 "ed3c0a94d59bece98835da7aa4f07ca2",
1569
1570 "00000000000000000000000000000000",
1571 "ffffffffffffffffffffffffff800000",
1572 "63919ed4ce10196438b6ad09d99cd795",
1573
1574 "00000000000000000000000000000000",
1575 "ffffffffffffffffffffffffffc00000",
1576 "7678f3a833f19fea95f3c6029e2bc610",
1577
1578 "00000000000000000000000000000000",
1579 "ffffffffffffffffffffffffffe00000",
1580 "3aa426831067d36b92be7c5f81c13c56",
1581
1582 "00000000000000000000000000000000",
1583 "fffffffffffffffffffffffffff00000",
1584 "9272e2d2cdd11050998c845077a30ea0",
1585
1586 "00000000000000000000000000000000",
1587 "fffffffffffffffffffffffffff80000",
1588 "088c4b53f5ec0ff814c19adae7f6246c",
1589
1590 "00000000000000000000000000000000",
1591 "fffffffffffffffffffffffffffc0000",
1592 "4010a5e401fdf0a0354ddbcc0d012b17",
1593
1594 "00000000000000000000000000000000",
1595 "fffffffffffffffffffffffffffe0000",
1596 "a87a385736c0a6189bd6589bd8445a93",
1597
1598 "00000000000000000000000000000000",
1599 "ffffffffffffffffffffffffffff0000",
1600 "545f2b83d9616dccf60fa9830e9cd287",
1601
1602 "00000000000000000000000000000000",
1603 "ffffffffffffffffffffffffffff8000",
1604 "4b706f7f92406352394037a6d4f4688d",
1605
1606 "00000000000000000000000000000000",
1607 "ffffffffffffffffffffffffffffc000",
1608 "b7972b3941c44b90afa7b264bfba7387",
1609
1610 "00000000000000000000000000000000",
1611 "ffffffffffffffffffffffffffffe000",
1612 "6f45732cf10881546f0fd23896d2bb60",
1613
1614 "00000000000000000000000000000000",
1615 "fffffffffffffffffffffffffffff000",
1616 "2e3579ca15af27f64b3c955a5bfc30ba",
1617
1618 "00000000000000000000000000000000",
1619 "fffffffffffffffffffffffffffff800",
1620 "34a2c5a91ae2aec99b7d1b5fa6780447",
1621
1622 "00000000000000000000000000000000",
1623 "fffffffffffffffffffffffffffffc00",
1624 "a4d6616bd04f87335b0e53351227a9ee",
1625
1626 "00000000000000000000000000000000",
1627 "fffffffffffffffffffffffffffffe00",
1628 "7f692b03945867d16179a8cefc83ea3f",
1629
1630 "00000000000000000000000000000000",
1631 "ffffffffffffffffffffffffffffff00",
1632 "3bd141ee84a0e6414a26e7a4f281f8a2",
1633
1634 "00000000000000000000000000000000",
1635 "ffffffffffffffffffffffffffffff80",
1636 "d1788f572d98b2b16ec5d5f3922b99bc",
1637
1638 "00000000000000000000000000000000",
1639 "ffffffffffffffffffffffffffffffc0",
1640 "0833ff6f61d98a57b288e8c3586b85a6",
1641
1642 "00000000000000000000000000000000",
1643 "ffffffffffffffffffffffffffffffe0",
1644 "8568261797de176bf0b43becc6285afb",
1645
1646 "00000000000000000000000000000000",
1647 "fffffffffffffffffffffffffffffff0",
1648 "f9b0fda0c4a898f5b9e6f661c4ce4d07",
1649
1650 "00000000000000000000000000000000",
1651 "fffffffffffffffffffffffffffffff8",
1652 "8ade895913685c67c5269f8aae42983e",
1653
1654 "00000000000000000000000000000000",
1655 "fffffffffffffffffffffffffffffffc",
1656 "39bde67d5c8ed8a8b1c37eb8fa9f5ac0",
1657
1658 "00000000000000000000000000000000",
1659 "fffffffffffffffffffffffffffffffe",
1660 "5c005e72c1418c44f569f2ea33ba54f3",
1661
1662 "00000000000000000000000000000000",
1663 "ffffffffffffffffffffffffffffffff",
1664 "3f5b8cc9ea855a0afa7347d23e8d664e",
1665
1666 /*
1667 * From NIST validation suite (ECBVarTxt192.rsp).
1668 */
1669 "000000000000000000000000000000000000000000000000",
1670 "80000000000000000000000000000000",
1671 "6cd02513e8d4dc986b4afe087a60bd0c",
1672
1673 "000000000000000000000000000000000000000000000000",
1674 "c0000000000000000000000000000000",
1675 "2ce1f8b7e30627c1c4519eada44bc436",
1676
1677 "000000000000000000000000000000000000000000000000",
1678 "e0000000000000000000000000000000",
1679 "9946b5f87af446f5796c1fee63a2da24",
1680
1681 "000000000000000000000000000000000000000000000000",
1682 "f0000000000000000000000000000000",
1683 "2a560364ce529efc21788779568d5555",
1684
1685 "000000000000000000000000000000000000000000000000",
1686 "f8000000000000000000000000000000",
1687 "35c1471837af446153bce55d5ba72a0a",
1688
1689 "000000000000000000000000000000000000000000000000",
1690 "fc000000000000000000000000000000",
1691 "ce60bc52386234f158f84341e534cd9e",
1692
1693 "000000000000000000000000000000000000000000000000",
1694 "fe000000000000000000000000000000",
1695 "8c7c27ff32bcf8dc2dc57c90c2903961",
1696
1697 "000000000000000000000000000000000000000000000000",
1698 "ff000000000000000000000000000000",
1699 "32bb6a7ec84499e166f936003d55a5bb",
1700
1701 "000000000000000000000000000000000000000000000000",
1702 "ff800000000000000000000000000000",
1703 "a5c772e5c62631ef660ee1d5877f6d1b",
1704
1705 "000000000000000000000000000000000000000000000000",
1706 "ffc00000000000000000000000000000",
1707 "030d7e5b64f380a7e4ea5387b5cd7f49",
1708
1709 "000000000000000000000000000000000000000000000000",
1710 "ffe00000000000000000000000000000",
1711 "0dc9a2610037009b698f11bb7e86c83e",
1712
1713 "000000000000000000000000000000000000000000000000",
1714 "fff00000000000000000000000000000",
1715 "0046612c766d1840c226364f1fa7ed72",
1716
1717 "000000000000000000000000000000000000000000000000",
1718 "fff80000000000000000000000000000",
1719 "4880c7e08f27befe78590743c05e698b",
1720
1721 "000000000000000000000000000000000000000000000000",
1722 "fffc0000000000000000000000000000",
1723 "2520ce829a26577f0f4822c4ecc87401",
1724
1725 "000000000000000000000000000000000000000000000000",
1726 "fffe0000000000000000000000000000",
1727 "8765e8acc169758319cb46dc7bcf3dca",
1728
1729 "000000000000000000000000000000000000000000000000",
1730 "ffff0000000000000000000000000000",
1731 "e98f4ba4f073df4baa116d011dc24a28",
1732
1733 "000000000000000000000000000000000000000000000000",
1734 "ffff8000000000000000000000000000",
1735 "f378f68c5dbf59e211b3a659a7317d94",
1736
1737 "000000000000000000000000000000000000000000000000",
1738 "ffffc000000000000000000000000000",
1739 "283d3b069d8eb9fb432d74b96ca762b4",
1740
1741 "000000000000000000000000000000000000000000000000",
1742 "ffffe000000000000000000000000000",
1743 "a7e1842e8a87861c221a500883245c51",
1744
1745 "000000000000000000000000000000000000000000000000",
1746 "fffff000000000000000000000000000",
1747 "77aa270471881be070fb52c7067ce732",
1748
1749 "000000000000000000000000000000000000000000000000",
1750 "fffff800000000000000000000000000",
1751 "01b0f476d484f43f1aeb6efa9361a8ac",
1752
1753 "000000000000000000000000000000000000000000000000",
1754 "fffffc00000000000000000000000000",
1755 "1c3a94f1c052c55c2d8359aff2163b4f",
1756
1757 "000000000000000000000000000000000000000000000000",
1758 "fffffe00000000000000000000000000",
1759 "e8a067b604d5373d8b0f2e05a03b341b",
1760
1761 "000000000000000000000000000000000000000000000000",
1762 "ffffff00000000000000000000000000",
1763 "a7876ec87f5a09bfea42c77da30fd50e",
1764
1765 "000000000000000000000000000000000000000000000000",
1766 "ffffff80000000000000000000000000",
1767 "0cf3e9d3a42be5b854ca65b13f35f48d",
1768
1769 "000000000000000000000000000000000000000000000000",
1770 "ffffffc0000000000000000000000000",
1771 "6c62f6bbcab7c3e821c9290f08892dda",
1772
1773 "000000000000000000000000000000000000000000000000",
1774 "ffffffe0000000000000000000000000",
1775 "7f5e05bd2068738196fee79ace7e3aec",
1776
1777 "000000000000000000000000000000000000000000000000",
1778 "fffffff0000000000000000000000000",
1779 "440e0d733255cda92fb46e842fe58054",
1780
1781 "000000000000000000000000000000000000000000000000",
1782 "fffffff8000000000000000000000000",
1783 "aa5d5b1c4ea1b7a22e5583ac2e9ed8a7",
1784
1785 "000000000000000000000000000000000000000000000000",
1786 "fffffffc000000000000000000000000",
1787 "77e537e89e8491e8662aae3bc809421d",
1788
1789 "000000000000000000000000000000000000000000000000",
1790 "fffffffe000000000000000000000000",
1791 "997dd3e9f1598bfa73f75973f7e93b76",
1792
1793 "000000000000000000000000000000000000000000000000",
1794 "ffffffff000000000000000000000000",
1795 "1b38d4f7452afefcb7fc721244e4b72e",
1796
1797 "000000000000000000000000000000000000000000000000",
1798 "ffffffff800000000000000000000000",
1799 "0be2b18252e774dda30cdda02c6906e3",
1800
1801 "000000000000000000000000000000000000000000000000",
1802 "ffffffffc00000000000000000000000",
1803 "d2695e59c20361d82652d7d58b6f11b2",
1804
1805 "000000000000000000000000000000000000000000000000",
1806 "ffffffffe00000000000000000000000",
1807 "902d88d13eae52089abd6143cfe394e9",
1808
1809 "000000000000000000000000000000000000000000000000",
1810 "fffffffff00000000000000000000000",
1811 "d49bceb3b823fedd602c305345734bd2",
1812
1813 "000000000000000000000000000000000000000000000000",
1814 "fffffffff80000000000000000000000",
1815 "707b1dbb0ffa40ef7d95def421233fae",
1816
1817 "000000000000000000000000000000000000000000000000",
1818 "fffffffffc0000000000000000000000",
1819 "7ca0c1d93356d9eb8aa952084d75f913",
1820
1821 "000000000000000000000000000000000000000000000000",
1822 "fffffffffe0000000000000000000000",
1823 "f2cbf9cb186e270dd7bdb0c28febc57d",
1824
1825 "000000000000000000000000000000000000000000000000",
1826 "ffffffffff0000000000000000000000",
1827 "c94337c37c4e790ab45780bd9c3674a0",
1828
1829 "000000000000000000000000000000000000000000000000",
1830 "ffffffffff8000000000000000000000",
1831 "8e3558c135252fb9c9f367ed609467a1",
1832
1833 "000000000000000000000000000000000000000000000000",
1834 "ffffffffffc000000000000000000000",
1835 "1b72eeaee4899b443914e5b3a57fba92",
1836
1837 "000000000000000000000000000000000000000000000000",
1838 "ffffffffffe000000000000000000000",
1839 "011865f91bc56868d051e52c9efd59b7",
1840
1841 "000000000000000000000000000000000000000000000000",
1842 "fffffffffff000000000000000000000",
1843 "e4771318ad7a63dd680f6e583b7747ea",
1844
1845 "000000000000000000000000000000000000000000000000",
1846 "fffffffffff800000000000000000000",
1847 "61e3d194088dc8d97e9e6db37457eac5",
1848
1849 "000000000000000000000000000000000000000000000000",
1850 "fffffffffffc00000000000000000000",
1851 "36ff1ec9ccfbc349e5d356d063693ad6",
1852
1853 "000000000000000000000000000000000000000000000000",
1854 "fffffffffffe00000000000000000000",
1855 "3cc9e9a9be8cc3f6fb2ea24088e9bb19",
1856
1857 "000000000000000000000000000000000000000000000000",
1858 "ffffffffffff00000000000000000000",
1859 "1ee5ab003dc8722e74905d9a8fe3d350",
1860
1861 "000000000000000000000000000000000000000000000000",
1862 "ffffffffffff80000000000000000000",
1863 "245339319584b0a412412869d6c2eada",
1864
1865 "000000000000000000000000000000000000000000000000",
1866 "ffffffffffffc0000000000000000000",
1867 "7bd496918115d14ed5380852716c8814",
1868
1869 "000000000000000000000000000000000000000000000000",
1870 "ffffffffffffe0000000000000000000",
1871 "273ab2f2b4a366a57d582a339313c8b1",
1872
1873 "000000000000000000000000000000000000000000000000",
1874 "fffffffffffff0000000000000000000",
1875 "113365a9ffbe3b0ca61e98507554168b",
1876
1877 "000000000000000000000000000000000000000000000000",
1878 "fffffffffffff8000000000000000000",
1879 "afa99c997ac478a0dea4119c9e45f8b1",
1880
1881 "000000000000000000000000000000000000000000000000",
1882 "fffffffffffffc000000000000000000",
1883 "9216309a7842430b83ffb98638011512",
1884
1885 "000000000000000000000000000000000000000000000000",
1886 "fffffffffffffe000000000000000000",
1887 "62abc792288258492a7cb45145f4b759",
1888
1889 "000000000000000000000000000000000000000000000000",
1890 "ffffffffffffff000000000000000000",
1891 "534923c169d504d7519c15d30e756c50",
1892
1893 "000000000000000000000000000000000000000000000000",
1894 "ffffffffffffff800000000000000000",
1895 "fa75e05bcdc7e00c273fa33f6ee441d2",
1896
1897 "000000000000000000000000000000000000000000000000",
1898 "ffffffffffffffc00000000000000000",
1899 "7d350fa6057080f1086a56b17ec240db",
1900
1901 "000000000000000000000000000000000000000000000000",
1902 "ffffffffffffffe00000000000000000",
1903 "f34e4a6324ea4a5c39a661c8fe5ada8f",
1904
1905 "000000000000000000000000000000000000000000000000",
1906 "fffffffffffffff00000000000000000",
1907 "0882a16f44088d42447a29ac090ec17e",
1908
1909 "000000000000000000000000000000000000000000000000",
1910 "fffffffffffffff80000000000000000",
1911 "3a3c15bfc11a9537c130687004e136ee",
1912
1913 "000000000000000000000000000000000000000000000000",
1914 "fffffffffffffffc0000000000000000",
1915 "22c0a7678dc6d8cf5c8a6d5a9960767c",
1916
1917 "000000000000000000000000000000000000000000000000",
1918 "fffffffffffffffe0000000000000000",
1919 "b46b09809d68b9a456432a79bdc2e38c",
1920
1921 "000000000000000000000000000000000000000000000000",
1922 "ffffffffffffffff0000000000000000",
1923 "93baaffb35fbe739c17c6ac22eecf18f",
1924
1925 "000000000000000000000000000000000000000000000000",
1926 "ffffffffffffffff8000000000000000",
1927 "c8aa80a7850675bc007c46df06b49868",
1928
1929 "000000000000000000000000000000000000000000000000",
1930 "ffffffffffffffffc000000000000000",
1931 "12c6f3877af421a918a84b775858021d",
1932
1933 "000000000000000000000000000000000000000000000000",
1934 "ffffffffffffffffe000000000000000",
1935 "33f123282c5d633924f7d5ba3f3cab11",
1936
1937 "000000000000000000000000000000000000000000000000",
1938 "fffffffffffffffff000000000000000",
1939 "a8f161002733e93ca4527d22c1a0c5bb",
1940
1941 "000000000000000000000000000000000000000000000000",
1942 "fffffffffffffffff800000000000000",
1943 "b72f70ebf3e3fda23f508eec76b42c02",
1944
1945 "000000000000000000000000000000000000000000000000",
1946 "fffffffffffffffffc00000000000000",
1947 "6a9d965e6274143f25afdcfc88ffd77c",
1948
1949 "000000000000000000000000000000000000000000000000",
1950 "fffffffffffffffffe00000000000000",
1951 "a0c74fd0b9361764ce91c5200b095357",
1952
1953 "000000000000000000000000000000000000000000000000",
1954 "ffffffffffffffffff00000000000000",
1955 "091d1fdc2bd2c346cd5046a8c6209146",
1956
1957 "000000000000000000000000000000000000000000000000",
1958 "ffffffffffffffffff80000000000000",
1959 "e2a37580116cfb71856254496ab0aca8",
1960
1961 "000000000000000000000000000000000000000000000000",
1962 "ffffffffffffffffffc0000000000000",
1963 "e0b3a00785917c7efc9adba322813571",
1964
1965 "000000000000000000000000000000000000000000000000",
1966 "ffffffffffffffffffe0000000000000",
1967 "733d41f4727b5ef0df4af4cf3cffa0cb",
1968
1969 "000000000000000000000000000000000000000000000000",
1970 "fffffffffffffffffff0000000000000",
1971 "a99ebb030260826f981ad3e64490aa4f",
1972
1973 "000000000000000000000000000000000000000000000000",
1974 "fffffffffffffffffff8000000000000",
1975 "73f34c7d3eae5e80082c1647524308ee",
1976
1977 "000000000000000000000000000000000000000000000000",
1978 "fffffffffffffffffffc000000000000",
1979 "40ebd5ad082345b7a2097ccd3464da02",
1980
1981 "000000000000000000000000000000000000000000000000",
1982 "fffffffffffffffffffe000000000000",
1983 "7cc4ae9a424b2cec90c97153c2457ec5",
1984
1985 "000000000000000000000000000000000000000000000000",
1986 "ffffffffffffffffffff000000000000",
1987 "54d632d03aba0bd0f91877ebdd4d09cb",
1988
1989 "000000000000000000000000000000000000000000000000",
1990 "ffffffffffffffffffff800000000000",
1991 "d3427be7e4d27cd54f5fe37b03cf0897",
1992
1993 "000000000000000000000000000000000000000000000000",
1994 "ffffffffffffffffffffc00000000000",
1995 "b2099795e88cc158fd75ea133d7e7fbe",
1996
1997 "000000000000000000000000000000000000000000000000",
1998 "ffffffffffffffffffffe00000000000",
1999 "a6cae46fb6fadfe7a2c302a34242817b",
2000
2001 "000000000000000000000000000000000000000000000000",
2002 "fffffffffffffffffffff00000000000",
2003 "026a7024d6a902e0b3ffccbaa910cc3f",
2004
2005 "000000000000000000000000000000000000000000000000",
2006 "fffffffffffffffffffff80000000000",
2007 "156f07767a85a4312321f63968338a01",
2008
2009 "000000000000000000000000000000000000000000000000",
2010 "fffffffffffffffffffffc0000000000",
2011 "15eec9ebf42b9ca76897d2cd6c5a12e2",
2012
2013 "000000000000000000000000000000000000000000000000",
2014 "fffffffffffffffffffffe0000000000",
2015 "db0d3a6fdcc13f915e2b302ceeb70fd8",
2016
2017 "000000000000000000000000000000000000000000000000",
2018 "ffffffffffffffffffffff0000000000",
2019 "71dbf37e87a2e34d15b20e8f10e48924",
2020
2021 "000000000000000000000000000000000000000000000000",
2022 "ffffffffffffffffffffff8000000000",
2023 "c745c451e96ff3c045e4367c833e3b54",
2024
2025 "000000000000000000000000000000000000000000000000",
2026 "ffffffffffffffffffffffc000000000",
2027 "340da09c2dd11c3b679d08ccd27dd595",
2028
2029 "000000000000000000000000000000000000000000000000",
2030 "ffffffffffffffffffffffe000000000",
2031 "8279f7c0c2a03ee660c6d392db025d18",
2032
2033 "000000000000000000000000000000000000000000000000",
2034 "fffffffffffffffffffffff000000000",
2035 "a4b2c7d8eba531ff47c5041a55fbd1ec",
2036
2037 "000000000000000000000000000000000000000000000000",
2038 "fffffffffffffffffffffff800000000",
2039 "74569a2ca5a7bd5131ce8dc7cbfbf72f",
2040
2041 "000000000000000000000000000000000000000000000000",
2042 "fffffffffffffffffffffffc00000000",
2043 "3713da0c0219b63454035613b5a403dd",
2044
2045 "000000000000000000000000000000000000000000000000",
2046 "fffffffffffffffffffffffe00000000",
2047 "8827551ddcc9df23fa72a3de4e9f0b07",
2048
2049 "000000000000000000000000000000000000000000000000",
2050 "ffffffffffffffffffffffff00000000",
2051 "2e3febfd625bfcd0a2c06eb460da1732",
2052
2053 "000000000000000000000000000000000000000000000000",
2054 "ffffffffffffffffffffffff80000000",
2055 "ee82e6ba488156f76496311da6941deb",
2056
2057 "000000000000000000000000000000000000000000000000",
2058 "ffffffffffffffffffffffffc0000000",
2059 "4770446f01d1f391256e85a1b30d89d3",
2060
2061 "000000000000000000000000000000000000000000000000",
2062 "ffffffffffffffffffffffffe0000000",
2063 "af04b68f104f21ef2afb4767cf74143c",
2064
2065 "000000000000000000000000000000000000000000000000",
2066 "fffffffffffffffffffffffff0000000",
2067 "cf3579a9ba38c8e43653173e14f3a4c6",
2068
2069 "000000000000000000000000000000000000000000000000",
2070 "fffffffffffffffffffffffff8000000",
2071 "b3bba904f4953e09b54800af2f62e7d4",
2072
2073 "000000000000000000000000000000000000000000000000",
2074 "fffffffffffffffffffffffffc000000",
2075 "fc4249656e14b29eb9c44829b4c59a46",
2076
2077 "000000000000000000000000000000000000000000000000",
2078 "fffffffffffffffffffffffffe000000",
2079 "9b31568febe81cfc2e65af1c86d1a308",
2080
2081 "000000000000000000000000000000000000000000000000",
2082 "ffffffffffffffffffffffffff000000",
2083 "9ca09c25f273a766db98a480ce8dfedc",
2084
2085 "000000000000000000000000000000000000000000000000",
2086 "ffffffffffffffffffffffffff800000",
2087 "b909925786f34c3c92d971883c9fbedf",
2088
2089 "000000000000000000000000000000000000000000000000",
2090 "ffffffffffffffffffffffffffc00000",
2091 "82647f1332fe570a9d4d92b2ee771d3b",
2092
2093 "000000000000000000000000000000000000000000000000",
2094 "ffffffffffffffffffffffffffe00000",
2095 "3604a7e80832b3a99954bca6f5b9f501",
2096
2097 "000000000000000000000000000000000000000000000000",
2098 "fffffffffffffffffffffffffff00000",
2099 "884607b128c5de3ab39a529a1ef51bef",
2100
2101 "000000000000000000000000000000000000000000000000",
2102 "fffffffffffffffffffffffffff80000",
2103 "670cfa093d1dbdb2317041404102435e",
2104
2105 "000000000000000000000000000000000000000000000000",
2106 "fffffffffffffffffffffffffffc0000",
2107 "7a867195f3ce8769cbd336502fbb5130",
2108
2109 "000000000000000000000000000000000000000000000000",
2110 "fffffffffffffffffffffffffffe0000",
2111 "52efcf64c72b2f7ca5b3c836b1078c15",
2112
2113 "000000000000000000000000000000000000000000000000",
2114 "ffffffffffffffffffffffffffff0000",
2115 "4019250f6eefb2ac5ccbcae044e75c7e",
2116
2117 "000000000000000000000000000000000000000000000000",
2118 "ffffffffffffffffffffffffffff8000",
2119 "022c4f6f5a017d292785627667ddef24",
2120
2121 "000000000000000000000000000000000000000000000000",
2122 "ffffffffffffffffffffffffffffc000",
2123 "e9c21078a2eb7e03250f71000fa9e3ed",
2124
2125 "000000000000000000000000000000000000000000000000",
2126 "ffffffffffffffffffffffffffffe000",
2127 "a13eaeeb9cd391da4e2b09490b3e7fad",
2128
2129 "000000000000000000000000000000000000000000000000",
2130 "fffffffffffffffffffffffffffff000",
2131 "c958a171dca1d4ed53e1af1d380803a9",
2132
2133 "000000000000000000000000000000000000000000000000",
2134 "fffffffffffffffffffffffffffff800",
2135 "21442e07a110667f2583eaeeee44dc8c",
2136
2137 "000000000000000000000000000000000000000000000000",
2138 "fffffffffffffffffffffffffffffc00",
2139 "59bbb353cf1dd867a6e33737af655e99",
2140
2141 "000000000000000000000000000000000000000000000000",
2142 "fffffffffffffffffffffffffffffe00",
2143 "43cd3b25375d0ce41087ff9fe2829639",
2144
2145 "000000000000000000000000000000000000000000000000",
2146 "ffffffffffffffffffffffffffffff00",
2147 "6b98b17e80d1118e3516bd768b285a84",
2148
2149 "000000000000000000000000000000000000000000000000",
2150 "ffffffffffffffffffffffffffffff80",
2151 "ae47ed3676ca0c08deea02d95b81db58",
2152
2153 "000000000000000000000000000000000000000000000000",
2154 "ffffffffffffffffffffffffffffffc0",
2155 "34ec40dc20413795ed53628ea748720b",
2156
2157 "000000000000000000000000000000000000000000000000",
2158 "ffffffffffffffffffffffffffffffe0",
2159 "4dc68163f8e9835473253542c8a65d46",
2160
2161 "000000000000000000000000000000000000000000000000",
2162 "fffffffffffffffffffffffffffffff0",
2163 "2aabb999f43693175af65c6c612c46fb",
2164
2165 "000000000000000000000000000000000000000000000000",
2166 "fffffffffffffffffffffffffffffff8",
2167 "e01f94499dac3547515c5b1d756f0f58",
2168
2169 "000000000000000000000000000000000000000000000000",
2170 "fffffffffffffffffffffffffffffffc",
2171 "9d12435a46480ce00ea349f71799df9a",
2172
2173 "000000000000000000000000000000000000000000000000",
2174 "fffffffffffffffffffffffffffffffe",
2175 "cef41d16d266bdfe46938ad7884cc0cf",
2176
2177 "000000000000000000000000000000000000000000000000",
2178 "ffffffffffffffffffffffffffffffff",
2179 "b13db4da1f718bc6904797c82bcf2d32",
2180
2181 /*
2182 * From NIST validation suite (ECBVarTxt256.rsp).
2183 */
2184 "0000000000000000000000000000000000000000000000000000000000000000",
2185 "80000000000000000000000000000000",
2186 "ddc6bf790c15760d8d9aeb6f9a75fd4e",
2187
2188 "0000000000000000000000000000000000000000000000000000000000000000",
2189 "c0000000000000000000000000000000",
2190 "0a6bdc6d4c1e6280301fd8e97ddbe601",
2191
2192 "0000000000000000000000000000000000000000000000000000000000000000",
2193 "e0000000000000000000000000000000",
2194 "9b80eefb7ebe2d2b16247aa0efc72f5d",
2195
2196 "0000000000000000000000000000000000000000000000000000000000000000",
2197 "f0000000000000000000000000000000",
2198 "7f2c5ece07a98d8bee13c51177395ff7",
2199
2200 "0000000000000000000000000000000000000000000000000000000000000000",
2201 "f8000000000000000000000000000000",
2202 "7818d800dcf6f4be1e0e94f403d1e4c2",
2203
2204 "0000000000000000000000000000000000000000000000000000000000000000",
2205 "fc000000000000000000000000000000",
2206 "e74cd1c92f0919c35a0324123d6177d3",
2207
2208 "0000000000000000000000000000000000000000000000000000000000000000",
2209 "fe000000000000000000000000000000",
2210 "8092a4dcf2da7e77e93bdd371dfed82e",
2211
2212 "0000000000000000000000000000000000000000000000000000000000000000",
2213 "ff000000000000000000000000000000",
2214 "49af6b372135acef10132e548f217b17",
2215
2216 "0000000000000000000000000000000000000000000000000000000000000000",
2217 "ff800000000000000000000000000000",
2218 "8bcd40f94ebb63b9f7909676e667f1e7",
2219
2220 "0000000000000000000000000000000000000000000000000000000000000000",
2221 "ffc00000000000000000000000000000",
2222 "fe1cffb83f45dcfb38b29be438dbd3ab",
2223
2224 "0000000000000000000000000000000000000000000000000000000000000000",
2225 "ffe00000000000000000000000000000",
2226 "0dc58a8d886623705aec15cb1e70dc0e",
2227
2228 "0000000000000000000000000000000000000000000000000000000000000000",
2229 "fff00000000000000000000000000000",
2230 "c218faa16056bd0774c3e8d79c35a5e4",
2231
2232 "0000000000000000000000000000000000000000000000000000000000000000",
2233 "fff80000000000000000000000000000",
2234 "047bba83f7aa841731504e012208fc9e",
2235
2236 "0000000000000000000000000000000000000000000000000000000000000000",
2237 "fffc0000000000000000000000000000",
2238 "dc8f0e4915fd81ba70a331310882f6da",
2239
2240 "0000000000000000000000000000000000000000000000000000000000000000",
2241 "fffe0000000000000000000000000000",
2242 "1569859ea6b7206c30bf4fd0cbfac33c",
2243
2244 "0000000000000000000000000000000000000000000000000000000000000000",
2245 "ffff0000000000000000000000000000",
2246 "300ade92f88f48fa2df730ec16ef44cd",
2247
2248 "0000000000000000000000000000000000000000000000000000000000000000",
2249 "ffff8000000000000000000000000000",
2250 "1fe6cc3c05965dc08eb0590c95ac71d0",
2251
2252 "0000000000000000000000000000000000000000000000000000000000000000",
2253 "ffffc000000000000000000000000000",
2254 "59e858eaaa97fec38111275b6cf5abc0",
2255
2256 "0000000000000000000000000000000000000000000000000000000000000000",
2257 "ffffe000000000000000000000000000",
2258 "2239455e7afe3b0616100288cc5a723b",
2259
2260 "0000000000000000000000000000000000000000000000000000000000000000",
2261 "fffff000000000000000000000000000",
2262 "3ee500c5c8d63479717163e55c5c4522",
2263
2264 "0000000000000000000000000000000000000000000000000000000000000000",
2265 "fffff800000000000000000000000000",
2266 "d5e38bf15f16d90e3e214041d774daa8",
2267
2268 "0000000000000000000000000000000000000000000000000000000000000000",
2269 "fffffc00000000000000000000000000",
2270 "b1f4066e6f4f187dfe5f2ad1b17819d0",
2271
2272 "0000000000000000000000000000000000000000000000000000000000000000",
2273 "fffffe00000000000000000000000000",
2274 "6ef4cc4de49b11065d7af2909854794a",
2275
2276 "0000000000000000000000000000000000000000000000000000000000000000",
2277 "ffffff00000000000000000000000000",
2278 "ac86bc606b6640c309e782f232bf367f",
2279
2280 "0000000000000000000000000000000000000000000000000000000000000000",
2281 "ffffff80000000000000000000000000",
2282 "36aff0ef7bf3280772cf4cac80a0d2b2",
2283
2284 "0000000000000000000000000000000000000000000000000000000000000000",
2285 "ffffffc0000000000000000000000000",
2286 "1f8eedea0f62a1406d58cfc3ecea72cf",
2287
2288 "0000000000000000000000000000000000000000000000000000000000000000",
2289 "ffffffe0000000000000000000000000",
2290 "abf4154a3375a1d3e6b1d454438f95a6",
2291
2292 "0000000000000000000000000000000000000000000000000000000000000000",
2293 "fffffff0000000000000000000000000",
2294 "96f96e9d607f6615fc192061ee648b07",
2295
2296 "0000000000000000000000000000000000000000000000000000000000000000",
2297 "fffffff8000000000000000000000000",
2298 "cf37cdaaa0d2d536c71857634c792064",
2299
2300 "0000000000000000000000000000000000000000000000000000000000000000",
2301 "fffffffc000000000000000000000000",
2302 "fbd6640c80245c2b805373f130703127",
2303
2304 "0000000000000000000000000000000000000000000000000000000000000000",
2305 "fffffffe000000000000000000000000",
2306 "8d6a8afe55a6e481badae0d146f436db",
2307
2308 "0000000000000000000000000000000000000000000000000000000000000000",
2309 "ffffffff000000000000000000000000",
2310 "6a4981f2915e3e68af6c22385dd06756",
2311
2312 "0000000000000000000000000000000000000000000000000000000000000000",
2313 "ffffffff800000000000000000000000",
2314 "42a1136e5f8d8d21d3101998642d573b",
2315
2316 "0000000000000000000000000000000000000000000000000000000000000000",
2317 "ffffffffc00000000000000000000000",
2318 "9b471596dc69ae1586cee6158b0b0181",
2319
2320 "0000000000000000000000000000000000000000000000000000000000000000",
2321 "ffffffffe00000000000000000000000",
2322 "753665c4af1eff33aa8b628bf8741cfd",
2323
2324 "0000000000000000000000000000000000000000000000000000000000000000",
2325 "fffffffff00000000000000000000000",
2326 "9a682acf40be01f5b2a4193c9a82404d",
2327
2328 "0000000000000000000000000000000000000000000000000000000000000000",
2329 "fffffffff80000000000000000000000",
2330 "54fafe26e4287f17d1935f87eb9ade01",
2331
2332 "0000000000000000000000000000000000000000000000000000000000000000",
2333 "fffffffffc0000000000000000000000",
2334 "49d541b2e74cfe73e6a8e8225f7bd449",
2335
2336 "0000000000000000000000000000000000000000000000000000000000000000",
2337 "fffffffffe0000000000000000000000",
2338 "11a45530f624ff6f76a1b3826626ff7b",
2339
2340 "0000000000000000000000000000000000000000000000000000000000000000",
2341 "ffffffffff0000000000000000000000",
2342 "f96b0c4a8bc6c86130289f60b43b8fba",
2343
2344 "0000000000000000000000000000000000000000000000000000000000000000",
2345 "ffffffffff8000000000000000000000",
2346 "48c7d0e80834ebdc35b6735f76b46c8b",
2347
2348 "0000000000000000000000000000000000000000000000000000000000000000",
2349 "ffffffffffc000000000000000000000",
2350 "2463531ab54d66955e73edc4cb8eaa45",
2351
2352 "0000000000000000000000000000000000000000000000000000000000000000",
2353 "ffffffffffe000000000000000000000",
2354 "ac9bd8e2530469134b9d5b065d4f565b",
2355
2356 "0000000000000000000000000000000000000000000000000000000000000000",
2357 "fffffffffff000000000000000000000",
2358 "3f5f9106d0e52f973d4890e6f37e8a00",
2359
2360 "0000000000000000000000000000000000000000000000000000000000000000",
2361 "fffffffffff800000000000000000000",
2362 "20ebc86f1304d272e2e207e59db639f0",
2363
2364 "0000000000000000000000000000000000000000000000000000000000000000",
2365 "fffffffffffc00000000000000000000",
2366 "e67ae6426bf9526c972cff072b52252c",
2367
2368 "0000000000000000000000000000000000000000000000000000000000000000",
2369 "fffffffffffe00000000000000000000",
2370 "1a518dddaf9efa0d002cc58d107edfc8",
2371
2372 "0000000000000000000000000000000000000000000000000000000000000000",
2373 "ffffffffffff00000000000000000000",
2374 "ead731af4d3a2fe3b34bed047942a49f",
2375
2376 "0000000000000000000000000000000000000000000000000000000000000000",
2377 "ffffffffffff80000000000000000000",
2378 "b1d4efe40242f83e93b6c8d7efb5eae9",
2379
2380 "0000000000000000000000000000000000000000000000000000000000000000",
2381 "ffffffffffffc0000000000000000000",
2382 "cd2b1fec11fd906c5c7630099443610a",
2383
2384 "0000000000000000000000000000000000000000000000000000000000000000",
2385 "ffffffffffffe0000000000000000000",
2386 "a1853fe47fe29289d153161d06387d21",
2387
2388 "0000000000000000000000000000000000000000000000000000000000000000",
2389 "fffffffffffff0000000000000000000",
2390 "4632154179a555c17ea604d0889fab14",
2391
2392 "0000000000000000000000000000000000000000000000000000000000000000",
2393 "fffffffffffff8000000000000000000",
2394 "dd27cac6401a022e8f38f9f93e774417",
2395
2396 "0000000000000000000000000000000000000000000000000000000000000000",
2397 "fffffffffffffc000000000000000000",
2398 "c090313eb98674f35f3123385fb95d4d",
2399
2400 "0000000000000000000000000000000000000000000000000000000000000000",
2401 "fffffffffffffe000000000000000000",
2402 "cc3526262b92f02edce548f716b9f45c",
2403
2404 "0000000000000000000000000000000000000000000000000000000000000000",
2405 "ffffffffffffff000000000000000000",
2406 "c0838d1a2b16a7c7f0dfcc433c399c33",
2407
2408 "0000000000000000000000000000000000000000000000000000000000000000",
2409 "ffffffffffffff800000000000000000",
2410 "0d9ac756eb297695eed4d382eb126d26",
2411
2412 "0000000000000000000000000000000000000000000000000000000000000000",
2413 "ffffffffffffffc00000000000000000",
2414 "56ede9dda3f6f141bff1757fa689c3e1",
2415
2416 "0000000000000000000000000000000000000000000000000000000000000000",
2417 "ffffffffffffffe00000000000000000",
2418 "768f520efe0f23e61d3ec8ad9ce91774",
2419
2420 "0000000000000000000000000000000000000000000000000000000000000000",
2421 "fffffffffffffff00000000000000000",
2422 "b1144ddfa75755213390e7c596660490",
2423
2424 "0000000000000000000000000000000000000000000000000000000000000000",
2425 "fffffffffffffff80000000000000000",
2426 "1d7c0c4040b355b9d107a99325e3b050",
2427
2428 "0000000000000000000000000000000000000000000000000000000000000000",
2429 "fffffffffffffffc0000000000000000",
2430 "d8e2bb1ae8ee3dcf5bf7d6c38da82a1a",
2431
2432 "0000000000000000000000000000000000000000000000000000000000000000",
2433 "fffffffffffffffe0000000000000000",
2434 "faf82d178af25a9886a47e7f789b98d7",
2435
2436 "0000000000000000000000000000000000000000000000000000000000000000",
2437 "ffffffffffffffff0000000000000000",
2438 "9b58dbfd77fe5aca9cfc190cd1b82d19",
2439
2440 "0000000000000000000000000000000000000000000000000000000000000000",
2441 "ffffffffffffffff8000000000000000",
2442 "77f392089042e478ac16c0c86a0b5db5",
2443
2444 "0000000000000000000000000000000000000000000000000000000000000000",
2445 "ffffffffffffffffc000000000000000",
2446 "19f08e3420ee69b477ca1420281c4782",
2447
2448 "0000000000000000000000000000000000000000000000000000000000000000",
2449 "ffffffffffffffffe000000000000000",
2450 "a1b19beee4e117139f74b3c53fdcb875",
2451
2452 "0000000000000000000000000000000000000000000000000000000000000000",
2453 "fffffffffffffffff000000000000000",
2454 "a37a5869b218a9f3a0868d19aea0ad6a",
2455
2456 "0000000000000000000000000000000000000000000000000000000000000000",
2457 "fffffffffffffffff800000000000000",
2458 "bc3594e865bcd0261b13202731f33580",
2459
2460 "0000000000000000000000000000000000000000000000000000000000000000",
2461 "fffffffffffffffffc00000000000000",
2462 "811441ce1d309eee7185e8c752c07557",
2463
2464 "0000000000000000000000000000000000000000000000000000000000000000",
2465 "fffffffffffffffffe00000000000000",
2466 "959971ce4134190563518e700b9874d1",
2467
2468 "0000000000000000000000000000000000000000000000000000000000000000",
2469 "ffffffffffffffffff00000000000000",
2470 "76b5614a042707c98e2132e2e805fe63",
2471
2472 "0000000000000000000000000000000000000000000000000000000000000000",
2473 "ffffffffffffffffff80000000000000",
2474 "7d9fa6a57530d0f036fec31c230b0cc6",
2475
2476 "0000000000000000000000000000000000000000000000000000000000000000",
2477 "ffffffffffffffffffc0000000000000",
2478 "964153a83bf6989a4ba80daa91c3e081",
2479
2480 "0000000000000000000000000000000000000000000000000000000000000000",
2481 "ffffffffffffffffffe0000000000000",
2482 "a013014d4ce8054cf2591d06f6f2f176",
2483
2484 "0000000000000000000000000000000000000000000000000000000000000000",
2485 "fffffffffffffffffff0000000000000",
2486 "d1c5f6399bf382502e385eee1474a869",
2487
2488 "0000000000000000000000000000000000000000000000000000000000000000",
2489 "fffffffffffffffffff8000000000000",
2490 "0007e20b8298ec354f0f5fe7470f36bd",
2491
2492 "0000000000000000000000000000000000000000000000000000000000000000",
2493 "fffffffffffffffffffc000000000000",
2494 "b95ba05b332da61ef63a2b31fcad9879",
2495
2496 "0000000000000000000000000000000000000000000000000000000000000000",
2497 "fffffffffffffffffffe000000000000",
2498 "4620a49bd967491561669ab25dce45f4",
2499
2500 "0000000000000000000000000000000000000000000000000000000000000000",
2501 "ffffffffffffffffffff000000000000",
2502 "12e71214ae8e04f0bb63d7425c6f14d5",
2503
2504 "0000000000000000000000000000000000000000000000000000000000000000",
2505 "ffffffffffffffffffff800000000000",
2506 "4cc42fc1407b008fe350907c092e80ac",
2507
2508 "0000000000000000000000000000000000000000000000000000000000000000",
2509 "ffffffffffffffffffffc00000000000",
2510 "08b244ce7cbc8ee97fbba808cb146fda",
2511
2512 "0000000000000000000000000000000000000000000000000000000000000000",
2513 "ffffffffffffffffffffe00000000000",
2514 "39b333e8694f21546ad1edd9d87ed95b",
2515
2516 "0000000000000000000000000000000000000000000000000000000000000000",
2517 "fffffffffffffffffffff00000000000",
2518 "3b271f8ab2e6e4a20ba8090f43ba78f3",
2519
2520 "0000000000000000000000000000000000000000000000000000000000000000",
2521 "fffffffffffffffffffff80000000000",
2522 "9ad983f3bf651cd0393f0a73cccdea50",
2523
2524 "0000000000000000000000000000000000000000000000000000000000000000",
2525 "fffffffffffffffffffffc0000000000",
2526 "8f476cbff75c1f725ce18e4bbcd19b32",
2527
2528 "0000000000000000000000000000000000000000000000000000000000000000",
2529 "fffffffffffffffffffffe0000000000",
2530 "905b6267f1d6ab5320835a133f096f2a",
2531
2532 "0000000000000000000000000000000000000000000000000000000000000000",
2533 "ffffffffffffffffffffff0000000000",
2534 "145b60d6d0193c23f4221848a892d61a",
2535
2536 "0000000000000000000000000000000000000000000000000000000000000000",
2537 "ffffffffffffffffffffff8000000000",
2538 "55cfb3fb6d75cad0445bbc8dafa25b0f",
2539
2540 "0000000000000000000000000000000000000000000000000000000000000000",
2541 "ffffffffffffffffffffffc000000000",
2542 "7b8e7098e357ef71237d46d8b075b0f5",
2543
2544 "0000000000000000000000000000000000000000000000000000000000000000",
2545 "ffffffffffffffffffffffe000000000",
2546 "2bf27229901eb40f2df9d8398d1505ae",
2547
2548 "0000000000000000000000000000000000000000000000000000000000000000",
2549 "fffffffffffffffffffffff000000000",
2550 "83a63402a77f9ad5c1e931a931ecd706",
2551
2552 "0000000000000000000000000000000000000000000000000000000000000000",
2553 "fffffffffffffffffffffff800000000",
2554 "6f8ba6521152d31f2bada1843e26b973",
2555
2556 "0000000000000000000000000000000000000000000000000000000000000000",
2557 "fffffffffffffffffffffffc00000000",
2558 "e5c3b8e30fd2d8e6239b17b44bd23bbd",
2559
2560 "0000000000000000000000000000000000000000000000000000000000000000",
2561 "fffffffffffffffffffffffe00000000",
2562 "1ac1f7102c59933e8b2ddc3f14e94baa",
2563
2564 "0000000000000000000000000000000000000000000000000000000000000000",
2565 "ffffffffffffffffffffffff00000000",
2566 "21d9ba49f276b45f11af8fc71a088e3d",
2567
2568 "0000000000000000000000000000000000000000000000000000000000000000",
2569 "ffffffffffffffffffffffff80000000",
2570 "649f1cddc3792b4638635a392bc9bade",
2571
2572 "0000000000000000000000000000000000000000000000000000000000000000",
2573 "ffffffffffffffffffffffffc0000000",
2574 "e2775e4b59c1bc2e31a2078c11b5a08c",
2575
2576 "0000000000000000000000000000000000000000000000000000000000000000",
2577 "ffffffffffffffffffffffffe0000000",
2578 "2be1fae5048a25582a679ca10905eb80",
2579
2580 "0000000000000000000000000000000000000000000000000000000000000000",
2581 "fffffffffffffffffffffffff0000000",
2582 "da86f292c6f41ea34fb2068df75ecc29",
2583
2584 "0000000000000000000000000000000000000000000000000000000000000000",
2585 "fffffffffffffffffffffffff8000000",
2586 "220df19f85d69b1b562fa69a3c5beca5",
2587
2588 "0000000000000000000000000000000000000000000000000000000000000000",
2589 "fffffffffffffffffffffffffc000000",
2590 "1f11d5d0355e0b556ccdb6c7f5083b4d",
2591
2592 "0000000000000000000000000000000000000000000000000000000000000000",
2593 "fffffffffffffffffffffffffe000000",
2594 "62526b78be79cb384633c91f83b4151b",
2595
2596 "0000000000000000000000000000000000000000000000000000000000000000",
2597 "ffffffffffffffffffffffffff000000",
2598 "90ddbcb950843592dd47bbef00fdc876",
2599
2600 "0000000000000000000000000000000000000000000000000000000000000000",
2601 "ffffffffffffffffffffffffff800000",
2602 "2fd0e41c5b8402277354a7391d2618e2",
2603
2604 "0000000000000000000000000000000000000000000000000000000000000000",
2605 "ffffffffffffffffffffffffffc00000",
2606 "3cdf13e72dee4c581bafec70b85f9660",
2607
2608 "0000000000000000000000000000000000000000000000000000000000000000",
2609 "ffffffffffffffffffffffffffe00000",
2610 "afa2ffc137577092e2b654fa199d2c43",
2611
2612 "0000000000000000000000000000000000000000000000000000000000000000",
2613 "fffffffffffffffffffffffffff00000",
2614 "8d683ee63e60d208e343ce48dbc44cac",
2615
2616 "0000000000000000000000000000000000000000000000000000000000000000",
2617 "fffffffffffffffffffffffffff80000",
2618 "705a4ef8ba2133729c20185c3d3a4763",
2619
2620 "0000000000000000000000000000000000000000000000000000000000000000",
2621 "fffffffffffffffffffffffffffc0000",
2622 "0861a861c3db4e94194211b77ed761b9",
2623
2624 "0000000000000000000000000000000000000000000000000000000000000000",
2625 "fffffffffffffffffffffffffffe0000",
2626 "4b00c27e8b26da7eab9d3a88dec8b031",
2627
2628 "0000000000000000000000000000000000000000000000000000000000000000",
2629 "ffffffffffffffffffffffffffff0000",
2630 "5f397bf03084820cc8810d52e5b666e9",
2631
2632 "0000000000000000000000000000000000000000000000000000000000000000",
2633 "ffffffffffffffffffffffffffff8000",
2634 "63fafabb72c07bfbd3ddc9b1203104b8",
2635
2636 "0000000000000000000000000000000000000000000000000000000000000000",
2637 "ffffffffffffffffffffffffffffc000",
2638 "683e2140585b18452dd4ffbb93c95df9",
2639
2640 "0000000000000000000000000000000000000000000000000000000000000000",
2641 "ffffffffffffffffffffffffffffe000",
2642 "286894e48e537f8763b56707d7d155c8",
2643
2644 "0000000000000000000000000000000000000000000000000000000000000000",
2645 "fffffffffffffffffffffffffffff000",
2646 "a423deabc173dcf7e2c4c53e77d37cd1",
2647
2648 "0000000000000000000000000000000000000000000000000000000000000000",
2649 "fffffffffffffffffffffffffffff800",
2650 "eb8168313e1cfdfdb5e986d5429cf172",
2651
2652 "0000000000000000000000000000000000000000000000000000000000000000",
2653 "fffffffffffffffffffffffffffffc00",
2654 "27127daafc9accd2fb334ec3eba52323",
2655
2656 "0000000000000000000000000000000000000000000000000000000000000000",
2657 "fffffffffffffffffffffffffffffe00",
2658 "ee0715b96f72e3f7a22a5064fc592f4c",
2659
2660 "0000000000000000000000000000000000000000000000000000000000000000",
2661 "ffffffffffffffffffffffffffffff00",
2662 "29ee526770f2a11dcfa989d1ce88830f",
2663
2664 "0000000000000000000000000000000000000000000000000000000000000000",
2665 "ffffffffffffffffffffffffffffff80",
2666 "0493370e054b09871130fe49af730a5a",
2667
2668 "0000000000000000000000000000000000000000000000000000000000000000",
2669 "ffffffffffffffffffffffffffffffc0",
2670 "9b7b940f6c509f9e44a4ee140448ee46",
2671
2672 "0000000000000000000000000000000000000000000000000000000000000000",
2673 "ffffffffffffffffffffffffffffffe0",
2674 "2915be4a1ecfdcbe3e023811a12bb6c7",
2675
2676 "0000000000000000000000000000000000000000000000000000000000000000",
2677 "fffffffffffffffffffffffffffffff0",
2678 "7240e524bc51d8c4d440b1be55d1062c",
2679
2680 "0000000000000000000000000000000000000000000000000000000000000000",
2681 "fffffffffffffffffffffffffffffff8",
2682 "da63039d38cb4612b2dc36ba26684b93",
2683
2684 "0000000000000000000000000000000000000000000000000000000000000000",
2685 "fffffffffffffffffffffffffffffffc",
2686 "0f59cb5a4b522e2ac56c1a64f558ad9a",
2687
2688 "0000000000000000000000000000000000000000000000000000000000000000",
2689 "fffffffffffffffffffffffffffffffe",
2690 "7bfe9d876c6d63c1d035da8fe21c409d",
2691
2692 "0000000000000000000000000000000000000000000000000000000000000000",
2693 "ffffffffffffffffffffffffffffffff",
2694 "acdace8078a32b1a182bfa4987ca1347",
2695
2696 /*
2697 * Table end marker.
2698 */
2699 NULL
2700 };
2701
2702 /*
2703 * AES known-answer tests for CBC. Order: key, IV, plaintext, ciphertext.
2704 */
2705 static const char *const KAT_AES_CBC[] = {
2706 /*
2707 * From NIST validation suite "Multiblock Message Test"
2708 * (cbcmmt128.rsp).
2709 */
2710 "1f8e4973953f3fb0bd6b16662e9a3c17",
2711 "2fe2b333ceda8f98f4a99b40d2cd34a8",
2712 "45cf12964fc824ab76616ae2f4bf0822",
2713 "0f61c4d44c5147c03c195ad7e2cc12b2",
2714
2715 "0700d603a1c514e46b6191ba430a3a0c",
2716 "aad1583cd91365e3bb2f0c3430d065bb",
2717 "068b25c7bfb1f8bdd4cfc908f69dffc5ddc726a197f0e5f720f730393279be91",
2718 "c4dc61d9725967a3020104a9738f23868527ce839aab1752fd8bdb95a82c4d00",
2719
2720 "3348aa51e9a45c2dbe33ccc47f96e8de",
2721 "19153c673160df2b1d38c28060e59b96",
2722 "9b7cee827a26575afdbb7c7a329f887238052e3601a7917456ba61251c214763d5e1847a6ad5d54127a399ab07ee3599",
2723 "d5aed6c9622ec451a15db12819952b6752501cf05cdbf8cda34a457726ded97818e1f127a28d72db5652749f0c6afee5",
2724
2725 "b7f3c9576e12dd0db63e8f8fac2b9a39",
2726 "c80f095d8bb1a060699f7c19974a1aa0",
2727 "9ac19954ce1319b354d3220460f71c1e373f1cd336240881160cfde46ebfed2e791e8d5a1a136ebd1dc469dec00c4187722b841cdabcb22c1be8a14657da200e",
2728 "19b9609772c63f338608bf6eb52ca10be65097f89c1e0905c42401fd47791ae2c5440b2d473116ca78bd9ff2fb6015cfd316524eae7dcb95ae738ebeae84a467",
2729
2730 "b6f9afbfe5a1562bba1368fc72ac9d9c",
2731 "3f9d5ebe250ee7ce384b0d00ee849322",
2732 "db397ec22718dbffb9c9d13de0efcd4611bf792be4fce0dc5f25d4f577ed8cdbd4eb9208d593dda3d4653954ab64f05676caa3ce9bfa795b08b67ceebc923fdc89a8c431188e9e482d8553982cf304d1",
2733 "10ea27b19e16b93af169c4a88e06e35c99d8b420980b058e34b4b8f132b13766f72728202b089f428fecdb41c79f8aa0d0ef68f5786481cca29e2126f69bc14160f1ae2187878ba5c49cf3961e1b7ee9",
2734
2735 "bbe7b7ba07124ff1ae7c3416fe8b465e",
2736 "7f65b5ee3630bed6b84202d97fb97a1e",
2737 "2aad0c2c4306568bad7447460fd3dac054346d26feddbc9abd9110914011b4794be2a9a00a519a51a5b5124014f4ed2735480db21b434e99a911bb0b60fe0253763725b628d5739a5117b7ee3aefafc5b4c1bf446467e7bf5f78f31ff7caf187",
2738 "3b8611bfc4973c5cd8e982b073b33184cd26110159172e44988eb5ff5661a1e16fad67258fcbfee55469267a12dc374893b4e3533d36f5634c3095583596f135aa8cd1138dc898bc5651ee35a92ebf89ab6aeb5366653bc60a70e0074fc11efe",
2739
2740 "89a553730433f7e6d67d16d373bd5360",
2741 "f724558db3433a523f4e51a5bea70497",
2742 "807bc4ea684eedcfdcca30180680b0f1ae2814f35f36d053c5aea6595a386c1442770f4d7297d8b91825ee7237241da8925dd594ccf676aecd46ca2068e8d37a3a0ec8a7d5185a201e663b5ff36ae197110188a23503763b8218826d23ced74b31e9f6e2d7fbfa6cb43420c7807a8625",
2743 "406af1429a478c3d07e555c5287a60500d37fc39b68e5bbb9bafd6ddb223828561d6171a308d5b1a4551e8a5e7d572918d25c968d3871848d2f16635caa9847f38590b1df58ab5efb985f2c66cfaf86f61b3f9c0afad6c963c49cee9b8bc81a2ddb06c967f325515a4849eec37ce721a",
2744
2745 "c491ca31f91708458e29a925ec558d78",
2746 "9ef934946e5cd0ae97bd58532cb49381",
2747 "cb6a787e0dec56f9a165957f81af336ca6b40785d9e94093c6190e5152649f882e874d79ac5e167bd2a74ce5ae088d2ee854f6539e0a94796b1e1bd4c9fcdbc79acbef4d01eeb89776d18af71ae2a4fc47dd66df6c4dbe1d1850e466549a47b636bcc7c2b3a62495b56bb67b6d455f1eebd9bfefecbca6c7f335cfce9b45cb9d",
2748 "7b2931f5855f717145e00f152a9f4794359b1ffcb3e55f594e33098b51c23a6c74a06c1d94fded7fd2ae42c7db7acaef5844cb33aeddc6852585ed0020a6699d2cb53809cefd169148ce42292afab063443978306c582c18b9ce0da3d084ce4d3c482cfd8fcf1a85084e89fb88b40a084d5e972466d07666126fb761f84078f2",
2749
2750 "f6e87d71b0104d6eb06a68dc6a71f498",
2751 "1c245f26195b76ebebc2edcac412a2f8",
2752 "f82bef3c73a6f7f80db285726d691db6bf55eec25a859d3ba0e0445f26b9bb3b16a3161ed1866e4dd8f2e5f8ecb4e46d74a7a78c20cdfc7bcc9e479ba7a0caba9438238ad0c01651d5d98de37f03ddce6e6b4bd4ab03cf9e8ed818aedfa1cf963b932067b97d776dce1087196e7e913f7448e38244509f0caf36bd8217e15336d35c149fd4e41707893fdb84014f8729",
2753 "b09512f3eff9ed0d85890983a73dadbb7c3678d52581be64a8a8fc586f490f2521297a478a0598040ebd0f5509fafb0969f9d9e600eaef33b1b93eed99687b167f89a5065aac439ce46f3b8d22d30865e64e45ef8cd30b6984353a844a11c8cd60dba0e8866b3ee30d24b3fa8a643b328353e06010fa8273c8fd54ef0a2b6930e5520aae5cd5902f9b86a33592ca4365",
2754
2755 "2c14413751c31e2730570ba3361c786b",
2756 "1dbbeb2f19abb448af849796244a19d7",
2757 "40d930f9a05334d9816fe204999c3f82a03f6a0457a8c475c94553d1d116693adc618049f0a769a2eed6a6cb14c0143ec5cccdbc8dec4ce560cfd206225709326d4de7948e54d603d01b12d7fed752fb23f1aa4494fbb00130e9ded4e77e37c079042d828040c325b1a5efd15fc842e44014ca4374bf38f3c3fc3ee327733b0c8aee1abcd055772f18dc04603f7b2c1ea69ff662361f2be0a171bbdcea1e5d3f",
2758 "6be8a12800455a320538853e0cba31bd2d80ea0c85164a4c5c261ae485417d93effe2ebc0d0a0b51d6ea18633d210cf63c0c4ddbc27607f2e81ed9113191ef86d56f3b99be6c415a4150299fb846ce7160b40b63baf1179d19275a2e83698376d28b92548c68e06e6d994e2c1501ed297014e702cdefee2f656447706009614d801de1caaf73f8b7fa56cf1ba94b631933bbe577624380850f117435a0355b2b",
2759
2760 /*
2761 * From NIST validation suite "Multiblock Message Test"
2762 * (cbcmmt192.rsp).
2763 */
2764 "ba75f4d1d9d7cf7f551445d56cc1a8ab2a078e15e049dc2c",
2765 "531ce78176401666aa30db94ec4a30eb",
2766 "c51fc276774dad94bcdc1d2891ec8668",
2767 "70dd95a14ee975e239df36ff4aee1d5d",
2768
2769 "eab3b19c581aa873e1981c83ab8d83bbf8025111fb2e6b21",
2770 "f3d6667e8d4d791e60f7505ba383eb05",
2771 "9d4e4cccd1682321856df069e3f1c6fa391a083a9fb02d59db74c14081b3acc4",
2772 "51d44779f90d40a80048276c035cb49ca2a47bcb9b9cf7270b9144793787d53f",
2773
2774 "16c93bb398f1fc0cf6d68fc7a5673cdf431fa147852b4a2d",
2775 "eaaeca2e07ddedf562f94df63f0a650f",
2776 "c5ce958613bf741718c17444484ebaf1050ddcacb59b9590178cbe69d7ad7919608cb03af13bbe04f3506b718a301ea0",
2777 "ed6a50e0c6921d52d6647f75d67b4fd56ace1fedb8b5a6a997b4d131640547d22c5d884a75e6752b5846b5b33a5181f4",
2778
2779 "067bb17b4df785697eaccf961f98e212cb75e6797ce935cb",
2780 "8b59c9209c529ca8391c9fc0ce033c38",
2781 "db3785a889b4bd387754da222f0e4c2d2bfe0d79e05bc910fba941beea30f1239eacf0068f4619ec01c368e986fca6b7c58e490579d29611bd10087986eff54f",
2782 "d5f5589760bf9c762228fde236de1fa2dd2dad448db3fa9be0c4196efd46a35c84dd1ac77d9db58c95918cb317a6430a08d2fb6a8e8b0f1c9b72c7a344dc349f",
2783
2784 "0fd39de83e0be77a79c8a4a612e3dd9c8aae2ce35e7a2bf8",
2785 "7e1d629b84f93b079be51f9a5f5cb23c",
2786 "38fbda37e28fa86d9d83a4345e419dea95d28c7818ff25925db6ac3aedaf0a86154e20a4dfcc5b1b4192895393e5eb5846c88bdbd41ecf7af3104f410eaee470f5d9017ed460475f626953035a13db1f",
2787 "edadae2f9a45ff3473e02d904c94d94a30a4d92da4deb6bcb4b0774472694571842039f21c496ef93fd658842c735f8a81fcd0aa578442ab893b18f606aed1bab11f81452dd45e9b56adf2eccf4ea095",
2788
2789 "e3fecc75f0075a09b383dfd389a3d33cc9b854b3b254c0f4",
2790 "36eab883afef936cc38f63284619cd19",
2791 "931b2f5f3a5820d53a6beaaa6431083a3488f4eb03b0f5b57ef838e1579623103bd6e6800377538b2e51ef708f3c4956432e8a8ee6a34e190642b26ad8bdae6c2af9a6c7996f3b6004d2671e41f1c9f40ee03d1c4a52b0a0654a331f15f34dce",
2792 "75395974bd32b3665654a6c8e396b88ae34b123575872a7ab687d8e76b46df911a8a590cd01d2f5c330be3a6626e9dd3aa5e10ed14e8ff829811b6fed50f3f533ca4385a1cbca78f5c4744e50f2f8359165c2485d1324e76c3eae76a0ccac629",
2793
2794 "f9c27565eb07947c8cb51b79248430f7b1066c3d2fdc3d13",
2795 "2bd67cc89ab7948d644a49672843cbd9",
2796 "6abcc270173cf114d44847e911a050db57ba7a2e2c161c6f37ccb6aaa4677bddcaf50cad0b5f8758fcf7c0ebc650ceb5cd52cafb8f8dd3edcece55d9f1f08b9fa8f54365cf56e28b9596a7e1dd1d3418e4444a7724add4cf79d527b183ec88de4be4eeff29c80a97e54f85351cb189ee",
2797 "ca282924a61187feb40520979106e5cc861957f23828dcb7285e0eaac8a0ca2a6b60503d63d6039f4693dba32fa1f73ae2e709ca94911f28a5edd1f30eaddd54680c43acc9c74cd90d8bb648b4e544275f47e514daa20697f66c738eb30337f017fca1a26da4d1a0cc0a0e98e2463070",
2798
2799 "fb09cf9e00dbf883689d079c920077c0073c31890b55bab5",
2800 "e3c89bd097c3abddf64f4881db6dbfe2",
2801 "c1a37683fb289467dd1b2c89efba16bbd2ee24cf18d19d44596ded2682c79a2f711c7a32bf6a24badd32a4ee637c73b7a41da6258635650f91fb9ffa45bdfc3cb122136241b3deced8996aa51ea8d3e81c9d70e006a44bc0571ed48623a0d622a93fa9da290baaedf5d9e876c94620945ff8ecc83f27379ed55cf490c5790f27",
2802 "8158e21420f25b59d6ae943fa1cbf21f02e979f419dab0126a721b7eef55bee9ad97f5ccff7d239057bbc19a8c378142f7672f1d5e7e17d7bebcb0070e8355cace6660171a53b61816ae824a6ef69ce470b6ffd3b5bb4b438874d91d27854d3b6f25860d3868958de3307d62b1339bdddb8a318c0ce0f33c17caf0e9f6040820",
2803
2804 "bca6fa3c67fd294e958f66fe8bd64f45f428f5bc8e9733a7",
2805 "92a47f2833f1450d1da41717bdc6e83c",
2806 "5becbc31d8bead6d36ae014a5863d14a431e6b55d29ea6baaa417271716db3a33b2e506b452086dfe690834ac2de30bc41254ec5401ec47d064237c7792fdcd7914d8af20eb114756642d519021a8c75a92f6bc53d326ae9a5b7e1b10a9756574692934d9939fc399e0c203f7edf8e7e6482eadd31a0400770e897b48c6bca2b404593045080e93377358c42a0f4dede",
2807 "926db248cc1ba20f0c57631a7c8aef094f791937b905949e3460240e8bfa6fa483115a1b310b6e4369caebc5262888377b1ddaa5800ea496a2bdff0f9a1031e7129c9a20e35621e7f0b8baca0d87030f2ae7ca8593c8599677a06fd4b26009ead08fecac24caa9cf2cad3b470c8227415a7b1e0f2eab3fad96d70a209c8bb26c627677e2531b9435ca6e3c444d195b5f",
2808
2809 "162ad50ee64a0702aa551f571dedc16b2c1b6a1e4d4b5eee",
2810 "24408038161a2ccae07b029bb66355c1",
2811 "be8abf00901363987a82cc77d0ec91697ba3857f9e4f84bd79406c138d02698f003276d0449120bef4578d78fecabe8e070e11710b3f0a2744bd52434ec70015884c181ebdfd51c604a71c52e4c0e110bc408cd462b248a80b8a8ac06bb952ac1d7faed144807f1a731b7febcaf7835762defe92eccfc7a9944e1c702cffe6bc86733ed321423121085ac02df8962bcbc1937092eebf0e90a8b20e3dd8c244ae",
2812 "c82cf2c476dea8cb6a6e607a40d2f0391be82ea9ec84a537a6820f9afb997b76397d005424faa6a74dc4e8c7aa4a8900690f894b6d1dca80675393d2243adac762f159301e357e98b724762310cd5a7bafe1c2a030dba46fd93a9fdb89cc132ca9c17dc72031ec6822ee5a9d99dbca66c784c01b0885cbb62e29d97801927ec415a5d215158d325f9ee689437ad1b7684ad33c0d92739451ac87f39ff8c31b84",
2813
2814 /*
2815 * From NIST validation suite "Multiblock Message Test"
2816 * (cbcmmt256.rsp).
2817 */
2818 "6ed76d2d97c69fd1339589523931f2a6cff554b15f738f21ec72dd97a7330907",
2819 "851e8764776e6796aab722dbb644ace8",
2820 "6282b8c05c5c1530b97d4816ca434762",
2821 "6acc04142e100a65f51b97adf5172c41",
2822
2823 "dce26c6b4cfb286510da4eecd2cffe6cdf430f33db9b5f77b460679bd49d13ae",
2824 "fdeaa134c8d7379d457175fd1a57d3fc",
2825 "50e9eee1ac528009e8cbcd356975881f957254b13f91d7c6662d10312052eb00",
2826 "2fa0df722a9fd3b64cb18fb2b3db55ff2267422757289413f8f657507412a64c",
2827
2828 "fe8901fecd3ccd2ec5fdc7c7a0b50519c245b42d611a5ef9e90268d59f3edf33",
2829 "bd416cb3b9892228d8f1df575692e4d0",
2830 "8d3aa196ec3d7c9b5bb122e7fe77fb1295a6da75abe5d3a510194d3a8a4157d5c89d40619716619859da3ec9b247ced9",
2831 "608e82c7ab04007adb22e389a44797fed7de090c8c03ca8a2c5acd9e84df37fbc58ce8edb293e98f02b640d6d1d72464",
2832
2833 "0493ff637108af6a5b8e90ac1fdf035a3d4bafd1afb573be7ade9e8682e663e5",
2834 "c0cd2bebccbb6c49920bd5482ac756e8",
2835 "8b37f9148df4bb25956be6310c73c8dc58ea9714ff49b643107b34c9bff096a94fedd6823526abc27a8e0b16616eee254ab4567dd68e8ccd4c38ac563b13639c",
2836 "05d5c77729421b08b737e41119fa4438d1f570cc772a4d6c3df7ffeda0384ef84288ce37fc4c4c7d1125a499b051364c389fd639bdda647daa3bdadab2eb5594",
2837
2838 "9adc8fbd506e032af7fa20cf5343719de6d1288c158c63d6878aaf64ce26ca85",
2839 "11958dc6ab81e1c7f01631e9944e620f",
2840 "c7917f84f747cd8c4b4fedc2219bdbc5f4d07588389d8248854cf2c2f89667a2d7bcf53e73d32684535f42318e24cd45793950b3825e5d5c5c8fcd3e5dda4ce9246d18337ef3052d8b21c5561c8b660e",
2841 "9c99e68236bb2e929db1089c7750f1b356d39ab9d0c40c3e2f05108ae9d0c30b04832ccdbdc08ebfa426b7f5efde986ed05784ce368193bb3699bc691065ac62e258b9aa4cc557e2b45b49ce05511e65",
2842
2843 "73b8faf00b3302ac99855cf6f9e9e48518690a5906a4869d4dcf48d282faae2a",
2844 "b3cb97a80a539912b8c21f450d3b9395",
2845 "3adea6e06e42c4f041021491f2775ef6378cb08824165edc4f6448e232175b60d0345b9f9c78df6596ec9d22b7b9e76e8f3c76b32d5d67273f1d83fe7a6fc3dd3c49139170fa5701b3beac61b490f0a9e13f844640c4500f9ad3087adfb0ae10",
2846 "ac3d6dbafe2e0f740632fd9e820bf6044cd5b1551cbb9cc03c0b25c39ccb7f33b83aacfca40a3265f2bbff879153448acacb88fcfb3bb7b10fe463a68c0109f028382e3e557b1adf02ed648ab6bb895df0205d26ebbfa9a5fd8cebd8e4bee3dc",
2847
2848 "9ddf3745896504ff360a51a3eb49c01b79fccebc71c3abcb94a949408b05b2c9",
2849 "e79026639d4aa230b5ccffb0b29d79bc",
2850 "cf52e5c3954c51b94c9e38acb8c9a7c76aebdaa9943eae0a1ce155a2efdb4d46985d935511471452d9ee64d2461cb2991d59fc0060697f9a671672163230f367fed1422316e52d29eceacb8768f56d9b80f6d278093c9a8acd3cfd7edd8ebd5c293859f64d2f8486ae1bd593c65bc014",
2851 "34df561bd2cfebbcb7af3b4b8d21ca5258312e7e2e4e538e35ad2490b6112f0d7f148f6aa8d522a7f3c61d785bd667db0e1dc4606c318ea4f26af4fe7d11d4dcff0456511b4aed1a0d91ba4a1fd6cd9029187bc5881a5a07fe02049d39368e83139b12825bae2c7be81e6f12c61bb5c5",
2852
2853 "458b67bf212d20f3a57fce392065582dcefbf381aa22949f8338ab9052260e1d",
2854 "4c12effc5963d40459602675153e9649",
2855 "256fd73ce35ae3ea9c25dd2a9454493e96d8633fe633b56176dce8785ce5dbbb84dbf2c8a2eeb1e96b51899605e4f13bbc11b93bf6f39b3469be14858b5b720d4a522d36feed7a329c9b1e852c9280c47db8039c17c4921571a07d1864128330e09c308ddea1694e95c84500f1a61e614197e86a30ecc28df64ccb3ccf5437aa",
2856 "90b7b9630a2378f53f501ab7beff039155008071bc8438e789932cfd3eb1299195465e6633849463fdb44375278e2fdb1310821e6492cf80ff15cb772509fb426f3aeee27bd4938882fd2ae6b5bd9d91fa4a43b17bb439ebbe59c042310163a82a5fe5388796eee35a181a1271f00be29b852d8fa759bad01ff4678f010594cd",
2857
2858 "d2412db0845d84e5732b8bbd642957473b81fb99ca8bff70e7920d16c1dbec89",
2859 "51c619fcf0b23f0c7925f400a6cacb6d",
2860 "026006c4a71a180c9929824d9d095b8faaa86fc4fa25ecac61d85ff6de92dfa8702688c02a282c1b8af4449707f22d75e91991015db22374c95f8f195d5bb0afeb03040ff8965e0e1339dba5653e174f8aa5a1b39fe3ac839ce307a4e44b4f8f1b0063f738ec18acdbff2ebfe07383e734558723e741f0a1836dafdf9de82210a9248bc113b3c1bc8b4e252ca01bd803",
2861 "0254b23463bcabec5a395eb74c8fb0eb137a07bc6f5e9f61ec0b057de305714f8fa294221c91a159c315939b81e300ee902192ec5f15254428d8772f79324ec43298ca21c00b370273ee5e5ed90e43efa1e05a5d171209fe34f9f29237dba2a6726650fd3b1321747d1208863c6c3c6b3e2d879ab5f25782f08ba8f2abbe63e0bedb4a227e81afb36bb6645508356d34",
2862
2863 "48be597e632c16772324c8d3fa1d9c5a9ecd010f14ec5d110d3bfec376c5532b",
2864 "d6d581b8cf04ebd3b6eaa1b53f047ee1",
2865 "0c63d413d3864570e70bb6618bf8a4b9585586688c32bba0a5ecc1362fada74ada32c52acfd1aa7444ba567b4e7daaecf7cc1cb29182af164ae5232b002868695635599807a9a7f07a1f137e97b1e1c9dabc89b6a5e4afa9db5855edaa575056a8f4f8242216242bb0c256310d9d329826ac353d715fa39f80cec144d6424558f9f70b98c920096e0f2c855d594885a00625880e9dfb734163cecef72cf030b8",
2866 "fc5873e50de8faf4c6b84ba707b0854e9db9ab2e9f7d707fbba338c6843a18fc6facebaf663d26296fb329b4d26f18494c79e09e779647f9bafa87489630d79f4301610c2300c19dbf3148b7cac8c4f4944102754f332e92b6f7c5e75bc6179eb877a078d4719009021744c14f13fd2a55a2b9c44d18000685a845a4f632c7c56a77306efa66a24d05d088dcd7c13fe24fc447275965db9e4d37fbc9304448cd",
2867
2868 /*
2869 * End-of-table marker.
2870 */
2871 NULL
2872 };
2873
2874 /*
2875 * AES known-answer tests for CTR. Order: key, IV, plaintext, ciphertext.
2876 */
2877 static const char *const KAT_AES_CTR[] = {
2878 /*
2879 * From RFC 3686.
2880 */
2881 "ae6852f8121067cc4bf7a5765577f39e",
2882 "000000300000000000000000",
2883 "53696e676c6520626c6f636b206d7367",
2884 "e4095d4fb7a7b3792d6175a3261311b8",
2885
2886 "7e24067817fae0d743d6ce1f32539163",
2887 "006cb6dbc0543b59da48d90b",
2888 "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
2889 "5104a106168a72d9790d41ee8edad388eb2e1efc46da57c8fce630df9141be28",
2890
2891 "7691be035e5020a8ac6e618529f9a0dc",
2892 "00e0017b27777f3f4a1786f0",
2893 "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20212223",
2894 "c1cf48a89f2ffdd9cf4652e9efdb72d74540a42bde6d7836d59a5ceaaef3105325b2072f",
2895
2896 "16af5b145fc9f579c175f93e3bfb0eed863d06ccfdb78515",
2897 "0000004836733c147d6d93cb",
2898 "53696e676c6520626c6f636b206d7367",
2899 "4b55384fe259c9c84e7935a003cbe928",
2900
2901 "7c5cb2401b3dc33c19e7340819e0f69c678c3db8e6f6a91a",
2902 "0096b03b020c6eadc2cb500d",
2903 "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
2904 "453243fc609b23327edfaafa7131cd9f8490701c5ad4a79cfc1fe0ff42f4fb00",
2905
2906 "02bf391ee8ecb159b959617b0965279bf59b60a786d3e0fe",
2907 "0007bdfd5cbd60278dcc0912",
2908 "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20212223",
2909 "96893fc55e5c722f540b7dd1ddf7e758d288bc95c69165884536c811662f2188abee0935",
2910
2911 "776beff2851db06f4c8a0542c8696f6c6a81af1eec96b4d37fc1d689e6c1c104",
2912 "00000060db5672c97aa8f0b2",
2913 "53696e676c6520626c6f636b206d7367",
2914 "145ad01dbf824ec7560863dc71e3e0c0",
2915
2916 "f6d66d6bd52d59bb0796365879eff886c66dd51a5b6a99744b50590c87a23884",
2917 "00faac24c1585ef15a43d875",
2918 "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
2919 "f05e231b3894612c49ee000b804eb2a9b8306b508f839d6a5530831d9344af1c",
2920
2921 "ff7a617ce69148e4f1726e2f43581de2aa62d9f805532edff1eed687fb54153d",
2922 "001cc5b751a51d70a1c11148",
2923 "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20212223",
2924 "eb6c52821d0bbbf7ce7594462aca4faab407df866569fd07f48cc0b583d6071f1ec0e6b8",
2925
2926 /*
2927 * End-of-table marker.
2928 */
2929 NULL
2930 };
2931
2932 static void
2933 monte_carlo_AES_encrypt(const br_block_cbcenc_class *ve,
2934 char *skey, char *splain, char *scipher)
2935 {
2936 unsigned char key[32];
2937 unsigned char buf[16];
2938 unsigned char pbuf[16];
2939 unsigned char cipher[16];
2940 size_t key_len;
2941 int i, j, k;
2942 br_aes_gen_cbcenc_keys v_ec;
2943 const br_block_cbcenc_class **ec;
2944
2945 ec = &v_ec.vtable;
2946 key_len = hextobin(key, skey);
2947 hextobin(buf, splain);
2948 hextobin(cipher, scipher);
2949 for (i = 0; i < 100; i ++) {
2950 ve->init(ec, key, key_len);
2951 for (j = 0; j < 1000; j ++) {
2952 unsigned char iv[16];
2953
2954 memcpy(pbuf, buf, sizeof buf);
2955 memset(iv, 0, sizeof iv);
2956 ve->run(ec, iv, buf, sizeof buf);
2957 }
2958 switch (key_len) {
2959 case 16:
2960 for (k = 0; k < 16; k ++) {
2961 key[k] ^= buf[k];
2962 }
2963 break;
2964 case 24:
2965 for (k = 0; k < 8; k ++) {
2966 key[k] ^= pbuf[8 + k];
2967 }
2968 for (k = 0; k < 16; k ++) {
2969 key[8 + k] ^= buf[k];
2970 }
2971 break;
2972 default:
2973 for (k = 0; k < 16; k ++) {
2974 key[k] ^= pbuf[k];
2975 key[16 + k] ^= buf[k];
2976 }
2977 break;
2978 }
2979 printf(".");
2980 fflush(stdout);
2981 }
2982 printf(" ");
2983 fflush(stdout);
2984 check_equals("MC AES encrypt", buf, cipher, sizeof buf);
2985 }
2986
2987 static void
2988 monte_carlo_AES_decrypt(const br_block_cbcdec_class *vd,
2989 char *skey, char *scipher, char *splain)
2990 {
2991 unsigned char key[32];
2992 unsigned char buf[16];
2993 unsigned char pbuf[16];
2994 unsigned char plain[16];
2995 size_t key_len;
2996 int i, j, k;
2997 br_aes_gen_cbcdec_keys v_dc;
2998 const br_block_cbcdec_class **dc;
2999
3000 dc = &v_dc.vtable;
3001 key_len = hextobin(key, skey);
3002 hextobin(buf, scipher);
3003 hextobin(plain, splain);
3004 for (i = 0; i < 100; i ++) {
3005 vd->init(dc, key, key_len);
3006 for (j = 0; j < 1000; j ++) {
3007 unsigned char iv[16];
3008
3009 memcpy(pbuf, buf, sizeof buf);
3010 memset(iv, 0, sizeof iv);
3011 vd->run(dc, iv, buf, sizeof buf);
3012 }
3013 switch (key_len) {
3014 case 16:
3015 for (k = 0; k < 16; k ++) {
3016 key[k] ^= buf[k];
3017 }
3018 break;
3019 case 24:
3020 for (k = 0; k < 8; k ++) {
3021 key[k] ^= pbuf[8 + k];
3022 }
3023 for (k = 0; k < 16; k ++) {
3024 key[8 + k] ^= buf[k];
3025 }
3026 break;
3027 default:
3028 for (k = 0; k < 16; k ++) {
3029 key[k] ^= pbuf[k];
3030 key[16 + k] ^= buf[k];
3031 }
3032 break;
3033 }
3034 printf(".");
3035 fflush(stdout);
3036 }
3037 printf(" ");
3038 fflush(stdout);
3039 check_equals("MC AES decrypt", buf, plain, sizeof buf);
3040 }
3041
3042 static void
3043 test_AES_generic(char *name,
3044 const br_block_cbcenc_class *ve,
3045 const br_block_cbcdec_class *vd,
3046 const br_block_ctr_class *vc,
3047 int with_MC, int with_CBC)
3048 {
3049 size_t u;
3050
3051 printf("Test %s: ", name);
3052 fflush(stdout);
3053
3054 if (ve->block_size != 16 || vd->block_size != 16
3055 || ve->log_block_size != 4 || vd->log_block_size != 4)
3056 {
3057 fprintf(stderr, "%s failed: wrong block size\n", name);
3058 exit(EXIT_FAILURE);
3059 }
3060
3061 for (u = 0; KAT_AES[u]; u += 3) {
3062 unsigned char key[32];
3063 unsigned char plain[16];
3064 unsigned char cipher[16];
3065 unsigned char buf[16];
3066 unsigned char iv[16];
3067 size_t key_len;
3068 br_aes_gen_cbcenc_keys v_ec;
3069 br_aes_gen_cbcdec_keys v_dc;
3070 const br_block_cbcenc_class **ec;
3071 const br_block_cbcdec_class **dc;
3072
3073 ec = &v_ec.vtable;
3074 dc = &v_dc.vtable;
3075 key_len = hextobin(key, KAT_AES[u]);
3076 hextobin(plain, KAT_AES[u + 1]);
3077 hextobin(cipher, KAT_AES[u + 2]);
3078 ve->init(ec, key, key_len);
3079 memcpy(buf, plain, sizeof plain);
3080 memset(iv, 0, sizeof iv);
3081 ve->run(ec, iv, buf, sizeof buf);
3082 check_equals("KAT AES encrypt", buf, cipher, sizeof cipher);
3083 vd->init(dc, key, key_len);
3084 memset(iv, 0, sizeof iv);
3085 vd->run(dc, iv, buf, sizeof buf);
3086 check_equals("KAT AES decrypt", buf, plain, sizeof plain);
3087 }
3088
3089 if (with_CBC) {
3090 for (u = 0; KAT_AES_CBC[u]; u += 4) {
3091 unsigned char key[32];
3092 unsigned char ivref[16];
3093 unsigned char plain[200];
3094 unsigned char cipher[200];
3095 unsigned char buf[200];
3096 unsigned char iv[16];
3097 size_t key_len, data_len, v;
3098 br_aes_gen_cbcenc_keys v_ec;
3099 br_aes_gen_cbcdec_keys v_dc;
3100 const br_block_cbcenc_class **ec;
3101 const br_block_cbcdec_class **dc;
3102
3103 ec = &v_ec.vtable;
3104 dc = &v_dc.vtable;
3105 key_len = hextobin(key, KAT_AES_CBC[u]);
3106 hextobin(ivref, KAT_AES_CBC[u + 1]);
3107 data_len = hextobin(plain, KAT_AES_CBC[u + 2]);
3108 hextobin(cipher, KAT_AES_CBC[u + 3]);
3109 ve->init(ec, key, key_len);
3110
3111 memcpy(buf, plain, data_len);
3112 memcpy(iv, ivref, 16);
3113 ve->run(ec, iv, buf, data_len);
3114 check_equals("KAT CBC AES encrypt",
3115 buf, cipher, data_len);
3116 vd->init(dc, key, key_len);
3117 memcpy(iv, ivref, 16);
3118 vd->run(dc, iv, buf, data_len);
3119 check_equals("KAT CBC AES decrypt",
3120 buf, plain, data_len);
3121
3122 memcpy(buf, plain, data_len);
3123 memcpy(iv, ivref, 16);
3124 for (v = 0; v < data_len; v += 16) {
3125 ve->run(ec, iv, buf + v, 16);
3126 }
3127 check_equals("KAT CBC AES encrypt (2)",
3128 buf, cipher, data_len);
3129 memcpy(iv, ivref, 16);
3130 for (v = 0; v < data_len; v += 16) {
3131 vd->run(dc, iv, buf + v, 16);
3132 }
3133 check_equals("KAT CBC AES decrypt (2)",
3134 buf, plain, data_len);
3135 }
3136 }
3137
3138 if (vc != NULL) {
3139 if (vc->block_size != 16 || vc->log_block_size != 4) {
3140 fprintf(stderr, "%s failed: wrong block size\n", name);
3141 exit(EXIT_FAILURE);
3142 }
3143 for (u = 0; KAT_AES_CTR[u]; u += 4) {
3144 unsigned char key[32];
3145 unsigned char iv[12];
3146 unsigned char plain[200];
3147 unsigned char cipher[200];
3148 unsigned char buf[200];
3149 size_t key_len, data_len, v;
3150 uint32_t c;
3151 br_aes_gen_ctr_keys v_xc;
3152 const br_block_ctr_class **xc;
3153
3154 xc = &v_xc.vtable;
3155 key_len = hextobin(key, KAT_AES_CTR[u]);
3156 hextobin(iv, KAT_AES_CTR[u + 1]);
3157 data_len = hextobin(plain, KAT_AES_CTR[u + 2]);
3158 hextobin(cipher, KAT_AES_CTR[u + 3]);
3159 vc->init(xc, key, key_len);
3160
3161 memcpy(buf, plain, data_len);
3162 vc->run(xc, iv, 1, buf, data_len);
3163 check_equals("KAT CTR AES (1)", buf, cipher, data_len);
3164 vc->run(xc, iv, 1, buf, data_len);
3165 check_equals("KAT CTR AES (2)", buf, plain, data_len);
3166
3167 memcpy(buf, plain, data_len);
3168 c = 1;
3169 for (v = 0; v < data_len; v += 32) {
3170 size_t clen;
3171
3172 clen = data_len - v;
3173 if (clen > 32) {
3174 clen = 32;
3175 }
3176 c = vc->run(xc, iv, c, buf + v, clen);
3177 }
3178 check_equals("KAT CTR AES (3)", buf, cipher, data_len);
3179
3180 memcpy(buf, plain, data_len);
3181 c = 1;
3182 for (v = 0; v < data_len; v += 16) {
3183 size_t clen;
3184
3185 clen = data_len - v;
3186 if (clen > 16) {
3187 clen = 16;
3188 }
3189 c = vc->run(xc, iv, c, buf + v, clen);
3190 }
3191 check_equals("KAT CTR AES (4)", buf, cipher, data_len);
3192 }
3193 }
3194
3195 if (with_MC) {
3196 monte_carlo_AES_encrypt(
3197 ve,
3198 "139a35422f1d61de3c91787fe0507afd",
3199 "b9145a768b7dc489a096b546f43b231f",
3200 "fb2649694783b551eacd9d5db6126d47");
3201 monte_carlo_AES_decrypt(
3202 vd,
3203 "0c60e7bf20ada9baa9e1ddf0d1540726",
3204 "b08a29b11a500ea3aca42c36675b9785",
3205 "d1d2bfdc58ffcad2341b095bce55221e");
3206
3207 monte_carlo_AES_encrypt(
3208 ve,
3209 "b9a63e09e1dfc42e93a90d9bad739e5967aef672eedd5da9",
3210 "85a1f7a58167b389cddc8a9ff175ee26",
3211 "5d1196da8f184975e240949a25104554");
3212 monte_carlo_AES_decrypt(
3213 vd,
3214 "4b97585701c03fbebdfa8555024f589f1482c58a00fdd9fd",
3215 "d0bd0e02ded155e4516be83f42d347a4",
3216 "b63ef1b79507a62eba3dafcec54a6328");
3217
3218 monte_carlo_AES_encrypt(
3219 ve,
3220 "f9e8389f5b80712e3886cc1fa2d28a3b8c9cd88a2d4a54c6aa86ce0fef944be0",
3221 "b379777f9050e2a818f2940cbbd9aba4",
3222 "c5d2cb3d5b7ff0e23e308967ee074825");
3223 monte_carlo_AES_decrypt(
3224 vd,
3225 "2b09ba39b834062b9e93f48373b8dd018dedf1e5ba1b8af831ebbacbc92a2643",
3226 "89649bd0115f30bd878567610223a59d",
3227 "e3d3868f578caf34e36445bf14cefc68");
3228 }
3229
3230 printf("done.\n");
3231 fflush(stdout);
3232 }
3233
3234 static void
3235 test_AES_big(void)
3236 {
3237 test_AES_generic("AES_big",
3238 &br_aes_big_cbcenc_vtable,
3239 &br_aes_big_cbcdec_vtable,
3240 &br_aes_big_ctr_vtable,
3241 1, 1);
3242 }
3243
3244 static void
3245 test_AES_small(void)
3246 {
3247 test_AES_generic("AES_small",
3248 &br_aes_small_cbcenc_vtable,
3249 &br_aes_small_cbcdec_vtable,
3250 &br_aes_small_ctr_vtable,
3251 1, 1);
3252 }
3253
3254 static void
3255 test_AES_ct(void)
3256 {
3257 test_AES_generic("AES_ct",
3258 &br_aes_ct_cbcenc_vtable,
3259 &br_aes_ct_cbcdec_vtable,
3260 &br_aes_ct_ctr_vtable,
3261 1, 1);
3262 }
3263
3264 static void
3265 test_AES_ct64(void)
3266 {
3267 test_AES_generic("AES_ct64",
3268 &br_aes_ct64_cbcenc_vtable,
3269 &br_aes_ct64_cbcdec_vtable,
3270 &br_aes_ct64_ctr_vtable,
3271 1, 1);
3272 }
3273
3274 /*
3275 * DES known-answer tests. Order: plaintext, key, ciphertext.
3276 * (mostly from NIST SP 800-20).
3277 */
3278 static const char *const KAT_DES[] = {
3279 "10316E028C8F3B4A", "0000000000000000", "82DCBAFBDEAB6602",
3280 "8000000000000000", "0000000000000000", "95A8D72813DAA94D",
3281 "4000000000000000", "0000000000000000", "0EEC1487DD8C26D5",
3282 "2000000000000000", "0000000000000000", "7AD16FFB79C45926",
3283 "1000000000000000", "0000000000000000", "D3746294CA6A6CF3",
3284 "0800000000000000", "0000000000000000", "809F5F873C1FD761",
3285 "0400000000000000", "0000000000000000", "C02FAFFEC989D1FC",
3286 "0200000000000000", "0000000000000000", "4615AA1D33E72F10",
3287 "0100000000000000", "0000000000000000", "8CA64DE9C1B123A7",
3288 "0080000000000000", "0000000000000000", "2055123350C00858",
3289 "0040000000000000", "0000000000000000", "DF3B99D6577397C8",
3290 "0020000000000000", "0000000000000000", "31FE17369B5288C9",
3291 "0010000000000000", "0000000000000000", "DFDD3CC64DAE1642",
3292 "0008000000000000", "0000000000000000", "178C83CE2B399D94",
3293 "0004000000000000", "0000000000000000", "50F636324A9B7F80",
3294 "0002000000000000", "0000000000000000", "A8468EE3BC18F06D",
3295 "0001000000000000", "0000000000000000", "8CA64DE9C1B123A7",
3296 "0000800000000000", "0000000000000000", "A2DC9E92FD3CDE92",
3297 "0000400000000000", "0000000000000000", "CAC09F797D031287",
3298 "0000200000000000", "0000000000000000", "90BA680B22AEB525",
3299 "0000100000000000", "0000000000000000", "CE7A24F350E280B6",
3300 "0000080000000000", "0000000000000000", "882BFF0AA01A0B87",
3301 "0000040000000000", "0000000000000000", "25610288924511C2",
3302 "0000020000000000", "0000000000000000", "C71516C29C75D170",
3303 "0000010000000000", "0000000000000000", "8CA64DE9C1B123A7",
3304 "0000008000000000", "0000000000000000", "5199C29A52C9F059",
3305 "0000004000000000", "0000000000000000", "C22F0A294A71F29F",
3306 "0000002000000000", "0000000000000000", "EE371483714C02EA",
3307 "0000001000000000", "0000000000000000", "A81FBD448F9E522F",
3308 "0000000800000000", "0000000000000000", "4F644C92E192DFED",
3309 "0000000400000000", "0000000000000000", "1AFA9A66A6DF92AE",
3310 "0000000200000000", "0000000000000000", "B3C1CC715CB879D8",
3311 "0000000100000000", "0000000000000000", "8CA64DE9C1B123A7",
3312 "0000000080000000", "0000000000000000", "19D032E64AB0BD8B",
3313 "0000000040000000", "0000000000000000", "3CFAA7A7DC8720DC",
3314 "0000000020000000", "0000000000000000", "B7265F7F447AC6F3",
3315 "0000000010000000", "0000000000000000", "9DB73B3C0D163F54",
3316 "0000000008000000", "0000000000000000", "8181B65BABF4A975",
3317 "0000000004000000", "0000000000000000", "93C9B64042EAA240",
3318 "0000000002000000", "0000000000000000", "5570530829705592",
3319 "0000000001000000", "0000000000000000", "8CA64DE9C1B123A7",
3320 "0000000000800000", "0000000000000000", "8638809E878787A0",
3321 "0000000000400000", "0000000000000000", "41B9A79AF79AC208",
3322 "0000000000200000", "0000000000000000", "7A9BE42F2009A892",
3323 "0000000000100000", "0000000000000000", "29038D56BA6D2745",
3324 &