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_CIPHER_C
231 FCT_SUITE_BGN(test_suite_cipher)
233 #ifdef POLARSSL_SELF_TEST
235 FCT_TEST_BGN(cipher_selftest)
243 FCT_TEST_BGN(decrypt_empty_buffer)
244 unsigned char key[32];
245 unsigned char iv[16];
250 unsigned char encbuf[64];
251 unsigned char decbuf[64];
255 memset( key, 0, 32 );
256 memset( iv , 0, 16 );
258 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
260 memset( encbuf, 0, 64 );
261 memset( decbuf, 0, 64 );
265 fct_chk( NULL != cipher_info);
274 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, 0, decbuf, &outlen ) );
275 fct_chk( 0 == outlen );
277 fct_chk( 0 == outlen );
282 #ifdef POLARSSL_BLOWFISH_C
284 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_0_bytes)
286 unsigned char key[32];
287 unsigned char iv[16];
293 unsigned char inbuf[64];
294 unsigned char encbuf[64];
295 unsigned char decbuf[64];
300 memset( key, 0, 32 );
301 memset( iv , 0, 16 );
303 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
304 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
306 memset( inbuf, 5, 64 );
307 memset( encbuf, 0, 64 );
308 memset( decbuf, 0, 64 );
312 fct_chk( NULL != cipher_info );
336 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
343 fct_chk( outlen == enclen );
346 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
353 fct_chk( outlen == 0 );
358 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
365 fct_chk( enclen == outlen );
368 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
375 fct_chk( outlen == 0 );
379 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
386 #ifdef POLARSSL_BLOWFISH_C
388 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_1_byte)
390 unsigned char key[32];
391 unsigned char iv[16];
397 unsigned char inbuf[64];
398 unsigned char encbuf[64];
399 unsigned char decbuf[64];
404 memset( key, 0, 32 );
405 memset( iv , 0, 16 );
407 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
408 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
410 memset( inbuf, 5, 64 );
411 memset( encbuf, 0, 64 );
412 memset( decbuf, 0, 64 );
416 fct_chk( NULL != cipher_info );
440 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
447 fct_chk( outlen == enclen );
450 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
457 fct_chk( outlen == 0 );
462 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
469 fct_chk( enclen == outlen );
472 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
479 fct_chk( outlen == 0 );
483 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
490 #ifdef POLARSSL_BLOWFISH_C
492 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_2_bytes)
494 unsigned char key[32];
495 unsigned char iv[16];
501 unsigned char inbuf[64];
502 unsigned char encbuf[64];
503 unsigned char decbuf[64];
508 memset( key, 0, 32 );
509 memset( iv , 0, 16 );
511 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
512 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
514 memset( inbuf, 5, 64 );
515 memset( encbuf, 0, 64 );
516 memset( decbuf, 0, 64 );
520 fct_chk( NULL != cipher_info );
544 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
551 fct_chk( outlen == enclen );
554 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
561 fct_chk( outlen == 0 );
566 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
573 fct_chk( enclen == outlen );
576 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
583 fct_chk( outlen == 0 );
587 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
594 #ifdef POLARSSL_BLOWFISH_C
596 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_7_bytes)
598 unsigned char key[32];
599 unsigned char iv[16];
605 unsigned char inbuf[64];
606 unsigned char encbuf[64];
607 unsigned char decbuf[64];
612 memset( key, 0, 32 );
613 memset( iv , 0, 16 );
615 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
616 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
618 memset( inbuf, 5, 64 );
619 memset( encbuf, 0, 64 );
620 memset( decbuf, 0, 64 );
624 fct_chk( NULL != cipher_info );
648 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
655 fct_chk( outlen == enclen );
658 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
665 fct_chk( outlen == 0 );
670 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
677 fct_chk( enclen == outlen );
680 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
687 fct_chk( outlen == 0 );
691 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
698 #ifdef POLARSSL_BLOWFISH_C
700 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_8_bytes)
702 unsigned char key[32];
703 unsigned char iv[16];
709 unsigned char inbuf[64];
710 unsigned char encbuf[64];
711 unsigned char decbuf[64];
716 memset( key, 0, 32 );
717 memset( iv , 0, 16 );
719 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
720 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
722 memset( inbuf, 5, 64 );
723 memset( encbuf, 0, 64 );
724 memset( decbuf, 0, 64 );
728 fct_chk( NULL != cipher_info );
752 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
759 fct_chk( outlen == enclen );
762 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
769 fct_chk( outlen == 0 );
774 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
781 fct_chk( enclen == outlen );
784 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
791 fct_chk( outlen == 0 );
795 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
802 #ifdef POLARSSL_BLOWFISH_C
804 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_9_bytes)
806 unsigned char key[32];
807 unsigned char iv[16];
813 unsigned char inbuf[64];
814 unsigned char encbuf[64];
815 unsigned char decbuf[64];
820 memset( key, 0, 32 );
821 memset( iv , 0, 16 );
823 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
824 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
826 memset( inbuf, 5, 64 );
827 memset( encbuf, 0, 64 );
828 memset( decbuf, 0, 64 );
832 fct_chk( NULL != cipher_info );
856 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
863 fct_chk( outlen == enclen );
866 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
873 fct_chk( outlen == 0 );
878 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
885 fct_chk( enclen == outlen );
888 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
895 fct_chk( outlen == 0 );
899 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
906 #ifdef POLARSSL_BLOWFISH_C
908 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_15_bytes)
910 unsigned char key[32];
911 unsigned char iv[16];
917 unsigned char inbuf[64];
918 unsigned char encbuf[64];
919 unsigned char decbuf[64];
924 memset( key, 0, 32 );
925 memset( iv , 0, 16 );
927 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
928 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
930 memset( inbuf, 5, 64 );
931 memset( encbuf, 0, 64 );
932 memset( decbuf, 0, 64 );
936 fct_chk( NULL != cipher_info );
960 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
967 fct_chk( outlen == enclen );
970 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
977 fct_chk( outlen == 0 );
982 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
989 fct_chk( enclen == outlen );
992 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
999 fct_chk( outlen == 0 );
1003 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1010 #ifdef POLARSSL_BLOWFISH_C
1012 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes)
1014 unsigned char key[32];
1015 unsigned char iv[16];
1021 unsigned char inbuf[64];
1022 unsigned char encbuf[64];
1023 unsigned char decbuf[64];
1028 memset( key, 0, 32 );
1029 memset( iv , 0, 16 );
1031 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1032 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1034 memset( inbuf, 5, 64 );
1035 memset( encbuf, 0, 64 );
1036 memset( decbuf, 0, 64 );
1040 fct_chk( NULL != cipher_info );
1064 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1071 fct_chk( outlen == enclen );
1074 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1081 fct_chk( outlen == 0 );
1086 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1093 fct_chk( enclen == outlen );
1096 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1103 fct_chk( outlen == 0 );
1107 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1114 #ifdef POLARSSL_BLOWFISH_C
1116 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_17_bytes)
1118 unsigned char key[32];
1119 unsigned char iv[16];
1125 unsigned char inbuf[64];
1126 unsigned char encbuf[64];
1127 unsigned char decbuf[64];
1132 memset( key, 0, 32 );
1133 memset( iv , 0, 16 );
1135 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1136 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1138 memset( inbuf, 5, 64 );
1139 memset( encbuf, 0, 64 );
1140 memset( decbuf, 0, 64 );
1144 fct_chk( NULL != cipher_info );
1168 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1175 fct_chk( outlen == enclen );
1178 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1185 fct_chk( outlen == 0 );
1190 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1197 fct_chk( enclen == outlen );
1200 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1207 fct_chk( outlen == 0 );
1211 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1218 #ifdef POLARSSL_BLOWFISH_C
1220 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_31_bytes)
1222 unsigned char key[32];
1223 unsigned char iv[16];
1229 unsigned char inbuf[64];
1230 unsigned char encbuf[64];
1231 unsigned char decbuf[64];
1236 memset( key, 0, 32 );
1237 memset( iv , 0, 16 );
1239 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1240 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1242 memset( inbuf, 5, 64 );
1243 memset( encbuf, 0, 64 );
1244 memset( decbuf, 0, 64 );
1248 fct_chk( NULL != cipher_info );
1272 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1279 fct_chk( outlen == enclen );
1282 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1289 fct_chk( outlen == 0 );
1294 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1301 fct_chk( enclen == outlen );
1304 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1311 fct_chk( outlen == 0 );
1315 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1322 #ifdef POLARSSL_BLOWFISH_C
1324 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_32_bytes)
1326 unsigned char key[32];
1327 unsigned char iv[16];
1333 unsigned char inbuf[64];
1334 unsigned char encbuf[64];
1335 unsigned char decbuf[64];
1340 memset( key, 0, 32 );
1341 memset( iv , 0, 16 );
1343 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1344 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1346 memset( inbuf, 5, 64 );
1347 memset( encbuf, 0, 64 );
1348 memset( decbuf, 0, 64 );
1352 fct_chk( NULL != cipher_info );
1376 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1383 fct_chk( outlen == enclen );
1386 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1393 fct_chk( outlen == 0 );
1398 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1405 fct_chk( enclen == outlen );
1408 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1415 fct_chk( outlen == 0 );
1419 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1426 #ifdef POLARSSL_BLOWFISH_C
1428 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_32_bytes)
1430 unsigned char key[32];
1431 unsigned char iv[16];
1437 unsigned char inbuf[64];
1438 unsigned char encbuf[64];
1439 unsigned char decbuf[64];
1444 memset( key, 0, 32 );
1445 memset( iv , 0, 16 );
1447 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1448 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1450 memset( inbuf, 5, 64 );
1451 memset( encbuf, 0, 64 );
1452 memset( decbuf, 0, 64 );
1456 fct_chk( NULL != cipher_info );
1480 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1487 fct_chk( outlen == enclen );
1490 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1497 fct_chk( outlen == 0 );
1502 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1509 fct_chk( enclen == outlen );
1512 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1519 fct_chk( outlen == 0 );
1523 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1530 #ifdef POLARSSL_BLOWFISH_C
1532 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_47_bytes)
1534 unsigned char key[32];
1535 unsigned char iv[16];
1541 unsigned char inbuf[64];
1542 unsigned char encbuf[64];
1543 unsigned char decbuf[64];
1548 memset( key, 0, 32 );
1549 memset( iv , 0, 16 );
1551 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1552 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1554 memset( inbuf, 5, 64 );
1555 memset( encbuf, 0, 64 );
1556 memset( decbuf, 0, 64 );
1560 fct_chk( NULL != cipher_info );
1584 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1591 fct_chk( outlen == enclen );
1594 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1601 fct_chk( outlen == 0 );
1606 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1613 fct_chk( enclen == outlen );
1616 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1623 fct_chk( outlen == 0 );
1627 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1634 #ifdef POLARSSL_BLOWFISH_C
1636 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_48_bytes)
1638 unsigned char key[32];
1639 unsigned char iv[16];
1645 unsigned char inbuf[64];
1646 unsigned char encbuf[64];
1647 unsigned char decbuf[64];
1652 memset( key, 0, 32 );
1653 memset( iv , 0, 16 );
1655 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1656 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1658 memset( inbuf, 5, 64 );
1659 memset( encbuf, 0, 64 );
1660 memset( decbuf, 0, 64 );
1664 fct_chk( NULL != cipher_info );
1688 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1695 fct_chk( outlen == enclen );
1698 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1705 fct_chk( outlen == 0 );
1710 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1717 fct_chk( enclen == outlen );
1720 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1727 fct_chk( outlen == 0 );
1731 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1738 #ifdef POLARSSL_BLOWFISH_C
1740 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_49_bytes)
1742 unsigned char key[32];
1743 unsigned char iv[16];
1749 unsigned char inbuf[64];
1750 unsigned char encbuf[64];
1751 unsigned char decbuf[64];
1756 memset( key, 0, 32 );
1757 memset( iv , 0, 16 );
1759 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1760 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1762 memset( inbuf, 5, 64 );
1763 memset( encbuf, 0, 64 );
1764 memset( decbuf, 0, 64 );
1768 fct_chk( NULL != cipher_info );
1792 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1799 fct_chk( outlen == enclen );
1802 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1809 fct_chk( outlen == 0 );
1814 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1821 fct_chk( enclen == outlen );
1824 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1831 fct_chk( outlen == 0 );
1835 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1842 #ifdef POLARSSL_BLOWFISH_C
1844 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_0_bytes_in_multiple_parts)
1845 size_t first_length = 0;
1846 size_t second_length = 0;
1847 size_t length = first_length + second_length;
1848 unsigned char key[32];
1849 unsigned char iv[16];
1855 unsigned char inbuf[64];
1856 unsigned char encbuf[64];
1857 unsigned char decbuf[64];
1860 size_t totaloutlen = 0;
1863 memset( key, 0, 32 );
1864 memset( iv , 0, 16 );
1866 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1867 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1869 memset( inbuf, 5, 64 );
1870 memset( encbuf, 0, 64 );
1871 memset( decbuf, 0, 64 );
1875 fct_chk( NULL != cipher_info);
1897 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
1898 totaloutlen = outlen;
1899 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
1900 totaloutlen += outlen;
1907 fct_chk( totaloutlen == enclen );
1909 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
1910 totaloutlen += outlen;
1917 fct_chk( outlen == 0 );
1921 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1928 fct_chk( enclen == outlen );
1930 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1937 fct_chk( outlen == 0 );
1941 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1948 #ifdef POLARSSL_BLOWFISH_C
1950 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_1_bytes_in_multiple_parts_1)
1951 size_t first_length = 1;
1952 size_t second_length = 0;
1953 size_t length = first_length + second_length;
1954 unsigned char key[32];
1955 unsigned char iv[16];
1961 unsigned char inbuf[64];
1962 unsigned char encbuf[64];
1963 unsigned char decbuf[64];
1966 size_t totaloutlen = 0;
1969 memset( key, 0, 32 );
1970 memset( iv , 0, 16 );
1972 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1973 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1975 memset( inbuf, 5, 64 );
1976 memset( encbuf, 0, 64 );
1977 memset( decbuf, 0, 64 );
1981 fct_chk( NULL != cipher_info);
2003 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2004 totaloutlen = outlen;
2005 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2006 totaloutlen += outlen;
2013 fct_chk( totaloutlen == enclen );
2015 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2016 totaloutlen += outlen;
2023 fct_chk( outlen == 0 );
2027 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2034 fct_chk( enclen == outlen );
2036 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2043 fct_chk( outlen == 0 );
2047 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2054 #ifdef POLARSSL_BLOWFISH_C
2056 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_1_bytes_in_multiple_parts_2)
2057 size_t first_length = 0;
2058 size_t second_length = 1;
2059 size_t length = first_length + second_length;
2060 unsigned char key[32];
2061 unsigned char iv[16];
2067 unsigned char inbuf[64];
2068 unsigned char encbuf[64];
2069 unsigned char decbuf[64];
2072 size_t totaloutlen = 0;
2075 memset( key, 0, 32 );
2076 memset( iv , 0, 16 );
2078 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2079 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2081 memset( inbuf, 5, 64 );
2082 memset( encbuf, 0, 64 );
2083 memset( decbuf, 0, 64 );
2087 fct_chk( NULL != cipher_info);
2109 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2110 totaloutlen = outlen;
2111 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2112 totaloutlen += outlen;
2119 fct_chk( totaloutlen == enclen );
2121 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2122 totaloutlen += outlen;
2129 fct_chk( outlen == 0 );
2133 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2140 fct_chk( enclen == outlen );
2142 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2149 fct_chk( outlen == 0 );
2153 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2160 #ifdef POLARSSL_BLOWFISH_C
2162 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_1)
2163 size_t first_length = 16;
2164 size_t second_length = 0;
2165 size_t length = first_length + second_length;
2166 unsigned char key[32];
2167 unsigned char iv[16];
2173 unsigned char inbuf[64];
2174 unsigned char encbuf[64];
2175 unsigned char decbuf[64];
2178 size_t totaloutlen = 0;
2181 memset( key, 0, 32 );
2182 memset( iv , 0, 16 );
2184 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2185 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2187 memset( inbuf, 5, 64 );
2188 memset( encbuf, 0, 64 );
2189 memset( decbuf, 0, 64 );
2193 fct_chk( NULL != cipher_info);
2215 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2216 totaloutlen = outlen;
2217 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2218 totaloutlen += outlen;
2225 fct_chk( totaloutlen == enclen );
2227 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2228 totaloutlen += outlen;
2235 fct_chk( outlen == 0 );
2239 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2246 fct_chk( enclen == outlen );
2248 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2255 fct_chk( outlen == 0 );
2259 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2266 #ifdef POLARSSL_BLOWFISH_C
2268 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_2)
2269 size_t first_length = 0;
2270 size_t second_length = 16;
2271 size_t length = first_length + second_length;
2272 unsigned char key[32];
2273 unsigned char iv[16];
2279 unsigned char inbuf[64];
2280 unsigned char encbuf[64];
2281 unsigned char decbuf[64];
2284 size_t totaloutlen = 0;
2287 memset( key, 0, 32 );
2288 memset( iv , 0, 16 );
2290 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2291 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2293 memset( inbuf, 5, 64 );
2294 memset( encbuf, 0, 64 );
2295 memset( decbuf, 0, 64 );
2299 fct_chk( NULL != cipher_info);
2321 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2322 totaloutlen = outlen;
2323 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2324 totaloutlen += outlen;
2331 fct_chk( totaloutlen == enclen );
2333 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2334 totaloutlen += outlen;
2341 fct_chk( outlen == 0 );
2345 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2352 fct_chk( enclen == outlen );
2354 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2361 fct_chk( outlen == 0 );
2365 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2372 #ifdef POLARSSL_BLOWFISH_C
2374 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_3)
2375 size_t first_length = 1;
2376 size_t second_length = 15;
2377 size_t length = first_length + second_length;
2378 unsigned char key[32];
2379 unsigned char iv[16];
2385 unsigned char inbuf[64];
2386 unsigned char encbuf[64];
2387 unsigned char decbuf[64];
2390 size_t totaloutlen = 0;
2393 memset( key, 0, 32 );
2394 memset( iv , 0, 16 );
2396 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2397 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2399 memset( inbuf, 5, 64 );
2400 memset( encbuf, 0, 64 );
2401 memset( decbuf, 0, 64 );
2405 fct_chk( NULL != cipher_info);
2427 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2428 totaloutlen = outlen;
2429 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2430 totaloutlen += outlen;
2437 fct_chk( totaloutlen == enclen );
2439 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2440 totaloutlen += outlen;
2447 fct_chk( outlen == 0 );
2451 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2458 fct_chk( enclen == outlen );
2460 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2467 fct_chk( outlen == 0 );
2471 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2478 #ifdef POLARSSL_BLOWFISH_C
2480 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_4)
2481 size_t first_length = 15;
2482 size_t second_length = 1;
2483 size_t length = first_length + second_length;
2484 unsigned char key[32];
2485 unsigned char iv[16];
2491 unsigned char inbuf[64];
2492 unsigned char encbuf[64];
2493 unsigned char decbuf[64];
2496 size_t totaloutlen = 0;
2499 memset( key, 0, 32 );
2500 memset( iv , 0, 16 );
2502 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2503 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2505 memset( inbuf, 5, 64 );
2506 memset( encbuf, 0, 64 );
2507 memset( decbuf, 0, 64 );
2511 fct_chk( NULL != cipher_info);
2533 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2534 totaloutlen = outlen;
2535 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2536 totaloutlen += outlen;
2543 fct_chk( totaloutlen == enclen );
2545 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2546 totaloutlen += outlen;
2553 fct_chk( outlen == 0 );
2557 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2564 fct_chk( enclen == outlen );
2566 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2573 fct_chk( outlen == 0 );
2577 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2584 #ifdef POLARSSL_BLOWFISH_C
2586 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
2587 size_t first_length = 15;
2588 size_t second_length = 7;
2589 size_t length = first_length + second_length;
2590 unsigned char key[32];
2591 unsigned char iv[16];
2597 unsigned char inbuf[64];
2598 unsigned char encbuf[64];
2599 unsigned char decbuf[64];
2602 size_t totaloutlen = 0;
2605 memset( key, 0, 32 );
2606 memset( iv , 0, 16 );
2608 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2609 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2611 memset( inbuf, 5, 64 );
2612 memset( encbuf, 0, 64 );
2613 memset( decbuf, 0, 64 );
2617 fct_chk( NULL != cipher_info);
2639 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2640 totaloutlen = outlen;
2641 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2642 totaloutlen += outlen;
2649 fct_chk( totaloutlen == enclen );
2651 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2652 totaloutlen += outlen;
2659 fct_chk( outlen == 0 );
2663 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2670 fct_chk( enclen == outlen );
2672 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2679 fct_chk( outlen == 0 );
2683 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2690 #ifdef POLARSSL_BLOWFISH_C
2692 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
2693 size_t first_length = 16;
2694 size_t second_length = 6;
2695 size_t length = first_length + second_length;
2696 unsigned char key[32];
2697 unsigned char iv[16];
2703 unsigned char inbuf[64];
2704 unsigned char encbuf[64];
2705 unsigned char decbuf[64];
2708 size_t totaloutlen = 0;
2711 memset( key, 0, 32 );
2712 memset( iv , 0, 16 );
2714 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2715 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2717 memset( inbuf, 5, 64 );
2718 memset( encbuf, 0, 64 );
2719 memset( decbuf, 0, 64 );
2723 fct_chk( NULL != cipher_info);
2745 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2746 totaloutlen = outlen;
2747 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2748 totaloutlen += outlen;
2755 fct_chk( totaloutlen == enclen );
2757 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2758 totaloutlen += outlen;
2765 fct_chk( outlen == 0 );
2769 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2776 fct_chk( enclen == outlen );
2778 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2785 fct_chk( outlen == 0 );
2789 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2796 #ifdef POLARSSL_BLOWFISH_C
2798 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
2799 size_t first_length = 17;
2800 size_t second_length = 6;
2801 size_t length = first_length + second_length;
2802 unsigned char key[32];
2803 unsigned char iv[16];
2809 unsigned char inbuf[64];
2810 unsigned char encbuf[64];
2811 unsigned char decbuf[64];
2814 size_t totaloutlen = 0;
2817 memset( key, 0, 32 );
2818 memset( iv , 0, 16 );
2820 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2821 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2823 memset( inbuf, 5, 64 );
2824 memset( encbuf, 0, 64 );
2825 memset( decbuf, 0, 64 );
2829 fct_chk( NULL != cipher_info);
2851 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2852 totaloutlen = outlen;
2853 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2854 totaloutlen += outlen;
2861 fct_chk( totaloutlen == enclen );
2863 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2864 totaloutlen += outlen;
2871 fct_chk( outlen == 0 );
2875 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2882 fct_chk( enclen == outlen );
2884 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2891 fct_chk( outlen == 0 );
2895 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2902 #ifdef POLARSSL_BLOWFISH_C
2904 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_32_bytes_in_multiple_parts_1)
2905 size_t first_length = 16;
2906 size_t second_length = 16;
2907 size_t length = first_length + second_length;
2908 unsigned char key[32];
2909 unsigned char iv[16];
2915 unsigned char inbuf[64];
2916 unsigned char encbuf[64];
2917 unsigned char decbuf[64];
2920 size_t totaloutlen = 0;
2923 memset( key, 0, 32 );
2924 memset( iv , 0, 16 );
2926 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2927 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2929 memset( inbuf, 5, 64 );
2930 memset( encbuf, 0, 64 );
2931 memset( decbuf, 0, 64 );
2935 fct_chk( NULL != cipher_info);
2957 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2958 totaloutlen = outlen;
2959 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2960 totaloutlen += outlen;
2967 fct_chk( totaloutlen == enclen );
2969 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2970 totaloutlen += outlen;
2977 fct_chk( outlen == 0 );
2981 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2988 fct_chk( enclen == outlen );
2990 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2997 fct_chk( outlen == 0 );
3001 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3008 #ifdef POLARSSL_BLOWFISH_C
3009 #ifdef POLARSSL_CIPHER_MODE_CFB
3011 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_0_bytes)
3013 unsigned char key[32];
3014 unsigned char iv[16];
3020 unsigned char inbuf[64];
3021 unsigned char encbuf[64];
3022 unsigned char decbuf[64];
3027 memset( key, 0, 32 );
3028 memset( iv , 0, 16 );
3030 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3031 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3033 memset( inbuf, 5, 64 );
3034 memset( encbuf, 0, 64 );
3035 memset( decbuf, 0, 64 );
3039 fct_chk( NULL != cipher_info );
3063 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3070 fct_chk( outlen == enclen );
3073 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3080 fct_chk( outlen == 0 );
3085 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3092 fct_chk( enclen == outlen );
3095 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3102 fct_chk( outlen == 0 );
3106 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3114 #ifdef POLARSSL_BLOWFISH_C
3115 #ifdef POLARSSL_CIPHER_MODE_CFB
3117 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_1_byte)
3119 unsigned char key[32];
3120 unsigned char iv[16];
3126 unsigned char inbuf[64];
3127 unsigned char encbuf[64];
3128 unsigned char decbuf[64];
3133 memset( key, 0, 32 );
3134 memset( iv , 0, 16 );
3136 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3137 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3139 memset( inbuf, 5, 64 );
3140 memset( encbuf, 0, 64 );
3141 memset( decbuf, 0, 64 );
3145 fct_chk( NULL != cipher_info );
3169 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3176 fct_chk( outlen == enclen );
3179 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3186 fct_chk( outlen == 0 );
3191 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3198 fct_chk( enclen == outlen );
3201 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3208 fct_chk( outlen == 0 );
3212 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3220 #ifdef POLARSSL_BLOWFISH_C
3221 #ifdef POLARSSL_CIPHER_MODE_CFB
3223 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_2_bytes)
3225 unsigned char key[32];
3226 unsigned char iv[16];
3232 unsigned char inbuf[64];
3233 unsigned char encbuf[64];
3234 unsigned char decbuf[64];
3239 memset( key, 0, 32 );
3240 memset( iv , 0, 16 );
3242 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3243 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3245 memset( inbuf, 5, 64 );
3246 memset( encbuf, 0, 64 );
3247 memset( decbuf, 0, 64 );
3251 fct_chk( NULL != cipher_info );
3275 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3282 fct_chk( outlen == enclen );
3285 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3292 fct_chk( outlen == 0 );
3297 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3304 fct_chk( enclen == outlen );
3307 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3314 fct_chk( outlen == 0 );
3318 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3326 #ifdef POLARSSL_BLOWFISH_C
3327 #ifdef POLARSSL_CIPHER_MODE_CFB
3329 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_7_bytes)
3331 unsigned char key[32];
3332 unsigned char iv[16];
3338 unsigned char inbuf[64];
3339 unsigned char encbuf[64];
3340 unsigned char decbuf[64];
3345 memset( key, 0, 32 );
3346 memset( iv , 0, 16 );
3348 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3349 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3351 memset( inbuf, 5, 64 );
3352 memset( encbuf, 0, 64 );
3353 memset( decbuf, 0, 64 );
3357 fct_chk( NULL != cipher_info );
3381 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3388 fct_chk( outlen == enclen );
3391 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3398 fct_chk( outlen == 0 );
3403 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3410 fct_chk( enclen == outlen );
3413 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3420 fct_chk( outlen == 0 );
3424 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3432 #ifdef POLARSSL_BLOWFISH_C
3433 #ifdef POLARSSL_CIPHER_MODE_CFB
3435 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_8_bytes)
3437 unsigned char key[32];
3438 unsigned char iv[16];
3444 unsigned char inbuf[64];
3445 unsigned char encbuf[64];
3446 unsigned char decbuf[64];
3451 memset( key, 0, 32 );
3452 memset( iv , 0, 16 );
3454 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3455 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3457 memset( inbuf, 5, 64 );
3458 memset( encbuf, 0, 64 );
3459 memset( decbuf, 0, 64 );
3463 fct_chk( NULL != cipher_info );
3487 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3494 fct_chk( outlen == enclen );
3497 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3504 fct_chk( outlen == 0 );
3509 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3516 fct_chk( enclen == outlen );
3519 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3526 fct_chk( outlen == 0 );
3530 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3538 #ifdef POLARSSL_BLOWFISH_C
3539 #ifdef POLARSSL_CIPHER_MODE_CFB
3541 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_9_bytes)
3543 unsigned char key[32];
3544 unsigned char iv[16];
3550 unsigned char inbuf[64];
3551 unsigned char encbuf[64];
3552 unsigned char decbuf[64];
3557 memset( key, 0, 32 );
3558 memset( iv , 0, 16 );
3560 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3561 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3563 memset( inbuf, 5, 64 );
3564 memset( encbuf, 0, 64 );
3565 memset( decbuf, 0, 64 );
3569 fct_chk( NULL != cipher_info );
3593 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3600 fct_chk( outlen == enclen );
3603 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3610 fct_chk( outlen == 0 );
3615 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3622 fct_chk( enclen == outlen );
3625 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3632 fct_chk( outlen == 0 );
3636 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3644 #ifdef POLARSSL_BLOWFISH_C
3645 #ifdef POLARSSL_CIPHER_MODE_CFB
3647 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_15_bytes)
3649 unsigned char key[32];
3650 unsigned char iv[16];
3656 unsigned char inbuf[64];
3657 unsigned char encbuf[64];
3658 unsigned char decbuf[64];
3663 memset( key, 0, 32 );
3664 memset( iv , 0, 16 );
3666 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3667 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3669 memset( inbuf, 5, 64 );
3670 memset( encbuf, 0, 64 );
3671 memset( decbuf, 0, 64 );
3675 fct_chk( NULL != cipher_info );
3699 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3706 fct_chk( outlen == enclen );
3709 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3716 fct_chk( outlen == 0 );
3721 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3728 fct_chk( enclen == outlen );
3731 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3738 fct_chk( outlen == 0 );
3742 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3750 #ifdef POLARSSL_BLOWFISH_C
3751 #ifdef POLARSSL_CIPHER_MODE_CFB
3753 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes)
3755 unsigned char key[32];
3756 unsigned char iv[16];
3762 unsigned char inbuf[64];
3763 unsigned char encbuf[64];
3764 unsigned char decbuf[64];
3769 memset( key, 0, 32 );
3770 memset( iv , 0, 16 );
3772 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3773 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3775 memset( inbuf, 5, 64 );
3776 memset( encbuf, 0, 64 );
3777 memset( decbuf, 0, 64 );
3781 fct_chk( NULL != cipher_info );
3805 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3812 fct_chk( outlen == enclen );
3815 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3822 fct_chk( outlen == 0 );
3827 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3834 fct_chk( enclen == outlen );
3837 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3844 fct_chk( outlen == 0 );
3848 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3856 #ifdef POLARSSL_BLOWFISH_C
3857 #ifdef POLARSSL_CIPHER_MODE_CFB
3859 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_17_bytes)
3861 unsigned char key[32];
3862 unsigned char iv[16];
3868 unsigned char inbuf[64];
3869 unsigned char encbuf[64];
3870 unsigned char decbuf[64];
3875 memset( key, 0, 32 );
3876 memset( iv , 0, 16 );
3878 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3879 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3881 memset( inbuf, 5, 64 );
3882 memset( encbuf, 0, 64 );
3883 memset( decbuf, 0, 64 );
3887 fct_chk( NULL != cipher_info );
3911 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3918 fct_chk( outlen == enclen );
3921 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3928 fct_chk( outlen == 0 );
3933 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3940 fct_chk( enclen == outlen );
3943 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3950 fct_chk( outlen == 0 );
3954 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3962 #ifdef POLARSSL_BLOWFISH_C
3963 #ifdef POLARSSL_CIPHER_MODE_CFB
3965 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_31_bytes)
3967 unsigned char key[32];
3968 unsigned char iv[16];
3974 unsigned char inbuf[64];
3975 unsigned char encbuf[64];
3976 unsigned char decbuf[64];
3981 memset( key, 0, 32 );
3982 memset( iv , 0, 16 );
3984 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3985 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3987 memset( inbuf, 5, 64 );
3988 memset( encbuf, 0, 64 );
3989 memset( decbuf, 0, 64 );
3993 fct_chk( NULL != cipher_info );
4017 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4024 fct_chk( outlen == enclen );
4027 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4034 fct_chk( outlen == 0 );
4039 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4046 fct_chk( enclen == outlen );
4049 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4056 fct_chk( outlen == 0 );
4060 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4068 #ifdef POLARSSL_BLOWFISH_C
4069 #ifdef POLARSSL_CIPHER_MODE_CFB
4071 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_32_bytes)
4073 unsigned char key[32];
4074 unsigned char iv[16];
4080 unsigned char inbuf[64];
4081 unsigned char encbuf[64];
4082 unsigned char decbuf[64];
4087 memset( key, 0, 32 );
4088 memset( iv , 0, 16 );
4090 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4091 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4093 memset( inbuf, 5, 64 );
4094 memset( encbuf, 0, 64 );
4095 memset( decbuf, 0, 64 );
4099 fct_chk( NULL != cipher_info );
4123 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4130 fct_chk( outlen == enclen );
4133 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4140 fct_chk( outlen == 0 );
4145 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4152 fct_chk( enclen == outlen );
4155 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4162 fct_chk( outlen == 0 );
4166 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4174 #ifdef POLARSSL_BLOWFISH_C
4175 #ifdef POLARSSL_CIPHER_MODE_CFB
4177 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_32_bytes)
4179 unsigned char key[32];
4180 unsigned char iv[16];
4186 unsigned char inbuf[64];
4187 unsigned char encbuf[64];
4188 unsigned char decbuf[64];
4193 memset( key, 0, 32 );
4194 memset( iv , 0, 16 );
4196 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4197 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4199 memset( inbuf, 5, 64 );
4200 memset( encbuf, 0, 64 );
4201 memset( decbuf, 0, 64 );
4205 fct_chk( NULL != cipher_info );
4229 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4236 fct_chk( outlen == enclen );
4239 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4246 fct_chk( outlen == 0 );
4251 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4258 fct_chk( enclen == outlen );
4261 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4268 fct_chk( outlen == 0 );
4272 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4280 #ifdef POLARSSL_BLOWFISH_C
4281 #ifdef POLARSSL_CIPHER_MODE_CFB
4283 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_47_bytes)
4285 unsigned char key[32];
4286 unsigned char iv[16];
4292 unsigned char inbuf[64];
4293 unsigned char encbuf[64];
4294 unsigned char decbuf[64];
4299 memset( key, 0, 32 );
4300 memset( iv , 0, 16 );
4302 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4303 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4305 memset( inbuf, 5, 64 );
4306 memset( encbuf, 0, 64 );
4307 memset( decbuf, 0, 64 );
4311 fct_chk( NULL != cipher_info );
4335 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4342 fct_chk( outlen == enclen );
4345 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4352 fct_chk( outlen == 0 );
4357 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4364 fct_chk( enclen == outlen );
4367 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4374 fct_chk( outlen == 0 );
4378 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4386 #ifdef POLARSSL_BLOWFISH_C
4387 #ifdef POLARSSL_CIPHER_MODE_CFB
4389 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_48_bytes)
4391 unsigned char key[32];
4392 unsigned char iv[16];
4398 unsigned char inbuf[64];
4399 unsigned char encbuf[64];
4400 unsigned char decbuf[64];
4405 memset( key, 0, 32 );
4406 memset( iv , 0, 16 );
4408 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4409 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4411 memset( inbuf, 5, 64 );
4412 memset( encbuf, 0, 64 );
4413 memset( decbuf, 0, 64 );
4417 fct_chk( NULL != cipher_info );
4441 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4448 fct_chk( outlen == enclen );
4451 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4458 fct_chk( outlen == 0 );
4463 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4470 fct_chk( enclen == outlen );
4473 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4480 fct_chk( outlen == 0 );
4484 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4492 #ifdef POLARSSL_BLOWFISH_C
4493 #ifdef POLARSSL_CIPHER_MODE_CFB
4495 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_49_bytes)
4497 unsigned char key[32];
4498 unsigned char iv[16];
4504 unsigned char inbuf[64];
4505 unsigned char encbuf[64];
4506 unsigned char decbuf[64];
4511 memset( key, 0, 32 );
4512 memset( iv , 0, 16 );
4514 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4515 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4517 memset( inbuf, 5, 64 );
4518 memset( encbuf, 0, 64 );
4519 memset( decbuf, 0, 64 );
4523 fct_chk( NULL != cipher_info );
4547 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4554 fct_chk( outlen == enclen );
4557 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4564 fct_chk( outlen == 0 );
4569 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4576 fct_chk( enclen == outlen );
4579 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4586 fct_chk( outlen == 0 );
4590 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4598 #ifdef POLARSSL_BLOWFISH_C
4599 #ifdef POLARSSL_CIPHER_MODE_CFB
4601 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_0_bytes_in_multiple_parts)
4602 size_t first_length = 0;
4603 size_t second_length = 0;
4604 size_t length = first_length + second_length;
4605 unsigned char key[32];
4606 unsigned char iv[16];
4612 unsigned char inbuf[64];
4613 unsigned char encbuf[64];
4614 unsigned char decbuf[64];
4617 size_t totaloutlen = 0;
4620 memset( key, 0, 32 );
4621 memset( iv , 0, 16 );
4623 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4624 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4626 memset( inbuf, 5, 64 );
4627 memset( encbuf, 0, 64 );
4628 memset( decbuf, 0, 64 );
4632 fct_chk( NULL != cipher_info);
4654 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4655 totaloutlen = outlen;
4656 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4657 totaloutlen += outlen;
4664 fct_chk( totaloutlen == enclen );
4666 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4667 totaloutlen += outlen;
4674 fct_chk( outlen == 0 );
4678 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4685 fct_chk( enclen == outlen );
4687 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4694 fct_chk( outlen == 0 );
4698 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4706 #ifdef POLARSSL_BLOWFISH_C
4707 #ifdef POLARSSL_CIPHER_MODE_CFB
4709 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_1_bytes_in_multiple_parts_1)
4710 size_t first_length = 1;
4711 size_t second_length = 0;
4712 size_t length = first_length + second_length;
4713 unsigned char key[32];
4714 unsigned char iv[16];
4720 unsigned char inbuf[64];
4721 unsigned char encbuf[64];
4722 unsigned char decbuf[64];
4725 size_t totaloutlen = 0;
4728 memset( key, 0, 32 );
4729 memset( iv , 0, 16 );
4731 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4732 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4734 memset( inbuf, 5, 64 );
4735 memset( encbuf, 0, 64 );
4736 memset( decbuf, 0, 64 );
4740 fct_chk( NULL != cipher_info);
4762 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4763 totaloutlen = outlen;
4764 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4765 totaloutlen += outlen;
4772 fct_chk( totaloutlen == enclen );
4774 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4775 totaloutlen += outlen;
4782 fct_chk( outlen == 0 );
4786 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4793 fct_chk( enclen == outlen );
4795 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4802 fct_chk( outlen == 0 );
4806 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4814 #ifdef POLARSSL_BLOWFISH_C
4815 #ifdef POLARSSL_CIPHER_MODE_CFB
4817 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_1_bytes_in_multiple_parts_2)
4818 size_t first_length = 0;
4819 size_t second_length = 1;
4820 size_t length = first_length + second_length;
4821 unsigned char key[32];
4822 unsigned char iv[16];
4828 unsigned char inbuf[64];
4829 unsigned char encbuf[64];
4830 unsigned char decbuf[64];
4833 size_t totaloutlen = 0;
4836 memset( key, 0, 32 );
4837 memset( iv , 0, 16 );
4839 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4840 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4842 memset( inbuf, 5, 64 );
4843 memset( encbuf, 0, 64 );
4844 memset( decbuf, 0, 64 );
4848 fct_chk( NULL != cipher_info);
4870 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4871 totaloutlen = outlen;
4872 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4873 totaloutlen += outlen;
4880 fct_chk( totaloutlen == enclen );
4882 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4883 totaloutlen += outlen;
4890 fct_chk( outlen == 0 );
4894 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4901 fct_chk( enclen == outlen );
4903 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4910 fct_chk( outlen == 0 );
4914 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4922 #ifdef POLARSSL_BLOWFISH_C
4923 #ifdef POLARSSL_CIPHER_MODE_CFB
4925 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_1)
4926 size_t first_length = 16;
4927 size_t second_length = 0;
4928 size_t length = first_length + second_length;
4929 unsigned char key[32];
4930 unsigned char iv[16];
4936 unsigned char inbuf[64];
4937 unsigned char encbuf[64];
4938 unsigned char decbuf[64];
4941 size_t totaloutlen = 0;
4944 memset( key, 0, 32 );
4945 memset( iv , 0, 16 );
4947 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4948 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4950 memset( inbuf, 5, 64 );
4951 memset( encbuf, 0, 64 );
4952 memset( decbuf, 0, 64 );
4956 fct_chk( NULL != cipher_info);
4978 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4979 totaloutlen = outlen;
4980 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4981 totaloutlen += outlen;
4988 fct_chk( totaloutlen == enclen );
4990 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4991 totaloutlen += outlen;
4998 fct_chk( outlen == 0 );
5002 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5009 fct_chk( enclen == outlen );
5011 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5018 fct_chk( outlen == 0 );
5022 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5030 #ifdef POLARSSL_BLOWFISH_C
5031 #ifdef POLARSSL_CIPHER_MODE_CFB
5033 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_2)
5034 size_t first_length = 0;
5035 size_t second_length = 16;
5036 size_t length = first_length + second_length;
5037 unsigned char key[32];
5038 unsigned char iv[16];
5044 unsigned char inbuf[64];
5045 unsigned char encbuf[64];
5046 unsigned char decbuf[64];
5049 size_t totaloutlen = 0;
5052 memset( key, 0, 32 );
5053 memset( iv , 0, 16 );
5055 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5056 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5058 memset( inbuf, 5, 64 );
5059 memset( encbuf, 0, 64 );
5060 memset( decbuf, 0, 64 );
5064 fct_chk( NULL != cipher_info);
5086 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5087 totaloutlen = outlen;
5088 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5089 totaloutlen += outlen;
5096 fct_chk( totaloutlen == enclen );
5098 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5099 totaloutlen += outlen;
5106 fct_chk( outlen == 0 );
5110 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5117 fct_chk( enclen == outlen );
5119 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5126 fct_chk( outlen == 0 );
5130 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5138 #ifdef POLARSSL_BLOWFISH_C
5139 #ifdef POLARSSL_CIPHER_MODE_CFB
5141 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_3)
5142 size_t first_length = 1;
5143 size_t second_length = 15;
5144 size_t length = first_length + second_length;
5145 unsigned char key[32];
5146 unsigned char iv[16];
5152 unsigned char inbuf[64];
5153 unsigned char encbuf[64];
5154 unsigned char decbuf[64];
5157 size_t totaloutlen = 0;
5160 memset( key, 0, 32 );
5161 memset( iv , 0, 16 );
5163 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5164 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5166 memset( inbuf, 5, 64 );
5167 memset( encbuf, 0, 64 );
5168 memset( decbuf, 0, 64 );
5172 fct_chk( NULL != cipher_info);
5194 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5195 totaloutlen = outlen;
5196 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5197 totaloutlen += outlen;
5204 fct_chk( totaloutlen == enclen );
5206 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5207 totaloutlen += outlen;
5214 fct_chk( outlen == 0 );
5218 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5225 fct_chk( enclen == outlen );
5227 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5234 fct_chk( outlen == 0 );
5238 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5246 #ifdef POLARSSL_BLOWFISH_C
5247 #ifdef POLARSSL_CIPHER_MODE_CFB
5249 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_4)
5250 size_t first_length = 15;
5251 size_t second_length = 1;
5252 size_t length = first_length + second_length;
5253 unsigned char key[32];
5254 unsigned char iv[16];
5260 unsigned char inbuf[64];
5261 unsigned char encbuf[64];
5262 unsigned char decbuf[64];
5265 size_t totaloutlen = 0;
5268 memset( key, 0, 32 );
5269 memset( iv , 0, 16 );
5271 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5272 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5274 memset( inbuf, 5, 64 );
5275 memset( encbuf, 0, 64 );
5276 memset( decbuf, 0, 64 );
5280 fct_chk( NULL != cipher_info);
5302 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5303 totaloutlen = outlen;
5304 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5305 totaloutlen += outlen;
5312 fct_chk( totaloutlen == enclen );
5314 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5315 totaloutlen += outlen;
5322 fct_chk( outlen == 0 );
5326 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5333 fct_chk( enclen == outlen );
5335 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5342 fct_chk( outlen == 0 );
5346 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5354 #ifdef POLARSSL_BLOWFISH_C
5355 #ifdef POLARSSL_CIPHER_MODE_CFB
5357 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
5358 size_t first_length = 15;
5359 size_t second_length = 7;
5360 size_t length = first_length + second_length;
5361 unsigned char key[32];
5362 unsigned char iv[16];
5368 unsigned char inbuf[64];
5369 unsigned char encbuf[64];
5370 unsigned char decbuf[64];
5373 size_t totaloutlen = 0;
5376 memset( key, 0, 32 );
5377 memset( iv , 0, 16 );
5379 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5380 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5382 memset( inbuf, 5, 64 );
5383 memset( encbuf, 0, 64 );
5384 memset( decbuf, 0, 64 );
5388 fct_chk( NULL != cipher_info);
5410 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5411 totaloutlen = outlen;
5412 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5413 totaloutlen += outlen;
5420 fct_chk( totaloutlen == enclen );
5422 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5423 totaloutlen += outlen;
5430 fct_chk( outlen == 0 );
5434 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5441 fct_chk( enclen == outlen );
5443 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5450 fct_chk( outlen == 0 );
5454 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5462 #ifdef POLARSSL_BLOWFISH_C
5463 #ifdef POLARSSL_CIPHER_MODE_CFB
5465 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
5466 size_t first_length = 16;
5467 size_t second_length = 6;
5468 size_t length = first_length + second_length;
5469 unsigned char key[32];
5470 unsigned char iv[16];
5476 unsigned char inbuf[64];
5477 unsigned char encbuf[64];
5478 unsigned char decbuf[64];
5481 size_t totaloutlen = 0;
5484 memset( key, 0, 32 );
5485 memset( iv , 0, 16 );
5487 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5488 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5490 memset( inbuf, 5, 64 );
5491 memset( encbuf, 0, 64 );
5492 memset( decbuf, 0, 64 );
5496 fct_chk( NULL != cipher_info);
5518 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5519 totaloutlen = outlen;
5520 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5521 totaloutlen += outlen;
5528 fct_chk( totaloutlen == enclen );
5530 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5531 totaloutlen += outlen;
5538 fct_chk( outlen == 0 );
5542 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5549 fct_chk( enclen == outlen );
5551 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5558 fct_chk( outlen == 0 );
5562 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5570 #ifdef POLARSSL_BLOWFISH_C
5571 #ifdef POLARSSL_CIPHER_MODE_CFB
5573 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
5574 size_t first_length = 17;
5575 size_t second_length = 6;
5576 size_t length = first_length + second_length;
5577 unsigned char key[32];
5578 unsigned char iv[16];
5584 unsigned char inbuf[64];
5585 unsigned char encbuf[64];
5586 unsigned char decbuf[64];
5589 size_t totaloutlen = 0;
5592 memset( key, 0, 32 );
5593 memset( iv , 0, 16 );
5595 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5596 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5598 memset( inbuf, 5, 64 );
5599 memset( encbuf, 0, 64 );
5600 memset( decbuf, 0, 64 );
5604 fct_chk( NULL != cipher_info);
5626 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5627 totaloutlen = outlen;
5628 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5629 totaloutlen += outlen;
5636 fct_chk( totaloutlen == enclen );
5638 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5639 totaloutlen += outlen;
5646 fct_chk( outlen == 0 );
5650 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5657 fct_chk( enclen == outlen );
5659 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5666 fct_chk( outlen == 0 );
5670 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5678 #ifdef POLARSSL_BLOWFISH_C
5679 #ifdef POLARSSL_CIPHER_MODE_CFB
5681 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_32_bytes_in_multiple_parts_1)
5682 size_t first_length = 16;
5683 size_t second_length = 16;
5684 size_t length = first_length + second_length;
5685 unsigned char key[32];
5686 unsigned char iv[16];
5692 unsigned char inbuf[64];
5693 unsigned char encbuf[64];
5694 unsigned char decbuf[64];
5697 size_t totaloutlen = 0;
5700 memset( key, 0, 32 );
5701 memset( iv , 0, 16 );
5703 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5704 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5706 memset( inbuf, 5, 64 );
5707 memset( encbuf, 0, 64 );
5708 memset( decbuf, 0, 64 );
5712 fct_chk( NULL != cipher_info);
5734 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5735 totaloutlen = outlen;
5736 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5737 totaloutlen += outlen;
5744 fct_chk( totaloutlen == enclen );
5746 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5747 totaloutlen += outlen;
5754 fct_chk( outlen == 0 );
5758 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5765 fct_chk( enclen == outlen );
5767 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5774 fct_chk( outlen == 0 );
5778 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5786 #ifdef POLARSSL_BLOWFISH_C
5787 #ifdef POLARSSL_CIPHER_MODE_CTR
5789 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_0_bytes)
5791 unsigned char key[32];
5792 unsigned char iv[16];
5798 unsigned char inbuf[64];
5799 unsigned char encbuf[64];
5800 unsigned char decbuf[64];
5805 memset( key, 0, 32 );
5806 memset( iv , 0, 16 );
5808 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5809 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5811 memset( inbuf, 5, 64 );
5812 memset( encbuf, 0, 64 );
5813 memset( decbuf, 0, 64 );
5817 fct_chk( NULL != cipher_info );
5841 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
5848 fct_chk( outlen == enclen );
5851 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
5858 fct_chk( outlen == 0 );
5863 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5870 fct_chk( enclen == outlen );
5873 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5880 fct_chk( outlen == 0 );
5884 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5892 #ifdef POLARSSL_BLOWFISH_C
5893 #ifdef POLARSSL_CIPHER_MODE_CTR
5895 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_1_byte)
5897 unsigned char key[32];
5898 unsigned char iv[16];
5904 unsigned char inbuf[64];
5905 unsigned char encbuf[64];
5906 unsigned char decbuf[64];
5911 memset( key, 0, 32 );
5912 memset( iv , 0, 16 );
5914 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5915 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5917 memset( inbuf, 5, 64 );
5918 memset( encbuf, 0, 64 );
5919 memset( decbuf, 0, 64 );
5923 fct_chk( NULL != cipher_info );
5947 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
5954 fct_chk( outlen == enclen );
5957 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
5964 fct_chk( outlen == 0 );
5969 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5976 fct_chk( enclen == outlen );
5979 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5986 fct_chk( outlen == 0 );
5990 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5998 #ifdef POLARSSL_BLOWFISH_C
5999 #ifdef POLARSSL_CIPHER_MODE_CTR
6001 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_2_bytes)
6003 unsigned char key[32];
6004 unsigned char iv[16];
6010 unsigned char inbuf[64];
6011 unsigned char encbuf[64];
6012 unsigned char decbuf[64];
6017 memset( key, 0, 32 );
6018 memset( iv , 0, 16 );
6020 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6021 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6023 memset( inbuf, 5, 64 );
6024 memset( encbuf, 0, 64 );
6025 memset( decbuf, 0, 64 );
6029 fct_chk( NULL != cipher_info );
6053 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6060 fct_chk( outlen == enclen );
6063 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6070 fct_chk( outlen == 0 );
6075 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6082 fct_chk( enclen == outlen );
6085 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6092 fct_chk( outlen == 0 );
6096 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6104 #ifdef POLARSSL_BLOWFISH_C
6105 #ifdef POLARSSL_CIPHER_MODE_CTR
6107 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_7_bytes)
6109 unsigned char key[32];
6110 unsigned char iv[16];
6116 unsigned char inbuf[64];
6117 unsigned char encbuf[64];
6118 unsigned char decbuf[64];
6123 memset( key, 0, 32 );
6124 memset( iv , 0, 16 );
6126 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6127 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6129 memset( inbuf, 5, 64 );
6130 memset( encbuf, 0, 64 );
6131 memset( decbuf, 0, 64 );
6135 fct_chk( NULL != cipher_info );
6159 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6166 fct_chk( outlen == enclen );
6169 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6176 fct_chk( outlen == 0 );
6181 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6188 fct_chk( enclen == outlen );
6191 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6198 fct_chk( outlen == 0 );
6202 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6210 #ifdef POLARSSL_BLOWFISH_C
6211 #ifdef POLARSSL_CIPHER_MODE_CTR
6213 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_8_bytes)
6215 unsigned char key[32];
6216 unsigned char iv[16];
6222 unsigned char inbuf[64];
6223 unsigned char encbuf[64];
6224 unsigned char decbuf[64];
6229 memset( key, 0, 32 );
6230 memset( iv , 0, 16 );
6232 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6233 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6235 memset( inbuf, 5, 64 );
6236 memset( encbuf, 0, 64 );
6237 memset( decbuf, 0, 64 );
6241 fct_chk( NULL != cipher_info );
6265 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6272 fct_chk( outlen == enclen );
6275 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6282 fct_chk( outlen == 0 );
6287 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6294 fct_chk( enclen == outlen );
6297 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6304 fct_chk( outlen == 0 );
6308 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6316 #ifdef POLARSSL_BLOWFISH_C
6317 #ifdef POLARSSL_CIPHER_MODE_CTR
6319 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_9_bytes)
6321 unsigned char key[32];
6322 unsigned char iv[16];
6328 unsigned char inbuf[64];
6329 unsigned char encbuf[64];
6330 unsigned char decbuf[64];
6335 memset( key, 0, 32 );
6336 memset( iv , 0, 16 );
6338 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6339 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6341 memset( inbuf, 5, 64 );
6342 memset( encbuf, 0, 64 );
6343 memset( decbuf, 0, 64 );
6347 fct_chk( NULL != cipher_info );
6371 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6378 fct_chk( outlen == enclen );
6381 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6388 fct_chk( outlen == 0 );
6393 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6400 fct_chk( enclen == outlen );
6403 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6410 fct_chk( outlen == 0 );
6414 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6422 #ifdef POLARSSL_BLOWFISH_C
6423 #ifdef POLARSSL_CIPHER_MODE_CTR
6425 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_15_bytes)
6427 unsigned char key[32];
6428 unsigned char iv[16];
6434 unsigned char inbuf[64];
6435 unsigned char encbuf[64];
6436 unsigned char decbuf[64];
6441 memset( key, 0, 32 );
6442 memset( iv , 0, 16 );
6444 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6445 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6447 memset( inbuf, 5, 64 );
6448 memset( encbuf, 0, 64 );
6449 memset( decbuf, 0, 64 );
6453 fct_chk( NULL != cipher_info );
6477 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6484 fct_chk( outlen == enclen );
6487 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6494 fct_chk( outlen == 0 );
6499 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6506 fct_chk( enclen == outlen );
6509 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6516 fct_chk( outlen == 0 );
6520 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6528 #ifdef POLARSSL_BLOWFISH_C
6529 #ifdef POLARSSL_CIPHER_MODE_CTR
6531 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes)
6533 unsigned char key[32];
6534 unsigned char iv[16];
6540 unsigned char inbuf[64];
6541 unsigned char encbuf[64];
6542 unsigned char decbuf[64];
6547 memset( key, 0, 32 );
6548 memset( iv , 0, 16 );
6550 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6551 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6553 memset( inbuf, 5, 64 );
6554 memset( encbuf, 0, 64 );
6555 memset( decbuf, 0, 64 );
6559 fct_chk( NULL != cipher_info );
6583 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6590 fct_chk( outlen == enclen );
6593 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6600 fct_chk( outlen == 0 );
6605 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6612 fct_chk( enclen == outlen );
6615 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6622 fct_chk( outlen == 0 );
6626 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6634 #ifdef POLARSSL_BLOWFISH_C
6635 #ifdef POLARSSL_CIPHER_MODE_CTR
6637 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_17_bytes)
6639 unsigned char key[32];
6640 unsigned char iv[16];
6646 unsigned char inbuf[64];
6647 unsigned char encbuf[64];
6648 unsigned char decbuf[64];
6653 memset( key, 0, 32 );
6654 memset( iv , 0, 16 );
6656 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6657 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6659 memset( inbuf, 5, 64 );
6660 memset( encbuf, 0, 64 );
6661 memset( decbuf, 0, 64 );
6665 fct_chk( NULL != cipher_info );
6689 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6696 fct_chk( outlen == enclen );
6699 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6706 fct_chk( outlen == 0 );
6711 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6718 fct_chk( enclen == outlen );
6721 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6728 fct_chk( outlen == 0 );
6732 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6740 #ifdef POLARSSL_BLOWFISH_C
6741 #ifdef POLARSSL_CIPHER_MODE_CTR
6743 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_31_bytes)
6745 unsigned char key[32];
6746 unsigned char iv[16];
6752 unsigned char inbuf[64];
6753 unsigned char encbuf[64];
6754 unsigned char decbuf[64];
6759 memset( key, 0, 32 );
6760 memset( iv , 0, 16 );
6762 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6763 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6765 memset( inbuf, 5, 64 );
6766 memset( encbuf, 0, 64 );
6767 memset( decbuf, 0, 64 );
6771 fct_chk( NULL != cipher_info );
6795 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6802 fct_chk( outlen == enclen );
6805 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6812 fct_chk( outlen == 0 );
6817 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6824 fct_chk( enclen == outlen );
6827 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6834 fct_chk( outlen == 0 );
6838 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6846 #ifdef POLARSSL_BLOWFISH_C
6847 #ifdef POLARSSL_CIPHER_MODE_CTR
6849 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_32_bytes)
6851 unsigned char key[32];
6852 unsigned char iv[16];
6858 unsigned char inbuf[64];
6859 unsigned char encbuf[64];
6860 unsigned char decbuf[64];
6865 memset( key, 0, 32 );
6866 memset( iv , 0, 16 );
6868 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6869 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6871 memset( inbuf, 5, 64 );
6872 memset( encbuf, 0, 64 );
6873 memset( decbuf, 0, 64 );
6877 fct_chk( NULL != cipher_info );
6901 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6908 fct_chk( outlen == enclen );
6911 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6918 fct_chk( outlen == 0 );
6923 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6930 fct_chk( enclen == outlen );
6933 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6940 fct_chk( outlen == 0 );
6944 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6952 #ifdef POLARSSL_BLOWFISH_C
6953 #ifdef POLARSSL_CIPHER_MODE_CTR
6955 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_32_bytes)
6957 unsigned char key[32];
6958 unsigned char iv[16];
6964 unsigned char inbuf[64];
6965 unsigned char encbuf[64];
6966 unsigned char decbuf[64];
6971 memset( key, 0, 32 );
6972 memset( iv , 0, 16 );
6974 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6975 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6977 memset( inbuf, 5, 64 );
6978 memset( encbuf, 0, 64 );
6979 memset( decbuf, 0, 64 );
6983 fct_chk( NULL != cipher_info );
7007 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
7014 fct_chk( outlen == enclen );
7017 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
7024 fct_chk( outlen == 0 );
7029 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7036 fct_chk( enclen == outlen );
7039 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7046 fct_chk( outlen == 0 );
7050 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7058 #ifdef POLARSSL_BLOWFISH_C
7059 #ifdef POLARSSL_CIPHER_MODE_CTR
7061 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_47_bytes)
7063 unsigned char key[32];
7064 unsigned char iv[16];
7070 unsigned char inbuf[64];
7071 unsigned char encbuf[64];
7072 unsigned char decbuf[64];
7077 memset( key, 0, 32 );
7078 memset( iv , 0, 16 );
7080 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7081 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7083 memset( inbuf, 5, 64 );
7084 memset( encbuf, 0, 64 );
7085 memset( decbuf, 0, 64 );
7089 fct_chk( NULL != cipher_info );
7113 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
7120 fct_chk( outlen == enclen );
7123 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
7130 fct_chk( outlen == 0 );
7135 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7142 fct_chk( enclen == outlen );
7145 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7152 fct_chk( outlen == 0 );
7156 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7164 #ifdef POLARSSL_BLOWFISH_C
7165 #ifdef POLARSSL_CIPHER_MODE_CTR
7167 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_48_bytes)
7169 unsigned char key[32];
7170 unsigned char iv[16];
7176 unsigned char inbuf[64];
7177 unsigned char encbuf[64];
7178 unsigned char decbuf[64];
7183 memset( key, 0, 32 );
7184 memset( iv , 0, 16 );
7186 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7187 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7189 memset( inbuf, 5, 64 );
7190 memset( encbuf, 0, 64 );
7191 memset( decbuf, 0, 64 );
7195 fct_chk( NULL != cipher_info );
7219 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
7226 fct_chk( outlen == enclen );
7229 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
7236 fct_chk( outlen == 0 );
7241 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7248 fct_chk( enclen == outlen );
7251 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7258 fct_chk( outlen == 0 );
7262 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7270 #ifdef POLARSSL_BLOWFISH_C
7271 #ifdef POLARSSL_CIPHER_MODE_CTR
7273 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_49_bytes)
7275 unsigned char key[32];
7276 unsigned char iv[16];
7282 unsigned char inbuf[64];
7283 unsigned char encbuf[64];
7284 unsigned char decbuf[64];
7289 memset( key, 0, 32 );
7290 memset( iv , 0, 16 );
7292 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7293 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7295 memset( inbuf, 5, 64 );
7296 memset( encbuf, 0, 64 );
7297 memset( decbuf, 0, 64 );
7301 fct_chk( NULL != cipher_info );
7325 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
7332 fct_chk( outlen == enclen );
7335 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
7342 fct_chk( outlen == 0 );
7347 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7354 fct_chk( enclen == outlen );
7357 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7364 fct_chk( outlen == 0 );
7368 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7376 #ifdef POLARSSL_BLOWFISH_C
7377 #ifdef POLARSSL_CIPHER_MODE_CTR
7379 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_0_bytes_in_multiple_parts)
7380 size_t first_length = 0;
7381 size_t second_length = 0;
7382 size_t length = first_length + second_length;
7383 unsigned char key[32];
7384 unsigned char iv[16];
7390 unsigned char inbuf[64];
7391 unsigned char encbuf[64];
7392 unsigned char decbuf[64];
7395 size_t totaloutlen = 0;
7398 memset( key, 0, 32 );
7399 memset( iv , 0, 16 );
7401 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7402 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7404 memset( inbuf, 5, 64 );
7405 memset( encbuf, 0, 64 );
7406 memset( decbuf, 0, 64 );
7410 fct_chk( NULL != cipher_info);
7432 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7433 totaloutlen = outlen;
7434 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7435 totaloutlen += outlen;
7442 fct_chk( totaloutlen == enclen );
7444 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7445 totaloutlen += outlen;
7452 fct_chk( outlen == 0 );
7456 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7463 fct_chk( enclen == outlen );
7465 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7472 fct_chk( outlen == 0 );
7476 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7484 #ifdef POLARSSL_BLOWFISH_C
7485 #ifdef POLARSSL_CIPHER_MODE_CTR
7487 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_1_bytes_in_multiple_parts_1)
7488 size_t first_length = 1;
7489 size_t second_length = 0;
7490 size_t length = first_length + second_length;
7491 unsigned char key[32];
7492 unsigned char iv[16];
7498 unsigned char inbuf[64];
7499 unsigned char encbuf[64];
7500 unsigned char decbuf[64];
7503 size_t totaloutlen = 0;
7506 memset( key, 0, 32 );
7507 memset( iv , 0, 16 );
7509 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7510 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7512 memset( inbuf, 5, 64 );
7513 memset( encbuf, 0, 64 );
7514 memset( decbuf, 0, 64 );
7518 fct_chk( NULL != cipher_info);
7540 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7541 totaloutlen = outlen;
7542 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7543 totaloutlen += outlen;
7550 fct_chk( totaloutlen == enclen );
7552 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7553 totaloutlen += outlen;
7560 fct_chk( outlen == 0 );
7564 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7571 fct_chk( enclen == outlen );
7573 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7580 fct_chk( outlen == 0 );
7584 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7592 #ifdef POLARSSL_BLOWFISH_C
7593 #ifdef POLARSSL_CIPHER_MODE_CTR
7595 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_1_bytes_in_multiple_parts_2)
7596 size_t first_length = 0;
7597 size_t second_length = 1;
7598 size_t length = first_length + second_length;
7599 unsigned char key[32];
7600 unsigned char iv[16];
7606 unsigned char inbuf[64];
7607 unsigned char encbuf[64];
7608 unsigned char decbuf[64];
7611 size_t totaloutlen = 0;
7614 memset( key, 0, 32 );
7615 memset( iv , 0, 16 );
7617 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7618 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7620 memset( inbuf, 5, 64 );
7621 memset( encbuf, 0, 64 );
7622 memset( decbuf, 0, 64 );
7626 fct_chk( NULL != cipher_info);
7648 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7649 totaloutlen = outlen;
7650 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7651 totaloutlen += outlen;
7658 fct_chk( totaloutlen == enclen );
7660 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7661 totaloutlen += outlen;
7668 fct_chk( outlen == 0 );
7672 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7679 fct_chk( enclen == outlen );
7681 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7688 fct_chk( outlen == 0 );
7692 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7700 #ifdef POLARSSL_BLOWFISH_C
7701 #ifdef POLARSSL_CIPHER_MODE_CTR
7703 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_1)
7704 size_t first_length = 16;
7705 size_t second_length = 0;
7706 size_t length = first_length + second_length;
7707 unsigned char key[32];
7708 unsigned char iv[16];
7714 unsigned char inbuf[64];
7715 unsigned char encbuf[64];
7716 unsigned char decbuf[64];
7719 size_t totaloutlen = 0;
7722 memset( key, 0, 32 );
7723 memset( iv , 0, 16 );
7725 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7726 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7728 memset( inbuf, 5, 64 );
7729 memset( encbuf, 0, 64 );
7730 memset( decbuf, 0, 64 );
7734 fct_chk( NULL != cipher_info);
7756 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7757 totaloutlen = outlen;
7758 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7759 totaloutlen += outlen;
7766 fct_chk( totaloutlen == enclen );
7768 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7769 totaloutlen += outlen;
7776 fct_chk( outlen == 0 );
7780 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7787 fct_chk( enclen == outlen );
7789 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7796 fct_chk( outlen == 0 );
7800 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7808 #ifdef POLARSSL_BLOWFISH_C
7809 #ifdef POLARSSL_CIPHER_MODE_CTR
7811 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_2)
7812 size_t first_length = 0;
7813 size_t second_length = 16;
7814 size_t length = first_length + second_length;
7815 unsigned char key[32];
7816 unsigned char iv[16];
7822 unsigned char inbuf[64];
7823 unsigned char encbuf[64];
7824 unsigned char decbuf[64];
7827 size_t totaloutlen = 0;
7830 memset( key, 0, 32 );
7831 memset( iv , 0, 16 );
7833 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7834 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7836 memset( inbuf, 5, 64 );
7837 memset( encbuf, 0, 64 );
7838 memset( decbuf, 0, 64 );
7842 fct_chk( NULL != cipher_info);
7864 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7865 totaloutlen = outlen;
7866 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7867 totaloutlen += outlen;
7874 fct_chk( totaloutlen == enclen );
7876 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7877 totaloutlen += outlen;
7884 fct_chk( outlen == 0 );
7888 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7895 fct_chk( enclen == outlen );
7897 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7904 fct_chk( outlen == 0 );
7908 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7916 #ifdef POLARSSL_BLOWFISH_C
7917 #ifdef POLARSSL_CIPHER_MODE_CTR
7919 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_3)
7920 size_t first_length = 1;
7921 size_t second_length = 15;
7922 size_t length = first_length + second_length;
7923 unsigned char key[32];
7924 unsigned char iv[16];
7930 unsigned char inbuf[64];
7931 unsigned char encbuf[64];
7932 unsigned char decbuf[64];
7935 size_t totaloutlen = 0;
7938 memset( key, 0, 32 );
7939 memset( iv , 0, 16 );
7941 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7942 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7944 memset( inbuf, 5, 64 );
7945 memset( encbuf, 0, 64 );
7946 memset( decbuf, 0, 64 );
7950 fct_chk( NULL != cipher_info);
7972 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7973 totaloutlen = outlen;
7974 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7975 totaloutlen += outlen;
7982 fct_chk( totaloutlen == enclen );
7984 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7985 totaloutlen += outlen;
7992 fct_chk( outlen == 0 );
7996 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8003 fct_chk( enclen == outlen );
8005 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8012 fct_chk( outlen == 0 );
8016 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8024 #ifdef POLARSSL_BLOWFISH_C
8025 #ifdef POLARSSL_CIPHER_MODE_CTR
8027 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_4)
8028 size_t first_length = 15;
8029 size_t second_length = 1;
8030 size_t length = first_length + second_length;
8031 unsigned char key[32];
8032 unsigned char iv[16];
8038 unsigned char inbuf[64];
8039 unsigned char encbuf[64];
8040 unsigned char decbuf[64];
8043 size_t totaloutlen = 0;
8046 memset( key, 0, 32 );
8047 memset( iv , 0, 16 );
8049 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8050 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8052 memset( inbuf, 5, 64 );
8053 memset( encbuf, 0, 64 );
8054 memset( decbuf, 0, 64 );
8058 fct_chk( NULL != cipher_info);
8080 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8081 totaloutlen = outlen;
8082 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8083 totaloutlen += outlen;
8090 fct_chk( totaloutlen == enclen );
8092 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8093 totaloutlen += outlen;
8100 fct_chk( outlen == 0 );
8104 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8111 fct_chk( enclen == outlen );
8113 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8120 fct_chk( outlen == 0 );
8124 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8132 #ifdef POLARSSL_BLOWFISH_C
8133 #ifdef POLARSSL_CIPHER_MODE_CTR
8135 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
8136 size_t first_length = 15;
8137 size_t second_length = 7;
8138 size_t length = first_length + second_length;
8139 unsigned char key[32];
8140 unsigned char iv[16];
8146 unsigned char inbuf[64];
8147 unsigned char encbuf[64];
8148 unsigned char decbuf[64];
8151 size_t totaloutlen = 0;
8154 memset( key, 0, 32 );
8155 memset( iv , 0, 16 );
8157 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8158 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8160 memset( inbuf, 5, 64 );
8161 memset( encbuf, 0, 64 );
8162 memset( decbuf, 0, 64 );
8166 fct_chk( NULL != cipher_info);
8188 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8189 totaloutlen = outlen;
8190 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8191 totaloutlen += outlen;
8198 fct_chk( totaloutlen == enclen );
8200 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8201 totaloutlen += outlen;
8208 fct_chk( outlen == 0 );
8212 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8219 fct_chk( enclen == outlen );
8221 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8228 fct_chk( outlen == 0 );
8232 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8240 #ifdef POLARSSL_BLOWFISH_C
8241 #ifdef POLARSSL_CIPHER_MODE_CTR
8243 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
8244 size_t first_length = 16;
8245 size_t second_length = 6;
8246 size_t length = first_length + second_length;
8247 unsigned char key[32];
8248 unsigned char iv[16];
8254 unsigned char inbuf[64];
8255 unsigned char encbuf[64];
8256 unsigned char decbuf[64];
8259 size_t totaloutlen = 0;
8262 memset( key, 0, 32 );
8263 memset( iv , 0, 16 );
8265 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8266 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8268 memset( inbuf, 5, 64 );
8269 memset( encbuf, 0, 64 );
8270 memset( decbuf, 0, 64 );
8274 fct_chk( NULL != cipher_info);
8296 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8297 totaloutlen = outlen;
8298 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8299 totaloutlen += outlen;
8306 fct_chk( totaloutlen == enclen );
8308 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8309 totaloutlen += outlen;
8316 fct_chk( outlen == 0 );
8320 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8327 fct_chk( enclen == outlen );
8329 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8336 fct_chk( outlen == 0 );
8340 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8348 #ifdef POLARSSL_BLOWFISH_C
8349 #ifdef POLARSSL_CIPHER_MODE_CTR
8351 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
8352 size_t first_length = 17;
8353 size_t second_length = 6;
8354 size_t length = first_length + second_length;
8355 unsigned char key[32];
8356 unsigned char iv[16];
8362 unsigned char inbuf[64];
8363 unsigned char encbuf[64];
8364 unsigned char decbuf[64];
8367 size_t totaloutlen = 0;
8370 memset( key, 0, 32 );
8371 memset( iv , 0, 16 );
8373 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8374 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8376 memset( inbuf, 5, 64 );
8377 memset( encbuf, 0, 64 );
8378 memset( decbuf, 0, 64 );
8382 fct_chk( NULL != cipher_info);
8404 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8405 totaloutlen = outlen;
8406 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8407 totaloutlen += outlen;
8414 fct_chk( totaloutlen == enclen );
8416 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8417 totaloutlen += outlen;
8424 fct_chk( outlen == 0 );
8428 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8435 fct_chk( enclen == outlen );
8437 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8444 fct_chk( outlen == 0 );
8448 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8456 #ifdef POLARSSL_BLOWFISH_C
8457 #ifdef POLARSSL_CIPHER_MODE_CTR
8459 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_32_bytes_in_multiple_parts_1)
8460 size_t first_length = 16;
8461 size_t second_length = 16;
8462 size_t length = first_length + second_length;
8463 unsigned char key[32];
8464 unsigned char iv[16];
8470 unsigned char inbuf[64];
8471 unsigned char encbuf[64];
8472 unsigned char decbuf[64];
8475 size_t totaloutlen = 0;
8478 memset( key, 0, 32 );
8479 memset( iv , 0, 16 );
8481 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8482 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8484 memset( inbuf, 5, 64 );
8485 memset( encbuf, 0, 64 );
8486 memset( decbuf, 0, 64 );
8490 fct_chk( NULL != cipher_info);
8512 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8513 totaloutlen = outlen;
8514 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8515 totaloutlen += outlen;
8522 fct_chk( totaloutlen == enclen );
8524 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8525 totaloutlen += outlen;
8532 fct_chk( outlen == 0 );
8536 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8543 fct_chk( enclen == outlen );
8545 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8552 fct_chk( outlen == 0 );
8556 fct_chk( 0 == memcmp(inbuf, decbuf, length) );