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_CAMELLIA_C
231 FCT_SUITE_BGN(test_suite_camellia)
234 FCT_TEST_BGN(camellia_128_ecb_encrypt_rfc3713_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,
"0123456789abcdeffedcba9876543210" );
249 unhexify( src_str,
"0123456789abcdeffedcba9876543210" );
255 hexify( dst_str, output, 16 );
257 fct_chk( strcasecmp( (
char *) dst_str,
"67673138549669730857065648eabe43" ) == 0 );
263 FCT_TEST_BGN(camellia_192_ecb_encrypt_rfc3713_1)
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,
"0123456789abcdeffedcba98765432100011223344556677" );
278 unhexify( src_str,
"0123456789abcdeffedcba9876543210" );
284 hexify( dst_str, output, 16 );
286 fct_chk( strcasecmp( (
char *) dst_str,
"b4993401b3e996f84ee5cee7d79b09b9" ) == 0 );
292 FCT_TEST_BGN(camellia_256_ecb_encrypt_rfc3713_1)
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,
"0123456789abcdeffedcba987654321000112233445566778899aabbccddeeff" );
307 unhexify( src_str,
"0123456789abcdeffedcba9876543210" );
313 hexify( dst_str, output, 16 );
315 fct_chk( strcasecmp( (
char *) dst_str,
"9acc237dff16d76c20ef7c919e3a7509" ) == 0 );
321 FCT_TEST_BGN(camellia_128_ecb_encrypt_perl_evp_1)
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,
"000102030405060708090A0B0C0D0E0F" );
336 unhexify( src_str,
"00112233445566778899AABBCCDDEEFF" );
342 hexify( dst_str, output, 16 );
344 fct_chk( strcasecmp( (
char *) dst_str,
"77CF412067AF8270613529149919546F" ) == 0 );
350 FCT_TEST_BGN(camellia_192_ecb_encrypt_perl_evp_1)
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,
"000102030405060708090A0B0C0D0E0F1011121314151617" );
365 unhexify( src_str,
"00112233445566778899AABBCCDDEEFF" );
371 hexify( dst_str, output, 16 );
373 fct_chk( strcasecmp( (
char *) dst_str,
"B22F3C36B72D31329EEE8ADDC2906C68" ) == 0 );
379 FCT_TEST_BGN(camellia_256_ecb_encrypt_perl_evp_1)
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,
"000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F" );
394 unhexify( src_str,
"00112233445566778899AABBCCDDEEFF" );
400 hexify( dst_str, output, 16 );
402 fct_chk( strcasecmp( (
char *) dst_str,
"2EDF1F3418D53B88841FC8985FB1ECF2" ) == 0 );
408 FCT_TEST_BGN(camellia_128_ecb_encrypt_perl_evp_1)
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,
"2B7E151628AED2A6ABF7158809CF4F3C" );
423 unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
429 hexify( dst_str, output, 16 );
431 fct_chk( strcasecmp( (
char *) dst_str,
"432FC5DCD628115B7C388D770B270C96" ) == 0 );
437 FCT_TEST_BGN(camellia_128_ecb_encrypt_perl_evp_2)
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,
"2B7E151628AED2A6ABF7158809CF4F3C" );
452 unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
458 hexify( dst_str, output, 16 );
460 fct_chk( strcasecmp( (
char *) dst_str,
"0BE1F14023782A22E8384C5ABB7FAB2B" ) == 0 );
466 FCT_TEST_BGN(camellia_128_ecb_encrypt_perl_evp_3)
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,
"2B7E151628AED2A6ABF7158809CF4F3C" );
481 unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
487 hexify( dst_str, output, 16 );
489 fct_chk( strcasecmp( (
char *) dst_str,
"A0A1ABCD1893AB6FE0FE5B65DF5F8636" ) == 0 );
495 FCT_TEST_BGN(camellia_128_ecb_encrypt_perl_evp_4)
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,
"2B7E151628AED2A6ABF7158809CF4F3C" );
510 unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
516 hexify( dst_str, output, 16 );
518 fct_chk( strcasecmp( (
char *) dst_str,
"E61925E0D5DFAA9BB29F815B3076E51A" ) == 0 );
524 FCT_TEST_BGN(camellia_192_ecb_encrypt_perl_evp_1)
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,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
539 unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
545 hexify( dst_str, output, 16 );
547 fct_chk( strcasecmp( (
char *) dst_str,
"CCCC6C4E138B45848514D48D0D3439D3" ) == 0 );
553 FCT_TEST_BGN(camellia_192_ecb_encrypt_perl_evp_2)
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,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
568 unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
574 hexify( dst_str, output, 16 );
576 fct_chk( strcasecmp( (
char *) dst_str,
"5713C62C14B2EC0F8393B6AFD6F5785A" ) == 0 );
582 FCT_TEST_BGN(camellia_192_ecb_encrypt_perl_evp_3)
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,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
597 unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
603 hexify( dst_str, output, 16 );
605 fct_chk( strcasecmp( (
char *) dst_str,
"B40ED2B60EB54D09D030CF511FEEF366" ) == 0 );
611 FCT_TEST_BGN(camellia_192_ecb_encrypt_perl_evp_4)
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,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
626 unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
632 hexify( dst_str, output, 16 );
634 fct_chk( strcasecmp( (
char *) dst_str,
"909DBD95799096748CB27357E73E1D26" ) == 0 );
640 FCT_TEST_BGN(camellia_256_ecb_encrypt_perl_evp_1)
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,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
655 unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
661 hexify( dst_str, output, 16 );
663 fct_chk( strcasecmp( (
char *) dst_str,
"BEFD219B112FA00098919CD101C9CCFA" ) == 0 );
669 FCT_TEST_BGN(camellia_256_ecb_encrypt_perl_evp_2)
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,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
684 unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
690 hexify( dst_str, output, 16 );
692 fct_chk( strcasecmp( (
char *) dst_str,
"C91D3A8F1AEA08A9386CF4B66C0169EA" ) == 0 );
698 FCT_TEST_BGN(camellia_256_ecb_encrypt_perl_evp_3)
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,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
713 unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
719 hexify( dst_str, output, 16 );
721 fct_chk( strcasecmp( (
char *) dst_str,
"A623D711DC5F25A51BB8A80D56397D28" ) == 0 );
727 FCT_TEST_BGN(camellia_256_ecb_encrypt_perl_evp_4)
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,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
742 unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
748 hexify( dst_str, output, 16 );
750 fct_chk( strcasecmp( (
char *) dst_str,
"7960109FB6DC42947FCFE59EA3C5EB6B" ) == 0 );
756 FCT_TEST_BGN(camellia_128_cbc_encrypt_perl_evp_1)
758 unsigned char key_str[100];
759 unsigned char iv_str[100];
760 unsigned char src_str[100];
761 unsigned char dst_str[100];
762 unsigned char output[100];
764 int key_len, data_len;
766 memset(key_str, 0x00, 100);
767 memset(iv_str, 0x00, 100);
768 memset(src_str, 0x00, 100);
769 memset(dst_str, 0x00, 100);
770 memset(output, 0x00, 100);
772 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
773 unhexify( iv_str,
"000102030405060708090A0B0C0D0E0F" );
774 data_len =
unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
780 hexify( dst_str, output, data_len );
782 fct_chk( strcasecmp( (
char *) dst_str,
"1607CF494B36BBF00DAEB0B503C831AB" ) == 0 );
788 FCT_TEST_BGN(camellia_128_cbc_encrypt_perl_evp_2)
790 unsigned char key_str[100];
791 unsigned char iv_str[100];
792 unsigned char src_str[100];
793 unsigned char dst_str[100];
794 unsigned char output[100];
796 int key_len, data_len;
798 memset(key_str, 0x00, 100);
799 memset(iv_str, 0x00, 100);
800 memset(src_str, 0x00, 100);
801 memset(dst_str, 0x00, 100);
802 memset(output, 0x00, 100);
804 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
805 unhexify( iv_str,
"1607CF494B36BBF00DAEB0B503C831AB" );
806 data_len =
unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
812 hexify( dst_str, output, data_len );
814 fct_chk( strcasecmp( (
char *) dst_str,
"A2F2CF671629EF7840C5A5DFB5074887" ) == 0 );
820 FCT_TEST_BGN(camellia_128_cbc_encrypt_perl_evp_3)
822 unsigned char key_str[100];
823 unsigned char iv_str[100];
824 unsigned char src_str[100];
825 unsigned char dst_str[100];
826 unsigned char output[100];
828 int key_len, data_len;
830 memset(key_str, 0x00, 100);
831 memset(iv_str, 0x00, 100);
832 memset(src_str, 0x00, 100);
833 memset(dst_str, 0x00, 100);
834 memset(output, 0x00, 100);
836 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
837 unhexify( iv_str,
"A2F2CF671629EF7840C5A5DFB5074887" );
838 data_len =
unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
844 hexify( dst_str, output, data_len );
846 fct_chk( strcasecmp( (
char *) dst_str,
"0F06165008CF8B8B5A63586362543E54" ) == 0 );
852 FCT_TEST_BGN(camellia_128_cbc_encrypt_perl_evp_4)
854 unsigned char key_str[100];
855 unsigned char iv_str[100];
856 unsigned char src_str[100];
857 unsigned char dst_str[100];
858 unsigned char output[100];
860 int key_len, data_len;
862 memset(key_str, 0x00, 100);
863 memset(iv_str, 0x00, 100);
864 memset(src_str, 0x00, 100);
865 memset(dst_str, 0x00, 100);
866 memset(output, 0x00, 100);
868 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
869 unhexify( iv_str,
"36A84CDAFD5F9A85ADA0F0A993D6D577" );
870 data_len =
unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
876 hexify( dst_str, output, data_len );
878 fct_chk( strcasecmp( (
char *) dst_str,
"74C64268CDB8B8FAF5B34E8AF3732980" ) == 0 );
884 FCT_TEST_BGN(camellia_192_cbc_encrypt_perl_evp_1)
886 unsigned char key_str[100];
887 unsigned char iv_str[100];
888 unsigned char src_str[100];
889 unsigned char dst_str[100];
890 unsigned char output[100];
892 int key_len, data_len;
894 memset(key_str, 0x00, 100);
895 memset(iv_str, 0x00, 100);
896 memset(src_str, 0x00, 100);
897 memset(dst_str, 0x00, 100);
898 memset(output, 0x00, 100);
900 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
901 unhexify( iv_str,
"000102030405060708090A0B0C0D0E0F" );
902 data_len =
unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
908 hexify( dst_str, output, data_len );
910 fct_chk( strcasecmp( (
char *) dst_str,
"2A4830AB5AC4A1A2405955FD2195CF93" ) == 0 );
916 FCT_TEST_BGN(camellia_192_cbc_encrypt_perl_evp_2)
918 unsigned char key_str[100];
919 unsigned char iv_str[100];
920 unsigned char src_str[100];
921 unsigned char dst_str[100];
922 unsigned char output[100];
924 int key_len, data_len;
926 memset(key_str, 0x00, 100);
927 memset(iv_str, 0x00, 100);
928 memset(src_str, 0x00, 100);
929 memset(dst_str, 0x00, 100);
930 memset(output, 0x00, 100);
932 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
933 unhexify( iv_str,
"2A4830AB5AC4A1A2405955FD2195CF93" );
934 data_len =
unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
940 hexify( dst_str, output, data_len );
942 fct_chk( strcasecmp( (
char *) dst_str,
"5D5A869BD14CE54264F892A6DD2EC3D5" ) == 0 );
948 FCT_TEST_BGN(camellia_192_cbc_encrypt_perl_evp_3)
950 unsigned char key_str[100];
951 unsigned char iv_str[100];
952 unsigned char src_str[100];
953 unsigned char dst_str[100];
954 unsigned char output[100];
956 int key_len, data_len;
958 memset(key_str, 0x00, 100);
959 memset(iv_str, 0x00, 100);
960 memset(src_str, 0x00, 100);
961 memset(dst_str, 0x00, 100);
962 memset(output, 0x00, 100);
964 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
965 unhexify( iv_str,
"5D5A869BD14CE54264F892A6DD2EC3D5" );
966 data_len =
unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
972 hexify( dst_str, output, data_len );
974 fct_chk( strcasecmp( (
char *) dst_str,
"37D359C3349836D884E310ADDF68C449" ) == 0 );
980 FCT_TEST_BGN(camellia_192_cbc_encrypt_perl_evp_4)
982 unsigned char key_str[100];
983 unsigned char iv_str[100];
984 unsigned char src_str[100];
985 unsigned char dst_str[100];
986 unsigned char output[100];
988 int key_len, data_len;
990 memset(key_str, 0x00, 100);
991 memset(iv_str, 0x00, 100);
992 memset(src_str, 0x00, 100);
993 memset(dst_str, 0x00, 100);
994 memset(output, 0x00, 100);
996 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
997 unhexify( iv_str,
"37D359C3349836D884E310ADDF68C449" );
998 data_len =
unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
1004 hexify( dst_str, output, data_len );
1006 fct_chk( strcasecmp( (
char *) dst_str,
"01FAAA930B4AB9916E9668E1428C6B08" ) == 0 );
1012 FCT_TEST_BGN(camellia_256_cbc_encrypt_perl_evp_1)
1014 unsigned char key_str[100];
1015 unsigned char iv_str[100];
1016 unsigned char src_str[100];
1017 unsigned char dst_str[100];
1018 unsigned char output[100];
1020 int key_len, data_len;
1022 memset(key_str, 0x00, 100);
1023 memset(iv_str, 0x00, 100);
1024 memset(src_str, 0x00, 100);
1025 memset(dst_str, 0x00, 100);
1026 memset(output, 0x00, 100);
1028 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1029 unhexify( iv_str,
"000102030405060708090A0B0C0D0E0F" );
1030 data_len =
unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
1036 hexify( dst_str, output, data_len );
1038 fct_chk( strcasecmp( (
char *) dst_str,
"E6CFA35FC02B134A4D2C0B6737AC3EDA" ) == 0 );
1044 FCT_TEST_BGN(camellia_256_cbc_encrypt_perl_evp_2)
1046 unsigned char key_str[100];
1047 unsigned char iv_str[100];
1048 unsigned char src_str[100];
1049 unsigned char dst_str[100];
1050 unsigned char output[100];
1052 int key_len, data_len;
1054 memset(key_str, 0x00, 100);
1055 memset(iv_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,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1061 unhexify( iv_str,
"E6CFA35FC02B134A4D2C0B6737AC3EDA" );
1062 data_len =
unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
1068 hexify( dst_str, output, data_len );
1070 fct_chk( strcasecmp( (
char *) dst_str,
"36CBEB73BD504B4070B1B7DE2B21EB50" ) == 0 );
1076 FCT_TEST_BGN(camellia_256_cbc_encrypt_perl_evp_3)
1078 unsigned char key_str[100];
1079 unsigned char iv_str[100];
1080 unsigned char src_str[100];
1081 unsigned char dst_str[100];
1082 unsigned char output[100];
1084 int key_len, data_len;
1086 memset(key_str, 0x00, 100);
1087 memset(iv_str, 0x00, 100);
1088 memset(src_str, 0x00, 100);
1089 memset(dst_str, 0x00, 100);
1090 memset(output, 0x00, 100);
1092 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1093 unhexify( iv_str,
"36CBEB73BD504B4070B1B7DE2B21EB50" );
1094 data_len =
unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
1100 hexify( dst_str, output, data_len );
1102 fct_chk( strcasecmp( (
char *) dst_str,
"E31A6055297D96CA3330CDF1B1860A83" ) == 0 );
1108 FCT_TEST_BGN(camellia_256_cbc_encrypt_perl_evp_4)
1110 unsigned char key_str[100];
1111 unsigned char iv_str[100];
1112 unsigned char src_str[100];
1113 unsigned char dst_str[100];
1114 unsigned char output[100];
1116 int key_len, data_len;
1118 memset(key_str, 0x00, 100);
1119 memset(iv_str, 0x00, 100);
1120 memset(src_str, 0x00, 100);
1121 memset(dst_str, 0x00, 100);
1122 memset(output, 0x00, 100);
1124 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1125 unhexify( iv_str,
"E31A6055297D96CA3330CDF1B1860A83" );
1126 data_len =
unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
1132 hexify( dst_str, output, data_len );
1134 fct_chk( strcasecmp( (
char *) dst_str,
"5D563F6D1CCCF236051C0C5C1C58F28F" ) == 0 );
1139 #ifdef POLARSSL_CIPHER_MODE_CFB
1141 FCT_TEST_BGN(camellia_128_cfb128_encrypt_perl_evp_1)
1143 unsigned char key_str[100];
1144 unsigned char iv_str[100];
1145 unsigned char src_str[100];
1146 unsigned char dst_str[100];
1147 unsigned char output[100];
1149 size_t iv_offset = 0;
1152 memset(key_str, 0x00, 100);
1153 memset(iv_str, 0x00, 100);
1154 memset(src_str, 0x00, 100);
1155 memset(dst_str, 0x00, 100);
1156 memset(output, 0x00, 100);
1158 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
1159 unhexify( iv_str,
"000102030405060708090A0B0C0D0E0F" );
1160 unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
1164 hexify( dst_str, output, 16 );
1166 fct_chk( strcasecmp( (
char *) dst_str,
"14F7646187817EB586599146B82BD719" ) == 0 );
1171 #ifdef POLARSSL_CIPHER_MODE_CFB
1173 FCT_TEST_BGN(camellia_128_cfb128_encrypt_perl_evp_2)
1175 unsigned char key_str[100];
1176 unsigned char iv_str[100];
1177 unsigned char src_str[100];
1178 unsigned char dst_str[100];
1179 unsigned char output[100];
1181 size_t iv_offset = 0;
1184 memset(key_str, 0x00, 100);
1185 memset(iv_str, 0x00, 100);
1186 memset(src_str, 0x00, 100);
1187 memset(dst_str, 0x00, 100);
1188 memset(output, 0x00, 100);
1190 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
1191 unhexify( iv_str,
"14F7646187817EB586599146B82BD719" );
1192 unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
1196 hexify( dst_str, output, 16 );
1198 fct_chk( strcasecmp( (
char *) dst_str,
"A53D28BB82DF741103EA4F921A44880B" ) == 0 );
1203 #ifdef POLARSSL_CIPHER_MODE_CFB
1205 FCT_TEST_BGN(camellia_128_cfb128_encrypt_perl_evp_3)
1207 unsigned char key_str[100];
1208 unsigned char iv_str[100];
1209 unsigned char src_str[100];
1210 unsigned char dst_str[100];
1211 unsigned char output[100];
1213 size_t iv_offset = 0;
1216 memset(key_str, 0x00, 100);
1217 memset(iv_str, 0x00, 100);
1218 memset(src_str, 0x00, 100);
1219 memset(dst_str, 0x00, 100);
1220 memset(output, 0x00, 100);
1222 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
1223 unhexify( iv_str,
"A53D28BB82DF741103EA4F921A44880B" );
1224 unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
1228 hexify( dst_str, output, 16 );
1230 fct_chk( strcasecmp( (
char *) dst_str,
"9C2157A664626D1DEF9EA420FDE69B96" ) == 0 );
1235 #ifdef POLARSSL_CIPHER_MODE_CFB
1237 FCT_TEST_BGN(camellia_128_cfb128_encrypt_perl_evp_4)
1239 unsigned char key_str[100];
1240 unsigned char iv_str[100];
1241 unsigned char src_str[100];
1242 unsigned char dst_str[100];
1243 unsigned char output[100];
1245 size_t iv_offset = 0;
1248 memset(key_str, 0x00, 100);
1249 memset(iv_str, 0x00, 100);
1250 memset(src_str, 0x00, 100);
1251 memset(dst_str, 0x00, 100);
1252 memset(output, 0x00, 100);
1254 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
1255 unhexify( iv_str,
"9C2157A664626D1DEF9EA420FDE69B96" );
1256 unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
1260 hexify( dst_str, output, 16 );
1262 fct_chk( strcasecmp( (
char *) dst_str,
"742A25F0542340C7BAEF24CA8482BB09" ) == 0 );
1267 #ifdef POLARSSL_CIPHER_MODE_CFB
1269 FCT_TEST_BGN(camellia_128_cfb128_decrypt_perl_evp_1)
1271 unsigned char key_str[100];
1272 unsigned char iv_str[100];
1273 unsigned char src_str[100];
1274 unsigned char dst_str[100];
1275 unsigned char output[100];
1277 size_t iv_offset = 0;
1280 memset(key_str, 0x00, 100);
1281 memset(iv_str, 0x00, 100);
1282 memset(src_str, 0x00, 100);
1283 memset(dst_str, 0x00, 100);
1284 memset(output, 0x00, 100);
1286 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
1287 unhexify( iv_str,
"000102030405060708090A0B0C0D0E0F" );
1288 unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
1292 hexify( dst_str, output, 16 );
1294 fct_chk( strcasecmp( (
char *) dst_str,
"14F7646187817EB586599146B82BD719" ) == 0 );
1299 #ifdef POLARSSL_CIPHER_MODE_CFB
1301 FCT_TEST_BGN(camellia_128_cfb128_decrypt_perl_evp_2)
1303 unsigned char key_str[100];
1304 unsigned char iv_str[100];
1305 unsigned char src_str[100];
1306 unsigned char dst_str[100];
1307 unsigned char output[100];
1309 size_t iv_offset = 0;
1312 memset(key_str, 0x00, 100);
1313 memset(iv_str, 0x00, 100);
1314 memset(src_str, 0x00, 100);
1315 memset(dst_str, 0x00, 100);
1316 memset(output, 0x00, 100);
1318 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
1319 unhexify( iv_str,
"14F7646187817EB586599146B82BD719" );
1320 unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
1324 hexify( dst_str, output, 16 );
1326 fct_chk( strcasecmp( (
char *) dst_str,
"A53D28BB82DF741103EA4F921A44880B" ) == 0 );
1331 #ifdef POLARSSL_CIPHER_MODE_CFB
1333 FCT_TEST_BGN(camellia_128_cfb128_decrypt_perl_evp_3)
1335 unsigned char key_str[100];
1336 unsigned char iv_str[100];
1337 unsigned char src_str[100];
1338 unsigned char dst_str[100];
1339 unsigned char output[100];
1341 size_t iv_offset = 0;
1344 memset(key_str, 0x00, 100);
1345 memset(iv_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,
"2B7E151628AED2A6ABF7158809CF4F3C" );
1351 unhexify( iv_str,
"A53D28BB82DF741103EA4F921A44880B" );
1352 unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
1356 hexify( dst_str, output, 16 );
1358 fct_chk( strcasecmp( (
char *) dst_str,
"9C2157A664626D1DEF9EA420FDE69B96" ) == 0 );
1363 #ifdef POLARSSL_CIPHER_MODE_CFB
1365 FCT_TEST_BGN(camellia_128_cfb128_decrypt_perl_evp_4)
1367 unsigned char key_str[100];
1368 unsigned char iv_str[100];
1369 unsigned char src_str[100];
1370 unsigned char dst_str[100];
1371 unsigned char output[100];
1373 size_t iv_offset = 0;
1376 memset(key_str, 0x00, 100);
1377 memset(iv_str, 0x00, 100);
1378 memset(src_str, 0x00, 100);
1379 memset(dst_str, 0x00, 100);
1380 memset(output, 0x00, 100);
1382 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
1383 unhexify( iv_str,
"9C2157A664626D1DEF9EA420FDE69B96" );
1384 unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
1388 hexify( dst_str, output, 16 );
1390 fct_chk( strcasecmp( (
char *) dst_str,
"742A25F0542340C7BAEF24CA8482BB09" ) == 0 );
1395 #ifdef POLARSSL_CIPHER_MODE_CFB
1397 FCT_TEST_BGN(camellia_192_cfb128_encrypt_perl_evp_1)
1399 unsigned char key_str[100];
1400 unsigned char iv_str[100];
1401 unsigned char src_str[100];
1402 unsigned char dst_str[100];
1403 unsigned char output[100];
1405 size_t iv_offset = 0;
1408 memset(key_str, 0x00, 100);
1409 memset(iv_str, 0x00, 100);
1410 memset(src_str, 0x00, 100);
1411 memset(dst_str, 0x00, 100);
1412 memset(output, 0x00, 100);
1414 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
1415 unhexify( iv_str,
"000102030405060708090A0B0C0D0E0F" );
1416 unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
1420 hexify( dst_str, output, 16 );
1422 fct_chk( strcasecmp( (
char *) dst_str,
"C832BB9780677DAA82D9B6860DCD565E" ) == 0 );
1427 #ifdef POLARSSL_CIPHER_MODE_CFB
1429 FCT_TEST_BGN(camellia_192_cfb128_encrypt_perl_evp_2)
1431 unsigned char key_str[100];
1432 unsigned char iv_str[100];
1433 unsigned char src_str[100];
1434 unsigned char dst_str[100];
1435 unsigned char output[100];
1437 size_t iv_offset = 0;
1440 memset(key_str, 0x00, 100);
1441 memset(iv_str, 0x00, 100);
1442 memset(src_str, 0x00, 100);
1443 memset(dst_str, 0x00, 100);
1444 memset(output, 0x00, 100);
1446 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
1447 unhexify( iv_str,
"C832BB9780677DAA82D9B6860DCD565E" );
1448 unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
1452 hexify( dst_str, output, 16 );
1454 fct_chk( strcasecmp( (
char *) dst_str,
"86F8491627906D780C7A6D46EA331F98" ) == 0 );
1459 #ifdef POLARSSL_CIPHER_MODE_CFB
1461 FCT_TEST_BGN(camellia_192_cfb128_encrypt_perl_evp_3)
1463 unsigned char key_str[100];
1464 unsigned char iv_str[100];
1465 unsigned char src_str[100];
1466 unsigned char dst_str[100];
1467 unsigned char output[100];
1469 size_t iv_offset = 0;
1472 memset(key_str, 0x00, 100);
1473 memset(iv_str, 0x00, 100);
1474 memset(src_str, 0x00, 100);
1475 memset(dst_str, 0x00, 100);
1476 memset(output, 0x00, 100);
1478 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
1479 unhexify( iv_str,
"86F8491627906D780C7A6D46EA331F98" );
1480 unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
1484 hexify( dst_str, output, 16 );
1486 fct_chk( strcasecmp( (
char *) dst_str,
"69511CCE594CF710CB98BB63D7221F01" ) == 0 );
1491 #ifdef POLARSSL_CIPHER_MODE_CFB
1493 FCT_TEST_BGN(camellia_192_cfb128_encrypt_perl_evp_4)
1495 unsigned char key_str[100];
1496 unsigned char iv_str[100];
1497 unsigned char src_str[100];
1498 unsigned char dst_str[100];
1499 unsigned char output[100];
1501 size_t iv_offset = 0;
1504 memset(key_str, 0x00, 100);
1505 memset(iv_str, 0x00, 100);
1506 memset(src_str, 0x00, 100);
1507 memset(dst_str, 0x00, 100);
1508 memset(output, 0x00, 100);
1510 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
1511 unhexify( iv_str,
"69511CCE594CF710CB98BB63D7221F01" );
1512 unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
1516 hexify( dst_str, output, 16 );
1518 fct_chk( strcasecmp( (
char *) dst_str,
"D5B5378A3ABED55803F25565D8907B84" ) == 0 );
1523 #ifdef POLARSSL_CIPHER_MODE_CFB
1525 FCT_TEST_BGN(camellia_192_cfb128_decrypt_perl_evp_1)
1527 unsigned char key_str[100];
1528 unsigned char iv_str[100];
1529 unsigned char src_str[100];
1530 unsigned char dst_str[100];
1531 unsigned char output[100];
1533 size_t iv_offset = 0;
1536 memset(key_str, 0x00, 100);
1537 memset(iv_str, 0x00, 100);
1538 memset(src_str, 0x00, 100);
1539 memset(dst_str, 0x00, 100);
1540 memset(output, 0x00, 100);
1542 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
1543 unhexify( iv_str,
"000102030405060708090A0B0C0D0E0F" );
1544 unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
1548 hexify( dst_str, output, 16 );
1550 fct_chk( strcasecmp( (
char *) dst_str,
"C832BB9780677DAA82D9B6860DCD565E" ) == 0 );
1555 #ifdef POLARSSL_CIPHER_MODE_CFB
1557 FCT_TEST_BGN(camellia_192_cfb128_decrypt_perl_evp_2)
1559 unsigned char key_str[100];
1560 unsigned char iv_str[100];
1561 unsigned char src_str[100];
1562 unsigned char dst_str[100];
1563 unsigned char output[100];
1565 size_t iv_offset = 0;
1568 memset(key_str, 0x00, 100);
1569 memset(iv_str, 0x00, 100);
1570 memset(src_str, 0x00, 100);
1571 memset(dst_str, 0x00, 100);
1572 memset(output, 0x00, 100);
1574 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
1575 unhexify( iv_str,
"C832BB9780677DAA82D9B6860DCD565E" );
1576 unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
1580 hexify( dst_str, output, 16 );
1582 fct_chk( strcasecmp( (
char *) dst_str,
"86F8491627906D780C7A6D46EA331F98" ) == 0 );
1587 #ifdef POLARSSL_CIPHER_MODE_CFB
1589 FCT_TEST_BGN(camellia_192_cfb128_decrypt_perl_evp_3)
1591 unsigned char key_str[100];
1592 unsigned char iv_str[100];
1593 unsigned char src_str[100];
1594 unsigned char dst_str[100];
1595 unsigned char output[100];
1597 size_t iv_offset = 0;
1600 memset(key_str, 0x00, 100);
1601 memset(iv_str, 0x00, 100);
1602 memset(src_str, 0x00, 100);
1603 memset(dst_str, 0x00, 100);
1604 memset(output, 0x00, 100);
1606 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
1607 unhexify( iv_str,
"86F8491627906D780C7A6D46EA331F98" );
1608 unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
1612 hexify( dst_str, output, 16 );
1614 fct_chk( strcasecmp( (
char *) dst_str,
"69511CCE594CF710CB98BB63D7221F01" ) == 0 );
1619 #ifdef POLARSSL_CIPHER_MODE_CFB
1621 FCT_TEST_BGN(camellia_192_cfb128_decrypt_perl_evp_4)
1623 unsigned char key_str[100];
1624 unsigned char iv_str[100];
1625 unsigned char src_str[100];
1626 unsigned char dst_str[100];
1627 unsigned char output[100];
1629 size_t iv_offset = 0;
1632 memset(key_str, 0x00, 100);
1633 memset(iv_str, 0x00, 100);
1634 memset(src_str, 0x00, 100);
1635 memset(dst_str, 0x00, 100);
1636 memset(output, 0x00, 100);
1638 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
1639 unhexify( iv_str,
"69511CCE594CF710CB98BB63D7221F01" );
1640 unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
1644 hexify( dst_str, output, 16 );
1646 fct_chk( strcasecmp( (
char *) dst_str,
"D5B5378A3ABED55803F25565D8907B84" ) == 0 );
1651 #ifdef POLARSSL_CIPHER_MODE_CFB
1653 FCT_TEST_BGN(camellia_256_cfb128_encrypt_perl_evp_1)
1655 unsigned char key_str[100];
1656 unsigned char iv_str[100];
1657 unsigned char src_str[100];
1658 unsigned char dst_str[100];
1659 unsigned char output[100];
1661 size_t iv_offset = 0;
1664 memset(key_str, 0x00, 100);
1665 memset(iv_str, 0x00, 100);
1666 memset(src_str, 0x00, 100);
1667 memset(dst_str, 0x00, 100);
1668 memset(output, 0x00, 100);
1670 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1671 unhexify( iv_str,
"000102030405060708090A0B0C0D0E0F" );
1672 unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
1676 hexify( dst_str, output, 16 );
1678 fct_chk( strcasecmp( (
char *) dst_str,
"CF6107BB0CEA7D7FB1BD31F5E7B06C93" ) == 0 );
1683 #ifdef POLARSSL_CIPHER_MODE_CFB
1685 FCT_TEST_BGN(camellia_256_cfb128_encrypt_perl_evp_2)
1687 unsigned char key_str[100];
1688 unsigned char iv_str[100];
1689 unsigned char src_str[100];
1690 unsigned char dst_str[100];
1691 unsigned char output[100];
1693 size_t iv_offset = 0;
1696 memset(key_str, 0x00, 100);
1697 memset(iv_str, 0x00, 100);
1698 memset(src_str, 0x00, 100);
1699 memset(dst_str, 0x00, 100);
1700 memset(output, 0x00, 100);
1702 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1703 unhexify( iv_str,
"CF6107BB0CEA7D7FB1BD31F5E7B06C93" );
1704 unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
1708 hexify( dst_str, output, 16 );
1710 fct_chk( strcasecmp( (
char *) dst_str,
"89BEDB4CCDD864EA11BA4CBE849B5E2B" ) == 0 );
1715 #ifdef POLARSSL_CIPHER_MODE_CFB
1717 FCT_TEST_BGN(camellia_256_cfb128_encrypt_perl_evp_3)
1719 unsigned char key_str[100];
1720 unsigned char iv_str[100];
1721 unsigned char src_str[100];
1722 unsigned char dst_str[100];
1723 unsigned char output[100];
1725 size_t iv_offset = 0;
1728 memset(key_str, 0x00, 100);
1729 memset(iv_str, 0x00, 100);
1730 memset(src_str, 0x00, 100);
1731 memset(dst_str, 0x00, 100);
1732 memset(output, 0x00, 100);
1734 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1735 unhexify( iv_str,
"89BEDB4CCDD864EA11BA4CBE849B5E2B" );
1736 unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
1740 hexify( dst_str, output, 16 );
1742 fct_chk( strcasecmp( (
char *) dst_str,
"555FC3F34BDD2D54C62D9E3BF338C1C4" ) == 0 );
1747 #ifdef POLARSSL_CIPHER_MODE_CFB
1749 FCT_TEST_BGN(camellia_256_cfb128_encrypt_perl_evp_4)
1751 unsigned char key_str[100];
1752 unsigned char iv_str[100];
1753 unsigned char src_str[100];
1754 unsigned char dst_str[100];
1755 unsigned char output[100];
1757 size_t iv_offset = 0;
1760 memset(key_str, 0x00, 100);
1761 memset(iv_str, 0x00, 100);
1762 memset(src_str, 0x00, 100);
1763 memset(dst_str, 0x00, 100);
1764 memset(output, 0x00, 100);
1766 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1767 unhexify( iv_str,
"555FC3F34BDD2D54C62D9E3BF338C1C4" );
1768 unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
1772 hexify( dst_str, output, 16 );
1774 fct_chk( strcasecmp( (
char *) dst_str,
"5953ADCE14DB8C7F39F1BD39F359BFFA" ) == 0 );
1779 #ifdef POLARSSL_CIPHER_MODE_CFB
1781 FCT_TEST_BGN(camellia_256_cfb128_decrypt_perl_evp_1)
1783 unsigned char key_str[100];
1784 unsigned char iv_str[100];
1785 unsigned char src_str[100];
1786 unsigned char dst_str[100];
1787 unsigned char output[100];
1789 size_t iv_offset = 0;
1792 memset(key_str, 0x00, 100);
1793 memset(iv_str, 0x00, 100);
1794 memset(src_str, 0x00, 100);
1795 memset(dst_str, 0x00, 100);
1796 memset(output, 0x00, 100);
1798 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1799 unhexify( iv_str,
"000102030405060708090A0B0C0D0E0F" );
1800 unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
1804 hexify( dst_str, output, 16 );
1806 fct_chk( strcasecmp( (
char *) dst_str,
"CF6107BB0CEA7D7FB1BD31F5E7B06C93" ) == 0 );
1811 #ifdef POLARSSL_CIPHER_MODE_CFB
1813 FCT_TEST_BGN(camellia_256_cfb128_decrypt_perl_evp_2)
1815 unsigned char key_str[100];
1816 unsigned char iv_str[100];
1817 unsigned char src_str[100];
1818 unsigned char dst_str[100];
1819 unsigned char output[100];
1821 size_t iv_offset = 0;
1824 memset(key_str, 0x00, 100);
1825 memset(iv_str, 0x00, 100);
1826 memset(src_str, 0x00, 100);
1827 memset(dst_str, 0x00, 100);
1828 memset(output, 0x00, 100);
1830 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1831 unhexify( iv_str,
"CF6107BB0CEA7D7FB1BD31F5E7B06C93" );
1832 unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
1836 hexify( dst_str, output, 16 );
1838 fct_chk( strcasecmp( (
char *) dst_str,
"89BEDB4CCDD864EA11BA4CBE849B5E2B" ) == 0 );
1843 #ifdef POLARSSL_CIPHER_MODE_CFB
1845 FCT_TEST_BGN(camellia_256_cfb128_decrypt_perl_evp_3)
1847 unsigned char key_str[100];
1848 unsigned char iv_str[100];
1849 unsigned char src_str[100];
1850 unsigned char dst_str[100];
1851 unsigned char output[100];
1853 size_t iv_offset = 0;
1856 memset(key_str, 0x00, 100);
1857 memset(iv_str, 0x00, 100);
1858 memset(src_str, 0x00, 100);
1859 memset(dst_str, 0x00, 100);
1860 memset(output, 0x00, 100);
1862 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1863 unhexify( iv_str,
"89BEDB4CCDD864EA11BA4CBE849B5E2B" );
1864 unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
1868 hexify( dst_str, output, 16 );
1870 fct_chk( strcasecmp( (
char *) dst_str,
"555FC3F34BDD2D54C62D9E3BF338C1C4" ) == 0 );
1875 #ifdef POLARSSL_CIPHER_MODE_CFB
1877 FCT_TEST_BGN(camellia_256_cfb128_decrypt_perl_evp_4)
1879 unsigned char key_str[100];
1880 unsigned char iv_str[100];
1881 unsigned char src_str[100];
1882 unsigned char dst_str[100];
1883 unsigned char output[100];
1885 size_t iv_offset = 0;
1888 memset(key_str, 0x00, 100);
1889 memset(iv_str, 0x00, 100);
1890 memset(src_str, 0x00, 100);
1891 memset(dst_str, 0x00, 100);
1892 memset(output, 0x00, 100);
1894 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1895 unhexify( iv_str,
"555FC3F34BDD2D54C62D9E3BF338C1C4" );
1896 unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
1900 hexify( dst_str, output, 16 );
1902 fct_chk( strcasecmp( (
char *) dst_str,
"5953ADCE14DB8C7F39F1BD39F359BFFA" ) == 0 );
1908 FCT_TEST_BGN(camellia_ecb_encrypt_invalid_key_length)
1910 unsigned char key_str[100];
1911 unsigned char src_str[100];
1912 unsigned char dst_str[100];
1913 unsigned char output[100];
1917 memset(key_str, 0x00, 100);
1918 memset(src_str, 0x00, 100);
1919 memset(dst_str, 0x00, 100);
1920 memset(output, 0x00, 100);
1922 key_len =
unhexify( key_str,
"0123456789abcdeffedcba98765432" );
1923 unhexify( src_str,
"0123456789abcdeffedcba9876543210" );
1929 hexify( dst_str, output, 16 );
1931 fct_chk( strcasecmp( (
char *) dst_str,
"67673138549669730857065648eabe43" ) == 0 );
1937 FCT_TEST_BGN(camellia_ecb_decrypt_invalid_key_length)
1939 unsigned char key_str[100];
1940 unsigned char src_str[100];
1941 unsigned char dst_str[100];
1942 unsigned char output[100];
1946 memset(key_str, 0x00, 100);
1947 memset(src_str, 0x00, 100);
1948 memset(dst_str, 0x00, 100);
1949 memset(output, 0x00, 100);
1951 key_len =
unhexify( key_str,
"0123456789abcdeffedcba98765432" );
1952 unhexify( src_str,
"0123456789abcdeffedcba9876543210" );
1958 hexify( dst_str, output, 16 );
1960 fct_chk( strcasecmp( (
char *) dst_str,
"67673138549669730857065648eabe43" ) == 0 );
1966 FCT_TEST_BGN(camellia_256_cbc_encrypt_invalid_input_length)
1968 unsigned char key_str[100];
1969 unsigned char iv_str[100];
1970 unsigned char src_str[100];
1971 unsigned char dst_str[100];
1972 unsigned char output[100];
1974 int key_len, data_len;
1976 memset(key_str, 0x00, 100);
1977 memset(iv_str, 0x00, 100);
1978 memset(src_str, 0x00, 100);
1979 memset(dst_str, 0x00, 100);
1980 memset(output, 0x00, 100);
1982 key_len =
unhexify( key_str,
"0000000000000000000000000000000000000000000000000000000000000000" );
1983 unhexify( iv_str,
"00000000000000000000000000000000" );
1984 data_len =
unhexify( src_str,
"ffffffffffffffe000000000000000" );
1990 hexify( dst_str, output, data_len );
1992 fct_chk( strcasecmp( (
char *) dst_str,
"" ) == 0 );
1998 FCT_TEST_BGN(camellia_256_cbc_decrypt_invalid_input_length)
2000 unsigned char key_str[100];
2001 unsigned char iv_str[100];
2002 unsigned char src_str[100];
2003 unsigned char dst_str[100];
2004 unsigned char output[100];
2006 int key_len, data_len;
2008 memset(key_str, 0x00, 100);
2009 memset(iv_str, 0x00, 100);
2010 memset(src_str, 0x00, 100);
2011 memset(dst_str, 0x00, 100);
2012 memset(output, 0x00, 100);
2014 key_len =
unhexify( key_str,
"0000000000000000000000000000000000000000000000000000000000000000" );
2015 unhexify( iv_str,
"00000000000000000000000000000000" );
2016 data_len =
unhexify( src_str,
"623a52fcea5d443e48d9181ab32c74" );
2022 hexify( dst_str, output, data_len );
2024 fct_chk( strcasecmp( (
char *) dst_str,
"" ) == 0 );
2029 #ifdef POLARSSL_SELF_TEST
2031 FCT_TEST_BGN(camellia_selftest)