9 typedef UINT32 uint32_t;
18 #define GET_UINT32_BE(n,b,i) \
20 (n) = ( (uint32_t) (b)[(i) ] << 24 ) \
21 | ( (uint32_t) (b)[(i) + 1] << 16 ) \
22 | ( (uint32_t) (b)[(i) + 2] << 8 ) \
23 | ( (uint32_t) (b)[(i) + 3] ); \
28 #define PUT_UINT32_BE(n,b,i) \
30 (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
31 (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
32 (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
33 (b)[(i) + 3] = (unsigned char) ( (n) ); \
37 int unhexify(
unsigned char *obuf,
const char *ibuf)
40 int len = strlen(ibuf) / 2;
41 assert(!(strlen(ibuf) %1));
46 if( c >=
'0' && c <=
'9' )
48 else if( c >=
'a' && c <=
'f' )
50 else if( c >=
'A' && c <=
'F' )
56 if( c2 >=
'0' && c2 <=
'9' )
58 else if( c2 >=
'a' && c2 <=
'f' )
60 else if( c2 >=
'A' && c2 <=
'F' )
65 *obuf++ = ( c << 4 ) | c2;
71 void hexify(
unsigned char *obuf,
const unsigned char *ibuf,
int len)
83 *obuf++ =
'a' + h - 10;
88 *obuf++ =
'a' + l - 10;
104 static int rnd_std_rand(
void *rng_state,
unsigned char *output,
size_t len )
108 if( rng_state != NULL )
111 for( i = 0; i < len; ++i )
122 static int rnd_zero_rand(
void *rng_state,
unsigned char *output,
size_t len )
124 if( rng_state != NULL )
127 memset( output, 0, len );
154 if( rng_state == NULL )
163 memcpy( output, info->
buf, use_len );
164 info->
buf += use_len;
168 if( len - use_len > 0 )
169 return(
rnd_std_rand( NULL, output + use_len, len - use_len ) );
198 uint32_t i, *k, sum, delta=0x9E3779B9;
199 unsigned char result[4];
201 if( rng_state == NULL )
208 size_t use_len = ( len > 4 ) ? 4 : len;
211 for( i = 0; i < 32; i++ )
213 info->
v0 += (((info->
v1 << 4) ^ (info->
v1 >> 5)) + info->
v1) ^ (sum + k[sum & 3]);
215 info->
v1 += (((info->
v0 << 4) ^ (info->
v0 >> 5)) + info->
v0) ^ (sum + k[(sum>>11) & 3]);
219 memcpy( output, result, use_len );
229 #ifdef POLARSSL_CAMELLIA_C
232 FCT_SUITE_BGN(test_suite_camellia)
235 FCT_TEST_BGN(camellia_128_ecb_encrypt_rfc3713_1)
237 unsigned char key_str[100];
238 unsigned char src_str[100];
239 unsigned char dst_str[100];
240 unsigned char output[100];
244 memset(key_str, 0x00, 100);
245 memset(src_str, 0x00, 100);
246 memset(dst_str, 0x00, 100);
247 memset(output, 0x00, 100);
249 key_len =
unhexify( key_str,
"0123456789abcdeffedcba9876543210" );
250 unhexify( src_str,
"0123456789abcdeffedcba9876543210" );
256 hexify( dst_str, output, 16 );
258 fct_chk( strcasecmp( (
char *) dst_str,
"67673138549669730857065648eabe43" ) == 0 );
264 FCT_TEST_BGN(camellia_192_ecb_encrypt_rfc3713_1)
266 unsigned char key_str[100];
267 unsigned char src_str[100];
268 unsigned char dst_str[100];
269 unsigned char output[100];
273 memset(key_str, 0x00, 100);
274 memset(src_str, 0x00, 100);
275 memset(dst_str, 0x00, 100);
276 memset(output, 0x00, 100);
278 key_len =
unhexify( key_str,
"0123456789abcdeffedcba98765432100011223344556677" );
279 unhexify( src_str,
"0123456789abcdeffedcba9876543210" );
285 hexify( dst_str, output, 16 );
287 fct_chk( strcasecmp( (
char *) dst_str,
"b4993401b3e996f84ee5cee7d79b09b9" ) == 0 );
293 FCT_TEST_BGN(camellia_256_ecb_encrypt_rfc3713_1)
295 unsigned char key_str[100];
296 unsigned char src_str[100];
297 unsigned char dst_str[100];
298 unsigned char output[100];
302 memset(key_str, 0x00, 100);
303 memset(src_str, 0x00, 100);
304 memset(dst_str, 0x00, 100);
305 memset(output, 0x00, 100);
307 key_len =
unhexify( key_str,
"0123456789abcdeffedcba987654321000112233445566778899aabbccddeeff" );
308 unhexify( src_str,
"0123456789abcdeffedcba9876543210" );
314 hexify( dst_str, output, 16 );
316 fct_chk( strcasecmp( (
char *) dst_str,
"9acc237dff16d76c20ef7c919e3a7509" ) == 0 );
322 FCT_TEST_BGN(camellia_128_ecb_encrypt_perl_evp_1)
324 unsigned char key_str[100];
325 unsigned char src_str[100];
326 unsigned char dst_str[100];
327 unsigned char output[100];
331 memset(key_str, 0x00, 100);
332 memset(src_str, 0x00, 100);
333 memset(dst_str, 0x00, 100);
334 memset(output, 0x00, 100);
336 key_len =
unhexify( key_str,
"000102030405060708090A0B0C0D0E0F" );
337 unhexify( src_str,
"00112233445566778899AABBCCDDEEFF" );
343 hexify( dst_str, output, 16 );
345 fct_chk( strcasecmp( (
char *) dst_str,
"77CF412067AF8270613529149919546F" ) == 0 );
351 FCT_TEST_BGN(camellia_192_ecb_encrypt_perl_evp_1)
353 unsigned char key_str[100];
354 unsigned char src_str[100];
355 unsigned char dst_str[100];
356 unsigned char output[100];
360 memset(key_str, 0x00, 100);
361 memset(src_str, 0x00, 100);
362 memset(dst_str, 0x00, 100);
363 memset(output, 0x00, 100);
365 key_len =
unhexify( key_str,
"000102030405060708090A0B0C0D0E0F1011121314151617" );
366 unhexify( src_str,
"00112233445566778899AABBCCDDEEFF" );
372 hexify( dst_str, output, 16 );
374 fct_chk( strcasecmp( (
char *) dst_str,
"B22F3C36B72D31329EEE8ADDC2906C68" ) == 0 );
380 FCT_TEST_BGN(camellia_256_ecb_encrypt_perl_evp_1)
382 unsigned char key_str[100];
383 unsigned char src_str[100];
384 unsigned char dst_str[100];
385 unsigned char output[100];
389 memset(key_str, 0x00, 100);
390 memset(src_str, 0x00, 100);
391 memset(dst_str, 0x00, 100);
392 memset(output, 0x00, 100);
394 key_len =
unhexify( key_str,
"000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F" );
395 unhexify( src_str,
"00112233445566778899AABBCCDDEEFF" );
401 hexify( dst_str, output, 16 );
403 fct_chk( strcasecmp( (
char *) dst_str,
"2EDF1F3418D53B88841FC8985FB1ECF2" ) == 0 );
409 FCT_TEST_BGN(camellia_128_ecb_encrypt_perl_evp_1)
411 unsigned char key_str[100];
412 unsigned char src_str[100];
413 unsigned char dst_str[100];
414 unsigned char output[100];
418 memset(key_str, 0x00, 100);
419 memset(src_str, 0x00, 100);
420 memset(dst_str, 0x00, 100);
421 memset(output, 0x00, 100);
423 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
424 unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
430 hexify( dst_str, output, 16 );
432 fct_chk( strcasecmp( (
char *) dst_str,
"432FC5DCD628115B7C388D770B270C96" ) == 0 );
438 FCT_TEST_BGN(camellia_128_ecb_encrypt_perl_evp_2)
440 unsigned char key_str[100];
441 unsigned char src_str[100];
442 unsigned char dst_str[100];
443 unsigned char output[100];
447 memset(key_str, 0x00, 100);
448 memset(src_str, 0x00, 100);
449 memset(dst_str, 0x00, 100);
450 memset(output, 0x00, 100);
452 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
453 unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
459 hexify( dst_str, output, 16 );
461 fct_chk( strcasecmp( (
char *) dst_str,
"0BE1F14023782A22E8384C5ABB7FAB2B" ) == 0 );
467 FCT_TEST_BGN(camellia_128_ecb_encrypt_perl_evp_3)
469 unsigned char key_str[100];
470 unsigned char src_str[100];
471 unsigned char dst_str[100];
472 unsigned char output[100];
476 memset(key_str, 0x00, 100);
477 memset(src_str, 0x00, 100);
478 memset(dst_str, 0x00, 100);
479 memset(output, 0x00, 100);
481 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
482 unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
488 hexify( dst_str, output, 16 );
490 fct_chk( strcasecmp( (
char *) dst_str,
"A0A1ABCD1893AB6FE0FE5B65DF5F8636" ) == 0 );
496 FCT_TEST_BGN(camellia_128_ecb_encrypt_perl_evp_4)
498 unsigned char key_str[100];
499 unsigned char src_str[100];
500 unsigned char dst_str[100];
501 unsigned char output[100];
505 memset(key_str, 0x00, 100);
506 memset(src_str, 0x00, 100);
507 memset(dst_str, 0x00, 100);
508 memset(output, 0x00, 100);
510 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
511 unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
517 hexify( dst_str, output, 16 );
519 fct_chk( strcasecmp( (
char *) dst_str,
"E61925E0D5DFAA9BB29F815B3076E51A" ) == 0 );
525 FCT_TEST_BGN(camellia_192_ecb_encrypt_perl_evp_1)
527 unsigned char key_str[100];
528 unsigned char src_str[100];
529 unsigned char dst_str[100];
530 unsigned char output[100];
534 memset(key_str, 0x00, 100);
535 memset(src_str, 0x00, 100);
536 memset(dst_str, 0x00, 100);
537 memset(output, 0x00, 100);
539 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
540 unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
546 hexify( dst_str, output, 16 );
548 fct_chk( strcasecmp( (
char *) dst_str,
"CCCC6C4E138B45848514D48D0D3439D3" ) == 0 );
554 FCT_TEST_BGN(camellia_192_ecb_encrypt_perl_evp_2)
556 unsigned char key_str[100];
557 unsigned char src_str[100];
558 unsigned char dst_str[100];
559 unsigned char output[100];
563 memset(key_str, 0x00, 100);
564 memset(src_str, 0x00, 100);
565 memset(dst_str, 0x00, 100);
566 memset(output, 0x00, 100);
568 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
569 unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
575 hexify( dst_str, output, 16 );
577 fct_chk( strcasecmp( (
char *) dst_str,
"5713C62C14B2EC0F8393B6AFD6F5785A" ) == 0 );
583 FCT_TEST_BGN(camellia_192_ecb_encrypt_perl_evp_3)
585 unsigned char key_str[100];
586 unsigned char src_str[100];
587 unsigned char dst_str[100];
588 unsigned char output[100];
592 memset(key_str, 0x00, 100);
593 memset(src_str, 0x00, 100);
594 memset(dst_str, 0x00, 100);
595 memset(output, 0x00, 100);
597 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
598 unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
604 hexify( dst_str, output, 16 );
606 fct_chk( strcasecmp( (
char *) dst_str,
"B40ED2B60EB54D09D030CF511FEEF366" ) == 0 );
612 FCT_TEST_BGN(camellia_192_ecb_encrypt_perl_evp_4)
614 unsigned char key_str[100];
615 unsigned char src_str[100];
616 unsigned char dst_str[100];
617 unsigned char output[100];
621 memset(key_str, 0x00, 100);
622 memset(src_str, 0x00, 100);
623 memset(dst_str, 0x00, 100);
624 memset(output, 0x00, 100);
626 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
627 unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
633 hexify( dst_str, output, 16 );
635 fct_chk( strcasecmp( (
char *) dst_str,
"909DBD95799096748CB27357E73E1D26" ) == 0 );
641 FCT_TEST_BGN(camellia_256_ecb_encrypt_perl_evp_1)
643 unsigned char key_str[100];
644 unsigned char src_str[100];
645 unsigned char dst_str[100];
646 unsigned char output[100];
650 memset(key_str, 0x00, 100);
651 memset(src_str, 0x00, 100);
652 memset(dst_str, 0x00, 100);
653 memset(output, 0x00, 100);
655 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
656 unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
662 hexify( dst_str, output, 16 );
664 fct_chk( strcasecmp( (
char *) dst_str,
"BEFD219B112FA00098919CD101C9CCFA" ) == 0 );
670 FCT_TEST_BGN(camellia_256_ecb_encrypt_perl_evp_2)
672 unsigned char key_str[100];
673 unsigned char src_str[100];
674 unsigned char dst_str[100];
675 unsigned char output[100];
679 memset(key_str, 0x00, 100);
680 memset(src_str, 0x00, 100);
681 memset(dst_str, 0x00, 100);
682 memset(output, 0x00, 100);
684 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
685 unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
691 hexify( dst_str, output, 16 );
693 fct_chk( strcasecmp( (
char *) dst_str,
"C91D3A8F1AEA08A9386CF4B66C0169EA" ) == 0 );
699 FCT_TEST_BGN(camellia_256_ecb_encrypt_perl_evp_3)
701 unsigned char key_str[100];
702 unsigned char src_str[100];
703 unsigned char dst_str[100];
704 unsigned char output[100];
708 memset(key_str, 0x00, 100);
709 memset(src_str, 0x00, 100);
710 memset(dst_str, 0x00, 100);
711 memset(output, 0x00, 100);
713 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
714 unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
720 hexify( dst_str, output, 16 );
722 fct_chk( strcasecmp( (
char *) dst_str,
"A623D711DC5F25A51BB8A80D56397D28" ) == 0 );
728 FCT_TEST_BGN(camellia_256_ecb_encrypt_perl_evp_4)
730 unsigned char key_str[100];
731 unsigned char src_str[100];
732 unsigned char dst_str[100];
733 unsigned char output[100];
737 memset(key_str, 0x00, 100);
738 memset(src_str, 0x00, 100);
739 memset(dst_str, 0x00, 100);
740 memset(output, 0x00, 100);
742 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
743 unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
749 hexify( dst_str, output, 16 );
751 fct_chk( strcasecmp( (
char *) dst_str,
"7960109FB6DC42947FCFE59EA3C5EB6B" ) == 0 );
757 FCT_TEST_BGN(camellia_128_cbc_encrypt_perl_evp_1)
759 unsigned char key_str[100];
760 unsigned char iv_str[100];
761 unsigned char src_str[100];
762 unsigned char dst_str[100];
763 unsigned char output[100];
765 int key_len, data_len;
767 memset(key_str, 0x00, 100);
768 memset(iv_str, 0x00, 100);
769 memset(src_str, 0x00, 100);
770 memset(dst_str, 0x00, 100);
771 memset(output, 0x00, 100);
773 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
774 unhexify( iv_str,
"000102030405060708090A0B0C0D0E0F" );
775 data_len =
unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
781 hexify( dst_str, output, data_len );
783 fct_chk( strcasecmp( (
char *) dst_str,
"1607CF494B36BBF00DAEB0B503C831AB" ) == 0 );
789 FCT_TEST_BGN(camellia_128_cbc_encrypt_perl_evp_2)
791 unsigned char key_str[100];
792 unsigned char iv_str[100];
793 unsigned char src_str[100];
794 unsigned char dst_str[100];
795 unsigned char output[100];
797 int key_len, data_len;
799 memset(key_str, 0x00, 100);
800 memset(iv_str, 0x00, 100);
801 memset(src_str, 0x00, 100);
802 memset(dst_str, 0x00, 100);
803 memset(output, 0x00, 100);
805 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
806 unhexify( iv_str,
"1607CF494B36BBF00DAEB0B503C831AB" );
807 data_len =
unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
813 hexify( dst_str, output, data_len );
815 fct_chk( strcasecmp( (
char *) dst_str,
"A2F2CF671629EF7840C5A5DFB5074887" ) == 0 );
821 FCT_TEST_BGN(camellia_128_cbc_encrypt_perl_evp_3)
823 unsigned char key_str[100];
824 unsigned char iv_str[100];
825 unsigned char src_str[100];
826 unsigned char dst_str[100];
827 unsigned char output[100];
829 int key_len, data_len;
831 memset(key_str, 0x00, 100);
832 memset(iv_str, 0x00, 100);
833 memset(src_str, 0x00, 100);
834 memset(dst_str, 0x00, 100);
835 memset(output, 0x00, 100);
837 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
838 unhexify( iv_str,
"A2F2CF671629EF7840C5A5DFB5074887" );
839 data_len =
unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
845 hexify( dst_str, output, data_len );
847 fct_chk( strcasecmp( (
char *) dst_str,
"0F06165008CF8B8B5A63586362543E54" ) == 0 );
853 FCT_TEST_BGN(camellia_128_cbc_encrypt_perl_evp_4)
855 unsigned char key_str[100];
856 unsigned char iv_str[100];
857 unsigned char src_str[100];
858 unsigned char dst_str[100];
859 unsigned char output[100];
861 int key_len, data_len;
863 memset(key_str, 0x00, 100);
864 memset(iv_str, 0x00, 100);
865 memset(src_str, 0x00, 100);
866 memset(dst_str, 0x00, 100);
867 memset(output, 0x00, 100);
869 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
870 unhexify( iv_str,
"36A84CDAFD5F9A85ADA0F0A993D6D577" );
871 data_len =
unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
877 hexify( dst_str, output, data_len );
879 fct_chk( strcasecmp( (
char *) dst_str,
"74C64268CDB8B8FAF5B34E8AF3732980" ) == 0 );
885 FCT_TEST_BGN(camellia_192_cbc_encrypt_perl_evp_1)
887 unsigned char key_str[100];
888 unsigned char iv_str[100];
889 unsigned char src_str[100];
890 unsigned char dst_str[100];
891 unsigned char output[100];
893 int key_len, data_len;
895 memset(key_str, 0x00, 100);
896 memset(iv_str, 0x00, 100);
897 memset(src_str, 0x00, 100);
898 memset(dst_str, 0x00, 100);
899 memset(output, 0x00, 100);
901 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
902 unhexify( iv_str,
"000102030405060708090A0B0C0D0E0F" );
903 data_len =
unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
909 hexify( dst_str, output, data_len );
911 fct_chk( strcasecmp( (
char *) dst_str,
"2A4830AB5AC4A1A2405955FD2195CF93" ) == 0 );
917 FCT_TEST_BGN(camellia_192_cbc_encrypt_perl_evp_2)
919 unsigned char key_str[100];
920 unsigned char iv_str[100];
921 unsigned char src_str[100];
922 unsigned char dst_str[100];
923 unsigned char output[100];
925 int key_len, data_len;
927 memset(key_str, 0x00, 100);
928 memset(iv_str, 0x00, 100);
929 memset(src_str, 0x00, 100);
930 memset(dst_str, 0x00, 100);
931 memset(output, 0x00, 100);
933 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
934 unhexify( iv_str,
"2A4830AB5AC4A1A2405955FD2195CF93" );
935 data_len =
unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
941 hexify( dst_str, output, data_len );
943 fct_chk( strcasecmp( (
char *) dst_str,
"5D5A869BD14CE54264F892A6DD2EC3D5" ) == 0 );
949 FCT_TEST_BGN(camellia_192_cbc_encrypt_perl_evp_3)
951 unsigned char key_str[100];
952 unsigned char iv_str[100];
953 unsigned char src_str[100];
954 unsigned char dst_str[100];
955 unsigned char output[100];
957 int key_len, data_len;
959 memset(key_str, 0x00, 100);
960 memset(iv_str, 0x00, 100);
961 memset(src_str, 0x00, 100);
962 memset(dst_str, 0x00, 100);
963 memset(output, 0x00, 100);
965 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
966 unhexify( iv_str,
"5D5A869BD14CE54264F892A6DD2EC3D5" );
967 data_len =
unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
973 hexify( dst_str, output, data_len );
975 fct_chk( strcasecmp( (
char *) dst_str,
"37D359C3349836D884E310ADDF68C449" ) == 0 );
981 FCT_TEST_BGN(camellia_192_cbc_encrypt_perl_evp_4)
983 unsigned char key_str[100];
984 unsigned char iv_str[100];
985 unsigned char src_str[100];
986 unsigned char dst_str[100];
987 unsigned char output[100];
989 int key_len, data_len;
991 memset(key_str, 0x00, 100);
992 memset(iv_str, 0x00, 100);
993 memset(src_str, 0x00, 100);
994 memset(dst_str, 0x00, 100);
995 memset(output, 0x00, 100);
997 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
998 unhexify( iv_str,
"37D359C3349836D884E310ADDF68C449" );
999 data_len =
unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
1005 hexify( dst_str, output, data_len );
1007 fct_chk( strcasecmp( (
char *) dst_str,
"01FAAA930B4AB9916E9668E1428C6B08" ) == 0 );
1013 FCT_TEST_BGN(camellia_256_cbc_encrypt_perl_evp_1)
1015 unsigned char key_str[100];
1016 unsigned char iv_str[100];
1017 unsigned char src_str[100];
1018 unsigned char dst_str[100];
1019 unsigned char output[100];
1021 int key_len, data_len;
1023 memset(key_str, 0x00, 100);
1024 memset(iv_str, 0x00, 100);
1025 memset(src_str, 0x00, 100);
1026 memset(dst_str, 0x00, 100);
1027 memset(output, 0x00, 100);
1029 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1030 unhexify( iv_str,
"000102030405060708090A0B0C0D0E0F" );
1031 data_len =
unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
1037 hexify( dst_str, output, data_len );
1039 fct_chk( strcasecmp( (
char *) dst_str,
"E6CFA35FC02B134A4D2C0B6737AC3EDA" ) == 0 );
1045 FCT_TEST_BGN(camellia_256_cbc_encrypt_perl_evp_2)
1047 unsigned char key_str[100];
1048 unsigned char iv_str[100];
1049 unsigned char src_str[100];
1050 unsigned char dst_str[100];
1051 unsigned char output[100];
1053 int key_len, data_len;
1055 memset(key_str, 0x00, 100);
1056 memset(iv_str, 0x00, 100);
1057 memset(src_str, 0x00, 100);
1058 memset(dst_str, 0x00, 100);
1059 memset(output, 0x00, 100);
1061 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1062 unhexify( iv_str,
"E6CFA35FC02B134A4D2C0B6737AC3EDA" );
1063 data_len =
unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
1069 hexify( dst_str, output, data_len );
1071 fct_chk( strcasecmp( (
char *) dst_str,
"36CBEB73BD504B4070B1B7DE2B21EB50" ) == 0 );
1077 FCT_TEST_BGN(camellia_256_cbc_encrypt_perl_evp_3)
1079 unsigned char key_str[100];
1080 unsigned char iv_str[100];
1081 unsigned char src_str[100];
1082 unsigned char dst_str[100];
1083 unsigned char output[100];
1085 int key_len, data_len;
1087 memset(key_str, 0x00, 100);
1088 memset(iv_str, 0x00, 100);
1089 memset(src_str, 0x00, 100);
1090 memset(dst_str, 0x00, 100);
1091 memset(output, 0x00, 100);
1093 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1094 unhexify( iv_str,
"36CBEB73BD504B4070B1B7DE2B21EB50" );
1095 data_len =
unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
1101 hexify( dst_str, output, data_len );
1103 fct_chk( strcasecmp( (
char *) dst_str,
"E31A6055297D96CA3330CDF1B1860A83" ) == 0 );
1109 FCT_TEST_BGN(camellia_256_cbc_encrypt_perl_evp_4)
1111 unsigned char key_str[100];
1112 unsigned char iv_str[100];
1113 unsigned char src_str[100];
1114 unsigned char dst_str[100];
1115 unsigned char output[100];
1117 int key_len, data_len;
1119 memset(key_str, 0x00, 100);
1120 memset(iv_str, 0x00, 100);
1121 memset(src_str, 0x00, 100);
1122 memset(dst_str, 0x00, 100);
1123 memset(output, 0x00, 100);
1125 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1126 unhexify( iv_str,
"E31A6055297D96CA3330CDF1B1860A83" );
1127 data_len =
unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
1133 hexify( dst_str, output, data_len );
1135 fct_chk( strcasecmp( (
char *) dst_str,
"5D563F6D1CCCF236051C0C5C1C58F28F" ) == 0 );
1140 #ifdef POLARSSL_CIPHER_MODE_CFB
1142 FCT_TEST_BGN(camellia_128_cfb128_encrypt_perl_evp_1)
1144 unsigned char key_str[100];
1145 unsigned char iv_str[100];
1146 unsigned char src_str[100];
1147 unsigned char dst_str[100];
1148 unsigned char output[100];
1150 size_t iv_offset = 0;
1153 memset(key_str, 0x00, 100);
1154 memset(iv_str, 0x00, 100);
1155 memset(src_str, 0x00, 100);
1156 memset(dst_str, 0x00, 100);
1157 memset(output, 0x00, 100);
1159 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
1160 unhexify( iv_str,
"000102030405060708090A0B0C0D0E0F" );
1161 unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
1165 hexify( dst_str, output, 16 );
1167 fct_chk( strcasecmp( (
char *) dst_str,
"14F7646187817EB586599146B82BD719" ) == 0 );
1172 #ifdef POLARSSL_CIPHER_MODE_CFB
1174 FCT_TEST_BGN(camellia_128_cfb128_encrypt_perl_evp_2)
1176 unsigned char key_str[100];
1177 unsigned char iv_str[100];
1178 unsigned char src_str[100];
1179 unsigned char dst_str[100];
1180 unsigned char output[100];
1182 size_t iv_offset = 0;
1185 memset(key_str, 0x00, 100);
1186 memset(iv_str, 0x00, 100);
1187 memset(src_str, 0x00, 100);
1188 memset(dst_str, 0x00, 100);
1189 memset(output, 0x00, 100);
1191 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
1192 unhexify( iv_str,
"14F7646187817EB586599146B82BD719" );
1193 unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
1197 hexify( dst_str, output, 16 );
1199 fct_chk( strcasecmp( (
char *) dst_str,
"A53D28BB82DF741103EA4F921A44880B" ) == 0 );
1204 #ifdef POLARSSL_CIPHER_MODE_CFB
1206 FCT_TEST_BGN(camellia_128_cfb128_encrypt_perl_evp_3)
1208 unsigned char key_str[100];
1209 unsigned char iv_str[100];
1210 unsigned char src_str[100];
1211 unsigned char dst_str[100];
1212 unsigned char output[100];
1214 size_t iv_offset = 0;
1217 memset(key_str, 0x00, 100);
1218 memset(iv_str, 0x00, 100);
1219 memset(src_str, 0x00, 100);
1220 memset(dst_str, 0x00, 100);
1221 memset(output, 0x00, 100);
1223 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
1224 unhexify( iv_str,
"A53D28BB82DF741103EA4F921A44880B" );
1225 unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
1229 hexify( dst_str, output, 16 );
1231 fct_chk( strcasecmp( (
char *) dst_str,
"9C2157A664626D1DEF9EA420FDE69B96" ) == 0 );
1236 #ifdef POLARSSL_CIPHER_MODE_CFB
1238 FCT_TEST_BGN(camellia_128_cfb128_encrypt_perl_evp_4)
1240 unsigned char key_str[100];
1241 unsigned char iv_str[100];
1242 unsigned char src_str[100];
1243 unsigned char dst_str[100];
1244 unsigned char output[100];
1246 size_t iv_offset = 0;
1249 memset(key_str, 0x00, 100);
1250 memset(iv_str, 0x00, 100);
1251 memset(src_str, 0x00, 100);
1252 memset(dst_str, 0x00, 100);
1253 memset(output, 0x00, 100);
1255 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
1256 unhexify( iv_str,
"9C2157A664626D1DEF9EA420FDE69B96" );
1257 unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
1261 hexify( dst_str, output, 16 );
1263 fct_chk( strcasecmp( (
char *) dst_str,
"742A25F0542340C7BAEF24CA8482BB09" ) == 0 );
1268 #ifdef POLARSSL_CIPHER_MODE_CFB
1270 FCT_TEST_BGN(camellia_128_cfb128_decrypt_perl_evp_1)
1272 unsigned char key_str[100];
1273 unsigned char iv_str[100];
1274 unsigned char src_str[100];
1275 unsigned char dst_str[100];
1276 unsigned char output[100];
1278 size_t iv_offset = 0;
1281 memset(key_str, 0x00, 100);
1282 memset(iv_str, 0x00, 100);
1283 memset(src_str, 0x00, 100);
1284 memset(dst_str, 0x00, 100);
1285 memset(output, 0x00, 100);
1287 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
1288 unhexify( iv_str,
"000102030405060708090A0B0C0D0E0F" );
1289 unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
1293 hexify( dst_str, output, 16 );
1295 fct_chk( strcasecmp( (
char *) dst_str,
"14F7646187817EB586599146B82BD719" ) == 0 );
1300 #ifdef POLARSSL_CIPHER_MODE_CFB
1302 FCT_TEST_BGN(camellia_128_cfb128_decrypt_perl_evp_2)
1304 unsigned char key_str[100];
1305 unsigned char iv_str[100];
1306 unsigned char src_str[100];
1307 unsigned char dst_str[100];
1308 unsigned char output[100];
1310 size_t iv_offset = 0;
1313 memset(key_str, 0x00, 100);
1314 memset(iv_str, 0x00, 100);
1315 memset(src_str, 0x00, 100);
1316 memset(dst_str, 0x00, 100);
1317 memset(output, 0x00, 100);
1319 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
1320 unhexify( iv_str,
"14F7646187817EB586599146B82BD719" );
1321 unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
1325 hexify( dst_str, output, 16 );
1327 fct_chk( strcasecmp( (
char *) dst_str,
"A53D28BB82DF741103EA4F921A44880B" ) == 0 );
1332 #ifdef POLARSSL_CIPHER_MODE_CFB
1334 FCT_TEST_BGN(camellia_128_cfb128_decrypt_perl_evp_3)
1336 unsigned char key_str[100];
1337 unsigned char iv_str[100];
1338 unsigned char src_str[100];
1339 unsigned char dst_str[100];
1340 unsigned char output[100];
1342 size_t iv_offset = 0;
1345 memset(key_str, 0x00, 100);
1346 memset(iv_str, 0x00, 100);
1347 memset(src_str, 0x00, 100);
1348 memset(dst_str, 0x00, 100);
1349 memset(output, 0x00, 100);
1351 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
1352 unhexify( iv_str,
"A53D28BB82DF741103EA4F921A44880B" );
1353 unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
1357 hexify( dst_str, output, 16 );
1359 fct_chk( strcasecmp( (
char *) dst_str,
"9C2157A664626D1DEF9EA420FDE69B96" ) == 0 );
1364 #ifdef POLARSSL_CIPHER_MODE_CFB
1366 FCT_TEST_BGN(camellia_128_cfb128_decrypt_perl_evp_4)
1368 unsigned char key_str[100];
1369 unsigned char iv_str[100];
1370 unsigned char src_str[100];
1371 unsigned char dst_str[100];
1372 unsigned char output[100];
1374 size_t iv_offset = 0;
1377 memset(key_str, 0x00, 100);
1378 memset(iv_str, 0x00, 100);
1379 memset(src_str, 0x00, 100);
1380 memset(dst_str, 0x00, 100);
1381 memset(output, 0x00, 100);
1383 key_len =
unhexify( key_str,
"2B7E151628AED2A6ABF7158809CF4F3C" );
1384 unhexify( iv_str,
"9C2157A664626D1DEF9EA420FDE69B96" );
1385 unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
1389 hexify( dst_str, output, 16 );
1391 fct_chk( strcasecmp( (
char *) dst_str,
"742A25F0542340C7BAEF24CA8482BB09" ) == 0 );
1396 #ifdef POLARSSL_CIPHER_MODE_CFB
1398 FCT_TEST_BGN(camellia_192_cfb128_encrypt_perl_evp_1)
1400 unsigned char key_str[100];
1401 unsigned char iv_str[100];
1402 unsigned char src_str[100];
1403 unsigned char dst_str[100];
1404 unsigned char output[100];
1406 size_t iv_offset = 0;
1409 memset(key_str, 0x00, 100);
1410 memset(iv_str, 0x00, 100);
1411 memset(src_str, 0x00, 100);
1412 memset(dst_str, 0x00, 100);
1413 memset(output, 0x00, 100);
1415 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
1416 unhexify( iv_str,
"000102030405060708090A0B0C0D0E0F" );
1417 unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
1421 hexify( dst_str, output, 16 );
1423 fct_chk( strcasecmp( (
char *) dst_str,
"C832BB9780677DAA82D9B6860DCD565E" ) == 0 );
1428 #ifdef POLARSSL_CIPHER_MODE_CFB
1430 FCT_TEST_BGN(camellia_192_cfb128_encrypt_perl_evp_2)
1432 unsigned char key_str[100];
1433 unsigned char iv_str[100];
1434 unsigned char src_str[100];
1435 unsigned char dst_str[100];
1436 unsigned char output[100];
1438 size_t iv_offset = 0;
1441 memset(key_str, 0x00, 100);
1442 memset(iv_str, 0x00, 100);
1443 memset(src_str, 0x00, 100);
1444 memset(dst_str, 0x00, 100);
1445 memset(output, 0x00, 100);
1447 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
1448 unhexify( iv_str,
"C832BB9780677DAA82D9B6860DCD565E" );
1449 unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
1453 hexify( dst_str, output, 16 );
1455 fct_chk( strcasecmp( (
char *) dst_str,
"86F8491627906D780C7A6D46EA331F98" ) == 0 );
1460 #ifdef POLARSSL_CIPHER_MODE_CFB
1462 FCT_TEST_BGN(camellia_192_cfb128_encrypt_perl_evp_3)
1464 unsigned char key_str[100];
1465 unsigned char iv_str[100];
1466 unsigned char src_str[100];
1467 unsigned char dst_str[100];
1468 unsigned char output[100];
1470 size_t iv_offset = 0;
1473 memset(key_str, 0x00, 100);
1474 memset(iv_str, 0x00, 100);
1475 memset(src_str, 0x00, 100);
1476 memset(dst_str, 0x00, 100);
1477 memset(output, 0x00, 100);
1479 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
1480 unhexify( iv_str,
"86F8491627906D780C7A6D46EA331F98" );
1481 unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
1485 hexify( dst_str, output, 16 );
1487 fct_chk( strcasecmp( (
char *) dst_str,
"69511CCE594CF710CB98BB63D7221F01" ) == 0 );
1492 #ifdef POLARSSL_CIPHER_MODE_CFB
1494 FCT_TEST_BGN(camellia_192_cfb128_encrypt_perl_evp_4)
1496 unsigned char key_str[100];
1497 unsigned char iv_str[100];
1498 unsigned char src_str[100];
1499 unsigned char dst_str[100];
1500 unsigned char output[100];
1502 size_t iv_offset = 0;
1505 memset(key_str, 0x00, 100);
1506 memset(iv_str, 0x00, 100);
1507 memset(src_str, 0x00, 100);
1508 memset(dst_str, 0x00, 100);
1509 memset(output, 0x00, 100);
1511 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
1512 unhexify( iv_str,
"69511CCE594CF710CB98BB63D7221F01" );
1513 unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
1517 hexify( dst_str, output, 16 );
1519 fct_chk( strcasecmp( (
char *) dst_str,
"D5B5378A3ABED55803F25565D8907B84" ) == 0 );
1524 #ifdef POLARSSL_CIPHER_MODE_CFB
1526 FCT_TEST_BGN(camellia_192_cfb128_decrypt_perl_evp_1)
1528 unsigned char key_str[100];
1529 unsigned char iv_str[100];
1530 unsigned char src_str[100];
1531 unsigned char dst_str[100];
1532 unsigned char output[100];
1534 size_t iv_offset = 0;
1537 memset(key_str, 0x00, 100);
1538 memset(iv_str, 0x00, 100);
1539 memset(src_str, 0x00, 100);
1540 memset(dst_str, 0x00, 100);
1541 memset(output, 0x00, 100);
1543 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
1544 unhexify( iv_str,
"000102030405060708090A0B0C0D0E0F" );
1545 unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
1549 hexify( dst_str, output, 16 );
1551 fct_chk( strcasecmp( (
char *) dst_str,
"C832BB9780677DAA82D9B6860DCD565E" ) == 0 );
1556 #ifdef POLARSSL_CIPHER_MODE_CFB
1558 FCT_TEST_BGN(camellia_192_cfb128_decrypt_perl_evp_2)
1560 unsigned char key_str[100];
1561 unsigned char iv_str[100];
1562 unsigned char src_str[100];
1563 unsigned char dst_str[100];
1564 unsigned char output[100];
1566 size_t iv_offset = 0;
1569 memset(key_str, 0x00, 100);
1570 memset(iv_str, 0x00, 100);
1571 memset(src_str, 0x00, 100);
1572 memset(dst_str, 0x00, 100);
1573 memset(output, 0x00, 100);
1575 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
1576 unhexify( iv_str,
"C832BB9780677DAA82D9B6860DCD565E" );
1577 unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
1581 hexify( dst_str, output, 16 );
1583 fct_chk( strcasecmp( (
char *) dst_str,
"86F8491627906D780C7A6D46EA331F98" ) == 0 );
1588 #ifdef POLARSSL_CIPHER_MODE_CFB
1590 FCT_TEST_BGN(camellia_192_cfb128_decrypt_perl_evp_3)
1592 unsigned char key_str[100];
1593 unsigned char iv_str[100];
1594 unsigned char src_str[100];
1595 unsigned char dst_str[100];
1596 unsigned char output[100];
1598 size_t iv_offset = 0;
1601 memset(key_str, 0x00, 100);
1602 memset(iv_str, 0x00, 100);
1603 memset(src_str, 0x00, 100);
1604 memset(dst_str, 0x00, 100);
1605 memset(output, 0x00, 100);
1607 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
1608 unhexify( iv_str,
"86F8491627906D780C7A6D46EA331F98" );
1609 unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
1613 hexify( dst_str, output, 16 );
1615 fct_chk( strcasecmp( (
char *) dst_str,
"69511CCE594CF710CB98BB63D7221F01" ) == 0 );
1620 #ifdef POLARSSL_CIPHER_MODE_CFB
1622 FCT_TEST_BGN(camellia_192_cfb128_decrypt_perl_evp_4)
1624 unsigned char key_str[100];
1625 unsigned char iv_str[100];
1626 unsigned char src_str[100];
1627 unsigned char dst_str[100];
1628 unsigned char output[100];
1630 size_t iv_offset = 0;
1633 memset(key_str, 0x00, 100);
1634 memset(iv_str, 0x00, 100);
1635 memset(src_str, 0x00, 100);
1636 memset(dst_str, 0x00, 100);
1637 memset(output, 0x00, 100);
1639 key_len =
unhexify( key_str,
"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B" );
1640 unhexify( iv_str,
"69511CCE594CF710CB98BB63D7221F01" );
1641 unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
1645 hexify( dst_str, output, 16 );
1647 fct_chk( strcasecmp( (
char *) dst_str,
"D5B5378A3ABED55803F25565D8907B84" ) == 0 );
1652 #ifdef POLARSSL_CIPHER_MODE_CFB
1654 FCT_TEST_BGN(camellia_256_cfb128_encrypt_perl_evp_1)
1656 unsigned char key_str[100];
1657 unsigned char iv_str[100];
1658 unsigned char src_str[100];
1659 unsigned char dst_str[100];
1660 unsigned char output[100];
1662 size_t iv_offset = 0;
1665 memset(key_str, 0x00, 100);
1666 memset(iv_str, 0x00, 100);
1667 memset(src_str, 0x00, 100);
1668 memset(dst_str, 0x00, 100);
1669 memset(output, 0x00, 100);
1671 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1672 unhexify( iv_str,
"000102030405060708090A0B0C0D0E0F" );
1673 unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
1677 hexify( dst_str, output, 16 );
1679 fct_chk( strcasecmp( (
char *) dst_str,
"CF6107BB0CEA7D7FB1BD31F5E7B06C93" ) == 0 );
1684 #ifdef POLARSSL_CIPHER_MODE_CFB
1686 FCT_TEST_BGN(camellia_256_cfb128_encrypt_perl_evp_2)
1688 unsigned char key_str[100];
1689 unsigned char iv_str[100];
1690 unsigned char src_str[100];
1691 unsigned char dst_str[100];
1692 unsigned char output[100];
1694 size_t iv_offset = 0;
1697 memset(key_str, 0x00, 100);
1698 memset(iv_str, 0x00, 100);
1699 memset(src_str, 0x00, 100);
1700 memset(dst_str, 0x00, 100);
1701 memset(output, 0x00, 100);
1703 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1704 unhexify( iv_str,
"CF6107BB0CEA7D7FB1BD31F5E7B06C93" );
1705 unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
1709 hexify( dst_str, output, 16 );
1711 fct_chk( strcasecmp( (
char *) dst_str,
"89BEDB4CCDD864EA11BA4CBE849B5E2B" ) == 0 );
1716 #ifdef POLARSSL_CIPHER_MODE_CFB
1718 FCT_TEST_BGN(camellia_256_cfb128_encrypt_perl_evp_3)
1720 unsigned char key_str[100];
1721 unsigned char iv_str[100];
1722 unsigned char src_str[100];
1723 unsigned char dst_str[100];
1724 unsigned char output[100];
1726 size_t iv_offset = 0;
1729 memset(key_str, 0x00, 100);
1730 memset(iv_str, 0x00, 100);
1731 memset(src_str, 0x00, 100);
1732 memset(dst_str, 0x00, 100);
1733 memset(output, 0x00, 100);
1735 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1736 unhexify( iv_str,
"89BEDB4CCDD864EA11BA4CBE849B5E2B" );
1737 unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
1741 hexify( dst_str, output, 16 );
1743 fct_chk( strcasecmp( (
char *) dst_str,
"555FC3F34BDD2D54C62D9E3BF338C1C4" ) == 0 );
1748 #ifdef POLARSSL_CIPHER_MODE_CFB
1750 FCT_TEST_BGN(camellia_256_cfb128_encrypt_perl_evp_4)
1752 unsigned char key_str[100];
1753 unsigned char iv_str[100];
1754 unsigned char src_str[100];
1755 unsigned char dst_str[100];
1756 unsigned char output[100];
1758 size_t iv_offset = 0;
1761 memset(key_str, 0x00, 100);
1762 memset(iv_str, 0x00, 100);
1763 memset(src_str, 0x00, 100);
1764 memset(dst_str, 0x00, 100);
1765 memset(output, 0x00, 100);
1767 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1768 unhexify( iv_str,
"555FC3F34BDD2D54C62D9E3BF338C1C4" );
1769 unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
1773 hexify( dst_str, output, 16 );
1775 fct_chk( strcasecmp( (
char *) dst_str,
"5953ADCE14DB8C7F39F1BD39F359BFFA" ) == 0 );
1780 #ifdef POLARSSL_CIPHER_MODE_CFB
1782 FCT_TEST_BGN(camellia_256_cfb128_decrypt_perl_evp_1)
1784 unsigned char key_str[100];
1785 unsigned char iv_str[100];
1786 unsigned char src_str[100];
1787 unsigned char dst_str[100];
1788 unsigned char output[100];
1790 size_t iv_offset = 0;
1793 memset(key_str, 0x00, 100);
1794 memset(iv_str, 0x00, 100);
1795 memset(src_str, 0x00, 100);
1796 memset(dst_str, 0x00, 100);
1797 memset(output, 0x00, 100);
1799 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1800 unhexify( iv_str,
"000102030405060708090A0B0C0D0E0F" );
1801 unhexify( src_str,
"6BC1BEE22E409F96E93D7E117393172A" );
1805 hexify( dst_str, output, 16 );
1807 fct_chk( strcasecmp( (
char *) dst_str,
"CF6107BB0CEA7D7FB1BD31F5E7B06C93" ) == 0 );
1812 #ifdef POLARSSL_CIPHER_MODE_CFB
1814 FCT_TEST_BGN(camellia_256_cfb128_decrypt_perl_evp_2)
1816 unsigned char key_str[100];
1817 unsigned char iv_str[100];
1818 unsigned char src_str[100];
1819 unsigned char dst_str[100];
1820 unsigned char output[100];
1822 size_t iv_offset = 0;
1825 memset(key_str, 0x00, 100);
1826 memset(iv_str, 0x00, 100);
1827 memset(src_str, 0x00, 100);
1828 memset(dst_str, 0x00, 100);
1829 memset(output, 0x00, 100);
1831 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1832 unhexify( iv_str,
"CF6107BB0CEA7D7FB1BD31F5E7B06C93" );
1833 unhexify( src_str,
"AE2D8A571E03AC9C9EB76FAC45AF8E51" );
1837 hexify( dst_str, output, 16 );
1839 fct_chk( strcasecmp( (
char *) dst_str,
"89BEDB4CCDD864EA11BA4CBE849B5E2B" ) == 0 );
1844 #ifdef POLARSSL_CIPHER_MODE_CFB
1846 FCT_TEST_BGN(camellia_256_cfb128_decrypt_perl_evp_3)
1848 unsigned char key_str[100];
1849 unsigned char iv_str[100];
1850 unsigned char src_str[100];
1851 unsigned char dst_str[100];
1852 unsigned char output[100];
1854 size_t iv_offset = 0;
1857 memset(key_str, 0x00, 100);
1858 memset(iv_str, 0x00, 100);
1859 memset(src_str, 0x00, 100);
1860 memset(dst_str, 0x00, 100);
1861 memset(output, 0x00, 100);
1863 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1864 unhexify( iv_str,
"89BEDB4CCDD864EA11BA4CBE849B5E2B" );
1865 unhexify( src_str,
"30C81C46A35CE411E5FBC1191A0A52EF" );
1869 hexify( dst_str, output, 16 );
1871 fct_chk( strcasecmp( (
char *) dst_str,
"555FC3F34BDD2D54C62D9E3BF338C1C4" ) == 0 );
1876 #ifdef POLARSSL_CIPHER_MODE_CFB
1878 FCT_TEST_BGN(camellia_256_cfb128_decrypt_perl_evp_4)
1880 unsigned char key_str[100];
1881 unsigned char iv_str[100];
1882 unsigned char src_str[100];
1883 unsigned char dst_str[100];
1884 unsigned char output[100];
1886 size_t iv_offset = 0;
1889 memset(key_str, 0x00, 100);
1890 memset(iv_str, 0x00, 100);
1891 memset(src_str, 0x00, 100);
1892 memset(dst_str, 0x00, 100);
1893 memset(output, 0x00, 100);
1895 key_len =
unhexify( key_str,
"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4" );
1896 unhexify( iv_str,
"555FC3F34BDD2D54C62D9E3BF338C1C4" );
1897 unhexify( src_str,
"F69F2445DF4F9B17AD2B417BE66C3710" );
1901 hexify( dst_str, output, 16 );
1903 fct_chk( strcasecmp( (
char *) dst_str,
"5953ADCE14DB8C7F39F1BD39F359BFFA" ) == 0 );
1909 FCT_TEST_BGN(camellia_ecb_encrypt_invalid_key_length)
1911 unsigned char key_str[100];
1912 unsigned char src_str[100];
1913 unsigned char dst_str[100];
1914 unsigned char output[100];
1918 memset(key_str, 0x00, 100);
1919 memset(src_str, 0x00, 100);
1920 memset(dst_str, 0x00, 100);
1921 memset(output, 0x00, 100);
1923 key_len =
unhexify( key_str,
"0123456789abcdeffedcba98765432" );
1924 unhexify( src_str,
"0123456789abcdeffedcba9876543210" );
1930 hexify( dst_str, output, 16 );
1932 fct_chk( strcasecmp( (
char *) dst_str,
"67673138549669730857065648eabe43" ) == 0 );
1938 FCT_TEST_BGN(camellia_ecb_decrypt_invalid_key_length)
1940 unsigned char key_str[100];
1941 unsigned char src_str[100];
1942 unsigned char dst_str[100];
1943 unsigned char output[100];
1947 memset(key_str, 0x00, 100);
1948 memset(src_str, 0x00, 100);
1949 memset(dst_str, 0x00, 100);
1950 memset(output, 0x00, 100);
1952 key_len =
unhexify( key_str,
"0123456789abcdeffedcba98765432" );
1953 unhexify( src_str,
"0123456789abcdeffedcba9876543210" );
1959 hexify( dst_str, output, 16 );
1961 fct_chk( strcasecmp( (
char *) dst_str,
"67673138549669730857065648eabe43" ) == 0 );
1967 FCT_TEST_BGN(camellia_256_cbc_encrypt_invalid_input_length)
1969 unsigned char key_str[100];
1970 unsigned char iv_str[100];
1971 unsigned char src_str[100];
1972 unsigned char dst_str[100];
1973 unsigned char output[100];
1975 int key_len, data_len;
1977 memset(key_str, 0x00, 100);
1978 memset(iv_str, 0x00, 100);
1979 memset(src_str, 0x00, 100);
1980 memset(dst_str, 0x00, 100);
1981 memset(output, 0x00, 100);
1983 key_len =
unhexify( key_str,
"0000000000000000000000000000000000000000000000000000000000000000" );
1984 unhexify( iv_str,
"00000000000000000000000000000000" );
1985 data_len =
unhexify( src_str,
"ffffffffffffffe000000000000000" );
1991 hexify( dst_str, output, data_len );
1993 fct_chk( strcasecmp( (
char *) dst_str,
"" ) == 0 );
1999 FCT_TEST_BGN(camellia_256_cbc_decrypt_invalid_input_length)
2001 unsigned char key_str[100];
2002 unsigned char iv_str[100];
2003 unsigned char src_str[100];
2004 unsigned char dst_str[100];
2005 unsigned char output[100];
2007 int key_len, data_len;
2009 memset(key_str, 0x00, 100);
2010 memset(iv_str, 0x00, 100);
2011 memset(src_str, 0x00, 100);
2012 memset(dst_str, 0x00, 100);
2013 memset(output, 0x00, 100);
2015 key_len =
unhexify( key_str,
"0000000000000000000000000000000000000000000000000000000000000000" );
2016 unhexify( iv_str,
"00000000000000000000000000000000" );
2017 data_len =
unhexify( src_str,
"623a52fcea5d443e48d9181ab32c74" );
2023 hexify( dst_str, output, data_len );
2025 fct_chk( strcasecmp( (
char *) dst_str,
"" ) == 0 );
2030 #ifdef POLARSSL_SELF_TEST
2032 FCT_TEST_BGN(camellia_selftest)