8 typedef UINT32 uint32_t;
17 #define GET_UINT32_BE(n,b,i) \
19 (n) = ( (uint32_t) (b)[(i) ] << 24 ) \
20 | ( (uint32_t) (b)[(i) + 1] << 16 ) \
21 | ( (uint32_t) (b)[(i) + 2] << 8 ) \
22 | ( (uint32_t) (b)[(i) + 3] ); \
27 #define PUT_UINT32_BE(n,b,i) \
29 (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
30 (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
31 (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
32 (b)[(i) + 3] = (unsigned char) ( (n) ); \
36 int unhexify(
unsigned char *obuf,
const char *ibuf)
39 int len = strlen(ibuf) / 2;
40 assert(!(strlen(ibuf) %1));
45 if( c >=
'0' && c <=
'9' )
47 else if( c >=
'a' && c <=
'f' )
49 else if( c >=
'A' && c <=
'F' )
55 if( c2 >=
'0' && c2 <=
'9' )
57 else if( c2 >=
'a' && c2 <=
'f' )
59 else if( c2 >=
'A' && c2 <=
'F' )
64 *obuf++ = ( c << 4 ) | c2;
70 void hexify(
unsigned char *obuf,
const unsigned char *ibuf,
int len)
82 *obuf++ =
'a' + h - 10;
87 *obuf++ =
'a' + l - 10;
103 static int rnd_std_rand(
void *rng_state,
unsigned char *output,
size_t len )
107 if( rng_state != NULL )
110 for( i = 0; i < len; ++i )
121 static int rnd_zero_rand(
void *rng_state,
unsigned char *output,
size_t len )
123 if( rng_state != NULL )
126 memset( output, 0, len );
153 if( rng_state == NULL )
162 memcpy( output, info->
buf, use_len );
163 info->
buf += use_len;
167 if( len - use_len > 0 )
168 return(
rnd_std_rand( NULL, output + use_len, len - use_len ) );
197 uint32_t i, *k, sum, delta=0x9E3779B9;
198 unsigned char result[4];
200 if( rng_state == NULL )
207 size_t use_len = ( len > 4 ) ? 4 : len;
210 for( i = 0; i < 32; i++ )
212 info->
v0 += (((info->
v1 << 4) ^ (info->
v1 >> 5)) + info->
v1) ^ (sum + k[sum & 3]);
214 info->
v1 += (((info->
v0 << 4) ^ (info->
v0 >> 5)) + info->
v0) ^ (sum + k[(sum>>11) & 3]);
218 memcpy( output, result, use_len );
228 #ifdef POLARSSL_AES_C
231 FCT_SUITE_BGN(test_suite_aes)
234 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_1)
236 unsigned char key_str[100];
237 unsigned char src_str[100];
238 unsigned char dst_str[100];
239 unsigned char output[100];
243 memset(key_str, 0x00, 100);
244 memset(src_str, 0x00, 100);
245 memset(dst_str, 0x00, 100);
246 memset(output, 0x00, 100);
248 key_len =
unhexify( key_str,
"00000000000000000000000000000000" );
249 unhexify( src_str,
"f34481ec3cc627bacd5dc3fb08f273e6" );
255 hexify( dst_str, output, 16 );
257 fct_chk( strcmp( (
char *) dst_str,
"0336763e966d92595a567cc9ce537f5e" ) == 0 );
263 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_2)
265 unsigned char key_str[100];
266 unsigned char src_str[100];
267 unsigned char dst_str[100];
268 unsigned char output[100];
272 memset(key_str, 0x00, 100);
273 memset(src_str, 0x00, 100);
274 memset(dst_str, 0x00, 100);
275 memset(output, 0x00, 100);
277 key_len =
unhexify( key_str,
"00000000000000000000000000000000" );
278 unhexify( src_str,
"9798c4640bad75c7c3227db910174e72" );
284 hexify( dst_str, output, 16 );
286 fct_chk( strcmp( (
char *) dst_str,
"a9a1631bf4996954ebc093957b234589" ) == 0 );
292 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_3)
294 unsigned char key_str[100];
295 unsigned char src_str[100];
296 unsigned char dst_str[100];
297 unsigned char output[100];
301 memset(key_str, 0x00, 100);
302 memset(src_str, 0x00, 100);
303 memset(dst_str, 0x00, 100);
304 memset(output, 0x00, 100);
306 key_len =
unhexify( key_str,
"00000000000000000000000000000000" );
307 unhexify( src_str,
"96ab5c2ff612d9dfaae8c31f30c42168" );
313 hexify( dst_str, output, 16 );
315 fct_chk( strcmp( (
char *) dst_str,
"ff4f8391a6a40ca5b25d23bedd44a597" ) == 0 );
321 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_4)
323 unsigned char key_str[100];
324 unsigned char src_str[100];
325 unsigned char dst_str[100];
326 unsigned char output[100];
330 memset(key_str, 0x00, 100);
331 memset(src_str, 0x00, 100);
332 memset(dst_str, 0x00, 100);
333 memset(output, 0x00, 100);
335 key_len =
unhexify( key_str,
"e0000000000000000000000000000000" );
336 unhexify( src_str,
"00000000000000000000000000000000" );
342 hexify( dst_str, output, 16 );
344 fct_chk( strcmp( (
char *) dst_str,
"72a1da770f5d7ac4c9ef94d822affd97" ) == 0 );
350 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_5)
352 unsigned char key_str[100];
353 unsigned char src_str[100];
354 unsigned char dst_str[100];
355 unsigned char output[100];
359 memset(key_str, 0x00, 100);
360 memset(src_str, 0x00, 100);
361 memset(dst_str, 0x00, 100);
362 memset(output, 0x00, 100);
364 key_len =
unhexify( key_str,
"f0000000000000000000000000000000" );
365 unhexify( src_str,
"00000000000000000000000000000000" );
371 hexify( dst_str, output, 16 );
373 fct_chk( strcmp( (
char *) dst_str,
"970014d634e2b7650777e8e84d03ccd8" ) == 0 );
379 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_6)
381 unsigned char key_str[100];
382 unsigned char src_str[100];
383 unsigned char dst_str[100];
384 unsigned char output[100];
388 memset(key_str, 0x00, 100);
389 memset(src_str, 0x00, 100);
390 memset(dst_str, 0x00, 100);
391 memset(output, 0x00, 100);
393 key_len =
unhexify( key_str,
"f8000000000000000000000000000000" );
394 unhexify( src_str,
"00000000000000000000000000000000" );
400 hexify( dst_str, output, 16 );
402 fct_chk( strcmp( (
char *) dst_str,
"f17e79aed0db7e279e955b5f493875a7" ) == 0 );
408 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_7)
410 unsigned char key_str[100];
411 unsigned char src_str[100];
412 unsigned char dst_str[100];
413 unsigned char output[100];
417 memset(key_str, 0x00, 100);
418 memset(src_str, 0x00, 100);
419 memset(dst_str, 0x00, 100);
420 memset(output, 0x00, 100);
422 key_len =
unhexify( key_str,
"fffffffffffff0000000000000000000" );
423 unhexify( src_str,
"00000000000000000000000000000000" );
429 hexify( dst_str, output, 16 );
431 fct_chk( strcmp( (
char *) dst_str,
"7b90785125505fad59b13c186dd66ce3" ) == 0 );
437 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_8)
439 unsigned char key_str[100];
440 unsigned char src_str[100];
441 unsigned char dst_str[100];
442 unsigned char output[100];
446 memset(key_str, 0x00, 100);
447 memset(src_str, 0x00, 100);
448 memset(dst_str, 0x00, 100);
449 memset(output, 0x00, 100);
451 key_len =
unhexify( key_str,
"fffffffffffff8000000000000000000" );
452 unhexify( src_str,
"00000000000000000000000000000000" );
458 hexify( dst_str, output, 16 );
460 fct_chk( strcmp( (
char *) dst_str,
"8b527a6aebdaec9eaef8eda2cb7783e5" ) == 0 );
466 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_9)
468 unsigned char key_str[100];
469 unsigned char src_str[100];
470 unsigned char dst_str[100];
471 unsigned char output[100];
475 memset(key_str, 0x00, 100);
476 memset(src_str, 0x00, 100);
477 memset(dst_str, 0x00, 100);
478 memset(output, 0x00, 100);
480 key_len =
unhexify( key_str,
"fffffffffffffc000000000000000000" );
481 unhexify( src_str,
"00000000000000000000000000000000" );
487 hexify( dst_str, output, 16 );
489 fct_chk( strcmp( (
char *) dst_str,
"43fdaf53ebbc9880c228617d6a9b548b" ) == 0 );
495 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_10)
497 unsigned char key_str[100];
498 unsigned char src_str[100];
499 unsigned char dst_str[100];
500 unsigned char output[100];
504 memset(key_str, 0x00, 100);
505 memset(src_str, 0x00, 100);
506 memset(dst_str, 0x00, 100);
507 memset(output, 0x00, 100);
509 key_len =
unhexify( key_str,
"ffffffffffffffffffffffffffffc000" );
510 unhexify( src_str,
"00000000000000000000000000000000" );
516 hexify( dst_str, output, 16 );
518 fct_chk( strcmp( (
char *) dst_str,
"70c46bb30692be657f7eaa93ebad9897" ) == 0 );
524 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_11)
526 unsigned char key_str[100];
527 unsigned char src_str[100];
528 unsigned char dst_str[100];
529 unsigned char output[100];
533 memset(key_str, 0x00, 100);
534 memset(src_str, 0x00, 100);
535 memset(dst_str, 0x00, 100);
536 memset(output, 0x00, 100);
538 key_len =
unhexify( key_str,
"ffffffffffffffffffffffffffffe000" );
539 unhexify( src_str,
"00000000000000000000000000000000" );
545 hexify( dst_str, output, 16 );
547 fct_chk( strcmp( (
char *) dst_str,
"323994cfb9da285a5d9642e1759b224a" ) == 0 );
553 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_12)
555 unsigned char key_str[100];
556 unsigned char src_str[100];
557 unsigned char dst_str[100];
558 unsigned char output[100];
562 memset(key_str, 0x00, 100);
563 memset(src_str, 0x00, 100);
564 memset(dst_str, 0x00, 100);
565 memset(output, 0x00, 100);
567 key_len =
unhexify( key_str,
"fffffffffffffffffffffffffffff000" );
568 unhexify( src_str,
"00000000000000000000000000000000" );
574 hexify( dst_str, output, 16 );
576 fct_chk( strcmp( (
char *) dst_str,
"1dbf57877b7b17385c85d0b54851e371" ) == 0 );
582 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_13)
584 unsigned char key_str[100];
585 unsigned char src_str[100];
586 unsigned char dst_str[100];
587 unsigned char output[100];
591 memset(key_str, 0x00, 100);
592 memset(src_str, 0x00, 100);
593 memset(dst_str, 0x00, 100);
594 memset(output, 0x00, 100);
596 key_len =
unhexify( key_str,
"00000000000000000000000000000000" );
597 unhexify( src_str,
"ffffffffffffffc00000000000000000" );
603 hexify( dst_str, output, 16 );
605 fct_chk( strcmp( (
char *) dst_str,
"3a4d354f02bb5a5e47d39666867f246a" ) == 0 );
611 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_14)
613 unsigned char key_str[100];
614 unsigned char src_str[100];
615 unsigned char dst_str[100];
616 unsigned char output[100];
620 memset(key_str, 0x00, 100);
621 memset(src_str, 0x00, 100);
622 memset(dst_str, 0x00, 100);
623 memset(output, 0x00, 100);
625 key_len =
unhexify( key_str,
"00000000000000000000000000000000" );
626 unhexify( src_str,
"ffffffffffffffe00000000000000000" );
632 hexify( dst_str, output, 16 );
634 fct_chk( strcmp( (
char *) dst_str,
"d451b8d6e1e1a0ebb155fbbf6e7b7dc3" ) == 0 );
640 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_15)
642 unsigned char key_str[100];
643 unsigned char src_str[100];
644 unsigned char dst_str[100];
645 unsigned char output[100];
649 memset(key_str, 0x00, 100);
650 memset(src_str, 0x00, 100);
651 memset(dst_str, 0x00, 100);
652 memset(output, 0x00, 100);
654 key_len =
unhexify( key_str,
"00000000000000000000000000000000" );
655 unhexify( src_str,
"fffffffffffffff00000000000000000" );
661 hexify( dst_str, output, 16 );
663 fct_chk( strcmp( (
char *) dst_str,
"6898d4f42fa7ba6a10ac05e87b9f2080" ) == 0 );
669 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_16)
671 unsigned char key_str[100];
672 unsigned char src_str[100];
673 unsigned char dst_str[100];
674 unsigned char output[100];
678 memset(key_str, 0x00, 100);
679 memset(src_str, 0x00, 100);
680 memset(dst_str, 0x00, 100);
681 memset(output, 0x00, 100);
683 key_len =
unhexify( key_str,
"00000000000000000000000000000000" );
684 unhexify( src_str,
"ffffffffffffffffffffffffe0000000" );
690 hexify( dst_str, output, 16 );
692 fct_chk( strcmp( (
char *) dst_str,
"082eb8be35f442fb52668e16a591d1d6" ) == 0 );
698 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_17)
700 unsigned char key_str[100];
701 unsigned char src_str[100];
702 unsigned char dst_str[100];
703 unsigned char output[100];
707 memset(key_str, 0x00, 100);
708 memset(src_str, 0x00, 100);
709 memset(dst_str, 0x00, 100);
710 memset(output, 0x00, 100);
712 key_len =
unhexify( key_str,
"00000000000000000000000000000000" );
713 unhexify( src_str,
"fffffffffffffffffffffffff0000000" );
719 hexify( dst_str, output, 16 );
721 fct_chk( strcmp( (
char *) dst_str,
"e656f9ecf5fe27ec3e4a73d00c282fb3" ) == 0 );
727 FCT_TEST_BGN(aes_128_ecb_encrypt_nist_kat_18)
729 unsigned char key_str[100];
730 unsigned char src_str[100];
731 unsigned char dst_str[100];
732 unsigned char output[100];
736 memset(key_str, 0x00, 100);
737 memset(src_str, 0x00, 100);
738 memset(dst_str, 0x00, 100);
739 memset(output, 0x00, 100);
741 key_len =
unhexify( key_str,
"00000000000000000000000000000000" );
742 unhexify( src_str,
"fffffffffffffffffffffffff8000000" );
748 hexify( dst_str, output, 16 );
750 fct_chk( strcmp( (
char *) dst_str,
"2ca8209d63274cd9a29bb74bcd77683a" ) == 0 );
756 FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_1)
758 unsigned char key_str[100];
759 unsigned char src_str[100];
760 unsigned char dst_str[100];
761 unsigned char output[100];
765 memset(key_str, 0x00, 100);
766 memset(src_str, 0x00, 100);
767 memset(dst_str, 0x00, 100);
768 memset(output, 0x00, 100);
770 key_len =
unhexify( key_str,
"00000000000000000000000000000000" );
771 unhexify( src_str,
"db4f1aa530967d6732ce4715eb0ee24b" );
777 hexify( dst_str, output, 16 );
779 fct_chk( strcmp( (
char *) dst_str,
"ff000000000000000000000000000000" ) == 0 );
785 FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_2)
787 unsigned char key_str[100];
788 unsigned char src_str[100];
789 unsigned char dst_str[100];
790 unsigned char output[100];
794 memset(key_str, 0x00, 100);
795 memset(src_str, 0x00, 100);
796 memset(dst_str, 0x00, 100);
797 memset(output, 0x00, 100);
799 key_len =
unhexify( key_str,
"00000000000000000000000000000000" );
800 unhexify( src_str,
"a81738252621dd180a34f3455b4baa2f" );
806 hexify( dst_str, output, 16 );
808 fct_chk( strcmp( (
char *) dst_str,
"ff800000000000000000000000000000" ) == 0 );
814 FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_3)
816 unsigned char key_str[100];
817 unsigned char src_str[100];
818 unsigned char dst_str[100];
819 unsigned char output[100];
823 memset(key_str, 0x00, 100);
824 memset(src_str, 0x00, 100);
825 memset(dst_str, 0x00, 100);
826 memset(output, 0x00, 100);
828 key_len =
unhexify( key_str,
"00000000000000000000000000000000" );
829 unhexify( src_str,
"77e2b508db7fd89234caf7939ee5621a" );
835 hexify( dst_str, output, 16 );
837 fct_chk( strcmp( (
char *) dst_str,
"ffc00000000000000000000000000000" ) == 0 );
843 FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_4)
845 unsigned char key_str[100];
846 unsigned char src_str[100];
847 unsigned char dst_str[100];
848 unsigned char output[100];
852 memset(key_str, 0x00, 100);
853 memset(src_str, 0x00, 100);
854 memset(dst_str, 0x00, 100);
855 memset(output, 0x00, 100);
857 key_len =
unhexify( key_str,
"00000000000000000000000000000000" );
858 unhexify( src_str,
"dc43be40be0e53712f7e2bf5ca707209" );
864 hexify( dst_str, output, 16 );
866 fct_chk( strcmp( (
char *) dst_str,
"6a118a874519e64e9963798a503f1d35" ) == 0 );
872 FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_5)
874 unsigned char key_str[100];
875 unsigned char src_str[100];
876 unsigned char dst_str[100];
877 unsigned char output[100];
881 memset(key_str, 0x00, 100);
882 memset(src_str, 0x00, 100);
883 memset(dst_str, 0x00, 100);
884 memset(output, 0x00, 100);
886 key_len =
unhexify( key_str,
"00000000000000000000000000000000" );
887 unhexify( src_str,
"92beedab1895a94faa69b632e5cc47ce" );
893 hexify( dst_str, output, 16 );
895 fct_chk( strcmp( (
char *) dst_str,
"cb9fceec81286ca3e989bd979b0cb284" ) == 0 );
901 FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_6)
903 unsigned char key_str[100];
904 unsigned char src_str[100];
905 unsigned char dst_str[100];
906 unsigned char output[100];
910 memset(key_str, 0x00, 100);
911 memset(src_str, 0x00, 100);
912 memset(dst_str, 0x00, 100);
913 memset(output, 0x00, 100);
915 key_len =
unhexify( key_str,
"00000000000000000000000000000000" );
916 unhexify( src_str,
"459264f4798f6a78bacb89c15ed3d601" );
922 hexify( dst_str, output, 16 );
924 fct_chk( strcmp( (
char *) dst_str,
"b26aeb1874e47ca8358ff22378f09144" ) == 0 );
930 FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_7)
932 unsigned char key_str[100];
933 unsigned char src_str[100];
934 unsigned char dst_str[100];
935 unsigned char output[100];
939 memset(key_str, 0x00, 100);
940 memset(src_str, 0x00, 100);
941 memset(dst_str, 0x00, 100);
942 memset(output, 0x00, 100);
944 key_len =
unhexify( key_str,
"b69418a85332240dc82492353956ae0c" );
945 unhexify( src_str,
"a303d940ded8f0baff6f75414cac5243" );
951 hexify( dst_str, output, 16 );
953 fct_chk( strcmp( (
char *) dst_str,
"00000000000000000000000000000000" ) == 0 );
959 FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_8)
961 unsigned char key_str[100];
962 unsigned char src_str[100];
963 unsigned char dst_str[100];
964 unsigned char output[100];
968 memset(key_str, 0x00, 100);
969 memset(src_str, 0x00, 100);
970 memset(dst_str, 0x00, 100);
971 memset(output, 0x00, 100);
973 key_len =
unhexify( key_str,
"71b5c08a1993e1362e4d0ce9b22b78d5" );
974 unhexify( src_str,
"c2dabd117f8a3ecabfbb11d12194d9d0" );
980 hexify( dst_str, output, 16 );
982 fct_chk( strcmp( (
char *) dst_str,
"00000000000000000000000000000000" ) == 0 );
988 FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_9)
990 unsigned char key_str[100];
991 unsigned char src_str[100];
992 unsigned char dst_str[100];
993 unsigned char output[100];
997 memset(key_str, 0x00, 100);
998 memset(src_str, 0x00, 100);
999 memset(dst_str, 0x00, 100);
1000 memset(output, 0x00, 100);
1002 key_len =
unhexify( key_str,
"e234cdca2606b81f29408d5f6da21206" );
1003 unhexify( src_str,
"fff60a4740086b3b9c56195b98d91a7b" );
1009 hexify( dst_str, output, 16 );
1011 fct_chk( strcmp( (
char *) dst_str,
"00000000000000000000000000000000" ) == 0 );
1017 FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_10)
1019 unsigned char key_str[100];
1020 unsigned char src_str[100];
1021 unsigned char dst_str[100];
1022 unsigned char output[100];
1026 memset(key_str, 0x00, 100);
1027 memset(src_str, 0x00, 100);
1028 memset(dst_str, 0x00, 100);
1029 memset(output, 0x00, 100);
1031 key_len =
unhexify( key_str,
"ffffffffffffffff0000000000000000" );
1032 unhexify( src_str,
"84be19e053635f09f2665e7bae85b42d" );
1038 hexify( dst_str, output, 16 );
1040 fct_chk( strcmp( (
char *) dst_str,
"00000000000000000000000000000000" ) == 0 );
1046 FCT_TEST_BGN(aes_128_ecb_decrypt_nist_kat_11)
1048 unsigned char key_str[100];
1049 unsigned char src_str[100];
1050 unsigned char dst_str[100];
1051 unsigned char output[100];
1055 memset(key_str, 0x00, 100);
1056 memset(src_str, 0x00, 100);
1057 memset(dst_str, 0x00, 100);
1058 memset(output, 0x00, 100);
1060 key_len =
unhexify( key_str,
"ffffffffffffffff8000000000000000" );
1061 unhexify( src_str,
"32cd652842926aea4aa6137bb2be2b5e" );
1067 hexify( dst_str, output, 16 );
1069 fct_chk( strcmp( (
char *) dst_str,
"00000000000000000000000000000000" ) == 0 );
1075 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_1)
1077 unsigned char key_str[100];
1078 unsigned char src_str[100];
1079 unsigned char dst_str[100];
1080 unsigned char output[100];
1084 memset(key_str, 0x00, 100);
1085 memset(src_str, 0x00, 100);
1086 memset(dst_str, 0x00, 100);
1087 memset(output, 0x00, 100);
1089 key_len =
unhexify( key_str,
"000000000000000000000000000000000000000000000000" );
1090 unhexify( src_str,
"fffffffffffffffffffff80000000000" );
1096 hexify( dst_str, output, 16 );
1098 fct_chk( strcmp( (
char *) dst_str,
"156f07767a85a4312321f63968338a01" ) == 0 );
1104 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_2)
1106 unsigned char key_str[100];
1107 unsigned char src_str[100];
1108 unsigned char dst_str[100];
1109 unsigned char output[100];
1113 memset(key_str, 0x00, 100);
1114 memset(src_str, 0x00, 100);
1115 memset(dst_str, 0x00, 100);
1116 memset(output, 0x00, 100);
1118 key_len =
unhexify( key_str,
"000000000000000000000000000000000000000000000000" );
1119 unhexify( src_str,
"fffffffffffffffffffffc0000000000" );
1125 hexify( dst_str, output, 16 );
1127 fct_chk( strcmp( (
char *) dst_str,
"15eec9ebf42b9ca76897d2cd6c5a12e2" ) == 0 );
1133 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_3)
1135 unsigned char key_str[100];
1136 unsigned char src_str[100];
1137 unsigned char dst_str[100];
1138 unsigned char output[100];
1142 memset(key_str, 0x00, 100);
1143 memset(src_str, 0x00, 100);
1144 memset(dst_str, 0x00, 100);
1145 memset(output, 0x00, 100);
1147 key_len =
unhexify( key_str,
"000000000000000000000000000000000000000000000000" );
1148 unhexify( src_str,
"fffffffffffffffffffffe0000000000" );
1154 hexify( dst_str, output, 16 );
1156 fct_chk( strcmp( (
char *) dst_str,
"db0d3a6fdcc13f915e2b302ceeb70fd8" ) == 0 );
1162 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_4)
1164 unsigned char key_str[100];
1165 unsigned char src_str[100];
1166 unsigned char dst_str[100];
1167 unsigned char output[100];
1171 memset(key_str, 0x00, 100);
1172 memset(src_str, 0x00, 100);
1173 memset(dst_str, 0x00, 100);
1174 memset(output, 0x00, 100);
1176 key_len =
unhexify( key_str,
"000000000000000000000000000000000000000000000000" );
1177 unhexify( src_str,
"51719783d3185a535bd75adc65071ce1" );
1183 hexify( dst_str, output, 16 );
1185 fct_chk( strcmp( (
char *) dst_str,
"4f354592ff7c8847d2d0870ca9481b7c" ) == 0 );
1191 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_5)
1193 unsigned char key_str[100];
1194 unsigned char src_str[100];
1195 unsigned char dst_str[100];
1196 unsigned char output[100];
1200 memset(key_str, 0x00, 100);
1201 memset(src_str, 0x00, 100);
1202 memset(dst_str, 0x00, 100);
1203 memset(output, 0x00, 100);
1205 key_len =
unhexify( key_str,
"000000000000000000000000000000000000000000000000" );
1206 unhexify( src_str,
"26aa49dcfe7629a8901a69a9914e6dfd" );
1212 hexify( dst_str, output, 16 );
1214 fct_chk( strcmp( (
char *) dst_str,
"d5e08bf9a182e857cf40b3a36ee248cc" ) == 0 );
1220 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_6)
1222 unsigned char key_str[100];
1223 unsigned char src_str[100];
1224 unsigned char dst_str[100];
1225 unsigned char output[100];
1229 memset(key_str, 0x00, 100);
1230 memset(src_str, 0x00, 100);
1231 memset(dst_str, 0x00, 100);
1232 memset(output, 0x00, 100);
1234 key_len =
unhexify( key_str,
"000000000000000000000000000000000000000000000000" );
1235 unhexify( src_str,
"941a4773058224e1ef66d10e0a6ee782" );
1241 hexify( dst_str, output, 16 );
1243 fct_chk( strcmp( (
char *) dst_str,
"067cd9d3749207791841562507fa9626" ) == 0 );
1249 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_7)
1251 unsigned char key_str[100];
1252 unsigned char src_str[100];
1253 unsigned char dst_str[100];
1254 unsigned char output[100];
1258 memset(key_str, 0x00, 100);
1259 memset(src_str, 0x00, 100);
1260 memset(dst_str, 0x00, 100);
1261 memset(output, 0x00, 100);
1263 key_len =
unhexify( key_str,
"d2926527e0aa9f37b45e2ec2ade5853ef807576104c7ace3" );
1264 unhexify( src_str,
"00000000000000000000000000000000" );
1270 hexify( dst_str, output, 16 );
1272 fct_chk( strcmp( (
char *) dst_str,
"dd619e1cf204446112e0af2b9afa8f8c" ) == 0 );
1278 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_8)
1280 unsigned char key_str[100];
1281 unsigned char src_str[100];
1282 unsigned char dst_str[100];
1283 unsigned char output[100];
1287 memset(key_str, 0x00, 100);
1288 memset(src_str, 0x00, 100);
1289 memset(dst_str, 0x00, 100);
1290 memset(output, 0x00, 100);
1292 key_len =
unhexify( key_str,
"982215f4e173dfa0fcffe5d3da41c4812c7bcc8ed3540f93" );
1293 unhexify( src_str,
"00000000000000000000000000000000" );
1299 hexify( dst_str, output, 16 );
1301 fct_chk( strcmp( (
char *) dst_str,
"d4f0aae13c8fe9339fbf9e69ed0ad74d" ) == 0 );
1307 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_9)
1309 unsigned char key_str[100];
1310 unsigned char src_str[100];
1311 unsigned char dst_str[100];
1312 unsigned char output[100];
1316 memset(key_str, 0x00, 100);
1317 memset(src_str, 0x00, 100);
1318 memset(dst_str, 0x00, 100);
1319 memset(output, 0x00, 100);
1321 key_len =
unhexify( key_str,
"98c6b8e01e379fbd14e61af6af891596583565f2a27d59e9" );
1322 unhexify( src_str,
"00000000000000000000000000000000" );
1328 hexify( dst_str, output, 16 );
1330 fct_chk( strcmp( (
char *) dst_str,
"19c80ec4a6deb7e5ed1033dda933498f" ) == 0 );
1336 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_10)
1338 unsigned char key_str[100];
1339 unsigned char src_str[100];
1340 unsigned char dst_str[100];
1341 unsigned char output[100];
1345 memset(key_str, 0x00, 100);
1346 memset(src_str, 0x00, 100);
1347 memset(dst_str, 0x00, 100);
1348 memset(output, 0x00, 100);
1350 key_len =
unhexify( key_str,
"fffffffffffffffffffffffffff800000000000000000000" );
1351 unhexify( src_str,
"00000000000000000000000000000000" );
1357 hexify( dst_str, output, 16 );
1359 fct_chk( strcmp( (
char *) dst_str,
"8dd274bd0f1b58ae345d9e7233f9b8f3" ) == 0 );
1365 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_11)
1367 unsigned char key_str[100];
1368 unsigned char src_str[100];
1369 unsigned char dst_str[100];
1370 unsigned char output[100];
1374 memset(key_str, 0x00, 100);
1375 memset(src_str, 0x00, 100);
1376 memset(dst_str, 0x00, 100);
1377 memset(output, 0x00, 100);
1379 key_len =
unhexify( key_str,
"fffffffffffffffffffffffffffc00000000000000000000" );
1380 unhexify( src_str,
"00000000000000000000000000000000" );
1386 hexify( dst_str, output, 16 );
1388 fct_chk( strcmp( (
char *) dst_str,
"9d6bdc8f4ce5feb0f3bed2e4b9a9bb0b" ) == 0 );
1394 FCT_TEST_BGN(aes_192_ecb_encrypt_nist_kat_12)
1396 unsigned char key_str[100];
1397 unsigned char src_str[100];
1398 unsigned char dst_str[100];
1399 unsigned char output[100];
1403 memset(key_str, 0x00, 100);
1404 memset(src_str, 0x00, 100);
1405 memset(dst_str, 0x00, 100);
1406 memset(output, 0x00, 100);
1408 key_len =
unhexify( key_str,
"fffffffffffffffffffffffffffe00000000000000000000" );
1409 unhexify( src_str,
"00000000000000000000000000000000" );
1415 hexify( dst_str, output, 16 );
1417 fct_chk( strcmp( (
char *) dst_str,
"fd5548bcf3f42565f7efa94562528d46" ) == 0 );
1423 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_1)
1425 unsigned char key_str[100];
1426 unsigned char src_str[100];
1427 unsigned char dst_str[100];
1428 unsigned char output[100];
1432 memset(key_str, 0x00, 100);
1433 memset(src_str, 0x00, 100);
1434 memset(dst_str, 0x00, 100);
1435 memset(output, 0x00, 100);
1437 key_len =
unhexify( key_str,
"fffffffffffffffffffffffffffffffff000000000000000" );
1438 unhexify( src_str,
"bb2852c891c5947d2ed44032c421b85f" );
1444 hexify( dst_str, output, 16 );
1446 fct_chk( strcmp( (
char *) dst_str,
"00000000000000000000000000000000" ) == 0 );
1452 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_2)
1454 unsigned char key_str[100];
1455 unsigned char src_str[100];
1456 unsigned char dst_str[100];
1457 unsigned char output[100];
1461 memset(key_str, 0x00, 100);
1462 memset(src_str, 0x00, 100);
1463 memset(dst_str, 0x00, 100);
1464 memset(output, 0x00, 100);
1466 key_len =
unhexify( key_str,
"fffffffffffffffffffffffffffffffff800000000000000" );
1467 unhexify( src_str,
"1b9f5fbd5e8a4264c0a85b80409afa5e" );
1473 hexify( dst_str, output, 16 );
1475 fct_chk( strcmp( (
char *) dst_str,
"00000000000000000000000000000000" ) == 0 );
1481 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_3)
1483 unsigned char key_str[100];
1484 unsigned char src_str[100];
1485 unsigned char dst_str[100];
1486 unsigned char output[100];
1490 memset(key_str, 0x00, 100);
1491 memset(src_str, 0x00, 100);
1492 memset(dst_str, 0x00, 100);
1493 memset(output, 0x00, 100);
1495 key_len =
unhexify( key_str,
"fffffffffffffffffffffffffffffffffc00000000000000" );
1496 unhexify( src_str,
"30dab809f85a917fe924733f424ac589" );
1502 hexify( dst_str, output, 16 );
1504 fct_chk( strcmp( (
char *) dst_str,
"00000000000000000000000000000000" ) == 0 );
1510 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_4)
1512 unsigned char key_str[100];
1513 unsigned char src_str[100];
1514 unsigned char dst_str[100];
1515 unsigned char output[100];
1519 memset(key_str, 0x00, 100);
1520 memset(src_str, 0x00, 100);
1521 memset(dst_str, 0x00, 100);
1522 memset(output, 0x00, 100);
1524 key_len =
unhexify( key_str,
"61257134a518a0d57d9d244d45f6498cbc32f2bafc522d79" );
1525 unhexify( src_str,
"cfe4d74002696ccf7d87b14a2f9cafc9" );
1531 hexify( dst_str, output, 16 );
1533 fct_chk( strcmp( (
char *) dst_str,
"00000000000000000000000000000000" ) == 0 );
1539 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_5)
1541 unsigned char key_str[100];
1542 unsigned char src_str[100];
1543 unsigned char dst_str[100];
1544 unsigned char output[100];
1548 memset(key_str, 0x00, 100);
1549 memset(src_str, 0x00, 100);
1550 memset(dst_str, 0x00, 100);
1551 memset(output, 0x00, 100);
1553 key_len =
unhexify( key_str,
"b0ab0a6a818baef2d11fa33eac947284fb7d748cfb75e570" );
1554 unhexify( src_str,
"d2eafd86f63b109b91f5dbb3a3fb7e13" );
1560 hexify( dst_str, output, 16 );
1562 fct_chk( strcmp( (
char *) dst_str,
"00000000000000000000000000000000" ) == 0 );
1568 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_6)
1570 unsigned char key_str[100];
1571 unsigned char src_str[100];
1572 unsigned char dst_str[100];
1573 unsigned char output[100];
1577 memset(key_str, 0x00, 100);
1578 memset(src_str, 0x00, 100);
1579 memset(dst_str, 0x00, 100);
1580 memset(output, 0x00, 100);
1582 key_len =
unhexify( key_str,
"ee053aa011c8b428cdcc3636313c54d6a03cac01c71579d6" );
1583 unhexify( src_str,
"9b9fdd1c5975655f539998b306a324af" );
1589 hexify( dst_str, output, 16 );
1591 fct_chk( strcmp( (
char *) dst_str,
"00000000000000000000000000000000" ) == 0 );
1597 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_7)
1599 unsigned char key_str[100];
1600 unsigned char src_str[100];
1601 unsigned char dst_str[100];
1602 unsigned char output[100];
1606 memset(key_str, 0x00, 100);
1607 memset(src_str, 0x00, 100);
1608 memset(dst_str, 0x00, 100);
1609 memset(output, 0x00, 100);
1611 key_len =
unhexify( key_str,
"000000000000000000000000000000000000000000000000" );
1612 unhexify( src_str,
"275cfc0413d8ccb70513c3859b1d0f72" );
1618 hexify( dst_str, output, 16 );
1620 fct_chk( strcmp( (
char *) dst_str,
"1b077a6af4b7f98229de786d7516b639" ) == 0 );
1626 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_8)
1628 unsigned char key_str[100];
1629 unsigned char src_str[100];
1630 unsigned char dst_str[100];
1631 unsigned char output[100];
1635 memset(key_str, 0x00, 100);
1636 memset(src_str, 0x00, 100);
1637 memset(dst_str, 0x00, 100);
1638 memset(output, 0x00, 100);
1640 key_len =
unhexify( key_str,
"000000000000000000000000000000000000000000000000" );
1641 unhexify( src_str,
"c9b8135ff1b5adc413dfd053b21bd96d" );
1647 hexify( dst_str, output, 16 );
1649 fct_chk( strcmp( (
char *) dst_str,
"9c2d8842e5f48f57648205d39a239af1" ) == 0 );
1655 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_9)
1657 unsigned char key_str[100];
1658 unsigned char src_str[100];
1659 unsigned char dst_str[100];
1660 unsigned char output[100];
1664 memset(key_str, 0x00, 100);
1665 memset(src_str, 0x00, 100);
1666 memset(dst_str, 0x00, 100);
1667 memset(output, 0x00, 100);
1669 key_len =
unhexify( key_str,
"000000000000000000000000000000000000000000000000" );
1670 unhexify( src_str,
"4a3650c3371ce2eb35e389a171427440" );
1676 hexify( dst_str, output, 16 );
1678 fct_chk( strcmp( (
char *) dst_str,
"bff52510095f518ecca60af4205444bb" ) == 0 );
1684 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_10)
1686 unsigned char key_str[100];
1687 unsigned char src_str[100];
1688 unsigned char dst_str[100];
1689 unsigned char output[100];
1693 memset(key_str, 0x00, 100);
1694 memset(src_str, 0x00, 100);
1695 memset(dst_str, 0x00, 100);
1696 memset(output, 0x00, 100);
1698 key_len =
unhexify( key_str,
"000000000000000000000000000000000000000000000000" );
1699 unhexify( src_str,
"b2099795e88cc158fd75ea133d7e7fbe" );
1705 hexify( dst_str, output, 16 );
1707 fct_chk( strcmp( (
char *) dst_str,
"ffffffffffffffffffffc00000000000" ) == 0 );
1713 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_11)
1715 unsigned char key_str[100];
1716 unsigned char src_str[100];
1717 unsigned char dst_str[100];
1718 unsigned char output[100];
1722 memset(key_str, 0x00, 100);
1723 memset(src_str, 0x00, 100);
1724 memset(dst_str, 0x00, 100);
1725 memset(output, 0x00, 100);
1727 key_len =
unhexify( key_str,
"000000000000000000000000000000000000000000000000" );
1728 unhexify( src_str,
"a6cae46fb6fadfe7a2c302a34242817b" );
1734 hexify( dst_str, output, 16 );
1736 fct_chk( strcmp( (
char *) dst_str,
"ffffffffffffffffffffe00000000000" ) == 0 );
1742 FCT_TEST_BGN(aes_192_ecb_decrypt_nist_kat_12)
1744 unsigned char key_str[100];
1745 unsigned char src_str[100];
1746 unsigned char dst_str[100];
1747 unsigned char output[100];
1751 memset(key_str, 0x00, 100);
1752 memset(src_str, 0x00, 100);
1753 memset(dst_str, 0x00, 100);
1754 memset(output, 0x00, 100);
1756 key_len =
unhexify( key_str,
"000000000000000000000000000000000000000000000000" );
1757 unhexify( src_str,
"026a7024d6a902e0b3ffccbaa910cc3f" );
1763 hexify( dst_str, output, 16 );
1765 fct_chk( strcmp( (
char *) dst_str,
"fffffffffffffffffffff00000000000" ) == 0 );
1771 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_1)
1773 unsigned char key_str[100];
1774 unsigned char src_str[100];
1775 unsigned char dst_str[100];
1776 unsigned char output[100];
1780 memset(key_str, 0x00, 100);
1781 memset(src_str, 0x00, 100);
1782 memset(dst_str, 0x00, 100);
1783 memset(output, 0x00, 100);
1785 key_len =
unhexify( key_str,
"c1cc358b449909a19436cfbb3f852ef8bcb5ed12ac7058325f56e6099aab1a1c" );
1786 unhexify( src_str,
"00000000000000000000000000000000" );
1792 hexify( dst_str, output, 16 );
1794 fct_chk( strcmp( (
char *) dst_str,
"352065272169abf9856843927d0674fd" ) == 0 );
1800 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_2)
1802 unsigned char key_str[100];
1803 unsigned char src_str[100];
1804 unsigned char dst_str[100];
1805 unsigned char output[100];
1809 memset(key_str, 0x00, 100);
1810 memset(src_str, 0x00, 100);
1811 memset(dst_str, 0x00, 100);
1812 memset(output, 0x00, 100);
1814 key_len =
unhexify( key_str,
"984ca75f4ee8d706f46c2d98c0bf4a45f5b00d791c2dfeb191b5ed8e420fd627" );
1815 unhexify( src_str,
"00000000000000000000000000000000" );
1821 hexify( dst_str, output, 16 );
1823 fct_chk( strcmp( (
char *) dst_str,
"4307456a9e67813b452e15fa8fffe398" ) == 0 );
1829 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_3)
1831 unsigned char key_str[100];
1832 unsigned char src_str[100];
1833 unsigned char dst_str[100];
1834 unsigned char output[100];
1838 memset(key_str, 0x00, 100);
1839 memset(src_str, 0x00, 100);
1840 memset(dst_str, 0x00, 100);
1841 memset(output, 0x00, 100);
1843 key_len =
unhexify( key_str,
"b43d08a447ac8609baadae4ff12918b9f68fc1653f1269222f123981ded7a92f" );
1844 unhexify( src_str,
"00000000000000000000000000000000" );
1850 hexify( dst_str, output, 16 );
1852 fct_chk( strcmp( (
char *) dst_str,
"4663446607354989477a5c6f0f007ef4" ) == 0 );
1858 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_4)
1860 unsigned char key_str[100];
1861 unsigned char src_str[100];
1862 unsigned char dst_str[100];
1863 unsigned char output[100];
1867 memset(key_str, 0x00, 100);
1868 memset(src_str, 0x00, 100);
1869 memset(dst_str, 0x00, 100);
1870 memset(output, 0x00, 100);
1872 key_len =
unhexify( key_str,
"0000000000000000000000000000000000000000000000000000000000000000" );
1873 unhexify( src_str,
"0b24af36193ce4665f2825d7b4749c98" );
1879 hexify( dst_str, output, 16 );
1881 fct_chk( strcmp( (
char *) dst_str,
"a9ff75bd7cf6613d3731c77c3b6d0c04" ) == 0 );
1887 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_5)
1889 unsigned char key_str[100];
1890 unsigned char src_str[100];
1891 unsigned char dst_str[100];
1892 unsigned char output[100];
1896 memset(key_str, 0x00, 100);
1897 memset(src_str, 0x00, 100);
1898 memset(dst_str, 0x00, 100);
1899 memset(output, 0x00, 100);
1901 key_len =
unhexify( key_str,
"0000000000000000000000000000000000000000000000000000000000000000" );
1902 unhexify( src_str,
"761c1fe41a18acf20d241650611d90f1" );
1908 hexify( dst_str, output, 16 );
1910 fct_chk( strcmp( (
char *) dst_str,
"623a52fcea5d443e48d9181ab32c7421" ) == 0 );
1916 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_6)
1918 unsigned char key_str[100];
1919 unsigned char src_str[100];
1920 unsigned char dst_str[100];
1921 unsigned char output[100];
1925 memset(key_str, 0x00, 100);
1926 memset(src_str, 0x00, 100);
1927 memset(dst_str, 0x00, 100);
1928 memset(output, 0x00, 100);
1930 key_len =
unhexify( key_str,
"0000000000000000000000000000000000000000000000000000000000000000" );
1931 unhexify( src_str,
"8a560769d605868ad80d819bdba03771" );
1937 hexify( dst_str, output, 16 );
1939 fct_chk( strcmp( (
char *) dst_str,
"38f2c7ae10612415d27ca190d27da8b4" ) == 0 );
1945 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_7)
1947 unsigned char key_str[100];
1948 unsigned char src_str[100];
1949 unsigned char dst_str[100];
1950 unsigned char output[100];
1954 memset(key_str, 0x00, 100);
1955 memset(src_str, 0x00, 100);
1956 memset(dst_str, 0x00, 100);
1957 memset(output, 0x00, 100);
1959 key_len =
unhexify( key_str,
"0000000000000000000000000000000000000000000000000000000000000000" );
1960 unhexify( src_str,
"ffffff80000000000000000000000000" );
1966 hexify( dst_str, output, 16 );
1968 fct_chk( strcmp( (
char *) dst_str,
"36aff0ef7bf3280772cf4cac80a0d2b2" ) == 0 );
1974 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_8)
1976 unsigned char key_str[100];
1977 unsigned char src_str[100];
1978 unsigned char dst_str[100];
1979 unsigned char output[100];
1983 memset(key_str, 0x00, 100);
1984 memset(src_str, 0x00, 100);
1985 memset(dst_str, 0x00, 100);
1986 memset(output, 0x00, 100);
1988 key_len =
unhexify( key_str,
"0000000000000000000000000000000000000000000000000000000000000000" );
1989 unhexify( src_str,
"ffffffc0000000000000000000000000" );
1995 hexify( dst_str, output, 16 );
1997 fct_chk( strcmp( (
char *) dst_str,
"1f8eedea0f62a1406d58cfc3ecea72cf" ) == 0 );
2003 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_9)
2005 unsigned char key_str[100];
2006 unsigned char src_str[100];
2007 unsigned char dst_str[100];
2008 unsigned char output[100];
2012 memset(key_str, 0x00, 100);
2013 memset(src_str, 0x00, 100);
2014 memset(dst_str, 0x00, 100);
2015 memset(output, 0x00, 100);
2017 key_len =
unhexify( key_str,
"0000000000000000000000000000000000000000000000000000000000000000" );
2018 unhexify( src_str,
"ffffffe0000000000000000000000000" );
2024 hexify( dst_str, output, 16 );
2026 fct_chk( strcmp( (
char *) dst_str,
"abf4154a3375a1d3e6b1d454438f95a6" ) == 0 );
2032 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_10)
2034 unsigned char key_str[100];
2035 unsigned char src_str[100];
2036 unsigned char dst_str[100];
2037 unsigned char output[100];
2041 memset(key_str, 0x00, 100);
2042 memset(src_str, 0x00, 100);
2043 memset(dst_str, 0x00, 100);
2044 memset(output, 0x00, 100);
2046 key_len =
unhexify( key_str,
"ffffffffffffffffffffffffffffffffffff8000000000000000000000000000" );
2047 unhexify( src_str,
"00000000000000000000000000000000" );
2053 hexify( dst_str, output, 16 );
2055 fct_chk( strcmp( (
char *) dst_str,
"45d089c36d5c5a4efc689e3b0de10dd5" ) == 0 );
2061 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_11)
2063 unsigned char key_str[100];
2064 unsigned char src_str[100];
2065 unsigned char dst_str[100];
2066 unsigned char output[100];
2070 memset(key_str, 0x00, 100);
2071 memset(src_str, 0x00, 100);
2072 memset(dst_str, 0x00, 100);
2073 memset(output, 0x00, 100);
2075 key_len =
unhexify( key_str,
"ffffffffffffffffffffffffffffffffffffc000000000000000000000000000" );
2076 unhexify( src_str,
"00000000000000000000000000000000" );
2082 hexify( dst_str, output, 16 );
2084 fct_chk( strcmp( (
char *) dst_str,
"b4da5df4becb5462e03a0ed00d295629" ) == 0 );
2090 FCT_TEST_BGN(aes_256_ecb_encrypt_nist_kat_12)
2092 unsigned char key_str[100];
2093 unsigned char src_str[100];
2094 unsigned char dst_str[100];
2095 unsigned char output[100];
2099 memset(key_str, 0x00, 100);
2100 memset(src_str, 0x00, 100);
2101 memset(dst_str, 0x00, 100);
2102 memset(output, 0x00, 100);
2104 key_len =
unhexify( key_str,
"ffffffffffffffffffffffffffffffffffffe000000000000000000000000000" );
2105 unhexify( src_str,
"00000000000000000000000000000000" );
2111 hexify( dst_str, output, 16 );
2113 fct_chk( strcmp( (
char *) dst_str,
"dcf4e129136c1a4b7a0f38935cc34b2b" ) == 0 );
2119 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_1)
2121 unsigned char key_str[100];
2122 unsigned char src_str[100];
2123 unsigned char dst_str[100];
2124 unsigned char output[100];
2128 memset(key_str, 0x00, 100);
2129 memset(src_str, 0x00, 100);
2130 memset(dst_str, 0x00, 100);
2131 memset(output, 0x00, 100);
2133 key_len =
unhexify( key_str,
"fffffffffffffffffffffffffffffffffffffffffffffff00000000000000000" );
2134 unhexify( src_str,
"edf61ae362e882ddc0167474a7a77f3a" );
2140 hexify( dst_str, output, 16 );
2142 fct_chk( strcmp( (
char *) dst_str,
"00000000000000000000000000000000" ) == 0 );
2148 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_2)
2150 unsigned char key_str[100];
2151 unsigned char src_str[100];
2152 unsigned char dst_str[100];
2153 unsigned char output[100];
2157 memset(key_str, 0x00, 100);
2158 memset(src_str, 0x00, 100);
2159 memset(dst_str, 0x00, 100);
2160 memset(output, 0x00, 100);
2162 key_len =
unhexify( key_str,
"fffffffffffffffffffffffffffffffffffffffffffffff80000000000000000" );
2163 unhexify( src_str,
"6168b00ba7859e0970ecfd757efecf7c" );
2169 hexify( dst_str, output, 16 );
2171 fct_chk( strcmp( (
char *) dst_str,
"00000000000000000000000000000000" ) == 0 );
2177 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_3)
2179 unsigned char key_str[100];
2180 unsigned char src_str[100];
2181 unsigned char dst_str[100];
2182 unsigned char output[100];
2186 memset(key_str, 0x00, 100);
2187 memset(src_str, 0x00, 100);
2188 memset(dst_str, 0x00, 100);
2189 memset(output, 0x00, 100);
2191 key_len =
unhexify( key_str,
"fffffffffffffffffffffffffffffffffffffffffffffffc0000000000000000" );
2192 unhexify( src_str,
"d1415447866230d28bb1ea18a4cdfd02" );
2198 hexify( dst_str, output, 16 );
2200 fct_chk( strcmp( (
char *) dst_str,
"00000000000000000000000000000000" ) == 0 );
2206 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_4)
2208 unsigned char key_str[100];
2209 unsigned char src_str[100];
2210 unsigned char dst_str[100];
2211 unsigned char output[100];
2215 memset(key_str, 0x00, 100);
2216 memset(src_str, 0x00, 100);
2217 memset(dst_str, 0x00, 100);
2218 memset(output, 0x00, 100);
2220 key_len =
unhexify( key_str,
"f8be9ba615c5a952cabbca24f68f8593039624d524c816acda2c9183bd917cb9" );
2221 unhexify( src_str,
"a3944b95ca0b52043584ef02151926a8" );
2227 hexify( dst_str, output, 16 );
2229 fct_chk( strcmp( (
char *) dst_str,
"00000000000000000000000000000000" ) == 0 );
2235 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_5)
2237 unsigned char key_str[100];
2238 unsigned char src_str[100];
2239 unsigned char dst_str[100];
2240 unsigned char output[100];
2244 memset(key_str, 0x00, 100);
2245 memset(src_str, 0x00, 100);
2246 memset(dst_str, 0x00, 100);
2247 memset(output, 0x00, 100);
2249 key_len =
unhexify( key_str,
"797f8b3d176dac5b7e34a2d539c4ef367a16f8635f6264737591c5c07bf57a3e" );
2250 unhexify( src_str,
"a74289fe73a4c123ca189ea1e1b49ad5" );
2256 hexify( dst_str, output, 16 );
2258 fct_chk( strcmp( (
char *) dst_str,
"00000000000000000000000000000000" ) == 0 );
2264 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_6)
2266 unsigned char key_str[100];
2267 unsigned char src_str[100];
2268 unsigned char dst_str[100];
2269 unsigned char output[100];
2273 memset(key_str, 0x00, 100);
2274 memset(src_str, 0x00, 100);
2275 memset(dst_str, 0x00, 100);
2276 memset(output, 0x00, 100);
2278 key_len =
unhexify( key_str,
"6838d40caf927749c13f0329d331f448e202c73ef52c5f73a37ca635d4c47707" );
2279 unhexify( src_str,
"b91d4ea4488644b56cf0812fa7fcf5fc" );
2285 hexify( dst_str, output, 16 );
2287 fct_chk( strcmp( (
char *) dst_str,
"00000000000000000000000000000000" ) == 0 );
2293 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_7)
2295 unsigned char key_str[100];
2296 unsigned char src_str[100];
2297 unsigned char dst_str[100];
2298 unsigned char output[100];
2302 memset(key_str, 0x00, 100);
2303 memset(src_str, 0x00, 100);
2304 memset(dst_str, 0x00, 100);
2305 memset(output, 0x00, 100);
2307 key_len =
unhexify( key_str,
"0000000000000000000000000000000000000000000000000000000000000000" );
2308 unhexify( src_str,
"623a52fcea5d443e48d9181ab32c7421" );
2314 hexify( dst_str, output, 16 );
2316 fct_chk( strcmp( (
char *) dst_str,
"761c1fe41a18acf20d241650611d90f1" ) == 0 );
2322 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_8)
2324 unsigned char key_str[100];
2325 unsigned char src_str[100];
2326 unsigned char dst_str[100];
2327 unsigned char output[100];
2331 memset(key_str, 0x00, 100);
2332 memset(src_str, 0x00, 100);
2333 memset(dst_str, 0x00, 100);
2334 memset(output, 0x00, 100);
2336 key_len =
unhexify( key_str,
"0000000000000000000000000000000000000000000000000000000000000000" );
2337 unhexify( src_str,
"38f2c7ae10612415d27ca190d27da8b4" );
2343 hexify( dst_str, output, 16 );
2345 fct_chk( strcmp( (
char *) dst_str,
"8a560769d605868ad80d819bdba03771" ) == 0 );
2351 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_9)
2353 unsigned char key_str[100];
2354 unsigned char src_str[100];
2355 unsigned char dst_str[100];
2356 unsigned char output[100];
2360 memset(key_str, 0x00, 100);
2361 memset(src_str, 0x00, 100);
2362 memset(dst_str, 0x00, 100);
2363 memset(output, 0x00, 100);
2365 key_len =
unhexify( key_str,
"0000000000000000000000000000000000000000000000000000000000000000" );
2366 unhexify( src_str,
"1bc704f1bce135ceb810341b216d7abe" );
2372 hexify( dst_str, output, 16 );
2374 fct_chk( strcmp( (
char *) dst_str,
"91fbef2d15a97816060bee1feaa49afe" ) == 0 );
2380 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_10)
2382 unsigned char key_str[100];
2383 unsigned char src_str[100];
2384 unsigned char dst_str[100];
2385 unsigned char output[100];
2389 memset(key_str, 0x00, 100);
2390 memset(src_str, 0x00, 100);
2391 memset(dst_str, 0x00, 100);
2392 memset(output, 0x00, 100);
2394 key_len =
unhexify( key_str,
"0000000000000000000000000000000000000000000000000000000000000000" );
2395 unhexify( src_str,
"ddc6bf790c15760d8d9aeb6f9a75fd4e" );
2401 hexify( dst_str, output, 16 );
2403 fct_chk( strcmp( (
char *) dst_str,
"80000000000000000000000000000000" ) == 0 );
2409 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_11)
2411 unsigned char key_str[100];
2412 unsigned char src_str[100];
2413 unsigned char dst_str[100];
2414 unsigned char output[100];
2418 memset(key_str, 0x00, 100);
2419 memset(src_str, 0x00, 100);
2420 memset(dst_str, 0x00, 100);
2421 memset(output, 0x00, 100);
2423 key_len =
unhexify( key_str,
"0000000000000000000000000000000000000000000000000000000000000000" );
2424 unhexify( src_str,
"0a6bdc6d4c1e6280301fd8e97ddbe601" );
2430 hexify( dst_str, output, 16 );
2432 fct_chk( strcmp( (
char *) dst_str,
"c0000000000000000000000000000000" ) == 0 );
2438 FCT_TEST_BGN(aes_256_ecb_decrypt_nist_kat_12)
2440 unsigned char key_str[100];
2441 unsigned char src_str[100];
2442 unsigned char dst_str[100];
2443 unsigned char output[100];
2447 memset(key_str, 0x00, 100);
2448 memset(src_str, 0x00, 100);
2449 memset(dst_str, 0x00, 100);
2450 memset(output, 0x00, 100);
2452 key_len =
unhexify( key_str,
"0000000000000000000000000000000000000000000000000000000000000000" );
2453 unhexify( src_str,
"9b80eefb7ebe2d2b16247aa0efc72f5d" );
2459 hexify( dst_str, output, 16 );
2461 fct_chk( strcmp( (
char *) dst_str,
"e0000000000000000000000000000000" ) == 0 );