8 typedef UINT32 uint32_t;
17 #define GET_UINT32_BE(n,b,i) \
19 (n) = ( (uint32_t) (b)[(i) ] << 24 ) \
20 | ( (uint32_t) (b)[(i) + 1] << 16 ) \
21 | ( (uint32_t) (b)[(i) + 2] << 8 ) \
22 | ( (uint32_t) (b)[(i) + 3] ); \
27 #define PUT_UINT32_BE(n,b,i) \
29 (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
30 (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
31 (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
32 (b)[(i) + 3] = (unsigned char) ( (n) ); \
36 int unhexify(
unsigned char *obuf,
const char *ibuf)
39 int len = strlen(ibuf) / 2;
40 assert(!(strlen(ibuf) %1));
45 if( c >=
'0' && c <=
'9' )
47 else if( c >=
'a' && c <=
'f' )
49 else if( c >=
'A' && c <=
'F' )
55 if( c2 >=
'0' && c2 <=
'9' )
57 else if( c2 >=
'a' && c2 <=
'f' )
59 else if( c2 >=
'A' && c2 <=
'F' )
64 *obuf++ = ( c << 4 ) | c2;
70 void hexify(
unsigned char *obuf,
const unsigned char *ibuf,
int len)
82 *obuf++ =
'a' + h - 10;
87 *obuf++ =
'a' + l - 10;
103 static int rnd_std_rand(
void *rng_state,
unsigned char *output,
size_t len )
107 if( rng_state != NULL )
110 for( i = 0; i < len; ++i )
121 static int rnd_zero_rand(
void *rng_state,
unsigned char *output,
size_t len )
123 if( rng_state != NULL )
126 memset( output, 0, len );
153 if( rng_state == NULL )
162 memcpy( output, info->
buf, use_len );
163 info->
buf += use_len;
167 if( len - use_len > 0 )
168 return(
rnd_std_rand( NULL, output + use_len, len - use_len ) );
197 uint32_t i, *k, sum, delta=0x9E3779B9;
198 unsigned char result[4];
200 if( rng_state == NULL )
207 size_t use_len = ( len > 4 ) ? 4 : len;
210 for( i = 0; i < 32; i++ )
212 info->
v0 += (((info->
v1 << 4) ^ (info->
v1 >> 5)) + info->
v1) ^ (sum + k[sum & 3]);
214 info->
v1 += (((info->
v0 << 4) ^ (info->
v0 >> 5)) + info->
v0) ^ (sum + k[(sum>>11) & 3]);
218 memcpy( output, result, use_len );
228 #ifdef POLARSSL_CIPHER_C
231 FCT_SUITE_BGN(test_suite_cipher)
233 #ifdef POLARSSL_SELF_TEST
235 FCT_TEST_BGN(cipher_selftest)
243 FCT_TEST_BGN(decrypt_empty_buffer)
244 unsigned char key[32];
245 unsigned char iv[16];
250 unsigned char encbuf[64];
251 unsigned char decbuf[64];
255 memset( key, 0, 32 );
256 memset( iv , 0, 16 );
258 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
260 memset( encbuf, 0, 64 );
261 memset( decbuf, 0, 64 );
265 fct_chk( NULL != cipher_info);
274 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, 0, decbuf, &outlen ) );
275 fct_chk( 0 == outlen );
277 fct_chk( 0 == outlen );
282 #ifdef POLARSSL_DES_C
284 FCT_TEST_BGN(des_encrypt_and_decrypt_0_bytes)
286 unsigned char key[32];
287 unsigned char iv[16];
293 unsigned char inbuf[64];
294 unsigned char encbuf[64];
295 unsigned char decbuf[64];
300 memset( key, 0, 32 );
301 memset( iv , 0, 16 );
303 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
304 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
306 memset( inbuf, 5, 64 );
307 memset( encbuf, 0, 64 );
308 memset( decbuf, 0, 64 );
312 fct_chk( NULL != cipher_info );
336 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
343 fct_chk( outlen == enclen );
346 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
353 fct_chk( outlen == 0 );
358 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
365 fct_chk( enclen == outlen );
368 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
375 fct_chk( outlen == 0 );
379 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
386 #ifdef POLARSSL_DES_C
388 FCT_TEST_BGN(des_encrypt_and_decrypt_1_byte)
390 unsigned char key[32];
391 unsigned char iv[16];
397 unsigned char inbuf[64];
398 unsigned char encbuf[64];
399 unsigned char decbuf[64];
404 memset( key, 0, 32 );
405 memset( iv , 0, 16 );
407 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
408 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
410 memset( inbuf, 5, 64 );
411 memset( encbuf, 0, 64 );
412 memset( decbuf, 0, 64 );
416 fct_chk( NULL != cipher_info );
440 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
447 fct_chk( outlen == enclen );
450 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
457 fct_chk( outlen == 0 );
462 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
469 fct_chk( enclen == outlen );
472 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
479 fct_chk( outlen == 0 );
483 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
490 #ifdef POLARSSL_DES_C
492 FCT_TEST_BGN(des_encrypt_and_decrypt_2_bytes)
494 unsigned char key[32];
495 unsigned char iv[16];
501 unsigned char inbuf[64];
502 unsigned char encbuf[64];
503 unsigned char decbuf[64];
508 memset( key, 0, 32 );
509 memset( iv , 0, 16 );
511 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
512 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
514 memset( inbuf, 5, 64 );
515 memset( encbuf, 0, 64 );
516 memset( decbuf, 0, 64 );
520 fct_chk( NULL != cipher_info );
544 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
551 fct_chk( outlen == enclen );
554 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
561 fct_chk( outlen == 0 );
566 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
573 fct_chk( enclen == outlen );
576 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
583 fct_chk( outlen == 0 );
587 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
594 #ifdef POLARSSL_DES_C
596 FCT_TEST_BGN(des_encrypt_and_decrypt_7_bytes)
598 unsigned char key[32];
599 unsigned char iv[16];
605 unsigned char inbuf[64];
606 unsigned char encbuf[64];
607 unsigned char decbuf[64];
612 memset( key, 0, 32 );
613 memset( iv , 0, 16 );
615 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
616 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
618 memset( inbuf, 5, 64 );
619 memset( encbuf, 0, 64 );
620 memset( decbuf, 0, 64 );
624 fct_chk( NULL != cipher_info );
648 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
655 fct_chk( outlen == enclen );
658 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
665 fct_chk( outlen == 0 );
670 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
677 fct_chk( enclen == outlen );
680 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
687 fct_chk( outlen == 0 );
691 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
698 #ifdef POLARSSL_DES_C
700 FCT_TEST_BGN(des_encrypt_and_decrypt_8_bytes)
702 unsigned char key[32];
703 unsigned char iv[16];
709 unsigned char inbuf[64];
710 unsigned char encbuf[64];
711 unsigned char decbuf[64];
716 memset( key, 0, 32 );
717 memset( iv , 0, 16 );
719 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
720 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
722 memset( inbuf, 5, 64 );
723 memset( encbuf, 0, 64 );
724 memset( decbuf, 0, 64 );
728 fct_chk( NULL != cipher_info );
752 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
759 fct_chk( outlen == enclen );
762 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
769 fct_chk( outlen == 0 );
774 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
781 fct_chk( enclen == outlen );
784 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
791 fct_chk( outlen == 0 );
795 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
802 #ifdef POLARSSL_DES_C
804 FCT_TEST_BGN(des_encrypt_and_decrypt_9_bytes)
806 unsigned char key[32];
807 unsigned char iv[16];
813 unsigned char inbuf[64];
814 unsigned char encbuf[64];
815 unsigned char decbuf[64];
820 memset( key, 0, 32 );
821 memset( iv , 0, 16 );
823 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
824 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
826 memset( inbuf, 5, 64 );
827 memset( encbuf, 0, 64 );
828 memset( decbuf, 0, 64 );
832 fct_chk( NULL != cipher_info );
856 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
863 fct_chk( outlen == enclen );
866 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
873 fct_chk( outlen == 0 );
878 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
885 fct_chk( enclen == outlen );
888 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
895 fct_chk( outlen == 0 );
899 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
906 #ifdef POLARSSL_DES_C
908 FCT_TEST_BGN(des_encrypt_and_decrypt_15_bytes)
910 unsigned char key[32];
911 unsigned char iv[16];
917 unsigned char inbuf[64];
918 unsigned char encbuf[64];
919 unsigned char decbuf[64];
924 memset( key, 0, 32 );
925 memset( iv , 0, 16 );
927 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
928 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
930 memset( inbuf, 5, 64 );
931 memset( encbuf, 0, 64 );
932 memset( decbuf, 0, 64 );
936 fct_chk( NULL != cipher_info );
960 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
967 fct_chk( outlen == enclen );
970 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
977 fct_chk( outlen == 0 );
982 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
989 fct_chk( enclen == outlen );
992 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
999 fct_chk( outlen == 0 );
1003 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1010 #ifdef POLARSSL_DES_C
1012 FCT_TEST_BGN(des_encrypt_and_decrypt_16_bytes)
1014 unsigned char key[32];
1015 unsigned char iv[16];
1021 unsigned char inbuf[64];
1022 unsigned char encbuf[64];
1023 unsigned char decbuf[64];
1028 memset( key, 0, 32 );
1029 memset( iv , 0, 16 );
1031 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1032 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1034 memset( inbuf, 5, 64 );
1035 memset( encbuf, 0, 64 );
1036 memset( decbuf, 0, 64 );
1040 fct_chk( NULL != cipher_info );
1064 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1071 fct_chk( outlen == enclen );
1074 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1081 fct_chk( outlen == 0 );
1086 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1093 fct_chk( enclen == outlen );
1096 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1103 fct_chk( outlen == 0 );
1107 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1114 #ifdef POLARSSL_DES_C
1116 FCT_TEST_BGN(des_encrypt_and_decrypt_17_bytes)
1118 unsigned char key[32];
1119 unsigned char iv[16];
1125 unsigned char inbuf[64];
1126 unsigned char encbuf[64];
1127 unsigned char decbuf[64];
1132 memset( key, 0, 32 );
1133 memset( iv , 0, 16 );
1135 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1136 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1138 memset( inbuf, 5, 64 );
1139 memset( encbuf, 0, 64 );
1140 memset( decbuf, 0, 64 );
1144 fct_chk( NULL != cipher_info );
1168 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1175 fct_chk( outlen == enclen );
1178 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1185 fct_chk( outlen == 0 );
1190 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1197 fct_chk( enclen == outlen );
1200 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1207 fct_chk( outlen == 0 );
1211 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1218 #ifdef POLARSSL_DES_C
1220 FCT_TEST_BGN(des_encrypt_and_decrypt_31_bytes)
1222 unsigned char key[32];
1223 unsigned char iv[16];
1229 unsigned char inbuf[64];
1230 unsigned char encbuf[64];
1231 unsigned char decbuf[64];
1236 memset( key, 0, 32 );
1237 memset( iv , 0, 16 );
1239 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1240 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1242 memset( inbuf, 5, 64 );
1243 memset( encbuf, 0, 64 );
1244 memset( decbuf, 0, 64 );
1248 fct_chk( NULL != cipher_info );
1272 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1279 fct_chk( outlen == enclen );
1282 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1289 fct_chk( outlen == 0 );
1294 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1301 fct_chk( enclen == outlen );
1304 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1311 fct_chk( outlen == 0 );
1315 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1322 #ifdef POLARSSL_DES_C
1324 FCT_TEST_BGN(des_encrypt_and_decrypt_32_bytes)
1326 unsigned char key[32];
1327 unsigned char iv[16];
1333 unsigned char inbuf[64];
1334 unsigned char encbuf[64];
1335 unsigned char decbuf[64];
1340 memset( key, 0, 32 );
1341 memset( iv , 0, 16 );
1343 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1344 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1346 memset( inbuf, 5, 64 );
1347 memset( encbuf, 0, 64 );
1348 memset( decbuf, 0, 64 );
1352 fct_chk( NULL != cipher_info );
1376 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1383 fct_chk( outlen == enclen );
1386 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1393 fct_chk( outlen == 0 );
1398 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1405 fct_chk( enclen == outlen );
1408 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1415 fct_chk( outlen == 0 );
1419 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1426 #ifdef POLARSSL_DES_C
1428 FCT_TEST_BGN(des_encrypt_and_decrypt_32_bytes)
1430 unsigned char key[32];
1431 unsigned char iv[16];
1437 unsigned char inbuf[64];
1438 unsigned char encbuf[64];
1439 unsigned char decbuf[64];
1444 memset( key, 0, 32 );
1445 memset( iv , 0, 16 );
1447 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1448 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1450 memset( inbuf, 5, 64 );
1451 memset( encbuf, 0, 64 );
1452 memset( decbuf, 0, 64 );
1456 fct_chk( NULL != cipher_info );
1480 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1487 fct_chk( outlen == enclen );
1490 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1497 fct_chk( outlen == 0 );
1502 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1509 fct_chk( enclen == outlen );
1512 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1519 fct_chk( outlen == 0 );
1523 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1530 #ifdef POLARSSL_DES_C
1532 FCT_TEST_BGN(des_encrypt_and_decrypt_47_bytes)
1534 unsigned char key[32];
1535 unsigned char iv[16];
1541 unsigned char inbuf[64];
1542 unsigned char encbuf[64];
1543 unsigned char decbuf[64];
1548 memset( key, 0, 32 );
1549 memset( iv , 0, 16 );
1551 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1552 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1554 memset( inbuf, 5, 64 );
1555 memset( encbuf, 0, 64 );
1556 memset( decbuf, 0, 64 );
1560 fct_chk( NULL != cipher_info );
1584 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1591 fct_chk( outlen == enclen );
1594 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1601 fct_chk( outlen == 0 );
1606 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1613 fct_chk( enclen == outlen );
1616 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1623 fct_chk( outlen == 0 );
1627 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1634 #ifdef POLARSSL_DES_C
1636 FCT_TEST_BGN(des_encrypt_and_decrypt_48_bytes)
1638 unsigned char key[32];
1639 unsigned char iv[16];
1645 unsigned char inbuf[64];
1646 unsigned char encbuf[64];
1647 unsigned char decbuf[64];
1652 memset( key, 0, 32 );
1653 memset( iv , 0, 16 );
1655 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1656 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1658 memset( inbuf, 5, 64 );
1659 memset( encbuf, 0, 64 );
1660 memset( decbuf, 0, 64 );
1664 fct_chk( NULL != cipher_info );
1688 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1695 fct_chk( outlen == enclen );
1698 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1705 fct_chk( outlen == 0 );
1710 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1717 fct_chk( enclen == outlen );
1720 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1727 fct_chk( outlen == 0 );
1731 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1738 #ifdef POLARSSL_DES_C
1740 FCT_TEST_BGN(des_encrypt_and_decrypt_49_bytes)
1742 unsigned char key[32];
1743 unsigned char iv[16];
1749 unsigned char inbuf[64];
1750 unsigned char encbuf[64];
1751 unsigned char decbuf[64];
1756 memset( key, 0, 32 );
1757 memset( iv , 0, 16 );
1759 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1760 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1762 memset( inbuf, 5, 64 );
1763 memset( encbuf, 0, 64 );
1764 memset( decbuf, 0, 64 );
1768 fct_chk( NULL != cipher_info );
1792 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1799 fct_chk( outlen == enclen );
1802 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1809 fct_chk( outlen == 0 );
1814 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1821 fct_chk( enclen == outlen );
1824 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1831 fct_chk( outlen == 0 );
1835 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1842 #ifdef POLARSSL_DES_C
1844 FCT_TEST_BGN(des_encrypt_and_decrypt_0_bytes_in_multiple_parts)
1845 size_t first_length = 0;
1846 size_t second_length = 0;
1847 size_t length = first_length + second_length;
1848 unsigned char key[32];
1849 unsigned char iv[16];
1855 unsigned char inbuf[64];
1856 unsigned char encbuf[64];
1857 unsigned char decbuf[64];
1860 size_t totaloutlen = 0;
1863 memset( key, 0, 32 );
1864 memset( iv , 0, 16 );
1866 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1867 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1869 memset( inbuf, 5, 64 );
1870 memset( encbuf, 0, 64 );
1871 memset( decbuf, 0, 64 );
1875 fct_chk( NULL != cipher_info);
1897 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
1898 totaloutlen = outlen;
1899 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
1900 totaloutlen += outlen;
1907 fct_chk( totaloutlen == enclen );
1909 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
1910 totaloutlen += outlen;
1917 fct_chk( outlen == 0 );
1921 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1928 fct_chk( enclen == outlen );
1930 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1937 fct_chk( outlen == 0 );
1941 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1948 #ifdef POLARSSL_DES_C
1950 FCT_TEST_BGN(des_encrypt_and_decrypt_1_bytes_in_multiple_parts_1)
1951 size_t first_length = 1;
1952 size_t second_length = 0;
1953 size_t length = first_length + second_length;
1954 unsigned char key[32];
1955 unsigned char iv[16];
1961 unsigned char inbuf[64];
1962 unsigned char encbuf[64];
1963 unsigned char decbuf[64];
1966 size_t totaloutlen = 0;
1969 memset( key, 0, 32 );
1970 memset( iv , 0, 16 );
1972 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1973 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1975 memset( inbuf, 5, 64 );
1976 memset( encbuf, 0, 64 );
1977 memset( decbuf, 0, 64 );
1981 fct_chk( NULL != cipher_info);
2003 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2004 totaloutlen = outlen;
2005 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2006 totaloutlen += outlen;
2013 fct_chk( totaloutlen == enclen );
2015 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2016 totaloutlen += outlen;
2023 fct_chk( outlen == 0 );
2027 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2034 fct_chk( enclen == outlen );
2036 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2043 fct_chk( outlen == 0 );
2047 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2054 #ifdef POLARSSL_DES_C
2056 FCT_TEST_BGN(des_encrypt_and_decrypt_1_bytes_in_multiple_parts_2)
2057 size_t first_length = 0;
2058 size_t second_length = 1;
2059 size_t length = first_length + second_length;
2060 unsigned char key[32];
2061 unsigned char iv[16];
2067 unsigned char inbuf[64];
2068 unsigned char encbuf[64];
2069 unsigned char decbuf[64];
2072 size_t totaloutlen = 0;
2075 memset( key, 0, 32 );
2076 memset( iv , 0, 16 );
2078 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2079 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2081 memset( inbuf, 5, 64 );
2082 memset( encbuf, 0, 64 );
2083 memset( decbuf, 0, 64 );
2087 fct_chk( NULL != cipher_info);
2109 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2110 totaloutlen = outlen;
2111 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2112 totaloutlen += outlen;
2119 fct_chk( totaloutlen == enclen );
2121 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2122 totaloutlen += outlen;
2129 fct_chk( outlen == 0 );
2133 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2140 fct_chk( enclen == outlen );
2142 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2149 fct_chk( outlen == 0 );
2153 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2160 #ifdef POLARSSL_DES_C
2162 FCT_TEST_BGN(des_encrypt_and_decrypt_16_bytes_in_multiple_parts_1)
2163 size_t first_length = 16;
2164 size_t second_length = 0;
2165 size_t length = first_length + second_length;
2166 unsigned char key[32];
2167 unsigned char iv[16];
2173 unsigned char inbuf[64];
2174 unsigned char encbuf[64];
2175 unsigned char decbuf[64];
2178 size_t totaloutlen = 0;
2181 memset( key, 0, 32 );
2182 memset( iv , 0, 16 );
2184 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2185 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2187 memset( inbuf, 5, 64 );
2188 memset( encbuf, 0, 64 );
2189 memset( decbuf, 0, 64 );
2193 fct_chk( NULL != cipher_info);
2215 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2216 totaloutlen = outlen;
2217 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2218 totaloutlen += outlen;
2225 fct_chk( totaloutlen == enclen );
2227 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2228 totaloutlen += outlen;
2235 fct_chk( outlen == 0 );
2239 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2246 fct_chk( enclen == outlen );
2248 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2255 fct_chk( outlen == 0 );
2259 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2266 #ifdef POLARSSL_DES_C
2268 FCT_TEST_BGN(des_encrypt_and_decrypt_16_bytes_in_multiple_parts_2)
2269 size_t first_length = 0;
2270 size_t second_length = 16;
2271 size_t length = first_length + second_length;
2272 unsigned char key[32];
2273 unsigned char iv[16];
2279 unsigned char inbuf[64];
2280 unsigned char encbuf[64];
2281 unsigned char decbuf[64];
2284 size_t totaloutlen = 0;
2287 memset( key, 0, 32 );
2288 memset( iv , 0, 16 );
2290 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2291 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2293 memset( inbuf, 5, 64 );
2294 memset( encbuf, 0, 64 );
2295 memset( decbuf, 0, 64 );
2299 fct_chk( NULL != cipher_info);
2321 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2322 totaloutlen = outlen;
2323 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2324 totaloutlen += outlen;
2331 fct_chk( totaloutlen == enclen );
2333 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2334 totaloutlen += outlen;
2341 fct_chk( outlen == 0 );
2345 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2352 fct_chk( enclen == outlen );
2354 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2361 fct_chk( outlen == 0 );
2365 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2372 #ifdef POLARSSL_DES_C
2374 FCT_TEST_BGN(des_encrypt_and_decrypt_16_bytes_in_multiple_parts_3)
2375 size_t first_length = 1;
2376 size_t second_length = 15;
2377 size_t length = first_length + second_length;
2378 unsigned char key[32];
2379 unsigned char iv[16];
2385 unsigned char inbuf[64];
2386 unsigned char encbuf[64];
2387 unsigned char decbuf[64];
2390 size_t totaloutlen = 0;
2393 memset( key, 0, 32 );
2394 memset( iv , 0, 16 );
2396 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2397 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2399 memset( inbuf, 5, 64 );
2400 memset( encbuf, 0, 64 );
2401 memset( decbuf, 0, 64 );
2405 fct_chk( NULL != cipher_info);
2427 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2428 totaloutlen = outlen;
2429 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2430 totaloutlen += outlen;
2437 fct_chk( totaloutlen == enclen );
2439 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2440 totaloutlen += outlen;
2447 fct_chk( outlen == 0 );
2451 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2458 fct_chk( enclen == outlen );
2460 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2467 fct_chk( outlen == 0 );
2471 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2478 #ifdef POLARSSL_DES_C
2480 FCT_TEST_BGN(des_encrypt_and_decrypt_16_bytes_in_multiple_parts_4)
2481 size_t first_length = 15;
2482 size_t second_length = 1;
2483 size_t length = first_length + second_length;
2484 unsigned char key[32];
2485 unsigned char iv[16];
2491 unsigned char inbuf[64];
2492 unsigned char encbuf[64];
2493 unsigned char decbuf[64];
2496 size_t totaloutlen = 0;
2499 memset( key, 0, 32 );
2500 memset( iv , 0, 16 );
2502 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2503 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2505 memset( inbuf, 5, 64 );
2506 memset( encbuf, 0, 64 );
2507 memset( decbuf, 0, 64 );
2511 fct_chk( NULL != cipher_info);
2533 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2534 totaloutlen = outlen;
2535 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2536 totaloutlen += outlen;
2543 fct_chk( totaloutlen == enclen );
2545 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2546 totaloutlen += outlen;
2553 fct_chk( outlen == 0 );
2557 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2564 fct_chk( enclen == outlen );
2566 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2573 fct_chk( outlen == 0 );
2577 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2584 #ifdef POLARSSL_DES_C
2586 FCT_TEST_BGN(des_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
2587 size_t first_length = 15;
2588 size_t second_length = 7;
2589 size_t length = first_length + second_length;
2590 unsigned char key[32];
2591 unsigned char iv[16];
2597 unsigned char inbuf[64];
2598 unsigned char encbuf[64];
2599 unsigned char decbuf[64];
2602 size_t totaloutlen = 0;
2605 memset( key, 0, 32 );
2606 memset( iv , 0, 16 );
2608 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2609 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2611 memset( inbuf, 5, 64 );
2612 memset( encbuf, 0, 64 );
2613 memset( decbuf, 0, 64 );
2617 fct_chk( NULL != cipher_info);
2639 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2640 totaloutlen = outlen;
2641 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2642 totaloutlen += outlen;
2649 fct_chk( totaloutlen == enclen );
2651 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2652 totaloutlen += outlen;
2659 fct_chk( outlen == 0 );
2663 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2670 fct_chk( enclen == outlen );
2672 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2679 fct_chk( outlen == 0 );
2683 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2690 #ifdef POLARSSL_DES_C
2692 FCT_TEST_BGN(des_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
2693 size_t first_length = 16;
2694 size_t second_length = 6;
2695 size_t length = first_length + second_length;
2696 unsigned char key[32];
2697 unsigned char iv[16];
2703 unsigned char inbuf[64];
2704 unsigned char encbuf[64];
2705 unsigned char decbuf[64];
2708 size_t totaloutlen = 0;
2711 memset( key, 0, 32 );
2712 memset( iv , 0, 16 );
2714 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2715 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2717 memset( inbuf, 5, 64 );
2718 memset( encbuf, 0, 64 );
2719 memset( decbuf, 0, 64 );
2723 fct_chk( NULL != cipher_info);
2745 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2746 totaloutlen = outlen;
2747 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2748 totaloutlen += outlen;
2755 fct_chk( totaloutlen == enclen );
2757 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2758 totaloutlen += outlen;
2765 fct_chk( outlen == 0 );
2769 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2776 fct_chk( enclen == outlen );
2778 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2785 fct_chk( outlen == 0 );
2789 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2796 #ifdef POLARSSL_DES_C
2798 FCT_TEST_BGN(des_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
2799 size_t first_length = 17;
2800 size_t second_length = 6;
2801 size_t length = first_length + second_length;
2802 unsigned char key[32];
2803 unsigned char iv[16];
2809 unsigned char inbuf[64];
2810 unsigned char encbuf[64];
2811 unsigned char decbuf[64];
2814 size_t totaloutlen = 0;
2817 memset( key, 0, 32 );
2818 memset( iv , 0, 16 );
2820 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2821 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2823 memset( inbuf, 5, 64 );
2824 memset( encbuf, 0, 64 );
2825 memset( decbuf, 0, 64 );
2829 fct_chk( NULL != cipher_info);
2851 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2852 totaloutlen = outlen;
2853 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2854 totaloutlen += outlen;
2861 fct_chk( totaloutlen == enclen );
2863 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2864 totaloutlen += outlen;
2871 fct_chk( outlen == 0 );
2875 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2882 fct_chk( enclen == outlen );
2884 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2891 fct_chk( outlen == 0 );
2895 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2902 #ifdef POLARSSL_DES_C
2904 FCT_TEST_BGN(des_encrypt_and_decrypt_32_bytes_in_multiple_parts_1)
2905 size_t first_length = 16;
2906 size_t second_length = 16;
2907 size_t length = first_length + second_length;
2908 unsigned char key[32];
2909 unsigned char iv[16];
2915 unsigned char inbuf[64];
2916 unsigned char encbuf[64];
2917 unsigned char decbuf[64];
2920 size_t totaloutlen = 0;
2923 memset( key, 0, 32 );
2924 memset( iv , 0, 16 );
2926 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2927 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2929 memset( inbuf, 5, 64 );
2930 memset( encbuf, 0, 64 );
2931 memset( decbuf, 0, 64 );
2935 fct_chk( NULL != cipher_info);
2957 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2958 totaloutlen = outlen;
2959 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2960 totaloutlen += outlen;
2967 fct_chk( totaloutlen == enclen );
2969 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2970 totaloutlen += outlen;
2977 fct_chk( outlen == 0 );
2981 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2988 fct_chk( enclen == outlen );
2990 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2997 fct_chk( outlen == 0 );
3001 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3008 #ifdef POLARSSL_DES_C
3010 FCT_TEST_BGN(des_encrypt_and_decrypt_0_bytes)
3012 unsigned char key[32];
3013 unsigned char iv[16];
3019 unsigned char inbuf[64];
3020 unsigned char encbuf[64];
3021 unsigned char decbuf[64];
3026 memset( key, 0, 32 );
3027 memset( iv , 0, 16 );
3029 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3030 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3032 memset( inbuf, 5, 64 );
3033 memset( encbuf, 0, 64 );
3034 memset( decbuf, 0, 64 );
3038 fct_chk( NULL != cipher_info );
3062 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3069 fct_chk( outlen == enclen );
3072 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3079 fct_chk( outlen == 0 );
3084 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3091 fct_chk( enclen == outlen );
3094 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3101 fct_chk( outlen == 0 );
3105 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3112 #ifdef POLARSSL_DES_C
3114 FCT_TEST_BGN(des3_encrypt_and_decrypt_1_byte)
3116 unsigned char key[32];
3117 unsigned char iv[16];
3123 unsigned char inbuf[64];
3124 unsigned char encbuf[64];
3125 unsigned char decbuf[64];
3130 memset( key, 0, 32 );
3131 memset( iv , 0, 16 );
3133 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3134 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3136 memset( inbuf, 5, 64 );
3137 memset( encbuf, 0, 64 );
3138 memset( decbuf, 0, 64 );
3142 fct_chk( NULL != cipher_info );
3166 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3173 fct_chk( outlen == enclen );
3176 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3183 fct_chk( outlen == 0 );
3188 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3195 fct_chk( enclen == outlen );
3198 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3205 fct_chk( outlen == 0 );
3209 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3216 #ifdef POLARSSL_DES_C
3218 FCT_TEST_BGN(des3_encrypt_and_decrypt_2_bytes)
3220 unsigned char key[32];
3221 unsigned char iv[16];
3227 unsigned char inbuf[64];
3228 unsigned char encbuf[64];
3229 unsigned char decbuf[64];
3234 memset( key, 0, 32 );
3235 memset( iv , 0, 16 );
3237 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3238 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3240 memset( inbuf, 5, 64 );
3241 memset( encbuf, 0, 64 );
3242 memset( decbuf, 0, 64 );
3246 fct_chk( NULL != cipher_info );
3270 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3277 fct_chk( outlen == enclen );
3280 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3287 fct_chk( outlen == 0 );
3292 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3299 fct_chk( enclen == outlen );
3302 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3309 fct_chk( outlen == 0 );
3313 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3320 #ifdef POLARSSL_DES_C
3322 FCT_TEST_BGN(des3_encrypt_and_decrypt_7_bytes)
3324 unsigned char key[32];
3325 unsigned char iv[16];
3331 unsigned char inbuf[64];
3332 unsigned char encbuf[64];
3333 unsigned char decbuf[64];
3338 memset( key, 0, 32 );
3339 memset( iv , 0, 16 );
3341 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3342 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3344 memset( inbuf, 5, 64 );
3345 memset( encbuf, 0, 64 );
3346 memset( decbuf, 0, 64 );
3350 fct_chk( NULL != cipher_info );
3374 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3381 fct_chk( outlen == enclen );
3384 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3391 fct_chk( outlen == 0 );
3396 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3403 fct_chk( enclen == outlen );
3406 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3413 fct_chk( outlen == 0 );
3417 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3424 #ifdef POLARSSL_DES_C
3426 FCT_TEST_BGN(des3_encrypt_and_decrypt_8_bytes)
3428 unsigned char key[32];
3429 unsigned char iv[16];
3435 unsigned char inbuf[64];
3436 unsigned char encbuf[64];
3437 unsigned char decbuf[64];
3442 memset( key, 0, 32 );
3443 memset( iv , 0, 16 );
3445 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3446 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3448 memset( inbuf, 5, 64 );
3449 memset( encbuf, 0, 64 );
3450 memset( decbuf, 0, 64 );
3454 fct_chk( NULL != cipher_info );
3478 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3485 fct_chk( outlen == enclen );
3488 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3495 fct_chk( outlen == 0 );
3500 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3507 fct_chk( enclen == outlen );
3510 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3517 fct_chk( outlen == 0 );
3521 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3528 #ifdef POLARSSL_DES_C
3530 FCT_TEST_BGN(des3_encrypt_and_decrypt_9_bytes)
3532 unsigned char key[32];
3533 unsigned char iv[16];
3539 unsigned char inbuf[64];
3540 unsigned char encbuf[64];
3541 unsigned char decbuf[64];
3546 memset( key, 0, 32 );
3547 memset( iv , 0, 16 );
3549 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3550 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3552 memset( inbuf, 5, 64 );
3553 memset( encbuf, 0, 64 );
3554 memset( decbuf, 0, 64 );
3558 fct_chk( NULL != cipher_info );
3582 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3589 fct_chk( outlen == enclen );
3592 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3599 fct_chk( outlen == 0 );
3604 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3611 fct_chk( enclen == outlen );
3614 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3621 fct_chk( outlen == 0 );
3625 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3632 #ifdef POLARSSL_DES_C
3634 FCT_TEST_BGN(des3_encrypt_and_decrypt_15_bytes)
3636 unsigned char key[32];
3637 unsigned char iv[16];
3643 unsigned char inbuf[64];
3644 unsigned char encbuf[64];
3645 unsigned char decbuf[64];
3650 memset( key, 0, 32 );
3651 memset( iv , 0, 16 );
3653 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3654 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3656 memset( inbuf, 5, 64 );
3657 memset( encbuf, 0, 64 );
3658 memset( decbuf, 0, 64 );
3662 fct_chk( NULL != cipher_info );
3686 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3693 fct_chk( outlen == enclen );
3696 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3703 fct_chk( outlen == 0 );
3708 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3715 fct_chk( enclen == outlen );
3718 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3725 fct_chk( outlen == 0 );
3729 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3736 #ifdef POLARSSL_DES_C
3738 FCT_TEST_BGN(des3_encrypt_and_decrypt_16_bytes)
3740 unsigned char key[32];
3741 unsigned char iv[16];
3747 unsigned char inbuf[64];
3748 unsigned char encbuf[64];
3749 unsigned char decbuf[64];
3754 memset( key, 0, 32 );
3755 memset( iv , 0, 16 );
3757 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3758 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3760 memset( inbuf, 5, 64 );
3761 memset( encbuf, 0, 64 );
3762 memset( decbuf, 0, 64 );
3766 fct_chk( NULL != cipher_info );
3790 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3797 fct_chk( outlen == enclen );
3800 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3807 fct_chk( outlen == 0 );
3812 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3819 fct_chk( enclen == outlen );
3822 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3829 fct_chk( outlen == 0 );
3833 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3840 #ifdef POLARSSL_DES_C
3842 FCT_TEST_BGN(des3_encrypt_and_decrypt_17_bytes)
3844 unsigned char key[32];
3845 unsigned char iv[16];
3851 unsigned char inbuf[64];
3852 unsigned char encbuf[64];
3853 unsigned char decbuf[64];
3858 memset( key, 0, 32 );
3859 memset( iv , 0, 16 );
3861 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3862 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3864 memset( inbuf, 5, 64 );
3865 memset( encbuf, 0, 64 );
3866 memset( decbuf, 0, 64 );
3870 fct_chk( NULL != cipher_info );
3894 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3901 fct_chk( outlen == enclen );
3904 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3911 fct_chk( outlen == 0 );
3916 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3923 fct_chk( enclen == outlen );
3926 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3933 fct_chk( outlen == 0 );
3937 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3944 #ifdef POLARSSL_DES_C
3946 FCT_TEST_BGN(des3_encrypt_and_decrypt_31_bytes)
3948 unsigned char key[32];
3949 unsigned char iv[16];
3955 unsigned char inbuf[64];
3956 unsigned char encbuf[64];
3957 unsigned char decbuf[64];
3962 memset( key, 0, 32 );
3963 memset( iv , 0, 16 );
3965 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3966 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3968 memset( inbuf, 5, 64 );
3969 memset( encbuf, 0, 64 );
3970 memset( decbuf, 0, 64 );
3974 fct_chk( NULL != cipher_info );
3998 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4005 fct_chk( outlen == enclen );
4008 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4015 fct_chk( outlen == 0 );
4020 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4027 fct_chk( enclen == outlen );
4030 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4037 fct_chk( outlen == 0 );
4041 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4048 #ifdef POLARSSL_DES_C
4050 FCT_TEST_BGN(des3_encrypt_and_decrypt_32_bytes)
4052 unsigned char key[32];
4053 unsigned char iv[16];
4059 unsigned char inbuf[64];
4060 unsigned char encbuf[64];
4061 unsigned char decbuf[64];
4066 memset( key, 0, 32 );
4067 memset( iv , 0, 16 );
4069 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4070 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4072 memset( inbuf, 5, 64 );
4073 memset( encbuf, 0, 64 );
4074 memset( decbuf, 0, 64 );
4078 fct_chk( NULL != cipher_info );
4102 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4109 fct_chk( outlen == enclen );
4112 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4119 fct_chk( outlen == 0 );
4124 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4131 fct_chk( enclen == outlen );
4134 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4141 fct_chk( outlen == 0 );
4145 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4152 #ifdef POLARSSL_DES_C
4154 FCT_TEST_BGN(des3_encrypt_and_decrypt_32_bytes)
4156 unsigned char key[32];
4157 unsigned char iv[16];
4163 unsigned char inbuf[64];
4164 unsigned char encbuf[64];
4165 unsigned char decbuf[64];
4170 memset( key, 0, 32 );
4171 memset( iv , 0, 16 );
4173 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4174 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4176 memset( inbuf, 5, 64 );
4177 memset( encbuf, 0, 64 );
4178 memset( decbuf, 0, 64 );
4182 fct_chk( NULL != cipher_info );
4206 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4213 fct_chk( outlen == enclen );
4216 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4223 fct_chk( outlen == 0 );
4228 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4235 fct_chk( enclen == outlen );
4238 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4245 fct_chk( outlen == 0 );
4249 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4256 #ifdef POLARSSL_DES_C
4258 FCT_TEST_BGN(des3_encrypt_and_decrypt_47_bytes)
4260 unsigned char key[32];
4261 unsigned char iv[16];
4267 unsigned char inbuf[64];
4268 unsigned char encbuf[64];
4269 unsigned char decbuf[64];
4274 memset( key, 0, 32 );
4275 memset( iv , 0, 16 );
4277 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4278 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4280 memset( inbuf, 5, 64 );
4281 memset( encbuf, 0, 64 );
4282 memset( decbuf, 0, 64 );
4286 fct_chk( NULL != cipher_info );
4310 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4317 fct_chk( outlen == enclen );
4320 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4327 fct_chk( outlen == 0 );
4332 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4339 fct_chk( enclen == outlen );
4342 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4349 fct_chk( outlen == 0 );
4353 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4360 #ifdef POLARSSL_DES_C
4362 FCT_TEST_BGN(des3_encrypt_and_decrypt_48_bytes)
4364 unsigned char key[32];
4365 unsigned char iv[16];
4371 unsigned char inbuf[64];
4372 unsigned char encbuf[64];
4373 unsigned char decbuf[64];
4378 memset( key, 0, 32 );
4379 memset( iv , 0, 16 );
4381 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4382 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4384 memset( inbuf, 5, 64 );
4385 memset( encbuf, 0, 64 );
4386 memset( decbuf, 0, 64 );
4390 fct_chk( NULL != cipher_info );
4414 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4421 fct_chk( outlen == enclen );
4424 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4431 fct_chk( outlen == 0 );
4436 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4443 fct_chk( enclen == outlen );
4446 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4453 fct_chk( outlen == 0 );
4457 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4464 #ifdef POLARSSL_DES_C
4466 FCT_TEST_BGN(des3_encrypt_and_decrypt_49_bytes)
4468 unsigned char key[32];
4469 unsigned char iv[16];
4475 unsigned char inbuf[64];
4476 unsigned char encbuf[64];
4477 unsigned char decbuf[64];
4482 memset( key, 0, 32 );
4483 memset( iv , 0, 16 );
4485 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4486 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4488 memset( inbuf, 5, 64 );
4489 memset( encbuf, 0, 64 );
4490 memset( decbuf, 0, 64 );
4494 fct_chk( NULL != cipher_info );
4518 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4525 fct_chk( outlen == enclen );
4528 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4535 fct_chk( outlen == 0 );
4540 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4547 fct_chk( enclen == outlen );
4550 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4557 fct_chk( outlen == 0 );
4561 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4568 #ifdef POLARSSL_DES_C
4570 FCT_TEST_BGN(des3_encrypt_and_decrypt_0_bytes_in_multiple_parts)
4571 size_t first_length = 0;
4572 size_t second_length = 0;
4573 size_t length = first_length + second_length;
4574 unsigned char key[32];
4575 unsigned char iv[16];
4581 unsigned char inbuf[64];
4582 unsigned char encbuf[64];
4583 unsigned char decbuf[64];
4586 size_t totaloutlen = 0;
4589 memset( key, 0, 32 );
4590 memset( iv , 0, 16 );
4592 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4593 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4595 memset( inbuf, 5, 64 );
4596 memset( encbuf, 0, 64 );
4597 memset( decbuf, 0, 64 );
4601 fct_chk( NULL != cipher_info);
4623 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4624 totaloutlen = outlen;
4625 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4626 totaloutlen += outlen;
4633 fct_chk( totaloutlen == enclen );
4635 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4636 totaloutlen += outlen;
4643 fct_chk( outlen == 0 );
4647 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4654 fct_chk( enclen == outlen );
4656 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4663 fct_chk( outlen == 0 );
4667 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4674 #ifdef POLARSSL_DES_C
4676 FCT_TEST_BGN(des3_encrypt_and_decrypt_1_bytes_in_multiple_parts_1)
4677 size_t first_length = 1;
4678 size_t second_length = 0;
4679 size_t length = first_length + second_length;
4680 unsigned char key[32];
4681 unsigned char iv[16];
4687 unsigned char inbuf[64];
4688 unsigned char encbuf[64];
4689 unsigned char decbuf[64];
4692 size_t totaloutlen = 0;
4695 memset( key, 0, 32 );
4696 memset( iv , 0, 16 );
4698 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4699 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4701 memset( inbuf, 5, 64 );
4702 memset( encbuf, 0, 64 );
4703 memset( decbuf, 0, 64 );
4707 fct_chk( NULL != cipher_info);
4729 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4730 totaloutlen = outlen;
4731 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4732 totaloutlen += outlen;
4739 fct_chk( totaloutlen == enclen );
4741 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4742 totaloutlen += outlen;
4749 fct_chk( outlen == 0 );
4753 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4760 fct_chk( enclen == outlen );
4762 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4769 fct_chk( outlen == 0 );
4773 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4780 #ifdef POLARSSL_DES_C
4782 FCT_TEST_BGN(des3_encrypt_and_decrypt_1_bytes_in_multiple_parts_2)
4783 size_t first_length = 0;
4784 size_t second_length = 1;
4785 size_t length = first_length + second_length;
4786 unsigned char key[32];
4787 unsigned char iv[16];
4793 unsigned char inbuf[64];
4794 unsigned char encbuf[64];
4795 unsigned char decbuf[64];
4798 size_t totaloutlen = 0;
4801 memset( key, 0, 32 );
4802 memset( iv , 0, 16 );
4804 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4805 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4807 memset( inbuf, 5, 64 );
4808 memset( encbuf, 0, 64 );
4809 memset( decbuf, 0, 64 );
4813 fct_chk( NULL != cipher_info);
4835 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4836 totaloutlen = outlen;
4837 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4838 totaloutlen += outlen;
4845 fct_chk( totaloutlen == enclen );
4847 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4848 totaloutlen += outlen;
4855 fct_chk( outlen == 0 );
4859 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4866 fct_chk( enclen == outlen );
4868 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4875 fct_chk( outlen == 0 );
4879 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4886 #ifdef POLARSSL_DES_C
4888 FCT_TEST_BGN(des3_encrypt_and_decrypt_16_bytes_in_multiple_parts_1)
4889 size_t first_length = 16;
4890 size_t second_length = 0;
4891 size_t length = first_length + second_length;
4892 unsigned char key[32];
4893 unsigned char iv[16];
4899 unsigned char inbuf[64];
4900 unsigned char encbuf[64];
4901 unsigned char decbuf[64];
4904 size_t totaloutlen = 0;
4907 memset( key, 0, 32 );
4908 memset( iv , 0, 16 );
4910 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4911 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4913 memset( inbuf, 5, 64 );
4914 memset( encbuf, 0, 64 );
4915 memset( decbuf, 0, 64 );
4919 fct_chk( NULL != cipher_info);
4941 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4942 totaloutlen = outlen;
4943 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4944 totaloutlen += outlen;
4951 fct_chk( totaloutlen == enclen );
4953 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4954 totaloutlen += outlen;
4961 fct_chk( outlen == 0 );
4965 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4972 fct_chk( enclen == outlen );
4974 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4981 fct_chk( outlen == 0 );
4985 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4992 #ifdef POLARSSL_DES_C
4994 FCT_TEST_BGN(des3_encrypt_and_decrypt_16_bytes_in_multiple_parts_2)
4995 size_t first_length = 0;
4996 size_t second_length = 16;
4997 size_t length = first_length + second_length;
4998 unsigned char key[32];
4999 unsigned char iv[16];
5005 unsigned char inbuf[64];
5006 unsigned char encbuf[64];
5007 unsigned char decbuf[64];
5010 size_t totaloutlen = 0;
5013 memset( key, 0, 32 );
5014 memset( iv , 0, 16 );
5016 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5017 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5019 memset( inbuf, 5, 64 );
5020 memset( encbuf, 0, 64 );
5021 memset( decbuf, 0, 64 );
5025 fct_chk( NULL != cipher_info);
5047 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5048 totaloutlen = outlen;
5049 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5050 totaloutlen += outlen;
5057 fct_chk( totaloutlen == enclen );
5059 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5060 totaloutlen += outlen;
5067 fct_chk( outlen == 0 );
5071 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5078 fct_chk( enclen == outlen );
5080 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5087 fct_chk( outlen == 0 );
5091 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5098 #ifdef POLARSSL_DES_C
5100 FCT_TEST_BGN(des3_encrypt_and_decrypt_16_bytes_in_multiple_parts_3)
5101 size_t first_length = 1;
5102 size_t second_length = 15;
5103 size_t length = first_length + second_length;
5104 unsigned char key[32];
5105 unsigned char iv[16];
5111 unsigned char inbuf[64];
5112 unsigned char encbuf[64];
5113 unsigned char decbuf[64];
5116 size_t totaloutlen = 0;
5119 memset( key, 0, 32 );
5120 memset( iv , 0, 16 );
5122 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5123 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5125 memset( inbuf, 5, 64 );
5126 memset( encbuf, 0, 64 );
5127 memset( decbuf, 0, 64 );
5131 fct_chk( NULL != cipher_info);
5153 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5154 totaloutlen = outlen;
5155 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5156 totaloutlen += outlen;
5163 fct_chk( totaloutlen == enclen );
5165 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5166 totaloutlen += outlen;
5173 fct_chk( outlen == 0 );
5177 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5184 fct_chk( enclen == outlen );
5186 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5193 fct_chk( outlen == 0 );
5197 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5204 #ifdef POLARSSL_DES_C
5206 FCT_TEST_BGN(des3_encrypt_and_decrypt_16_bytes_in_multiple_parts_4)
5207 size_t first_length = 15;
5208 size_t second_length = 1;
5209 size_t length = first_length + second_length;
5210 unsigned char key[32];
5211 unsigned char iv[16];
5217 unsigned char inbuf[64];
5218 unsigned char encbuf[64];
5219 unsigned char decbuf[64];
5222 size_t totaloutlen = 0;
5225 memset( key, 0, 32 );
5226 memset( iv , 0, 16 );
5228 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5229 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5231 memset( inbuf, 5, 64 );
5232 memset( encbuf, 0, 64 );
5233 memset( decbuf, 0, 64 );
5237 fct_chk( NULL != cipher_info);
5259 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5260 totaloutlen = outlen;
5261 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5262 totaloutlen += outlen;
5269 fct_chk( totaloutlen == enclen );
5271 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5272 totaloutlen += outlen;
5279 fct_chk( outlen == 0 );
5283 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5290 fct_chk( enclen == outlen );
5292 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5299 fct_chk( outlen == 0 );
5303 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5310 #ifdef POLARSSL_DES_C
5312 FCT_TEST_BGN(des3_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
5313 size_t first_length = 15;
5314 size_t second_length = 7;
5315 size_t length = first_length + second_length;
5316 unsigned char key[32];
5317 unsigned char iv[16];
5323 unsigned char inbuf[64];
5324 unsigned char encbuf[64];
5325 unsigned char decbuf[64];
5328 size_t totaloutlen = 0;
5331 memset( key, 0, 32 );
5332 memset( iv , 0, 16 );
5334 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5335 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5337 memset( inbuf, 5, 64 );
5338 memset( encbuf, 0, 64 );
5339 memset( decbuf, 0, 64 );
5343 fct_chk( NULL != cipher_info);
5365 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5366 totaloutlen = outlen;
5367 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5368 totaloutlen += outlen;
5375 fct_chk( totaloutlen == enclen );
5377 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5378 totaloutlen += outlen;
5385 fct_chk( outlen == 0 );
5389 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5396 fct_chk( enclen == outlen );
5398 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5405 fct_chk( outlen == 0 );
5409 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5416 #ifdef POLARSSL_DES_C
5418 FCT_TEST_BGN(des3_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
5419 size_t first_length = 16;
5420 size_t second_length = 6;
5421 size_t length = first_length + second_length;
5422 unsigned char key[32];
5423 unsigned char iv[16];
5429 unsigned char inbuf[64];
5430 unsigned char encbuf[64];
5431 unsigned char decbuf[64];
5434 size_t totaloutlen = 0;
5437 memset( key, 0, 32 );
5438 memset( iv , 0, 16 );
5440 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5441 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5443 memset( inbuf, 5, 64 );
5444 memset( encbuf, 0, 64 );
5445 memset( decbuf, 0, 64 );
5449 fct_chk( NULL != cipher_info);
5471 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5472 totaloutlen = outlen;
5473 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5474 totaloutlen += outlen;
5481 fct_chk( totaloutlen == enclen );
5483 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5484 totaloutlen += outlen;
5491 fct_chk( outlen == 0 );
5495 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5502 fct_chk( enclen == outlen );
5504 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5511 fct_chk( outlen == 0 );
5515 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5522 #ifdef POLARSSL_DES_C
5524 FCT_TEST_BGN(des3_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
5525 size_t first_length = 17;
5526 size_t second_length = 6;
5527 size_t length = first_length + second_length;
5528 unsigned char key[32];
5529 unsigned char iv[16];
5535 unsigned char inbuf[64];
5536 unsigned char encbuf[64];
5537 unsigned char decbuf[64];
5540 size_t totaloutlen = 0;
5543 memset( key, 0, 32 );
5544 memset( iv , 0, 16 );
5546 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5547 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5549 memset( inbuf, 5, 64 );
5550 memset( encbuf, 0, 64 );
5551 memset( decbuf, 0, 64 );
5555 fct_chk( NULL != cipher_info);
5577 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5578 totaloutlen = outlen;
5579 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5580 totaloutlen += outlen;
5587 fct_chk( totaloutlen == enclen );
5589 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5590 totaloutlen += outlen;
5597 fct_chk( outlen == 0 );
5601 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5608 fct_chk( enclen == outlen );
5610 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5617 fct_chk( outlen == 0 );
5621 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5628 #ifdef POLARSSL_DES_C
5630 FCT_TEST_BGN(des3_encrypt_and_decrypt_32_bytes_in_multiple_parts_1)
5631 size_t first_length = 16;
5632 size_t second_length = 16;
5633 size_t length = first_length + second_length;
5634 unsigned char key[32];
5635 unsigned char iv[16];
5641 unsigned char inbuf[64];
5642 unsigned char encbuf[64];
5643 unsigned char decbuf[64];
5646 size_t totaloutlen = 0;
5649 memset( key, 0, 32 );
5650 memset( iv , 0, 16 );
5652 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5653 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5655 memset( inbuf, 5, 64 );
5656 memset( encbuf, 0, 64 );
5657 memset( decbuf, 0, 64 );
5661 fct_chk( NULL != cipher_info);
5683 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5684 totaloutlen = outlen;
5685 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5686 totaloutlen += outlen;
5693 fct_chk( totaloutlen == enclen );
5695 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5696 totaloutlen += outlen;
5703 fct_chk( outlen == 0 );
5707 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5714 fct_chk( enclen == outlen );
5716 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5723 fct_chk( outlen == 0 );
5727 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5734 #ifdef POLARSSL_DES_C
5736 FCT_TEST_BGN(des3_encrypt_and_decrypt_0_bytes)
5738 unsigned char key[32];
5739 unsigned char iv[16];
5745 unsigned char inbuf[64];
5746 unsigned char encbuf[64];
5747 unsigned char decbuf[64];
5752 memset( key, 0, 32 );
5753 memset( iv , 0, 16 );
5755 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5756 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5758 memset( inbuf, 5, 64 );
5759 memset( encbuf, 0, 64 );
5760 memset( decbuf, 0, 64 );
5764 fct_chk( NULL != cipher_info );
5788 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
5795 fct_chk( outlen == enclen );
5798 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
5805 fct_chk( outlen == 0 );
5810 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5817 fct_chk( enclen == outlen );
5820 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5827 fct_chk( outlen == 0 );
5831 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5838 #ifdef POLARSSL_DES_C
5840 FCT_TEST_BGN(des3_encrypt_and_decrypt_1_byte)
5842 unsigned char key[32];
5843 unsigned char iv[16];
5849 unsigned char inbuf[64];
5850 unsigned char encbuf[64];
5851 unsigned char decbuf[64];
5856 memset( key, 0, 32 );
5857 memset( iv , 0, 16 );
5859 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5860 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5862 memset( inbuf, 5, 64 );
5863 memset( encbuf, 0, 64 );
5864 memset( decbuf, 0, 64 );
5868 fct_chk( NULL != cipher_info );
5892 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
5899 fct_chk( outlen == enclen );
5902 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
5909 fct_chk( outlen == 0 );
5914 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5921 fct_chk( enclen == outlen );
5924 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5931 fct_chk( outlen == 0 );
5935 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5942 #ifdef POLARSSL_DES_C
5944 FCT_TEST_BGN(des3_encrypt_and_decrypt_2_bytes)
5946 unsigned char key[32];
5947 unsigned char iv[16];
5953 unsigned char inbuf[64];
5954 unsigned char encbuf[64];
5955 unsigned char decbuf[64];
5960 memset( key, 0, 32 );
5961 memset( iv , 0, 16 );
5963 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5964 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5966 memset( inbuf, 5, 64 );
5967 memset( encbuf, 0, 64 );
5968 memset( decbuf, 0, 64 );
5972 fct_chk( NULL != cipher_info );
5996 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6003 fct_chk( outlen == enclen );
6006 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6013 fct_chk( outlen == 0 );
6018 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6025 fct_chk( enclen == outlen );
6028 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6035 fct_chk( outlen == 0 );
6039 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6046 #ifdef POLARSSL_DES_C
6048 FCT_TEST_BGN(des3_encrypt_and_decrypt_7_bytes)
6050 unsigned char key[32];
6051 unsigned char iv[16];
6057 unsigned char inbuf[64];
6058 unsigned char encbuf[64];
6059 unsigned char decbuf[64];
6064 memset( key, 0, 32 );
6065 memset( iv , 0, 16 );
6067 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6068 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6070 memset( inbuf, 5, 64 );
6071 memset( encbuf, 0, 64 );
6072 memset( decbuf, 0, 64 );
6076 fct_chk( NULL != cipher_info );
6100 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6107 fct_chk( outlen == enclen );
6110 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6117 fct_chk( outlen == 0 );
6122 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6129 fct_chk( enclen == outlen );
6132 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6139 fct_chk( outlen == 0 );
6143 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6150 #ifdef POLARSSL_DES_C
6152 FCT_TEST_BGN(des3_encrypt_and_decrypt_8_bytes)
6154 unsigned char key[32];
6155 unsigned char iv[16];
6161 unsigned char inbuf[64];
6162 unsigned char encbuf[64];
6163 unsigned char decbuf[64];
6168 memset( key, 0, 32 );
6169 memset( iv , 0, 16 );
6171 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6172 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6174 memset( inbuf, 5, 64 );
6175 memset( encbuf, 0, 64 );
6176 memset( decbuf, 0, 64 );
6180 fct_chk( NULL != cipher_info );
6204 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6211 fct_chk( outlen == enclen );
6214 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6221 fct_chk( outlen == 0 );
6226 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6233 fct_chk( enclen == outlen );
6236 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6243 fct_chk( outlen == 0 );
6247 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6254 #ifdef POLARSSL_DES_C
6256 FCT_TEST_BGN(des3_encrypt_and_decrypt_9_bytes)
6258 unsigned char key[32];
6259 unsigned char iv[16];
6265 unsigned char inbuf[64];
6266 unsigned char encbuf[64];
6267 unsigned char decbuf[64];
6272 memset( key, 0, 32 );
6273 memset( iv , 0, 16 );
6275 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6276 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6278 memset( inbuf, 5, 64 );
6279 memset( encbuf, 0, 64 );
6280 memset( decbuf, 0, 64 );
6284 fct_chk( NULL != cipher_info );
6308 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6315 fct_chk( outlen == enclen );
6318 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6325 fct_chk( outlen == 0 );
6330 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6337 fct_chk( enclen == outlen );
6340 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6347 fct_chk( outlen == 0 );
6351 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6358 #ifdef POLARSSL_DES_C
6360 FCT_TEST_BGN(des3_encrypt_and_decrypt_15_bytes)
6362 unsigned char key[32];
6363 unsigned char iv[16];
6369 unsigned char inbuf[64];
6370 unsigned char encbuf[64];
6371 unsigned char decbuf[64];
6376 memset( key, 0, 32 );
6377 memset( iv , 0, 16 );
6379 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6380 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6382 memset( inbuf, 5, 64 );
6383 memset( encbuf, 0, 64 );
6384 memset( decbuf, 0, 64 );
6388 fct_chk( NULL != cipher_info );
6412 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6419 fct_chk( outlen == enclen );
6422 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6429 fct_chk( outlen == 0 );
6434 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6441 fct_chk( enclen == outlen );
6444 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6451 fct_chk( outlen == 0 );
6455 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6462 #ifdef POLARSSL_DES_C
6464 FCT_TEST_BGN(des3_encrypt_and_decrypt_16_bytes)
6466 unsigned char key[32];
6467 unsigned char iv[16];
6473 unsigned char inbuf[64];
6474 unsigned char encbuf[64];
6475 unsigned char decbuf[64];
6480 memset( key, 0, 32 );
6481 memset( iv , 0, 16 );
6483 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6484 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6486 memset( inbuf, 5, 64 );
6487 memset( encbuf, 0, 64 );
6488 memset( decbuf, 0, 64 );
6492 fct_chk( NULL != cipher_info );
6516 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6523 fct_chk( outlen == enclen );
6526 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6533 fct_chk( outlen == 0 );
6538 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6545 fct_chk( enclen == outlen );
6548 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6555 fct_chk( outlen == 0 );
6559 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6566 #ifdef POLARSSL_DES_C
6568 FCT_TEST_BGN(des3_encrypt_and_decrypt_17_bytes)
6570 unsigned char key[32];
6571 unsigned char iv[16];
6577 unsigned char inbuf[64];
6578 unsigned char encbuf[64];
6579 unsigned char decbuf[64];
6584 memset( key, 0, 32 );
6585 memset( iv , 0, 16 );
6587 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6588 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6590 memset( inbuf, 5, 64 );
6591 memset( encbuf, 0, 64 );
6592 memset( decbuf, 0, 64 );
6596 fct_chk( NULL != cipher_info );
6620 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6627 fct_chk( outlen == enclen );
6630 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6637 fct_chk( outlen == 0 );
6642 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6649 fct_chk( enclen == outlen );
6652 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6659 fct_chk( outlen == 0 );
6663 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6670 #ifdef POLARSSL_DES_C
6672 FCT_TEST_BGN(des3_encrypt_and_decrypt_31_bytes)
6674 unsigned char key[32];
6675 unsigned char iv[16];
6681 unsigned char inbuf[64];
6682 unsigned char encbuf[64];
6683 unsigned char decbuf[64];
6688 memset( key, 0, 32 );
6689 memset( iv , 0, 16 );
6691 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6692 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6694 memset( inbuf, 5, 64 );
6695 memset( encbuf, 0, 64 );
6696 memset( decbuf, 0, 64 );
6700 fct_chk( NULL != cipher_info );
6724 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6731 fct_chk( outlen == enclen );
6734 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6741 fct_chk( outlen == 0 );
6746 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6753 fct_chk( enclen == outlen );
6756 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6763 fct_chk( outlen == 0 );
6767 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6774 #ifdef POLARSSL_DES_C
6776 FCT_TEST_BGN(des3_encrypt_and_decrypt_32_bytes)
6778 unsigned char key[32];
6779 unsigned char iv[16];
6785 unsigned char inbuf[64];
6786 unsigned char encbuf[64];
6787 unsigned char decbuf[64];
6792 memset( key, 0, 32 );
6793 memset( iv , 0, 16 );
6795 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6796 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6798 memset( inbuf, 5, 64 );
6799 memset( encbuf, 0, 64 );
6800 memset( decbuf, 0, 64 );
6804 fct_chk( NULL != cipher_info );
6828 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6835 fct_chk( outlen == enclen );
6838 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6845 fct_chk( outlen == 0 );
6850 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6857 fct_chk( enclen == outlen );
6860 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6867 fct_chk( outlen == 0 );
6871 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6878 #ifdef POLARSSL_DES_C
6880 FCT_TEST_BGN(des3_encrypt_and_decrypt_32_bytes)
6882 unsigned char key[32];
6883 unsigned char iv[16];
6889 unsigned char inbuf[64];
6890 unsigned char encbuf[64];
6891 unsigned char decbuf[64];
6896 memset( key, 0, 32 );
6897 memset( iv , 0, 16 );
6899 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6900 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6902 memset( inbuf, 5, 64 );
6903 memset( encbuf, 0, 64 );
6904 memset( decbuf, 0, 64 );
6908 fct_chk( NULL != cipher_info );
6932 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6939 fct_chk( outlen == enclen );
6942 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6949 fct_chk( outlen == 0 );
6954 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6961 fct_chk( enclen == outlen );
6964 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6971 fct_chk( outlen == 0 );
6975 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6982 #ifdef POLARSSL_DES_C
6984 FCT_TEST_BGN(des3_encrypt_and_decrypt_47_bytes)
6986 unsigned char key[32];
6987 unsigned char iv[16];
6993 unsigned char inbuf[64];
6994 unsigned char encbuf[64];
6995 unsigned char decbuf[64];
7000 memset( key, 0, 32 );
7001 memset( iv , 0, 16 );
7003 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7004 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7006 memset( inbuf, 5, 64 );
7007 memset( encbuf, 0, 64 );
7008 memset( decbuf, 0, 64 );
7012 fct_chk( NULL != cipher_info );
7036 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
7043 fct_chk( outlen == enclen );
7046 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
7053 fct_chk( outlen == 0 );
7058 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7065 fct_chk( enclen == outlen );
7068 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7075 fct_chk( outlen == 0 );
7079 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7086 #ifdef POLARSSL_DES_C
7088 FCT_TEST_BGN(des3_encrypt_and_decrypt_48_bytes)
7090 unsigned char key[32];
7091 unsigned char iv[16];
7097 unsigned char inbuf[64];
7098 unsigned char encbuf[64];
7099 unsigned char decbuf[64];
7104 memset( key, 0, 32 );
7105 memset( iv , 0, 16 );
7107 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7108 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7110 memset( inbuf, 5, 64 );
7111 memset( encbuf, 0, 64 );
7112 memset( decbuf, 0, 64 );
7116 fct_chk( NULL != cipher_info );
7140 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
7147 fct_chk( outlen == enclen );
7150 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
7157 fct_chk( outlen == 0 );
7162 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7169 fct_chk( enclen == outlen );
7172 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7179 fct_chk( outlen == 0 );
7183 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7190 #ifdef POLARSSL_DES_C
7192 FCT_TEST_BGN(des3_encrypt_and_decrypt_49_bytes)
7194 unsigned char key[32];
7195 unsigned char iv[16];
7201 unsigned char inbuf[64];
7202 unsigned char encbuf[64];
7203 unsigned char decbuf[64];
7208 memset( key, 0, 32 );
7209 memset( iv , 0, 16 );
7211 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7212 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7214 memset( inbuf, 5, 64 );
7215 memset( encbuf, 0, 64 );
7216 memset( decbuf, 0, 64 );
7220 fct_chk( NULL != cipher_info );
7244 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
7251 fct_chk( outlen == enclen );
7254 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
7261 fct_chk( outlen == 0 );
7266 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7273 fct_chk( enclen == outlen );
7276 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7283 fct_chk( outlen == 0 );
7287 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7294 #ifdef POLARSSL_DES_C
7296 FCT_TEST_BGN(des3_encrypt_and_decrypt_0_bytes_in_multiple_parts)
7297 size_t first_length = 0;
7298 size_t second_length = 0;
7299 size_t length = first_length + second_length;
7300 unsigned char key[32];
7301 unsigned char iv[16];
7307 unsigned char inbuf[64];
7308 unsigned char encbuf[64];
7309 unsigned char decbuf[64];
7312 size_t totaloutlen = 0;
7315 memset( key, 0, 32 );
7316 memset( iv , 0, 16 );
7318 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7319 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7321 memset( inbuf, 5, 64 );
7322 memset( encbuf, 0, 64 );
7323 memset( decbuf, 0, 64 );
7327 fct_chk( NULL != cipher_info);
7349 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7350 totaloutlen = outlen;
7351 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7352 totaloutlen += outlen;
7359 fct_chk( totaloutlen == enclen );
7361 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7362 totaloutlen += outlen;
7369 fct_chk( outlen == 0 );
7373 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7380 fct_chk( enclen == outlen );
7382 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7389 fct_chk( outlen == 0 );
7393 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7400 #ifdef POLARSSL_DES_C
7402 FCT_TEST_BGN(des3_encrypt_and_decrypt_1_bytes_in_multiple_parts_1)
7403 size_t first_length = 1;
7404 size_t second_length = 0;
7405 size_t length = first_length + second_length;
7406 unsigned char key[32];
7407 unsigned char iv[16];
7413 unsigned char inbuf[64];
7414 unsigned char encbuf[64];
7415 unsigned char decbuf[64];
7418 size_t totaloutlen = 0;
7421 memset( key, 0, 32 );
7422 memset( iv , 0, 16 );
7424 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7425 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7427 memset( inbuf, 5, 64 );
7428 memset( encbuf, 0, 64 );
7429 memset( decbuf, 0, 64 );
7433 fct_chk( NULL != cipher_info);
7455 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7456 totaloutlen = outlen;
7457 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7458 totaloutlen += outlen;
7465 fct_chk( totaloutlen == enclen );
7467 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7468 totaloutlen += outlen;
7475 fct_chk( outlen == 0 );
7479 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7486 fct_chk( enclen == outlen );
7488 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7495 fct_chk( outlen == 0 );
7499 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7506 #ifdef POLARSSL_DES_C
7508 FCT_TEST_BGN(des3_encrypt_and_decrypt_1_bytes_in_multiple_parts_2)
7509 size_t first_length = 0;
7510 size_t second_length = 1;
7511 size_t length = first_length + second_length;
7512 unsigned char key[32];
7513 unsigned char iv[16];
7519 unsigned char inbuf[64];
7520 unsigned char encbuf[64];
7521 unsigned char decbuf[64];
7524 size_t totaloutlen = 0;
7527 memset( key, 0, 32 );
7528 memset( iv , 0, 16 );
7530 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7531 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7533 memset( inbuf, 5, 64 );
7534 memset( encbuf, 0, 64 );
7535 memset( decbuf, 0, 64 );
7539 fct_chk( NULL != cipher_info);
7561 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7562 totaloutlen = outlen;
7563 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7564 totaloutlen += outlen;
7571 fct_chk( totaloutlen == enclen );
7573 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7574 totaloutlen += outlen;
7581 fct_chk( outlen == 0 );
7585 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7592 fct_chk( enclen == outlen );
7594 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7601 fct_chk( outlen == 0 );
7605 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7612 #ifdef POLARSSL_DES_C
7614 FCT_TEST_BGN(des3_encrypt_and_decrypt_16_bytes_in_multiple_parts_1)
7615 size_t first_length = 16;
7616 size_t second_length = 0;
7617 size_t length = first_length + second_length;
7618 unsigned char key[32];
7619 unsigned char iv[16];
7625 unsigned char inbuf[64];
7626 unsigned char encbuf[64];
7627 unsigned char decbuf[64];
7630 size_t totaloutlen = 0;
7633 memset( key, 0, 32 );
7634 memset( iv , 0, 16 );
7636 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7637 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7639 memset( inbuf, 5, 64 );
7640 memset( encbuf, 0, 64 );
7641 memset( decbuf, 0, 64 );
7645 fct_chk( NULL != cipher_info);
7667 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7668 totaloutlen = outlen;
7669 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7670 totaloutlen += outlen;
7677 fct_chk( totaloutlen == enclen );
7679 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7680 totaloutlen += outlen;
7687 fct_chk( outlen == 0 );
7691 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7698 fct_chk( enclen == outlen );
7700 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7707 fct_chk( outlen == 0 );
7711 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7718 #ifdef POLARSSL_DES_C
7720 FCT_TEST_BGN(des3_encrypt_and_decrypt_16_bytes_in_multiple_parts_2)
7721 size_t first_length = 0;
7722 size_t second_length = 16;
7723 size_t length = first_length + second_length;
7724 unsigned char key[32];
7725 unsigned char iv[16];
7731 unsigned char inbuf[64];
7732 unsigned char encbuf[64];
7733 unsigned char decbuf[64];
7736 size_t totaloutlen = 0;
7739 memset( key, 0, 32 );
7740 memset( iv , 0, 16 );
7742 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7743 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7745 memset( inbuf, 5, 64 );
7746 memset( encbuf, 0, 64 );
7747 memset( decbuf, 0, 64 );
7751 fct_chk( NULL != cipher_info);
7773 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7774 totaloutlen = outlen;
7775 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7776 totaloutlen += outlen;
7783 fct_chk( totaloutlen == enclen );
7785 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7786 totaloutlen += outlen;
7793 fct_chk( outlen == 0 );
7797 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7804 fct_chk( enclen == outlen );
7806 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7813 fct_chk( outlen == 0 );
7817 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7824 #ifdef POLARSSL_DES_C
7826 FCT_TEST_BGN(des3_encrypt_and_decrypt_16_bytes_in_multiple_parts_3)
7827 size_t first_length = 1;
7828 size_t second_length = 15;
7829 size_t length = first_length + second_length;
7830 unsigned char key[32];
7831 unsigned char iv[16];
7837 unsigned char inbuf[64];
7838 unsigned char encbuf[64];
7839 unsigned char decbuf[64];
7842 size_t totaloutlen = 0;
7845 memset( key, 0, 32 );
7846 memset( iv , 0, 16 );
7848 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7849 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7851 memset( inbuf, 5, 64 );
7852 memset( encbuf, 0, 64 );
7853 memset( decbuf, 0, 64 );
7857 fct_chk( NULL != cipher_info);
7879 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7880 totaloutlen = outlen;
7881 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7882 totaloutlen += outlen;
7889 fct_chk( totaloutlen == enclen );
7891 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7892 totaloutlen += outlen;
7899 fct_chk( outlen == 0 );
7903 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7910 fct_chk( enclen == outlen );
7912 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7919 fct_chk( outlen == 0 );
7923 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7930 #ifdef POLARSSL_DES_C
7932 FCT_TEST_BGN(des3_encrypt_and_decrypt_16_bytes_in_multiple_parts_4)
7933 size_t first_length = 15;
7934 size_t second_length = 1;
7935 size_t length = first_length + second_length;
7936 unsigned char key[32];
7937 unsigned char iv[16];
7943 unsigned char inbuf[64];
7944 unsigned char encbuf[64];
7945 unsigned char decbuf[64];
7948 size_t totaloutlen = 0;
7951 memset( key, 0, 32 );
7952 memset( iv , 0, 16 );
7954 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7955 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7957 memset( inbuf, 5, 64 );
7958 memset( encbuf, 0, 64 );
7959 memset( decbuf, 0, 64 );
7963 fct_chk( NULL != cipher_info);
7985 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7986 totaloutlen = outlen;
7987 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7988 totaloutlen += outlen;
7995 fct_chk( totaloutlen == enclen );
7997 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7998 totaloutlen += outlen;
8005 fct_chk( outlen == 0 );
8009 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8016 fct_chk( enclen == outlen );
8018 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8025 fct_chk( outlen == 0 );
8029 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8036 #ifdef POLARSSL_DES_C
8038 FCT_TEST_BGN(des3_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
8039 size_t first_length = 15;
8040 size_t second_length = 7;
8041 size_t length = first_length + second_length;
8042 unsigned char key[32];
8043 unsigned char iv[16];
8049 unsigned char inbuf[64];
8050 unsigned char encbuf[64];
8051 unsigned char decbuf[64];
8054 size_t totaloutlen = 0;
8057 memset( key, 0, 32 );
8058 memset( iv , 0, 16 );
8060 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8061 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8063 memset( inbuf, 5, 64 );
8064 memset( encbuf, 0, 64 );
8065 memset( decbuf, 0, 64 );
8069 fct_chk( NULL != cipher_info);
8091 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8092 totaloutlen = outlen;
8093 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8094 totaloutlen += outlen;
8101 fct_chk( totaloutlen == enclen );
8103 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8104 totaloutlen += outlen;
8111 fct_chk( outlen == 0 );
8115 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8122 fct_chk( enclen == outlen );
8124 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8131 fct_chk( outlen == 0 );
8135 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8142 #ifdef POLARSSL_DES_C
8144 FCT_TEST_BGN(des3_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
8145 size_t first_length = 16;
8146 size_t second_length = 6;
8147 size_t length = first_length + second_length;
8148 unsigned char key[32];
8149 unsigned char iv[16];
8155 unsigned char inbuf[64];
8156 unsigned char encbuf[64];
8157 unsigned char decbuf[64];
8160 size_t totaloutlen = 0;
8163 memset( key, 0, 32 );
8164 memset( iv , 0, 16 );
8166 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8167 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8169 memset( inbuf, 5, 64 );
8170 memset( encbuf, 0, 64 );
8171 memset( decbuf, 0, 64 );
8175 fct_chk( NULL != cipher_info);
8197 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8198 totaloutlen = outlen;
8199 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8200 totaloutlen += outlen;
8207 fct_chk( totaloutlen == enclen );
8209 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8210 totaloutlen += outlen;
8217 fct_chk( outlen == 0 );
8221 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8228 fct_chk( enclen == outlen );
8230 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8237 fct_chk( outlen == 0 );
8241 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8248 #ifdef POLARSSL_DES_C
8250 FCT_TEST_BGN(des3_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
8251 size_t first_length = 17;
8252 size_t second_length = 6;
8253 size_t length = first_length + second_length;
8254 unsigned char key[32];
8255 unsigned char iv[16];
8261 unsigned char inbuf[64];
8262 unsigned char encbuf[64];
8263 unsigned char decbuf[64];
8266 size_t totaloutlen = 0;
8269 memset( key, 0, 32 );
8270 memset( iv , 0, 16 );
8272 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8273 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8275 memset( inbuf, 5, 64 );
8276 memset( encbuf, 0, 64 );
8277 memset( decbuf, 0, 64 );
8281 fct_chk( NULL != cipher_info);
8303 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8304 totaloutlen = outlen;
8305 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8306 totaloutlen += outlen;
8313 fct_chk( totaloutlen == enclen );
8315 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8316 totaloutlen += outlen;
8323 fct_chk( outlen == 0 );
8327 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8334 fct_chk( enclen == outlen );
8336 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8343 fct_chk( outlen == 0 );
8347 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8354 #ifdef POLARSSL_DES_C
8356 FCT_TEST_BGN(des3_encrypt_and_decrypt_32_bytes_in_multiple_parts_1)
8357 size_t first_length = 16;
8358 size_t second_length = 16;
8359 size_t length = first_length + second_length;
8360 unsigned char key[32];
8361 unsigned char iv[16];
8367 unsigned char inbuf[64];
8368 unsigned char encbuf[64];
8369 unsigned char decbuf[64];
8372 size_t totaloutlen = 0;
8375 memset( key, 0, 32 );
8376 memset( iv , 0, 16 );
8378 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8379 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8381 memset( inbuf, 5, 64 );
8382 memset( encbuf, 0, 64 );
8383 memset( decbuf, 0, 64 );
8387 fct_chk( NULL != cipher_info);
8409 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8410 totaloutlen = outlen;
8411 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8412 totaloutlen += outlen;
8419 fct_chk( totaloutlen == enclen );
8421 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8422 totaloutlen += outlen;
8429 fct_chk( outlen == 0 );
8433 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8440 fct_chk( enclen == outlen );
8442 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8449 fct_chk( outlen == 0 );
8453 fct_chk( 0 == memcmp(inbuf, decbuf, length) );