9 typedef UINT32 uint32_t;
18 #define GET_UINT32_BE(n,b,i) \
20 (n) = ( (uint32_t) (b)[(i) ] << 24 ) \
21 | ( (uint32_t) (b)[(i) + 1] << 16 ) \
22 | ( (uint32_t) (b)[(i) + 2] << 8 ) \
23 | ( (uint32_t) (b)[(i) + 3] ); \
28 #define PUT_UINT32_BE(n,b,i) \
30 (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
31 (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
32 (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
33 (b)[(i) + 3] = (unsigned char) ( (n) ); \
37 int unhexify(
unsigned char *obuf,
const char *ibuf)
40 int len = strlen(ibuf) / 2;
41 assert(!(strlen(ibuf) %1));
46 if( c >=
'0' && c <=
'9' )
48 else if( c >=
'a' && c <=
'f' )
50 else if( c >=
'A' && c <=
'F' )
56 if( c2 >=
'0' && c2 <=
'9' )
58 else if( c2 >=
'a' && c2 <=
'f' )
60 else if( c2 >=
'A' && c2 <=
'F' )
65 *obuf++ = ( c << 4 ) | c2;
71 void hexify(
unsigned char *obuf,
const unsigned char *ibuf,
int len)
83 *obuf++ =
'a' + h - 10;
88 *obuf++ =
'a' + l - 10;
104 static int rnd_std_rand(
void *rng_state,
unsigned char *output,
size_t len )
108 if( rng_state != NULL )
111 for( i = 0; i < len; ++i )
122 static int rnd_zero_rand(
void *rng_state,
unsigned char *output,
size_t len )
124 if( rng_state != NULL )
127 memset( output, 0, len );
154 if( rng_state == NULL )
163 memcpy( output, info->
buf, use_len );
164 info->
buf += use_len;
168 if( len - use_len > 0 )
169 return(
rnd_std_rand( NULL, output + use_len, len - use_len ) );
198 uint32_t i, *k, sum, delta=0x9E3779B9;
199 unsigned char result[4];
201 if( rng_state == NULL )
208 size_t use_len = ( len > 4 ) ? 4 : len;
211 for( i = 0; i < 32; i++ )
213 info->
v0 += (((info->
v1 << 4) ^ (info->
v1 >> 5)) + info->
v1) ^ (sum + k[sum & 3]);
215 info->
v1 += (((info->
v0 << 4) ^ (info->
v0 >> 5)) + info->
v0) ^ (sum + k[(sum>>11) & 3]);
219 memcpy( output, result, use_len );
229 #ifdef POLARSSL_CIPHER_C
232 FCT_SUITE_BGN(test_suite_cipher)
234 #ifdef POLARSSL_SELF_TEST
236 FCT_TEST_BGN(cipher_selftest)
244 FCT_TEST_BGN(decrypt_empty_buffer)
245 unsigned char key[32];
246 unsigned char iv[16];
251 unsigned char encbuf[64];
252 unsigned char decbuf[64];
256 memset( key, 0, 32 );
257 memset( iv , 0, 16 );
259 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
261 memset( encbuf, 0, 64 );
262 memset( decbuf, 0, 64 );
266 fct_chk( NULL != cipher_info);
275 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, 0, decbuf, &outlen ) );
276 fct_chk( 0 == outlen );
278 fct_chk( 0 == outlen );
283 #ifdef POLARSSL_BLOWFISH_C
285 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_0_bytes)
287 unsigned char key[32];
288 unsigned char iv[16];
294 unsigned char inbuf[64];
295 unsigned char encbuf[64];
296 unsigned char decbuf[64];
301 memset( key, 0, 32 );
302 memset( iv , 0, 16 );
304 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
305 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
307 memset( inbuf, 5, 64 );
308 memset( encbuf, 0, 64 );
309 memset( decbuf, 0, 64 );
313 fct_chk( NULL != cipher_info );
337 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
344 fct_chk( outlen == enclen );
347 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
354 fct_chk( outlen == 0 );
359 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
366 fct_chk( enclen == outlen );
369 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
376 fct_chk( outlen == 0 );
380 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
387 #ifdef POLARSSL_BLOWFISH_C
389 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_1_byte)
391 unsigned char key[32];
392 unsigned char iv[16];
398 unsigned char inbuf[64];
399 unsigned char encbuf[64];
400 unsigned char decbuf[64];
405 memset( key, 0, 32 );
406 memset( iv , 0, 16 );
408 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
409 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
411 memset( inbuf, 5, 64 );
412 memset( encbuf, 0, 64 );
413 memset( decbuf, 0, 64 );
417 fct_chk( NULL != cipher_info );
441 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
448 fct_chk( outlen == enclen );
451 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
458 fct_chk( outlen == 0 );
463 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
470 fct_chk( enclen == outlen );
473 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
480 fct_chk( outlen == 0 );
484 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
491 #ifdef POLARSSL_BLOWFISH_C
493 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_2_bytes)
495 unsigned char key[32];
496 unsigned char iv[16];
502 unsigned char inbuf[64];
503 unsigned char encbuf[64];
504 unsigned char decbuf[64];
509 memset( key, 0, 32 );
510 memset( iv , 0, 16 );
512 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
513 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
515 memset( inbuf, 5, 64 );
516 memset( encbuf, 0, 64 );
517 memset( decbuf, 0, 64 );
521 fct_chk( NULL != cipher_info );
545 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
552 fct_chk( outlen == enclen );
555 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
562 fct_chk( outlen == 0 );
567 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
574 fct_chk( enclen == outlen );
577 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
584 fct_chk( outlen == 0 );
588 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
595 #ifdef POLARSSL_BLOWFISH_C
597 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_7_bytes)
599 unsigned char key[32];
600 unsigned char iv[16];
606 unsigned char inbuf[64];
607 unsigned char encbuf[64];
608 unsigned char decbuf[64];
613 memset( key, 0, 32 );
614 memset( iv , 0, 16 );
616 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
617 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
619 memset( inbuf, 5, 64 );
620 memset( encbuf, 0, 64 );
621 memset( decbuf, 0, 64 );
625 fct_chk( NULL != cipher_info );
649 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
656 fct_chk( outlen == enclen );
659 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
666 fct_chk( outlen == 0 );
671 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
678 fct_chk( enclen == outlen );
681 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
688 fct_chk( outlen == 0 );
692 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
699 #ifdef POLARSSL_BLOWFISH_C
701 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_8_bytes)
703 unsigned char key[32];
704 unsigned char iv[16];
710 unsigned char inbuf[64];
711 unsigned char encbuf[64];
712 unsigned char decbuf[64];
717 memset( key, 0, 32 );
718 memset( iv , 0, 16 );
720 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
721 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
723 memset( inbuf, 5, 64 );
724 memset( encbuf, 0, 64 );
725 memset( decbuf, 0, 64 );
729 fct_chk( NULL != cipher_info );
753 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
760 fct_chk( outlen == enclen );
763 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
770 fct_chk( outlen == 0 );
775 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
782 fct_chk( enclen == outlen );
785 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
792 fct_chk( outlen == 0 );
796 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
803 #ifdef POLARSSL_BLOWFISH_C
805 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_9_bytes)
807 unsigned char key[32];
808 unsigned char iv[16];
814 unsigned char inbuf[64];
815 unsigned char encbuf[64];
816 unsigned char decbuf[64];
821 memset( key, 0, 32 );
822 memset( iv , 0, 16 );
824 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
825 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
827 memset( inbuf, 5, 64 );
828 memset( encbuf, 0, 64 );
829 memset( decbuf, 0, 64 );
833 fct_chk( NULL != cipher_info );
857 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
864 fct_chk( outlen == enclen );
867 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
874 fct_chk( outlen == 0 );
879 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
886 fct_chk( enclen == outlen );
889 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
896 fct_chk( outlen == 0 );
900 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
907 #ifdef POLARSSL_BLOWFISH_C
909 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_15_bytes)
911 unsigned char key[32];
912 unsigned char iv[16];
918 unsigned char inbuf[64];
919 unsigned char encbuf[64];
920 unsigned char decbuf[64];
925 memset( key, 0, 32 );
926 memset( iv , 0, 16 );
928 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
929 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
931 memset( inbuf, 5, 64 );
932 memset( encbuf, 0, 64 );
933 memset( decbuf, 0, 64 );
937 fct_chk( NULL != cipher_info );
961 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
968 fct_chk( outlen == enclen );
971 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
978 fct_chk( outlen == 0 );
983 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
990 fct_chk( enclen == outlen );
993 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1000 fct_chk( outlen == 0 );
1004 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1011 #ifdef POLARSSL_BLOWFISH_C
1013 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes)
1015 unsigned char key[32];
1016 unsigned char iv[16];
1022 unsigned char inbuf[64];
1023 unsigned char encbuf[64];
1024 unsigned char decbuf[64];
1029 memset( key, 0, 32 );
1030 memset( iv , 0, 16 );
1032 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1033 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1035 memset( inbuf, 5, 64 );
1036 memset( encbuf, 0, 64 );
1037 memset( decbuf, 0, 64 );
1041 fct_chk( NULL != cipher_info );
1065 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1072 fct_chk( outlen == enclen );
1075 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1082 fct_chk( outlen == 0 );
1087 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1094 fct_chk( enclen == outlen );
1097 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1104 fct_chk( outlen == 0 );
1108 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1115 #ifdef POLARSSL_BLOWFISH_C
1117 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_17_bytes)
1119 unsigned char key[32];
1120 unsigned char iv[16];
1126 unsigned char inbuf[64];
1127 unsigned char encbuf[64];
1128 unsigned char decbuf[64];
1133 memset( key, 0, 32 );
1134 memset( iv , 0, 16 );
1136 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1137 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1139 memset( inbuf, 5, 64 );
1140 memset( encbuf, 0, 64 );
1141 memset( decbuf, 0, 64 );
1145 fct_chk( NULL != cipher_info );
1169 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1176 fct_chk( outlen == enclen );
1179 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1186 fct_chk( outlen == 0 );
1191 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1198 fct_chk( enclen == outlen );
1201 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1208 fct_chk( outlen == 0 );
1212 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1219 #ifdef POLARSSL_BLOWFISH_C
1221 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_31_bytes)
1223 unsigned char key[32];
1224 unsigned char iv[16];
1230 unsigned char inbuf[64];
1231 unsigned char encbuf[64];
1232 unsigned char decbuf[64];
1237 memset( key, 0, 32 );
1238 memset( iv , 0, 16 );
1240 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1241 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1243 memset( inbuf, 5, 64 );
1244 memset( encbuf, 0, 64 );
1245 memset( decbuf, 0, 64 );
1249 fct_chk( NULL != cipher_info );
1273 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1280 fct_chk( outlen == enclen );
1283 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1290 fct_chk( outlen == 0 );
1295 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1302 fct_chk( enclen == outlen );
1305 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1312 fct_chk( outlen == 0 );
1316 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1323 #ifdef POLARSSL_BLOWFISH_C
1325 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_32_bytes)
1327 unsigned char key[32];
1328 unsigned char iv[16];
1334 unsigned char inbuf[64];
1335 unsigned char encbuf[64];
1336 unsigned char decbuf[64];
1341 memset( key, 0, 32 );
1342 memset( iv , 0, 16 );
1344 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1345 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1347 memset( inbuf, 5, 64 );
1348 memset( encbuf, 0, 64 );
1349 memset( decbuf, 0, 64 );
1353 fct_chk( NULL != cipher_info );
1377 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1384 fct_chk( outlen == enclen );
1387 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1394 fct_chk( outlen == 0 );
1399 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1406 fct_chk( enclen == outlen );
1409 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1416 fct_chk( outlen == 0 );
1420 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1427 #ifdef POLARSSL_BLOWFISH_C
1429 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_32_bytes)
1431 unsigned char key[32];
1432 unsigned char iv[16];
1438 unsigned char inbuf[64];
1439 unsigned char encbuf[64];
1440 unsigned char decbuf[64];
1445 memset( key, 0, 32 );
1446 memset( iv , 0, 16 );
1448 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1449 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1451 memset( inbuf, 5, 64 );
1452 memset( encbuf, 0, 64 );
1453 memset( decbuf, 0, 64 );
1457 fct_chk( NULL != cipher_info );
1481 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1488 fct_chk( outlen == enclen );
1491 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1498 fct_chk( outlen == 0 );
1503 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1510 fct_chk( enclen == outlen );
1513 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1520 fct_chk( outlen == 0 );
1524 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1531 #ifdef POLARSSL_BLOWFISH_C
1533 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_47_bytes)
1535 unsigned char key[32];
1536 unsigned char iv[16];
1542 unsigned char inbuf[64];
1543 unsigned char encbuf[64];
1544 unsigned char decbuf[64];
1549 memset( key, 0, 32 );
1550 memset( iv , 0, 16 );
1552 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1553 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1555 memset( inbuf, 5, 64 );
1556 memset( encbuf, 0, 64 );
1557 memset( decbuf, 0, 64 );
1561 fct_chk( NULL != cipher_info );
1585 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1592 fct_chk( outlen == enclen );
1595 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1602 fct_chk( outlen == 0 );
1607 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1614 fct_chk( enclen == outlen );
1617 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1624 fct_chk( outlen == 0 );
1628 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1635 #ifdef POLARSSL_BLOWFISH_C
1637 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_48_bytes)
1639 unsigned char key[32];
1640 unsigned char iv[16];
1646 unsigned char inbuf[64];
1647 unsigned char encbuf[64];
1648 unsigned char decbuf[64];
1653 memset( key, 0, 32 );
1654 memset( iv , 0, 16 );
1656 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1657 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1659 memset( inbuf, 5, 64 );
1660 memset( encbuf, 0, 64 );
1661 memset( decbuf, 0, 64 );
1665 fct_chk( NULL != cipher_info );
1689 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1696 fct_chk( outlen == enclen );
1699 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1706 fct_chk( outlen == 0 );
1711 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1718 fct_chk( enclen == outlen );
1721 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1728 fct_chk( outlen == 0 );
1732 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1739 #ifdef POLARSSL_BLOWFISH_C
1741 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_49_bytes)
1743 unsigned char key[32];
1744 unsigned char iv[16];
1750 unsigned char inbuf[64];
1751 unsigned char encbuf[64];
1752 unsigned char decbuf[64];
1757 memset( key, 0, 32 );
1758 memset( iv , 0, 16 );
1760 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1761 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1763 memset( inbuf, 5, 64 );
1764 memset( encbuf, 0, 64 );
1765 memset( decbuf, 0, 64 );
1769 fct_chk( NULL != cipher_info );
1793 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1800 fct_chk( outlen == enclen );
1803 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1810 fct_chk( outlen == 0 );
1815 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1822 fct_chk( enclen == outlen );
1825 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1832 fct_chk( outlen == 0 );
1836 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1843 #ifdef POLARSSL_BLOWFISH_C
1845 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_0_bytes_in_multiple_parts)
1846 size_t first_length = 0;
1847 size_t second_length = 0;
1848 size_t length = first_length + second_length;
1849 unsigned char key[32];
1850 unsigned char iv[16];
1856 unsigned char inbuf[64];
1857 unsigned char encbuf[64];
1858 unsigned char decbuf[64];
1861 size_t totaloutlen = 0;
1864 memset( key, 0, 32 );
1865 memset( iv , 0, 16 );
1867 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1868 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1870 memset( inbuf, 5, 64 );
1871 memset( encbuf, 0, 64 );
1872 memset( decbuf, 0, 64 );
1876 fct_chk( NULL != cipher_info);
1898 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
1899 totaloutlen = outlen;
1900 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
1901 totaloutlen += outlen;
1908 fct_chk( totaloutlen == enclen );
1910 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
1911 totaloutlen += outlen;
1918 fct_chk( outlen == 0 );
1922 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1929 fct_chk( enclen == outlen );
1931 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1938 fct_chk( outlen == 0 );
1942 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1949 #ifdef POLARSSL_BLOWFISH_C
1951 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_1_bytes_in_multiple_parts_1)
1952 size_t first_length = 1;
1953 size_t second_length = 0;
1954 size_t length = first_length + second_length;
1955 unsigned char key[32];
1956 unsigned char iv[16];
1962 unsigned char inbuf[64];
1963 unsigned char encbuf[64];
1964 unsigned char decbuf[64];
1967 size_t totaloutlen = 0;
1970 memset( key, 0, 32 );
1971 memset( iv , 0, 16 );
1973 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1974 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1976 memset( inbuf, 5, 64 );
1977 memset( encbuf, 0, 64 );
1978 memset( decbuf, 0, 64 );
1982 fct_chk( NULL != cipher_info);
2004 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2005 totaloutlen = outlen;
2006 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2007 totaloutlen += outlen;
2014 fct_chk( totaloutlen == enclen );
2016 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2017 totaloutlen += outlen;
2024 fct_chk( outlen == 0 );
2028 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2035 fct_chk( enclen == outlen );
2037 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2044 fct_chk( outlen == 0 );
2048 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2055 #ifdef POLARSSL_BLOWFISH_C
2057 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_1_bytes_in_multiple_parts_2)
2058 size_t first_length = 0;
2059 size_t second_length = 1;
2060 size_t length = first_length + second_length;
2061 unsigned char key[32];
2062 unsigned char iv[16];
2068 unsigned char inbuf[64];
2069 unsigned char encbuf[64];
2070 unsigned char decbuf[64];
2073 size_t totaloutlen = 0;
2076 memset( key, 0, 32 );
2077 memset( iv , 0, 16 );
2079 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2080 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2082 memset( inbuf, 5, 64 );
2083 memset( encbuf, 0, 64 );
2084 memset( decbuf, 0, 64 );
2088 fct_chk( NULL != cipher_info);
2110 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2111 totaloutlen = outlen;
2112 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2113 totaloutlen += outlen;
2120 fct_chk( totaloutlen == enclen );
2122 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2123 totaloutlen += outlen;
2130 fct_chk( outlen == 0 );
2134 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2141 fct_chk( enclen == outlen );
2143 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2150 fct_chk( outlen == 0 );
2154 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2161 #ifdef POLARSSL_BLOWFISH_C
2163 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_1)
2164 size_t first_length = 16;
2165 size_t second_length = 0;
2166 size_t length = first_length + second_length;
2167 unsigned char key[32];
2168 unsigned char iv[16];
2174 unsigned char inbuf[64];
2175 unsigned char encbuf[64];
2176 unsigned char decbuf[64];
2179 size_t totaloutlen = 0;
2182 memset( key, 0, 32 );
2183 memset( iv , 0, 16 );
2185 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2186 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2188 memset( inbuf, 5, 64 );
2189 memset( encbuf, 0, 64 );
2190 memset( decbuf, 0, 64 );
2194 fct_chk( NULL != cipher_info);
2216 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2217 totaloutlen = outlen;
2218 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2219 totaloutlen += outlen;
2226 fct_chk( totaloutlen == enclen );
2228 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2229 totaloutlen += outlen;
2236 fct_chk( outlen == 0 );
2240 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2247 fct_chk( enclen == outlen );
2249 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2256 fct_chk( outlen == 0 );
2260 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2267 #ifdef POLARSSL_BLOWFISH_C
2269 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_2)
2270 size_t first_length = 0;
2271 size_t second_length = 16;
2272 size_t length = first_length + second_length;
2273 unsigned char key[32];
2274 unsigned char iv[16];
2280 unsigned char inbuf[64];
2281 unsigned char encbuf[64];
2282 unsigned char decbuf[64];
2285 size_t totaloutlen = 0;
2288 memset( key, 0, 32 );
2289 memset( iv , 0, 16 );
2291 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2292 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2294 memset( inbuf, 5, 64 );
2295 memset( encbuf, 0, 64 );
2296 memset( decbuf, 0, 64 );
2300 fct_chk( NULL != cipher_info);
2322 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2323 totaloutlen = outlen;
2324 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2325 totaloutlen += outlen;
2332 fct_chk( totaloutlen == enclen );
2334 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2335 totaloutlen += outlen;
2342 fct_chk( outlen == 0 );
2346 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2353 fct_chk( enclen == outlen );
2355 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2362 fct_chk( outlen == 0 );
2366 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2373 #ifdef POLARSSL_BLOWFISH_C
2375 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_3)
2376 size_t first_length = 1;
2377 size_t second_length = 15;
2378 size_t length = first_length + second_length;
2379 unsigned char key[32];
2380 unsigned char iv[16];
2386 unsigned char inbuf[64];
2387 unsigned char encbuf[64];
2388 unsigned char decbuf[64];
2391 size_t totaloutlen = 0;
2394 memset( key, 0, 32 );
2395 memset( iv , 0, 16 );
2397 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2398 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2400 memset( inbuf, 5, 64 );
2401 memset( encbuf, 0, 64 );
2402 memset( decbuf, 0, 64 );
2406 fct_chk( NULL != cipher_info);
2428 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2429 totaloutlen = outlen;
2430 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2431 totaloutlen += outlen;
2438 fct_chk( totaloutlen == enclen );
2440 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2441 totaloutlen += outlen;
2448 fct_chk( outlen == 0 );
2452 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2459 fct_chk( enclen == outlen );
2461 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2468 fct_chk( outlen == 0 );
2472 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2479 #ifdef POLARSSL_BLOWFISH_C
2481 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_4)
2482 size_t first_length = 15;
2483 size_t second_length = 1;
2484 size_t length = first_length + second_length;
2485 unsigned char key[32];
2486 unsigned char iv[16];
2492 unsigned char inbuf[64];
2493 unsigned char encbuf[64];
2494 unsigned char decbuf[64];
2497 size_t totaloutlen = 0;
2500 memset( key, 0, 32 );
2501 memset( iv , 0, 16 );
2503 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2504 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2506 memset( inbuf, 5, 64 );
2507 memset( encbuf, 0, 64 );
2508 memset( decbuf, 0, 64 );
2512 fct_chk( NULL != cipher_info);
2534 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2535 totaloutlen = outlen;
2536 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2537 totaloutlen += outlen;
2544 fct_chk( totaloutlen == enclen );
2546 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2547 totaloutlen += outlen;
2554 fct_chk( outlen == 0 );
2558 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2565 fct_chk( enclen == outlen );
2567 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2574 fct_chk( outlen == 0 );
2578 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2585 #ifdef POLARSSL_BLOWFISH_C
2587 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
2588 size_t first_length = 15;
2589 size_t second_length = 7;
2590 size_t length = first_length + second_length;
2591 unsigned char key[32];
2592 unsigned char iv[16];
2598 unsigned char inbuf[64];
2599 unsigned char encbuf[64];
2600 unsigned char decbuf[64];
2603 size_t totaloutlen = 0;
2606 memset( key, 0, 32 );
2607 memset( iv , 0, 16 );
2609 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2610 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2612 memset( inbuf, 5, 64 );
2613 memset( encbuf, 0, 64 );
2614 memset( decbuf, 0, 64 );
2618 fct_chk( NULL != cipher_info);
2640 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2641 totaloutlen = outlen;
2642 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2643 totaloutlen += outlen;
2650 fct_chk( totaloutlen == enclen );
2652 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2653 totaloutlen += outlen;
2660 fct_chk( outlen == 0 );
2664 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2671 fct_chk( enclen == outlen );
2673 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2680 fct_chk( outlen == 0 );
2684 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2691 #ifdef POLARSSL_BLOWFISH_C
2693 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
2694 size_t first_length = 16;
2695 size_t second_length = 6;
2696 size_t length = first_length + second_length;
2697 unsigned char key[32];
2698 unsigned char iv[16];
2704 unsigned char inbuf[64];
2705 unsigned char encbuf[64];
2706 unsigned char decbuf[64];
2709 size_t totaloutlen = 0;
2712 memset( key, 0, 32 );
2713 memset( iv , 0, 16 );
2715 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2716 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2718 memset( inbuf, 5, 64 );
2719 memset( encbuf, 0, 64 );
2720 memset( decbuf, 0, 64 );
2724 fct_chk( NULL != cipher_info);
2746 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2747 totaloutlen = outlen;
2748 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2749 totaloutlen += outlen;
2756 fct_chk( totaloutlen == enclen );
2758 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2759 totaloutlen += outlen;
2766 fct_chk( outlen == 0 );
2770 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2777 fct_chk( enclen == outlen );
2779 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2786 fct_chk( outlen == 0 );
2790 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2797 #ifdef POLARSSL_BLOWFISH_C
2799 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
2800 size_t first_length = 17;
2801 size_t second_length = 6;
2802 size_t length = first_length + second_length;
2803 unsigned char key[32];
2804 unsigned char iv[16];
2810 unsigned char inbuf[64];
2811 unsigned char encbuf[64];
2812 unsigned char decbuf[64];
2815 size_t totaloutlen = 0;
2818 memset( key, 0, 32 );
2819 memset( iv , 0, 16 );
2821 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2822 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2824 memset( inbuf, 5, 64 );
2825 memset( encbuf, 0, 64 );
2826 memset( decbuf, 0, 64 );
2830 fct_chk( NULL != cipher_info);
2852 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2853 totaloutlen = outlen;
2854 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2855 totaloutlen += outlen;
2862 fct_chk( totaloutlen == enclen );
2864 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2865 totaloutlen += outlen;
2872 fct_chk( outlen == 0 );
2876 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2883 fct_chk( enclen == outlen );
2885 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2892 fct_chk( outlen == 0 );
2896 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2903 #ifdef POLARSSL_BLOWFISH_C
2905 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_32_bytes_in_multiple_parts_1)
2906 size_t first_length = 16;
2907 size_t second_length = 16;
2908 size_t length = first_length + second_length;
2909 unsigned char key[32];
2910 unsigned char iv[16];
2916 unsigned char inbuf[64];
2917 unsigned char encbuf[64];
2918 unsigned char decbuf[64];
2921 size_t totaloutlen = 0;
2924 memset( key, 0, 32 );
2925 memset( iv , 0, 16 );
2927 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2928 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2930 memset( inbuf, 5, 64 );
2931 memset( encbuf, 0, 64 );
2932 memset( decbuf, 0, 64 );
2936 fct_chk( NULL != cipher_info);
2958 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2959 totaloutlen = outlen;
2960 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2961 totaloutlen += outlen;
2968 fct_chk( totaloutlen == enclen );
2970 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2971 totaloutlen += outlen;
2978 fct_chk( outlen == 0 );
2982 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2989 fct_chk( enclen == outlen );
2991 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2998 fct_chk( outlen == 0 );
3002 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3009 #ifdef POLARSSL_BLOWFISH_C
3010 #ifdef POLARSSL_CIPHER_MODE_CFB
3012 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_0_bytes)
3014 unsigned char key[32];
3015 unsigned char iv[16];
3021 unsigned char inbuf[64];
3022 unsigned char encbuf[64];
3023 unsigned char decbuf[64];
3028 memset( key, 0, 32 );
3029 memset( iv , 0, 16 );
3031 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3032 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3034 memset( inbuf, 5, 64 );
3035 memset( encbuf, 0, 64 );
3036 memset( decbuf, 0, 64 );
3040 fct_chk( NULL != cipher_info );
3064 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3071 fct_chk( outlen == enclen );
3074 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3081 fct_chk( outlen == 0 );
3086 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3093 fct_chk( enclen == outlen );
3096 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3103 fct_chk( outlen == 0 );
3107 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3115 #ifdef POLARSSL_BLOWFISH_C
3116 #ifdef POLARSSL_CIPHER_MODE_CFB
3118 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_1_byte)
3120 unsigned char key[32];
3121 unsigned char iv[16];
3127 unsigned char inbuf[64];
3128 unsigned char encbuf[64];
3129 unsigned char decbuf[64];
3134 memset( key, 0, 32 );
3135 memset( iv , 0, 16 );
3137 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3138 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3140 memset( inbuf, 5, 64 );
3141 memset( encbuf, 0, 64 );
3142 memset( decbuf, 0, 64 );
3146 fct_chk( NULL != cipher_info );
3170 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3177 fct_chk( outlen == enclen );
3180 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3187 fct_chk( outlen == 0 );
3192 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3199 fct_chk( enclen == outlen );
3202 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3209 fct_chk( outlen == 0 );
3213 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3221 #ifdef POLARSSL_BLOWFISH_C
3222 #ifdef POLARSSL_CIPHER_MODE_CFB
3224 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_2_bytes)
3226 unsigned char key[32];
3227 unsigned char iv[16];
3233 unsigned char inbuf[64];
3234 unsigned char encbuf[64];
3235 unsigned char decbuf[64];
3240 memset( key, 0, 32 );
3241 memset( iv , 0, 16 );
3243 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3244 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3246 memset( inbuf, 5, 64 );
3247 memset( encbuf, 0, 64 );
3248 memset( decbuf, 0, 64 );
3252 fct_chk( NULL != cipher_info );
3276 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3283 fct_chk( outlen == enclen );
3286 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3293 fct_chk( outlen == 0 );
3298 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3305 fct_chk( enclen == outlen );
3308 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3315 fct_chk( outlen == 0 );
3319 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3327 #ifdef POLARSSL_BLOWFISH_C
3328 #ifdef POLARSSL_CIPHER_MODE_CFB
3330 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_7_bytes)
3332 unsigned char key[32];
3333 unsigned char iv[16];
3339 unsigned char inbuf[64];
3340 unsigned char encbuf[64];
3341 unsigned char decbuf[64];
3346 memset( key, 0, 32 );
3347 memset( iv , 0, 16 );
3349 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3350 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3352 memset( inbuf, 5, 64 );
3353 memset( encbuf, 0, 64 );
3354 memset( decbuf, 0, 64 );
3358 fct_chk( NULL != cipher_info );
3382 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3389 fct_chk( outlen == enclen );
3392 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3399 fct_chk( outlen == 0 );
3404 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3411 fct_chk( enclen == outlen );
3414 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3421 fct_chk( outlen == 0 );
3425 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3433 #ifdef POLARSSL_BLOWFISH_C
3434 #ifdef POLARSSL_CIPHER_MODE_CFB
3436 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_8_bytes)
3438 unsigned char key[32];
3439 unsigned char iv[16];
3445 unsigned char inbuf[64];
3446 unsigned char encbuf[64];
3447 unsigned char decbuf[64];
3452 memset( key, 0, 32 );
3453 memset( iv , 0, 16 );
3455 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3456 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3458 memset( inbuf, 5, 64 );
3459 memset( encbuf, 0, 64 );
3460 memset( decbuf, 0, 64 );
3464 fct_chk( NULL != cipher_info );
3488 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3495 fct_chk( outlen == enclen );
3498 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3505 fct_chk( outlen == 0 );
3510 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3517 fct_chk( enclen == outlen );
3520 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3527 fct_chk( outlen == 0 );
3531 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3539 #ifdef POLARSSL_BLOWFISH_C
3540 #ifdef POLARSSL_CIPHER_MODE_CFB
3542 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_9_bytes)
3544 unsigned char key[32];
3545 unsigned char iv[16];
3551 unsigned char inbuf[64];
3552 unsigned char encbuf[64];
3553 unsigned char decbuf[64];
3558 memset( key, 0, 32 );
3559 memset( iv , 0, 16 );
3561 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3562 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3564 memset( inbuf, 5, 64 );
3565 memset( encbuf, 0, 64 );
3566 memset( decbuf, 0, 64 );
3570 fct_chk( NULL != cipher_info );
3594 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3601 fct_chk( outlen == enclen );
3604 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3611 fct_chk( outlen == 0 );
3616 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3623 fct_chk( enclen == outlen );
3626 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3633 fct_chk( outlen == 0 );
3637 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3645 #ifdef POLARSSL_BLOWFISH_C
3646 #ifdef POLARSSL_CIPHER_MODE_CFB
3648 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_15_bytes)
3650 unsigned char key[32];
3651 unsigned char iv[16];
3657 unsigned char inbuf[64];
3658 unsigned char encbuf[64];
3659 unsigned char decbuf[64];
3664 memset( key, 0, 32 );
3665 memset( iv , 0, 16 );
3667 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3668 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3670 memset( inbuf, 5, 64 );
3671 memset( encbuf, 0, 64 );
3672 memset( decbuf, 0, 64 );
3676 fct_chk( NULL != cipher_info );
3700 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3707 fct_chk( outlen == enclen );
3710 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3717 fct_chk( outlen == 0 );
3722 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3729 fct_chk( enclen == outlen );
3732 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3739 fct_chk( outlen == 0 );
3743 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3751 #ifdef POLARSSL_BLOWFISH_C
3752 #ifdef POLARSSL_CIPHER_MODE_CFB
3754 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes)
3756 unsigned char key[32];
3757 unsigned char iv[16];
3763 unsigned char inbuf[64];
3764 unsigned char encbuf[64];
3765 unsigned char decbuf[64];
3770 memset( key, 0, 32 );
3771 memset( iv , 0, 16 );
3773 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3774 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3776 memset( inbuf, 5, 64 );
3777 memset( encbuf, 0, 64 );
3778 memset( decbuf, 0, 64 );
3782 fct_chk( NULL != cipher_info );
3806 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3813 fct_chk( outlen == enclen );
3816 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3823 fct_chk( outlen == 0 );
3828 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3835 fct_chk( enclen == outlen );
3838 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3845 fct_chk( outlen == 0 );
3849 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3857 #ifdef POLARSSL_BLOWFISH_C
3858 #ifdef POLARSSL_CIPHER_MODE_CFB
3860 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_17_bytes)
3862 unsigned char key[32];
3863 unsigned char iv[16];
3869 unsigned char inbuf[64];
3870 unsigned char encbuf[64];
3871 unsigned char decbuf[64];
3876 memset( key, 0, 32 );
3877 memset( iv , 0, 16 );
3879 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3880 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3882 memset( inbuf, 5, 64 );
3883 memset( encbuf, 0, 64 );
3884 memset( decbuf, 0, 64 );
3888 fct_chk( NULL != cipher_info );
3912 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3919 fct_chk( outlen == enclen );
3922 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3929 fct_chk( outlen == 0 );
3934 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3941 fct_chk( enclen == outlen );
3944 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3951 fct_chk( outlen == 0 );
3955 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3963 #ifdef POLARSSL_BLOWFISH_C
3964 #ifdef POLARSSL_CIPHER_MODE_CFB
3966 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_31_bytes)
3968 unsigned char key[32];
3969 unsigned char iv[16];
3975 unsigned char inbuf[64];
3976 unsigned char encbuf[64];
3977 unsigned char decbuf[64];
3982 memset( key, 0, 32 );
3983 memset( iv , 0, 16 );
3985 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3986 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3988 memset( inbuf, 5, 64 );
3989 memset( encbuf, 0, 64 );
3990 memset( decbuf, 0, 64 );
3994 fct_chk( NULL != cipher_info );
4018 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4025 fct_chk( outlen == enclen );
4028 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4035 fct_chk( outlen == 0 );
4040 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4047 fct_chk( enclen == outlen );
4050 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4057 fct_chk( outlen == 0 );
4061 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4069 #ifdef POLARSSL_BLOWFISH_C
4070 #ifdef POLARSSL_CIPHER_MODE_CFB
4072 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_32_bytes)
4074 unsigned char key[32];
4075 unsigned char iv[16];
4081 unsigned char inbuf[64];
4082 unsigned char encbuf[64];
4083 unsigned char decbuf[64];
4088 memset( key, 0, 32 );
4089 memset( iv , 0, 16 );
4091 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4092 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4094 memset( inbuf, 5, 64 );
4095 memset( encbuf, 0, 64 );
4096 memset( decbuf, 0, 64 );
4100 fct_chk( NULL != cipher_info );
4124 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4131 fct_chk( outlen == enclen );
4134 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4141 fct_chk( outlen == 0 );
4146 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4153 fct_chk( enclen == outlen );
4156 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4163 fct_chk( outlen == 0 );
4167 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4175 #ifdef POLARSSL_BLOWFISH_C
4176 #ifdef POLARSSL_CIPHER_MODE_CFB
4178 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_32_bytes)
4180 unsigned char key[32];
4181 unsigned char iv[16];
4187 unsigned char inbuf[64];
4188 unsigned char encbuf[64];
4189 unsigned char decbuf[64];
4194 memset( key, 0, 32 );
4195 memset( iv , 0, 16 );
4197 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4198 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4200 memset( inbuf, 5, 64 );
4201 memset( encbuf, 0, 64 );
4202 memset( decbuf, 0, 64 );
4206 fct_chk( NULL != cipher_info );
4230 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4237 fct_chk( outlen == enclen );
4240 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4247 fct_chk( outlen == 0 );
4252 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4259 fct_chk( enclen == outlen );
4262 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4269 fct_chk( outlen == 0 );
4273 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4281 #ifdef POLARSSL_BLOWFISH_C
4282 #ifdef POLARSSL_CIPHER_MODE_CFB
4284 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_47_bytes)
4286 unsigned char key[32];
4287 unsigned char iv[16];
4293 unsigned char inbuf[64];
4294 unsigned char encbuf[64];
4295 unsigned char decbuf[64];
4300 memset( key, 0, 32 );
4301 memset( iv , 0, 16 );
4303 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4304 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4306 memset( inbuf, 5, 64 );
4307 memset( encbuf, 0, 64 );
4308 memset( decbuf, 0, 64 );
4312 fct_chk( NULL != cipher_info );
4336 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4343 fct_chk( outlen == enclen );
4346 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4353 fct_chk( outlen == 0 );
4358 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4365 fct_chk( enclen == outlen );
4368 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4375 fct_chk( outlen == 0 );
4379 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4387 #ifdef POLARSSL_BLOWFISH_C
4388 #ifdef POLARSSL_CIPHER_MODE_CFB
4390 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_48_bytes)
4392 unsigned char key[32];
4393 unsigned char iv[16];
4399 unsigned char inbuf[64];
4400 unsigned char encbuf[64];
4401 unsigned char decbuf[64];
4406 memset( key, 0, 32 );
4407 memset( iv , 0, 16 );
4409 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4410 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4412 memset( inbuf, 5, 64 );
4413 memset( encbuf, 0, 64 );
4414 memset( decbuf, 0, 64 );
4418 fct_chk( NULL != cipher_info );
4442 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4449 fct_chk( outlen == enclen );
4452 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4459 fct_chk( outlen == 0 );
4464 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4471 fct_chk( enclen == outlen );
4474 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4481 fct_chk( outlen == 0 );
4485 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4493 #ifdef POLARSSL_BLOWFISH_C
4494 #ifdef POLARSSL_CIPHER_MODE_CFB
4496 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_49_bytes)
4498 unsigned char key[32];
4499 unsigned char iv[16];
4505 unsigned char inbuf[64];
4506 unsigned char encbuf[64];
4507 unsigned char decbuf[64];
4512 memset( key, 0, 32 );
4513 memset( iv , 0, 16 );
4515 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4516 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4518 memset( inbuf, 5, 64 );
4519 memset( encbuf, 0, 64 );
4520 memset( decbuf, 0, 64 );
4524 fct_chk( NULL != cipher_info );
4548 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4555 fct_chk( outlen == enclen );
4558 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4565 fct_chk( outlen == 0 );
4570 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4577 fct_chk( enclen == outlen );
4580 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4587 fct_chk( outlen == 0 );
4591 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4599 #ifdef POLARSSL_BLOWFISH_C
4600 #ifdef POLARSSL_CIPHER_MODE_CFB
4602 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_0_bytes_in_multiple_parts)
4603 size_t first_length = 0;
4604 size_t second_length = 0;
4605 size_t length = first_length + second_length;
4606 unsigned char key[32];
4607 unsigned char iv[16];
4613 unsigned char inbuf[64];
4614 unsigned char encbuf[64];
4615 unsigned char decbuf[64];
4618 size_t totaloutlen = 0;
4621 memset( key, 0, 32 );
4622 memset( iv , 0, 16 );
4624 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4625 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4627 memset( inbuf, 5, 64 );
4628 memset( encbuf, 0, 64 );
4629 memset( decbuf, 0, 64 );
4633 fct_chk( NULL != cipher_info);
4655 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4656 totaloutlen = outlen;
4657 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4658 totaloutlen += outlen;
4665 fct_chk( totaloutlen == enclen );
4667 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4668 totaloutlen += outlen;
4675 fct_chk( outlen == 0 );
4679 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4686 fct_chk( enclen == outlen );
4688 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4695 fct_chk( outlen == 0 );
4699 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4707 #ifdef POLARSSL_BLOWFISH_C
4708 #ifdef POLARSSL_CIPHER_MODE_CFB
4710 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_1_bytes_in_multiple_parts_1)
4711 size_t first_length = 1;
4712 size_t second_length = 0;
4713 size_t length = first_length + second_length;
4714 unsigned char key[32];
4715 unsigned char iv[16];
4721 unsigned char inbuf[64];
4722 unsigned char encbuf[64];
4723 unsigned char decbuf[64];
4726 size_t totaloutlen = 0;
4729 memset( key, 0, 32 );
4730 memset( iv , 0, 16 );
4732 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4733 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4735 memset( inbuf, 5, 64 );
4736 memset( encbuf, 0, 64 );
4737 memset( decbuf, 0, 64 );
4741 fct_chk( NULL != cipher_info);
4763 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4764 totaloutlen = outlen;
4765 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4766 totaloutlen += outlen;
4773 fct_chk( totaloutlen == enclen );
4775 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4776 totaloutlen += outlen;
4783 fct_chk( outlen == 0 );
4787 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4794 fct_chk( enclen == outlen );
4796 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4803 fct_chk( outlen == 0 );
4807 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4815 #ifdef POLARSSL_BLOWFISH_C
4816 #ifdef POLARSSL_CIPHER_MODE_CFB
4818 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_1_bytes_in_multiple_parts_2)
4819 size_t first_length = 0;
4820 size_t second_length = 1;
4821 size_t length = first_length + second_length;
4822 unsigned char key[32];
4823 unsigned char iv[16];
4829 unsigned char inbuf[64];
4830 unsigned char encbuf[64];
4831 unsigned char decbuf[64];
4834 size_t totaloutlen = 0;
4837 memset( key, 0, 32 );
4838 memset( iv , 0, 16 );
4840 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4841 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4843 memset( inbuf, 5, 64 );
4844 memset( encbuf, 0, 64 );
4845 memset( decbuf, 0, 64 );
4849 fct_chk( NULL != cipher_info);
4871 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4872 totaloutlen = outlen;
4873 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4874 totaloutlen += outlen;
4881 fct_chk( totaloutlen == enclen );
4883 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4884 totaloutlen += outlen;
4891 fct_chk( outlen == 0 );
4895 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4902 fct_chk( enclen == outlen );
4904 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4911 fct_chk( outlen == 0 );
4915 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4923 #ifdef POLARSSL_BLOWFISH_C
4924 #ifdef POLARSSL_CIPHER_MODE_CFB
4926 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_1)
4927 size_t first_length = 16;
4928 size_t second_length = 0;
4929 size_t length = first_length + second_length;
4930 unsigned char key[32];
4931 unsigned char iv[16];
4937 unsigned char inbuf[64];
4938 unsigned char encbuf[64];
4939 unsigned char decbuf[64];
4942 size_t totaloutlen = 0;
4945 memset( key, 0, 32 );
4946 memset( iv , 0, 16 );
4948 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4949 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4951 memset( inbuf, 5, 64 );
4952 memset( encbuf, 0, 64 );
4953 memset( decbuf, 0, 64 );
4957 fct_chk( NULL != cipher_info);
4979 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4980 totaloutlen = outlen;
4981 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4982 totaloutlen += outlen;
4989 fct_chk( totaloutlen == enclen );
4991 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4992 totaloutlen += outlen;
4999 fct_chk( outlen == 0 );
5003 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5010 fct_chk( enclen == outlen );
5012 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5019 fct_chk( outlen == 0 );
5023 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5031 #ifdef POLARSSL_BLOWFISH_C
5032 #ifdef POLARSSL_CIPHER_MODE_CFB
5034 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_2)
5035 size_t first_length = 0;
5036 size_t second_length = 16;
5037 size_t length = first_length + second_length;
5038 unsigned char key[32];
5039 unsigned char iv[16];
5045 unsigned char inbuf[64];
5046 unsigned char encbuf[64];
5047 unsigned char decbuf[64];
5050 size_t totaloutlen = 0;
5053 memset( key, 0, 32 );
5054 memset( iv , 0, 16 );
5056 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5057 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5059 memset( inbuf, 5, 64 );
5060 memset( encbuf, 0, 64 );
5061 memset( decbuf, 0, 64 );
5065 fct_chk( NULL != cipher_info);
5087 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5088 totaloutlen = outlen;
5089 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5090 totaloutlen += outlen;
5097 fct_chk( totaloutlen == enclen );
5099 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5100 totaloutlen += outlen;
5107 fct_chk( outlen == 0 );
5111 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5118 fct_chk( enclen == outlen );
5120 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5127 fct_chk( outlen == 0 );
5131 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5139 #ifdef POLARSSL_BLOWFISH_C
5140 #ifdef POLARSSL_CIPHER_MODE_CFB
5142 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_3)
5143 size_t first_length = 1;
5144 size_t second_length = 15;
5145 size_t length = first_length + second_length;
5146 unsigned char key[32];
5147 unsigned char iv[16];
5153 unsigned char inbuf[64];
5154 unsigned char encbuf[64];
5155 unsigned char decbuf[64];
5158 size_t totaloutlen = 0;
5161 memset( key, 0, 32 );
5162 memset( iv , 0, 16 );
5164 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5165 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5167 memset( inbuf, 5, 64 );
5168 memset( encbuf, 0, 64 );
5169 memset( decbuf, 0, 64 );
5173 fct_chk( NULL != cipher_info);
5195 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5196 totaloutlen = outlen;
5197 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5198 totaloutlen += outlen;
5205 fct_chk( totaloutlen == enclen );
5207 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5208 totaloutlen += outlen;
5215 fct_chk( outlen == 0 );
5219 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5226 fct_chk( enclen == outlen );
5228 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5235 fct_chk( outlen == 0 );
5239 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5247 #ifdef POLARSSL_BLOWFISH_C
5248 #ifdef POLARSSL_CIPHER_MODE_CFB
5250 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_4)
5251 size_t first_length = 15;
5252 size_t second_length = 1;
5253 size_t length = first_length + second_length;
5254 unsigned char key[32];
5255 unsigned char iv[16];
5261 unsigned char inbuf[64];
5262 unsigned char encbuf[64];
5263 unsigned char decbuf[64];
5266 size_t totaloutlen = 0;
5269 memset( key, 0, 32 );
5270 memset( iv , 0, 16 );
5272 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5273 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5275 memset( inbuf, 5, 64 );
5276 memset( encbuf, 0, 64 );
5277 memset( decbuf, 0, 64 );
5281 fct_chk( NULL != cipher_info);
5303 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5304 totaloutlen = outlen;
5305 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5306 totaloutlen += outlen;
5313 fct_chk( totaloutlen == enclen );
5315 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5316 totaloutlen += outlen;
5323 fct_chk( outlen == 0 );
5327 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5334 fct_chk( enclen == outlen );
5336 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5343 fct_chk( outlen == 0 );
5347 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5355 #ifdef POLARSSL_BLOWFISH_C
5356 #ifdef POLARSSL_CIPHER_MODE_CFB
5358 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
5359 size_t first_length = 15;
5360 size_t second_length = 7;
5361 size_t length = first_length + second_length;
5362 unsigned char key[32];
5363 unsigned char iv[16];
5369 unsigned char inbuf[64];
5370 unsigned char encbuf[64];
5371 unsigned char decbuf[64];
5374 size_t totaloutlen = 0;
5377 memset( key, 0, 32 );
5378 memset( iv , 0, 16 );
5380 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5381 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5383 memset( inbuf, 5, 64 );
5384 memset( encbuf, 0, 64 );
5385 memset( decbuf, 0, 64 );
5389 fct_chk( NULL != cipher_info);
5411 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5412 totaloutlen = outlen;
5413 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5414 totaloutlen += outlen;
5421 fct_chk( totaloutlen == enclen );
5423 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5424 totaloutlen += outlen;
5431 fct_chk( outlen == 0 );
5435 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5442 fct_chk( enclen == outlen );
5444 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5451 fct_chk( outlen == 0 );
5455 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5463 #ifdef POLARSSL_BLOWFISH_C
5464 #ifdef POLARSSL_CIPHER_MODE_CFB
5466 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
5467 size_t first_length = 16;
5468 size_t second_length = 6;
5469 size_t length = first_length + second_length;
5470 unsigned char key[32];
5471 unsigned char iv[16];
5477 unsigned char inbuf[64];
5478 unsigned char encbuf[64];
5479 unsigned char decbuf[64];
5482 size_t totaloutlen = 0;
5485 memset( key, 0, 32 );
5486 memset( iv , 0, 16 );
5488 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5489 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5491 memset( inbuf, 5, 64 );
5492 memset( encbuf, 0, 64 );
5493 memset( decbuf, 0, 64 );
5497 fct_chk( NULL != cipher_info);
5519 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5520 totaloutlen = outlen;
5521 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5522 totaloutlen += outlen;
5529 fct_chk( totaloutlen == enclen );
5531 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5532 totaloutlen += outlen;
5539 fct_chk( outlen == 0 );
5543 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5550 fct_chk( enclen == outlen );
5552 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5559 fct_chk( outlen == 0 );
5563 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5571 #ifdef POLARSSL_BLOWFISH_C
5572 #ifdef POLARSSL_CIPHER_MODE_CFB
5574 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
5575 size_t first_length = 17;
5576 size_t second_length = 6;
5577 size_t length = first_length + second_length;
5578 unsigned char key[32];
5579 unsigned char iv[16];
5585 unsigned char inbuf[64];
5586 unsigned char encbuf[64];
5587 unsigned char decbuf[64];
5590 size_t totaloutlen = 0;
5593 memset( key, 0, 32 );
5594 memset( iv , 0, 16 );
5596 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5597 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5599 memset( inbuf, 5, 64 );
5600 memset( encbuf, 0, 64 );
5601 memset( decbuf, 0, 64 );
5605 fct_chk( NULL != cipher_info);
5627 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5628 totaloutlen = outlen;
5629 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5630 totaloutlen += outlen;
5637 fct_chk( totaloutlen == enclen );
5639 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5640 totaloutlen += outlen;
5647 fct_chk( outlen == 0 );
5651 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5658 fct_chk( enclen == outlen );
5660 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5667 fct_chk( outlen == 0 );
5671 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5679 #ifdef POLARSSL_BLOWFISH_C
5680 #ifdef POLARSSL_CIPHER_MODE_CFB
5682 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_32_bytes_in_multiple_parts_1)
5683 size_t first_length = 16;
5684 size_t second_length = 16;
5685 size_t length = first_length + second_length;
5686 unsigned char key[32];
5687 unsigned char iv[16];
5693 unsigned char inbuf[64];
5694 unsigned char encbuf[64];
5695 unsigned char decbuf[64];
5698 size_t totaloutlen = 0;
5701 memset( key, 0, 32 );
5702 memset( iv , 0, 16 );
5704 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5705 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5707 memset( inbuf, 5, 64 );
5708 memset( encbuf, 0, 64 );
5709 memset( decbuf, 0, 64 );
5713 fct_chk( NULL != cipher_info);
5735 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5736 totaloutlen = outlen;
5737 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5738 totaloutlen += outlen;
5745 fct_chk( totaloutlen == enclen );
5747 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5748 totaloutlen += outlen;
5755 fct_chk( outlen == 0 );
5759 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5766 fct_chk( enclen == outlen );
5768 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5775 fct_chk( outlen == 0 );
5779 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5787 #ifdef POLARSSL_BLOWFISH_C
5788 #ifdef POLARSSL_CIPHER_MODE_CTR
5790 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_0_bytes)
5792 unsigned char key[32];
5793 unsigned char iv[16];
5799 unsigned char inbuf[64];
5800 unsigned char encbuf[64];
5801 unsigned char decbuf[64];
5806 memset( key, 0, 32 );
5807 memset( iv , 0, 16 );
5809 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5810 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5812 memset( inbuf, 5, 64 );
5813 memset( encbuf, 0, 64 );
5814 memset( decbuf, 0, 64 );
5818 fct_chk( NULL != cipher_info );
5842 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
5849 fct_chk( outlen == enclen );
5852 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
5859 fct_chk( outlen == 0 );
5864 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5871 fct_chk( enclen == outlen );
5874 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5881 fct_chk( outlen == 0 );
5885 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5893 #ifdef POLARSSL_BLOWFISH_C
5894 #ifdef POLARSSL_CIPHER_MODE_CTR
5896 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_1_byte)
5898 unsigned char key[32];
5899 unsigned char iv[16];
5905 unsigned char inbuf[64];
5906 unsigned char encbuf[64];
5907 unsigned char decbuf[64];
5912 memset( key, 0, 32 );
5913 memset( iv , 0, 16 );
5915 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5916 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5918 memset( inbuf, 5, 64 );
5919 memset( encbuf, 0, 64 );
5920 memset( decbuf, 0, 64 );
5924 fct_chk( NULL != cipher_info );
5948 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
5955 fct_chk( outlen == enclen );
5958 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
5965 fct_chk( outlen == 0 );
5970 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5977 fct_chk( enclen == outlen );
5980 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5987 fct_chk( outlen == 0 );
5991 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5999 #ifdef POLARSSL_BLOWFISH_C
6000 #ifdef POLARSSL_CIPHER_MODE_CTR
6002 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_2_bytes)
6004 unsigned char key[32];
6005 unsigned char iv[16];
6011 unsigned char inbuf[64];
6012 unsigned char encbuf[64];
6013 unsigned char decbuf[64];
6018 memset( key, 0, 32 );
6019 memset( iv , 0, 16 );
6021 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6022 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6024 memset( inbuf, 5, 64 );
6025 memset( encbuf, 0, 64 );
6026 memset( decbuf, 0, 64 );
6030 fct_chk( NULL != cipher_info );
6054 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6061 fct_chk( outlen == enclen );
6064 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6071 fct_chk( outlen == 0 );
6076 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6083 fct_chk( enclen == outlen );
6086 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6093 fct_chk( outlen == 0 );
6097 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6105 #ifdef POLARSSL_BLOWFISH_C
6106 #ifdef POLARSSL_CIPHER_MODE_CTR
6108 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_7_bytes)
6110 unsigned char key[32];
6111 unsigned char iv[16];
6117 unsigned char inbuf[64];
6118 unsigned char encbuf[64];
6119 unsigned char decbuf[64];
6124 memset( key, 0, 32 );
6125 memset( iv , 0, 16 );
6127 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6128 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6130 memset( inbuf, 5, 64 );
6131 memset( encbuf, 0, 64 );
6132 memset( decbuf, 0, 64 );
6136 fct_chk( NULL != cipher_info );
6160 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6167 fct_chk( outlen == enclen );
6170 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6177 fct_chk( outlen == 0 );
6182 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6189 fct_chk( enclen == outlen );
6192 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6199 fct_chk( outlen == 0 );
6203 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6211 #ifdef POLARSSL_BLOWFISH_C
6212 #ifdef POLARSSL_CIPHER_MODE_CTR
6214 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_8_bytes)
6216 unsigned char key[32];
6217 unsigned char iv[16];
6223 unsigned char inbuf[64];
6224 unsigned char encbuf[64];
6225 unsigned char decbuf[64];
6230 memset( key, 0, 32 );
6231 memset( iv , 0, 16 );
6233 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6234 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6236 memset( inbuf, 5, 64 );
6237 memset( encbuf, 0, 64 );
6238 memset( decbuf, 0, 64 );
6242 fct_chk( NULL != cipher_info );
6266 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6273 fct_chk( outlen == enclen );
6276 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6283 fct_chk( outlen == 0 );
6288 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6295 fct_chk( enclen == outlen );
6298 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6305 fct_chk( outlen == 0 );
6309 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6317 #ifdef POLARSSL_BLOWFISH_C
6318 #ifdef POLARSSL_CIPHER_MODE_CTR
6320 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_9_bytes)
6322 unsigned char key[32];
6323 unsigned char iv[16];
6329 unsigned char inbuf[64];
6330 unsigned char encbuf[64];
6331 unsigned char decbuf[64];
6336 memset( key, 0, 32 );
6337 memset( iv , 0, 16 );
6339 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6340 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6342 memset( inbuf, 5, 64 );
6343 memset( encbuf, 0, 64 );
6344 memset( decbuf, 0, 64 );
6348 fct_chk( NULL != cipher_info );
6372 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6379 fct_chk( outlen == enclen );
6382 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6389 fct_chk( outlen == 0 );
6394 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6401 fct_chk( enclen == outlen );
6404 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6411 fct_chk( outlen == 0 );
6415 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6423 #ifdef POLARSSL_BLOWFISH_C
6424 #ifdef POLARSSL_CIPHER_MODE_CTR
6426 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_15_bytes)
6428 unsigned char key[32];
6429 unsigned char iv[16];
6435 unsigned char inbuf[64];
6436 unsigned char encbuf[64];
6437 unsigned char decbuf[64];
6442 memset( key, 0, 32 );
6443 memset( iv , 0, 16 );
6445 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6446 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6448 memset( inbuf, 5, 64 );
6449 memset( encbuf, 0, 64 );
6450 memset( decbuf, 0, 64 );
6454 fct_chk( NULL != cipher_info );
6478 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6485 fct_chk( outlen == enclen );
6488 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6495 fct_chk( outlen == 0 );
6500 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6507 fct_chk( enclen == outlen );
6510 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6517 fct_chk( outlen == 0 );
6521 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6529 #ifdef POLARSSL_BLOWFISH_C
6530 #ifdef POLARSSL_CIPHER_MODE_CTR
6532 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes)
6534 unsigned char key[32];
6535 unsigned char iv[16];
6541 unsigned char inbuf[64];
6542 unsigned char encbuf[64];
6543 unsigned char decbuf[64];
6548 memset( key, 0, 32 );
6549 memset( iv , 0, 16 );
6551 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6552 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6554 memset( inbuf, 5, 64 );
6555 memset( encbuf, 0, 64 );
6556 memset( decbuf, 0, 64 );
6560 fct_chk( NULL != cipher_info );
6584 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6591 fct_chk( outlen == enclen );
6594 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6601 fct_chk( outlen == 0 );
6606 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6613 fct_chk( enclen == outlen );
6616 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6623 fct_chk( outlen == 0 );
6627 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6635 #ifdef POLARSSL_BLOWFISH_C
6636 #ifdef POLARSSL_CIPHER_MODE_CTR
6638 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_17_bytes)
6640 unsigned char key[32];
6641 unsigned char iv[16];
6647 unsigned char inbuf[64];
6648 unsigned char encbuf[64];
6649 unsigned char decbuf[64];
6654 memset( key, 0, 32 );
6655 memset( iv , 0, 16 );
6657 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6658 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6660 memset( inbuf, 5, 64 );
6661 memset( encbuf, 0, 64 );
6662 memset( decbuf, 0, 64 );
6666 fct_chk( NULL != cipher_info );
6690 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6697 fct_chk( outlen == enclen );
6700 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6707 fct_chk( outlen == 0 );
6712 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6719 fct_chk( enclen == outlen );
6722 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6729 fct_chk( outlen == 0 );
6733 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6741 #ifdef POLARSSL_BLOWFISH_C
6742 #ifdef POLARSSL_CIPHER_MODE_CTR
6744 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_31_bytes)
6746 unsigned char key[32];
6747 unsigned char iv[16];
6753 unsigned char inbuf[64];
6754 unsigned char encbuf[64];
6755 unsigned char decbuf[64];
6760 memset( key, 0, 32 );
6761 memset( iv , 0, 16 );
6763 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6764 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6766 memset( inbuf, 5, 64 );
6767 memset( encbuf, 0, 64 );
6768 memset( decbuf, 0, 64 );
6772 fct_chk( NULL != cipher_info );
6796 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6803 fct_chk( outlen == enclen );
6806 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6813 fct_chk( outlen == 0 );
6818 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6825 fct_chk( enclen == outlen );
6828 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6835 fct_chk( outlen == 0 );
6839 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6847 #ifdef POLARSSL_BLOWFISH_C
6848 #ifdef POLARSSL_CIPHER_MODE_CTR
6850 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_32_bytes)
6852 unsigned char key[32];
6853 unsigned char iv[16];
6859 unsigned char inbuf[64];
6860 unsigned char encbuf[64];
6861 unsigned char decbuf[64];
6866 memset( key, 0, 32 );
6867 memset( iv , 0, 16 );
6869 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6870 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6872 memset( inbuf, 5, 64 );
6873 memset( encbuf, 0, 64 );
6874 memset( decbuf, 0, 64 );
6878 fct_chk( NULL != cipher_info );
6902 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6909 fct_chk( outlen == enclen );
6912 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6919 fct_chk( outlen == 0 );
6924 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6931 fct_chk( enclen == outlen );
6934 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6941 fct_chk( outlen == 0 );
6945 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6953 #ifdef POLARSSL_BLOWFISH_C
6954 #ifdef POLARSSL_CIPHER_MODE_CTR
6956 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_32_bytes)
6958 unsigned char key[32];
6959 unsigned char iv[16];
6965 unsigned char inbuf[64];
6966 unsigned char encbuf[64];
6967 unsigned char decbuf[64];
6972 memset( key, 0, 32 );
6973 memset( iv , 0, 16 );
6975 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6976 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6978 memset( inbuf, 5, 64 );
6979 memset( encbuf, 0, 64 );
6980 memset( decbuf, 0, 64 );
6984 fct_chk( NULL != cipher_info );
7008 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
7015 fct_chk( outlen == enclen );
7018 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
7025 fct_chk( outlen == 0 );
7030 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7037 fct_chk( enclen == outlen );
7040 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7047 fct_chk( outlen == 0 );
7051 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7059 #ifdef POLARSSL_BLOWFISH_C
7060 #ifdef POLARSSL_CIPHER_MODE_CTR
7062 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_47_bytes)
7064 unsigned char key[32];
7065 unsigned char iv[16];
7071 unsigned char inbuf[64];
7072 unsigned char encbuf[64];
7073 unsigned char decbuf[64];
7078 memset( key, 0, 32 );
7079 memset( iv , 0, 16 );
7081 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7082 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7084 memset( inbuf, 5, 64 );
7085 memset( encbuf, 0, 64 );
7086 memset( decbuf, 0, 64 );
7090 fct_chk( NULL != cipher_info );
7114 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
7121 fct_chk( outlen == enclen );
7124 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
7131 fct_chk( outlen == 0 );
7136 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7143 fct_chk( enclen == outlen );
7146 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7153 fct_chk( outlen == 0 );
7157 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7165 #ifdef POLARSSL_BLOWFISH_C
7166 #ifdef POLARSSL_CIPHER_MODE_CTR
7168 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_48_bytes)
7170 unsigned char key[32];
7171 unsigned char iv[16];
7177 unsigned char inbuf[64];
7178 unsigned char encbuf[64];
7179 unsigned char decbuf[64];
7184 memset( key, 0, 32 );
7185 memset( iv , 0, 16 );
7187 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7188 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7190 memset( inbuf, 5, 64 );
7191 memset( encbuf, 0, 64 );
7192 memset( decbuf, 0, 64 );
7196 fct_chk( NULL != cipher_info );
7220 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
7227 fct_chk( outlen == enclen );
7230 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
7237 fct_chk( outlen == 0 );
7242 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7249 fct_chk( enclen == outlen );
7252 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7259 fct_chk( outlen == 0 );
7263 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7271 #ifdef POLARSSL_BLOWFISH_C
7272 #ifdef POLARSSL_CIPHER_MODE_CTR
7274 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_49_bytes)
7276 unsigned char key[32];
7277 unsigned char iv[16];
7283 unsigned char inbuf[64];
7284 unsigned char encbuf[64];
7285 unsigned char decbuf[64];
7290 memset( key, 0, 32 );
7291 memset( iv , 0, 16 );
7293 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7294 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7296 memset( inbuf, 5, 64 );
7297 memset( encbuf, 0, 64 );
7298 memset( decbuf, 0, 64 );
7302 fct_chk( NULL != cipher_info );
7326 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
7333 fct_chk( outlen == enclen );
7336 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
7343 fct_chk( outlen == 0 );
7348 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7355 fct_chk( enclen == outlen );
7358 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7365 fct_chk( outlen == 0 );
7369 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7377 #ifdef POLARSSL_BLOWFISH_C
7378 #ifdef POLARSSL_CIPHER_MODE_CTR
7380 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_0_bytes_in_multiple_parts)
7381 size_t first_length = 0;
7382 size_t second_length = 0;
7383 size_t length = first_length + second_length;
7384 unsigned char key[32];
7385 unsigned char iv[16];
7391 unsigned char inbuf[64];
7392 unsigned char encbuf[64];
7393 unsigned char decbuf[64];
7396 size_t totaloutlen = 0;
7399 memset( key, 0, 32 );
7400 memset( iv , 0, 16 );
7402 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7403 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7405 memset( inbuf, 5, 64 );
7406 memset( encbuf, 0, 64 );
7407 memset( decbuf, 0, 64 );
7411 fct_chk( NULL != cipher_info);
7433 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7434 totaloutlen = outlen;
7435 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7436 totaloutlen += outlen;
7443 fct_chk( totaloutlen == enclen );
7445 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7446 totaloutlen += outlen;
7453 fct_chk( outlen == 0 );
7457 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7464 fct_chk( enclen == outlen );
7466 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7473 fct_chk( outlen == 0 );
7477 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7485 #ifdef POLARSSL_BLOWFISH_C
7486 #ifdef POLARSSL_CIPHER_MODE_CTR
7488 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_1_bytes_in_multiple_parts_1)
7489 size_t first_length = 1;
7490 size_t second_length = 0;
7491 size_t length = first_length + second_length;
7492 unsigned char key[32];
7493 unsigned char iv[16];
7499 unsigned char inbuf[64];
7500 unsigned char encbuf[64];
7501 unsigned char decbuf[64];
7504 size_t totaloutlen = 0;
7507 memset( key, 0, 32 );
7508 memset( iv , 0, 16 );
7510 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7511 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7513 memset( inbuf, 5, 64 );
7514 memset( encbuf, 0, 64 );
7515 memset( decbuf, 0, 64 );
7519 fct_chk( NULL != cipher_info);
7541 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7542 totaloutlen = outlen;
7543 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7544 totaloutlen += outlen;
7551 fct_chk( totaloutlen == enclen );
7553 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7554 totaloutlen += outlen;
7561 fct_chk( outlen == 0 );
7565 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7572 fct_chk( enclen == outlen );
7574 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7581 fct_chk( outlen == 0 );
7585 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7593 #ifdef POLARSSL_BLOWFISH_C
7594 #ifdef POLARSSL_CIPHER_MODE_CTR
7596 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_1_bytes_in_multiple_parts_2)
7597 size_t first_length = 0;
7598 size_t second_length = 1;
7599 size_t length = first_length + second_length;
7600 unsigned char key[32];
7601 unsigned char iv[16];
7607 unsigned char inbuf[64];
7608 unsigned char encbuf[64];
7609 unsigned char decbuf[64];
7612 size_t totaloutlen = 0;
7615 memset( key, 0, 32 );
7616 memset( iv , 0, 16 );
7618 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7619 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7621 memset( inbuf, 5, 64 );
7622 memset( encbuf, 0, 64 );
7623 memset( decbuf, 0, 64 );
7627 fct_chk( NULL != cipher_info);
7649 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7650 totaloutlen = outlen;
7651 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7652 totaloutlen += outlen;
7659 fct_chk( totaloutlen == enclen );
7661 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7662 totaloutlen += outlen;
7669 fct_chk( outlen == 0 );
7673 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7680 fct_chk( enclen == outlen );
7682 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7689 fct_chk( outlen == 0 );
7693 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7701 #ifdef POLARSSL_BLOWFISH_C
7702 #ifdef POLARSSL_CIPHER_MODE_CTR
7704 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_1)
7705 size_t first_length = 16;
7706 size_t second_length = 0;
7707 size_t length = first_length + second_length;
7708 unsigned char key[32];
7709 unsigned char iv[16];
7715 unsigned char inbuf[64];
7716 unsigned char encbuf[64];
7717 unsigned char decbuf[64];
7720 size_t totaloutlen = 0;
7723 memset( key, 0, 32 );
7724 memset( iv , 0, 16 );
7726 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7727 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7729 memset( inbuf, 5, 64 );
7730 memset( encbuf, 0, 64 );
7731 memset( decbuf, 0, 64 );
7735 fct_chk( NULL != cipher_info);
7757 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7758 totaloutlen = outlen;
7759 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7760 totaloutlen += outlen;
7767 fct_chk( totaloutlen == enclen );
7769 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7770 totaloutlen += outlen;
7777 fct_chk( outlen == 0 );
7781 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7788 fct_chk( enclen == outlen );
7790 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7797 fct_chk( outlen == 0 );
7801 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7809 #ifdef POLARSSL_BLOWFISH_C
7810 #ifdef POLARSSL_CIPHER_MODE_CTR
7812 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_2)
7813 size_t first_length = 0;
7814 size_t second_length = 16;
7815 size_t length = first_length + second_length;
7816 unsigned char key[32];
7817 unsigned char iv[16];
7823 unsigned char inbuf[64];
7824 unsigned char encbuf[64];
7825 unsigned char decbuf[64];
7828 size_t totaloutlen = 0;
7831 memset( key, 0, 32 );
7832 memset( iv , 0, 16 );
7834 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7835 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7837 memset( inbuf, 5, 64 );
7838 memset( encbuf, 0, 64 );
7839 memset( decbuf, 0, 64 );
7843 fct_chk( NULL != cipher_info);
7865 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7866 totaloutlen = outlen;
7867 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7868 totaloutlen += outlen;
7875 fct_chk( totaloutlen == enclen );
7877 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7878 totaloutlen += outlen;
7885 fct_chk( outlen == 0 );
7889 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7896 fct_chk( enclen == outlen );
7898 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7905 fct_chk( outlen == 0 );
7909 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7917 #ifdef POLARSSL_BLOWFISH_C
7918 #ifdef POLARSSL_CIPHER_MODE_CTR
7920 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_3)
7921 size_t first_length = 1;
7922 size_t second_length = 15;
7923 size_t length = first_length + second_length;
7924 unsigned char key[32];
7925 unsigned char iv[16];
7931 unsigned char inbuf[64];
7932 unsigned char encbuf[64];
7933 unsigned char decbuf[64];
7936 size_t totaloutlen = 0;
7939 memset( key, 0, 32 );
7940 memset( iv , 0, 16 );
7942 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7943 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7945 memset( inbuf, 5, 64 );
7946 memset( encbuf, 0, 64 );
7947 memset( decbuf, 0, 64 );
7951 fct_chk( NULL != cipher_info);
7973 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7974 totaloutlen = outlen;
7975 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7976 totaloutlen += outlen;
7983 fct_chk( totaloutlen == enclen );
7985 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7986 totaloutlen += outlen;
7993 fct_chk( outlen == 0 );
7997 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8004 fct_chk( enclen == outlen );
8006 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8013 fct_chk( outlen == 0 );
8017 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8025 #ifdef POLARSSL_BLOWFISH_C
8026 #ifdef POLARSSL_CIPHER_MODE_CTR
8028 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_16_bytes_in_multiple_parts_4)
8029 size_t first_length = 15;
8030 size_t second_length = 1;
8031 size_t length = first_length + second_length;
8032 unsigned char key[32];
8033 unsigned char iv[16];
8039 unsigned char inbuf[64];
8040 unsigned char encbuf[64];
8041 unsigned char decbuf[64];
8044 size_t totaloutlen = 0;
8047 memset( key, 0, 32 );
8048 memset( iv , 0, 16 );
8050 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8051 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8053 memset( inbuf, 5, 64 );
8054 memset( encbuf, 0, 64 );
8055 memset( decbuf, 0, 64 );
8059 fct_chk( NULL != cipher_info);
8081 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8082 totaloutlen = outlen;
8083 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8084 totaloutlen += outlen;
8091 fct_chk( totaloutlen == enclen );
8093 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8094 totaloutlen += outlen;
8101 fct_chk( outlen == 0 );
8105 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8112 fct_chk( enclen == outlen );
8114 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8121 fct_chk( outlen == 0 );
8125 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8133 #ifdef POLARSSL_BLOWFISH_C
8134 #ifdef POLARSSL_CIPHER_MODE_CTR
8136 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
8137 size_t first_length = 15;
8138 size_t second_length = 7;
8139 size_t length = first_length + second_length;
8140 unsigned char key[32];
8141 unsigned char iv[16];
8147 unsigned char inbuf[64];
8148 unsigned char encbuf[64];
8149 unsigned char decbuf[64];
8152 size_t totaloutlen = 0;
8155 memset( key, 0, 32 );
8156 memset( iv , 0, 16 );
8158 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8159 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8161 memset( inbuf, 5, 64 );
8162 memset( encbuf, 0, 64 );
8163 memset( decbuf, 0, 64 );
8167 fct_chk( NULL != cipher_info);
8189 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8190 totaloutlen = outlen;
8191 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8192 totaloutlen += outlen;
8199 fct_chk( totaloutlen == enclen );
8201 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8202 totaloutlen += outlen;
8209 fct_chk( outlen == 0 );
8213 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8220 fct_chk( enclen == outlen );
8222 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8229 fct_chk( outlen == 0 );
8233 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8241 #ifdef POLARSSL_BLOWFISH_C
8242 #ifdef POLARSSL_CIPHER_MODE_CTR
8244 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
8245 size_t first_length = 16;
8246 size_t second_length = 6;
8247 size_t length = first_length + second_length;
8248 unsigned char key[32];
8249 unsigned char iv[16];
8255 unsigned char inbuf[64];
8256 unsigned char encbuf[64];
8257 unsigned char decbuf[64];
8260 size_t totaloutlen = 0;
8263 memset( key, 0, 32 );
8264 memset( iv , 0, 16 );
8266 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8267 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8269 memset( inbuf, 5, 64 );
8270 memset( encbuf, 0, 64 );
8271 memset( decbuf, 0, 64 );
8275 fct_chk( NULL != cipher_info);
8297 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8298 totaloutlen = outlen;
8299 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8300 totaloutlen += outlen;
8307 fct_chk( totaloutlen == enclen );
8309 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8310 totaloutlen += outlen;
8317 fct_chk( outlen == 0 );
8321 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8328 fct_chk( enclen == outlen );
8330 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8337 fct_chk( outlen == 0 );
8341 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8349 #ifdef POLARSSL_BLOWFISH_C
8350 #ifdef POLARSSL_CIPHER_MODE_CTR
8352 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
8353 size_t first_length = 17;
8354 size_t second_length = 6;
8355 size_t length = first_length + second_length;
8356 unsigned char key[32];
8357 unsigned char iv[16];
8363 unsigned char inbuf[64];
8364 unsigned char encbuf[64];
8365 unsigned char decbuf[64];
8368 size_t totaloutlen = 0;
8371 memset( key, 0, 32 );
8372 memset( iv , 0, 16 );
8374 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8375 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8377 memset( inbuf, 5, 64 );
8378 memset( encbuf, 0, 64 );
8379 memset( decbuf, 0, 64 );
8383 fct_chk( NULL != cipher_info);
8405 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8406 totaloutlen = outlen;
8407 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8408 totaloutlen += outlen;
8415 fct_chk( totaloutlen == enclen );
8417 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8418 totaloutlen += outlen;
8425 fct_chk( outlen == 0 );
8429 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8436 fct_chk( enclen == outlen );
8438 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8445 fct_chk( outlen == 0 );
8449 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8457 #ifdef POLARSSL_BLOWFISH_C
8458 #ifdef POLARSSL_CIPHER_MODE_CTR
8460 FCT_TEST_BGN(blowfish_encrypt_and_decrypt_32_bytes_in_multiple_parts_1)
8461 size_t first_length = 16;
8462 size_t second_length = 16;
8463 size_t length = first_length + second_length;
8464 unsigned char key[32];
8465 unsigned char iv[16];
8471 unsigned char inbuf[64];
8472 unsigned char encbuf[64];
8473 unsigned char decbuf[64];
8476 size_t totaloutlen = 0;
8479 memset( key, 0, 32 );
8480 memset( iv , 0, 16 );
8482 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8483 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8485 memset( inbuf, 5, 64 );
8486 memset( encbuf, 0, 64 );
8487 memset( decbuf, 0, 64 );
8491 fct_chk( NULL != cipher_info);
8513 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8514 totaloutlen = outlen;
8515 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8516 totaloutlen += outlen;
8523 fct_chk( totaloutlen == enclen );
8525 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8526 totaloutlen += outlen;
8533 fct_chk( outlen == 0 );
8537 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8544 fct_chk( enclen == outlen );
8546 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8553 fct_chk( outlen == 0 );
8557 fct_chk( 0 == memcmp(inbuf, decbuf, length) );