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_AES_C
284 FCT_TEST_BGN(aes_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_AES_C
388 FCT_TEST_BGN(aes_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_AES_C
492 FCT_TEST_BGN(aes_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_AES_C
596 FCT_TEST_BGN(aes_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_AES_C
700 FCT_TEST_BGN(aes_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_AES_C
804 FCT_TEST_BGN(aes_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_AES_C
908 FCT_TEST_BGN(aes_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_AES_C
1012 FCT_TEST_BGN(aes_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_AES_C
1116 FCT_TEST_BGN(aes_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_AES_C
1220 FCT_TEST_BGN(aes_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_AES_C
1324 FCT_TEST_BGN(aes_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_AES_C
1428 FCT_TEST_BGN(aes_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_AES_C
1532 FCT_TEST_BGN(aes_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_AES_C
1636 FCT_TEST_BGN(aes_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_AES_C
1740 FCT_TEST_BGN(aes_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_AES_C
1844 FCT_TEST_BGN(aes_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_AES_C
1950 FCT_TEST_BGN(aes_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_AES_C
2056 FCT_TEST_BGN(aes_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_AES_C
2162 FCT_TEST_BGN(aes_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_AES_C
2268 FCT_TEST_BGN(aes_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_AES_C
2374 FCT_TEST_BGN(aes_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_AES_C
2480 FCT_TEST_BGN(aes_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_AES_C
2586 FCT_TEST_BGN(aes_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_AES_C
2692 FCT_TEST_BGN(aes_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_AES_C
2798 FCT_TEST_BGN(aes_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_AES_C
2904 FCT_TEST_BGN(aes_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_AES_C
3009 #ifdef POLARSSL_CIPHER_MODE_CFB
3011 FCT_TEST_BGN(aes_encrypt_and_decrypt_0_bytes)
3013 unsigned char key[32];
3014 unsigned char iv[16];
3020 unsigned char inbuf[64];
3021 unsigned char encbuf[64];
3022 unsigned char decbuf[64];
3027 memset( key, 0, 32 );
3028 memset( iv , 0, 16 );
3030 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3031 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3033 memset( inbuf, 5, 64 );
3034 memset( encbuf, 0, 64 );
3035 memset( decbuf, 0, 64 );
3039 fct_chk( NULL != cipher_info );
3063 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3070 fct_chk( outlen == enclen );
3073 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3080 fct_chk( outlen == 0 );
3085 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3092 fct_chk( enclen == outlen );
3095 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3102 fct_chk( outlen == 0 );
3106 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3114 #ifdef POLARSSL_AES_C
3115 #ifdef POLARSSL_CIPHER_MODE_CFB
3117 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_byte)
3119 unsigned char key[32];
3120 unsigned char iv[16];
3126 unsigned char inbuf[64];
3127 unsigned char encbuf[64];
3128 unsigned char decbuf[64];
3133 memset( key, 0, 32 );
3134 memset( iv , 0, 16 );
3136 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3137 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3139 memset( inbuf, 5, 64 );
3140 memset( encbuf, 0, 64 );
3141 memset( decbuf, 0, 64 );
3145 fct_chk( NULL != cipher_info );
3169 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3176 fct_chk( outlen == enclen );
3179 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3186 fct_chk( outlen == 0 );
3191 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3198 fct_chk( enclen == outlen );
3201 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3208 fct_chk( outlen == 0 );
3212 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3220 #ifdef POLARSSL_AES_C
3221 #ifdef POLARSSL_CIPHER_MODE_CFB
3223 FCT_TEST_BGN(aes_encrypt_and_decrypt_2_bytes)
3225 unsigned char key[32];
3226 unsigned char iv[16];
3232 unsigned char inbuf[64];
3233 unsigned char encbuf[64];
3234 unsigned char decbuf[64];
3239 memset( key, 0, 32 );
3240 memset( iv , 0, 16 );
3242 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3243 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3245 memset( inbuf, 5, 64 );
3246 memset( encbuf, 0, 64 );
3247 memset( decbuf, 0, 64 );
3251 fct_chk( NULL != cipher_info );
3275 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3282 fct_chk( outlen == enclen );
3285 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3292 fct_chk( outlen == 0 );
3297 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3304 fct_chk( enclen == outlen );
3307 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3314 fct_chk( outlen == 0 );
3318 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3326 #ifdef POLARSSL_AES_C
3327 #ifdef POLARSSL_CIPHER_MODE_CFB
3329 FCT_TEST_BGN(aes_encrypt_and_decrypt_7_bytes)
3331 unsigned char key[32];
3332 unsigned char iv[16];
3338 unsigned char inbuf[64];
3339 unsigned char encbuf[64];
3340 unsigned char decbuf[64];
3345 memset( key, 0, 32 );
3346 memset( iv , 0, 16 );
3348 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3349 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3351 memset( inbuf, 5, 64 );
3352 memset( encbuf, 0, 64 );
3353 memset( decbuf, 0, 64 );
3357 fct_chk( NULL != cipher_info );
3381 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3388 fct_chk( outlen == enclen );
3391 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3398 fct_chk( outlen == 0 );
3403 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3410 fct_chk( enclen == outlen );
3413 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3420 fct_chk( outlen == 0 );
3424 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3432 #ifdef POLARSSL_AES_C
3433 #ifdef POLARSSL_CIPHER_MODE_CFB
3435 FCT_TEST_BGN(aes_encrypt_and_decrypt_8_bytes)
3437 unsigned char key[32];
3438 unsigned char iv[16];
3444 unsigned char inbuf[64];
3445 unsigned char encbuf[64];
3446 unsigned char decbuf[64];
3451 memset( key, 0, 32 );
3452 memset( iv , 0, 16 );
3454 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3455 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3457 memset( inbuf, 5, 64 );
3458 memset( encbuf, 0, 64 );
3459 memset( decbuf, 0, 64 );
3463 fct_chk( NULL != cipher_info );
3487 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3494 fct_chk( outlen == enclen );
3497 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3504 fct_chk( outlen == 0 );
3509 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3516 fct_chk( enclen == outlen );
3519 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3526 fct_chk( outlen == 0 );
3530 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3538 #ifdef POLARSSL_AES_C
3539 #ifdef POLARSSL_CIPHER_MODE_CFB
3541 FCT_TEST_BGN(aes_encrypt_and_decrypt_9_bytes)
3543 unsigned char key[32];
3544 unsigned char iv[16];
3550 unsigned char inbuf[64];
3551 unsigned char encbuf[64];
3552 unsigned char decbuf[64];
3557 memset( key, 0, 32 );
3558 memset( iv , 0, 16 );
3560 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3561 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3563 memset( inbuf, 5, 64 );
3564 memset( encbuf, 0, 64 );
3565 memset( decbuf, 0, 64 );
3569 fct_chk( NULL != cipher_info );
3593 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3600 fct_chk( outlen == enclen );
3603 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3610 fct_chk( outlen == 0 );
3615 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3622 fct_chk( enclen == outlen );
3625 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3632 fct_chk( outlen == 0 );
3636 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3644 #ifdef POLARSSL_AES_C
3645 #ifdef POLARSSL_CIPHER_MODE_CFB
3647 FCT_TEST_BGN(aes_encrypt_and_decrypt_15_bytes)
3649 unsigned char key[32];
3650 unsigned char iv[16];
3656 unsigned char inbuf[64];
3657 unsigned char encbuf[64];
3658 unsigned char decbuf[64];
3663 memset( key, 0, 32 );
3664 memset( iv , 0, 16 );
3666 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3667 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3669 memset( inbuf, 5, 64 );
3670 memset( encbuf, 0, 64 );
3671 memset( decbuf, 0, 64 );
3675 fct_chk( NULL != cipher_info );
3699 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3706 fct_chk( outlen == enclen );
3709 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3716 fct_chk( outlen == 0 );
3721 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3728 fct_chk( enclen == outlen );
3731 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3738 fct_chk( outlen == 0 );
3742 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3750 #ifdef POLARSSL_AES_C
3751 #ifdef POLARSSL_CIPHER_MODE_CFB
3753 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes)
3755 unsigned char key[32];
3756 unsigned char iv[16];
3762 unsigned char inbuf[64];
3763 unsigned char encbuf[64];
3764 unsigned char decbuf[64];
3769 memset( key, 0, 32 );
3770 memset( iv , 0, 16 );
3772 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3773 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3775 memset( inbuf, 5, 64 );
3776 memset( encbuf, 0, 64 );
3777 memset( decbuf, 0, 64 );
3781 fct_chk( NULL != cipher_info );
3805 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3812 fct_chk( outlen == enclen );
3815 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3822 fct_chk( outlen == 0 );
3827 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3834 fct_chk( enclen == outlen );
3837 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3844 fct_chk( outlen == 0 );
3848 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3856 #ifdef POLARSSL_AES_C
3857 #ifdef POLARSSL_CIPHER_MODE_CFB
3859 FCT_TEST_BGN(aes_encrypt_and_decrypt_17_bytes)
3861 unsigned char key[32];
3862 unsigned char iv[16];
3868 unsigned char inbuf[64];
3869 unsigned char encbuf[64];
3870 unsigned char decbuf[64];
3875 memset( key, 0, 32 );
3876 memset( iv , 0, 16 );
3878 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3879 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3881 memset( inbuf, 5, 64 );
3882 memset( encbuf, 0, 64 );
3883 memset( decbuf, 0, 64 );
3887 fct_chk( NULL != cipher_info );
3911 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3918 fct_chk( outlen == enclen );
3921 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3928 fct_chk( outlen == 0 );
3933 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3940 fct_chk( enclen == outlen );
3943 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3950 fct_chk( outlen == 0 );
3954 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3962 #ifdef POLARSSL_AES_C
3963 #ifdef POLARSSL_CIPHER_MODE_CFB
3965 FCT_TEST_BGN(aes_encrypt_and_decrypt_31_bytes)
3967 unsigned char key[32];
3968 unsigned char iv[16];
3974 unsigned char inbuf[64];
3975 unsigned char encbuf[64];
3976 unsigned char decbuf[64];
3981 memset( key, 0, 32 );
3982 memset( iv , 0, 16 );
3984 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3985 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3987 memset( inbuf, 5, 64 );
3988 memset( encbuf, 0, 64 );
3989 memset( decbuf, 0, 64 );
3993 fct_chk( NULL != cipher_info );
4017 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4024 fct_chk( outlen == enclen );
4027 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4034 fct_chk( outlen == 0 );
4039 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4046 fct_chk( enclen == outlen );
4049 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4056 fct_chk( outlen == 0 );
4060 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4068 #ifdef POLARSSL_AES_C
4069 #ifdef POLARSSL_CIPHER_MODE_CFB
4071 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes)
4073 unsigned char key[32];
4074 unsigned char iv[16];
4080 unsigned char inbuf[64];
4081 unsigned char encbuf[64];
4082 unsigned char decbuf[64];
4087 memset( key, 0, 32 );
4088 memset( iv , 0, 16 );
4090 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4091 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4093 memset( inbuf, 5, 64 );
4094 memset( encbuf, 0, 64 );
4095 memset( decbuf, 0, 64 );
4099 fct_chk( NULL != cipher_info );
4123 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4130 fct_chk( outlen == enclen );
4133 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4140 fct_chk( outlen == 0 );
4145 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4152 fct_chk( enclen == outlen );
4155 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4162 fct_chk( outlen == 0 );
4166 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4174 #ifdef POLARSSL_AES_C
4175 #ifdef POLARSSL_CIPHER_MODE_CFB
4177 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes)
4179 unsigned char key[32];
4180 unsigned char iv[16];
4186 unsigned char inbuf[64];
4187 unsigned char encbuf[64];
4188 unsigned char decbuf[64];
4193 memset( key, 0, 32 );
4194 memset( iv , 0, 16 );
4196 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4197 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4199 memset( inbuf, 5, 64 );
4200 memset( encbuf, 0, 64 );
4201 memset( decbuf, 0, 64 );
4205 fct_chk( NULL != cipher_info );
4229 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4236 fct_chk( outlen == enclen );
4239 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4246 fct_chk( outlen == 0 );
4251 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4258 fct_chk( enclen == outlen );
4261 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4268 fct_chk( outlen == 0 );
4272 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4280 #ifdef POLARSSL_AES_C
4281 #ifdef POLARSSL_CIPHER_MODE_CFB
4283 FCT_TEST_BGN(aes_encrypt_and_decrypt_47_bytes)
4285 unsigned char key[32];
4286 unsigned char iv[16];
4292 unsigned char inbuf[64];
4293 unsigned char encbuf[64];
4294 unsigned char decbuf[64];
4299 memset( key, 0, 32 );
4300 memset( iv , 0, 16 );
4302 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4303 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4305 memset( inbuf, 5, 64 );
4306 memset( encbuf, 0, 64 );
4307 memset( decbuf, 0, 64 );
4311 fct_chk( NULL != cipher_info );
4335 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4342 fct_chk( outlen == enclen );
4345 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4352 fct_chk( outlen == 0 );
4357 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4364 fct_chk( enclen == outlen );
4367 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4374 fct_chk( outlen == 0 );
4378 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4386 #ifdef POLARSSL_AES_C
4387 #ifdef POLARSSL_CIPHER_MODE_CFB
4389 FCT_TEST_BGN(aes_encrypt_and_decrypt_48_bytes)
4391 unsigned char key[32];
4392 unsigned char iv[16];
4398 unsigned char inbuf[64];
4399 unsigned char encbuf[64];
4400 unsigned char decbuf[64];
4405 memset( key, 0, 32 );
4406 memset( iv , 0, 16 );
4408 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4409 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4411 memset( inbuf, 5, 64 );
4412 memset( encbuf, 0, 64 );
4413 memset( decbuf, 0, 64 );
4417 fct_chk( NULL != cipher_info );
4441 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4448 fct_chk( outlen == enclen );
4451 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4458 fct_chk( outlen == 0 );
4463 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4470 fct_chk( enclen == outlen );
4473 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4480 fct_chk( outlen == 0 );
4484 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4492 #ifdef POLARSSL_AES_C
4493 #ifdef POLARSSL_CIPHER_MODE_CFB
4495 FCT_TEST_BGN(aes_encrypt_and_decrypt_49_bytes)
4497 unsigned char key[32];
4498 unsigned char iv[16];
4504 unsigned char inbuf[64];
4505 unsigned char encbuf[64];
4506 unsigned char decbuf[64];
4511 memset( key, 0, 32 );
4512 memset( iv , 0, 16 );
4514 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4515 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4517 memset( inbuf, 5, 64 );
4518 memset( encbuf, 0, 64 );
4519 memset( decbuf, 0, 64 );
4523 fct_chk( NULL != cipher_info );
4547 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4554 fct_chk( outlen == enclen );
4557 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4564 fct_chk( outlen == 0 );
4569 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4576 fct_chk( enclen == outlen );
4579 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4586 fct_chk( outlen == 0 );
4590 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4598 #ifdef POLARSSL_AES_C
4599 #ifdef POLARSSL_CIPHER_MODE_CFB
4601 FCT_TEST_BGN(aes_encrypt_and_decrypt_0_bytes_in_multiple_parts)
4602 size_t first_length = 0;
4603 size_t second_length = 0;
4604 size_t length = first_length + second_length;
4605 unsigned char key[32];
4606 unsigned char iv[16];
4612 unsigned char inbuf[64];
4613 unsigned char encbuf[64];
4614 unsigned char decbuf[64];
4617 size_t totaloutlen = 0;
4620 memset( key, 0, 32 );
4621 memset( iv , 0, 16 );
4623 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4624 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4626 memset( inbuf, 5, 64 );
4627 memset( encbuf, 0, 64 );
4628 memset( decbuf, 0, 64 );
4632 fct_chk( NULL != cipher_info);
4654 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4655 totaloutlen = outlen;
4656 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4657 totaloutlen += outlen;
4664 fct_chk( totaloutlen == enclen );
4666 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4667 totaloutlen += outlen;
4674 fct_chk( outlen == 0 );
4678 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4685 fct_chk( enclen == outlen );
4687 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4694 fct_chk( outlen == 0 );
4698 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4706 #ifdef POLARSSL_AES_C
4707 #ifdef POLARSSL_CIPHER_MODE_CFB
4709 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_bytes_in_multiple_parts_1)
4710 size_t first_length = 1;
4711 size_t second_length = 0;
4712 size_t length = first_length + second_length;
4713 unsigned char key[32];
4714 unsigned char iv[16];
4720 unsigned char inbuf[64];
4721 unsigned char encbuf[64];
4722 unsigned char decbuf[64];
4725 size_t totaloutlen = 0;
4728 memset( key, 0, 32 );
4729 memset( iv , 0, 16 );
4731 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4732 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4734 memset( inbuf, 5, 64 );
4735 memset( encbuf, 0, 64 );
4736 memset( decbuf, 0, 64 );
4740 fct_chk( NULL != cipher_info);
4762 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4763 totaloutlen = outlen;
4764 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4765 totaloutlen += outlen;
4772 fct_chk( totaloutlen == enclen );
4774 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4775 totaloutlen += outlen;
4782 fct_chk( outlen == 0 );
4786 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4793 fct_chk( enclen == outlen );
4795 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4802 fct_chk( outlen == 0 );
4806 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4814 #ifdef POLARSSL_AES_C
4815 #ifdef POLARSSL_CIPHER_MODE_CFB
4817 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_bytes_in_multiple_parts_2)
4818 size_t first_length = 0;
4819 size_t second_length = 1;
4820 size_t length = first_length + second_length;
4821 unsigned char key[32];
4822 unsigned char iv[16];
4828 unsigned char inbuf[64];
4829 unsigned char encbuf[64];
4830 unsigned char decbuf[64];
4833 size_t totaloutlen = 0;
4836 memset( key, 0, 32 );
4837 memset( iv , 0, 16 );
4839 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4840 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4842 memset( inbuf, 5, 64 );
4843 memset( encbuf, 0, 64 );
4844 memset( decbuf, 0, 64 );
4848 fct_chk( NULL != cipher_info);
4870 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4871 totaloutlen = outlen;
4872 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4873 totaloutlen += outlen;
4880 fct_chk( totaloutlen == enclen );
4882 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4883 totaloutlen += outlen;
4890 fct_chk( outlen == 0 );
4894 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4901 fct_chk( enclen == outlen );
4903 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4910 fct_chk( outlen == 0 );
4914 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4922 #ifdef POLARSSL_AES_C
4923 #ifdef POLARSSL_CIPHER_MODE_CFB
4925 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_1)
4926 size_t first_length = 16;
4927 size_t second_length = 0;
4928 size_t length = first_length + second_length;
4929 unsigned char key[32];
4930 unsigned char iv[16];
4936 unsigned char inbuf[64];
4937 unsigned char encbuf[64];
4938 unsigned char decbuf[64];
4941 size_t totaloutlen = 0;
4944 memset( key, 0, 32 );
4945 memset( iv , 0, 16 );
4947 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4948 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4950 memset( inbuf, 5, 64 );
4951 memset( encbuf, 0, 64 );
4952 memset( decbuf, 0, 64 );
4956 fct_chk( NULL != cipher_info);
4978 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4979 totaloutlen = outlen;
4980 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4981 totaloutlen += outlen;
4988 fct_chk( totaloutlen == enclen );
4990 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4991 totaloutlen += outlen;
4998 fct_chk( outlen == 0 );
5002 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5009 fct_chk( enclen == outlen );
5011 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5018 fct_chk( outlen == 0 );
5022 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5030 #ifdef POLARSSL_AES_C
5031 #ifdef POLARSSL_CIPHER_MODE_CFB
5033 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_2)
5034 size_t first_length = 0;
5035 size_t second_length = 16;
5036 size_t length = first_length + second_length;
5037 unsigned char key[32];
5038 unsigned char iv[16];
5044 unsigned char inbuf[64];
5045 unsigned char encbuf[64];
5046 unsigned char decbuf[64];
5049 size_t totaloutlen = 0;
5052 memset( key, 0, 32 );
5053 memset( iv , 0, 16 );
5055 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5056 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5058 memset( inbuf, 5, 64 );
5059 memset( encbuf, 0, 64 );
5060 memset( decbuf, 0, 64 );
5064 fct_chk( NULL != cipher_info);
5086 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5087 totaloutlen = outlen;
5088 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5089 totaloutlen += outlen;
5096 fct_chk( totaloutlen == enclen );
5098 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5099 totaloutlen += outlen;
5106 fct_chk( outlen == 0 );
5110 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5117 fct_chk( enclen == outlen );
5119 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5126 fct_chk( outlen == 0 );
5130 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5138 #ifdef POLARSSL_AES_C
5139 #ifdef POLARSSL_CIPHER_MODE_CFB
5141 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_3)
5142 size_t first_length = 1;
5143 size_t second_length = 15;
5144 size_t length = first_length + second_length;
5145 unsigned char key[32];
5146 unsigned char iv[16];
5152 unsigned char inbuf[64];
5153 unsigned char encbuf[64];
5154 unsigned char decbuf[64];
5157 size_t totaloutlen = 0;
5160 memset( key, 0, 32 );
5161 memset( iv , 0, 16 );
5163 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5164 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5166 memset( inbuf, 5, 64 );
5167 memset( encbuf, 0, 64 );
5168 memset( decbuf, 0, 64 );
5172 fct_chk( NULL != cipher_info);
5194 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5195 totaloutlen = outlen;
5196 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5197 totaloutlen += outlen;
5204 fct_chk( totaloutlen == enclen );
5206 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5207 totaloutlen += outlen;
5214 fct_chk( outlen == 0 );
5218 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5225 fct_chk( enclen == outlen );
5227 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5234 fct_chk( outlen == 0 );
5238 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5246 #ifdef POLARSSL_AES_C
5247 #ifdef POLARSSL_CIPHER_MODE_CFB
5249 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_4)
5250 size_t first_length = 15;
5251 size_t second_length = 1;
5252 size_t length = first_length + second_length;
5253 unsigned char key[32];
5254 unsigned char iv[16];
5260 unsigned char inbuf[64];
5261 unsigned char encbuf[64];
5262 unsigned char decbuf[64];
5265 size_t totaloutlen = 0;
5268 memset( key, 0, 32 );
5269 memset( iv , 0, 16 );
5271 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5272 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5274 memset( inbuf, 5, 64 );
5275 memset( encbuf, 0, 64 );
5276 memset( decbuf, 0, 64 );
5280 fct_chk( NULL != cipher_info);
5302 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5303 totaloutlen = outlen;
5304 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5305 totaloutlen += outlen;
5312 fct_chk( totaloutlen == enclen );
5314 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5315 totaloutlen += outlen;
5322 fct_chk( outlen == 0 );
5326 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5333 fct_chk( enclen == outlen );
5335 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5342 fct_chk( outlen == 0 );
5346 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5354 #ifdef POLARSSL_AES_C
5355 #ifdef POLARSSL_CIPHER_MODE_CFB
5357 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
5358 size_t first_length = 15;
5359 size_t second_length = 7;
5360 size_t length = first_length + second_length;
5361 unsigned char key[32];
5362 unsigned char iv[16];
5368 unsigned char inbuf[64];
5369 unsigned char encbuf[64];
5370 unsigned char decbuf[64];
5373 size_t totaloutlen = 0;
5376 memset( key, 0, 32 );
5377 memset( iv , 0, 16 );
5379 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5380 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5382 memset( inbuf, 5, 64 );
5383 memset( encbuf, 0, 64 );
5384 memset( decbuf, 0, 64 );
5388 fct_chk( NULL != cipher_info);
5410 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5411 totaloutlen = outlen;
5412 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5413 totaloutlen += outlen;
5420 fct_chk( totaloutlen == enclen );
5422 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5423 totaloutlen += outlen;
5430 fct_chk( outlen == 0 );
5434 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5441 fct_chk( enclen == outlen );
5443 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5450 fct_chk( outlen == 0 );
5454 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5462 #ifdef POLARSSL_AES_C
5463 #ifdef POLARSSL_CIPHER_MODE_CFB
5465 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
5466 size_t first_length = 16;
5467 size_t second_length = 6;
5468 size_t length = first_length + second_length;
5469 unsigned char key[32];
5470 unsigned char iv[16];
5476 unsigned char inbuf[64];
5477 unsigned char encbuf[64];
5478 unsigned char decbuf[64];
5481 size_t totaloutlen = 0;
5484 memset( key, 0, 32 );
5485 memset( iv , 0, 16 );
5487 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5488 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5490 memset( inbuf, 5, 64 );
5491 memset( encbuf, 0, 64 );
5492 memset( decbuf, 0, 64 );
5496 fct_chk( NULL != cipher_info);
5518 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5519 totaloutlen = outlen;
5520 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5521 totaloutlen += outlen;
5528 fct_chk( totaloutlen == enclen );
5530 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5531 totaloutlen += outlen;
5538 fct_chk( outlen == 0 );
5542 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5549 fct_chk( enclen == outlen );
5551 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5558 fct_chk( outlen == 0 );
5562 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5570 #ifdef POLARSSL_AES_C
5571 #ifdef POLARSSL_CIPHER_MODE_CFB
5573 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
5574 size_t first_length = 17;
5575 size_t second_length = 6;
5576 size_t length = first_length + second_length;
5577 unsigned char key[32];
5578 unsigned char iv[16];
5584 unsigned char inbuf[64];
5585 unsigned char encbuf[64];
5586 unsigned char decbuf[64];
5589 size_t totaloutlen = 0;
5592 memset( key, 0, 32 );
5593 memset( iv , 0, 16 );
5595 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5596 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5598 memset( inbuf, 5, 64 );
5599 memset( encbuf, 0, 64 );
5600 memset( decbuf, 0, 64 );
5604 fct_chk( NULL != cipher_info);
5626 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5627 totaloutlen = outlen;
5628 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5629 totaloutlen += outlen;
5636 fct_chk( totaloutlen == enclen );
5638 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5639 totaloutlen += outlen;
5646 fct_chk( outlen == 0 );
5650 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5657 fct_chk( enclen == outlen );
5659 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5666 fct_chk( outlen == 0 );
5670 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5678 #ifdef POLARSSL_AES_C
5679 #ifdef POLARSSL_CIPHER_MODE_CFB
5681 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes_in_multiple_parts_1)
5682 size_t first_length = 16;
5683 size_t second_length = 16;
5684 size_t length = first_length + second_length;
5685 unsigned char key[32];
5686 unsigned char iv[16];
5692 unsigned char inbuf[64];
5693 unsigned char encbuf[64];
5694 unsigned char decbuf[64];
5697 size_t totaloutlen = 0;
5700 memset( key, 0, 32 );
5701 memset( iv , 0, 16 );
5703 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5704 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5706 memset( inbuf, 5, 64 );
5707 memset( encbuf, 0, 64 );
5708 memset( decbuf, 0, 64 );
5712 fct_chk( NULL != cipher_info);
5734 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5735 totaloutlen = outlen;
5736 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5737 totaloutlen += outlen;
5744 fct_chk( totaloutlen == enclen );
5746 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5747 totaloutlen += outlen;
5754 fct_chk( outlen == 0 );
5758 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5765 fct_chk( enclen == outlen );
5767 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5774 fct_chk( outlen == 0 );
5778 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5786 #ifdef POLARSSL_AES_C
5787 #ifdef POLARSSL_CIPHER_MODE_CTR
5789 FCT_TEST_BGN(aes_encrypt_and_decrypt_0_bytes)
5791 unsigned char key[32];
5792 unsigned char iv[16];
5798 unsigned char inbuf[64];
5799 unsigned char encbuf[64];
5800 unsigned char decbuf[64];
5805 memset( key, 0, 32 );
5806 memset( iv , 0, 16 );
5808 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5809 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5811 memset( inbuf, 5, 64 );
5812 memset( encbuf, 0, 64 );
5813 memset( decbuf, 0, 64 );
5817 fct_chk( NULL != cipher_info );
5841 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
5848 fct_chk( outlen == enclen );
5851 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
5858 fct_chk( outlen == 0 );
5863 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5870 fct_chk( enclen == outlen );
5873 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5880 fct_chk( outlen == 0 );
5884 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5892 #ifdef POLARSSL_AES_C
5893 #ifdef POLARSSL_CIPHER_MODE_CTR
5895 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_byte)
5897 unsigned char key[32];
5898 unsigned char iv[16];
5904 unsigned char inbuf[64];
5905 unsigned char encbuf[64];
5906 unsigned char decbuf[64];
5911 memset( key, 0, 32 );
5912 memset( iv , 0, 16 );
5914 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5915 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5917 memset( inbuf, 5, 64 );
5918 memset( encbuf, 0, 64 );
5919 memset( decbuf, 0, 64 );
5923 fct_chk( NULL != cipher_info );
5947 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
5954 fct_chk( outlen == enclen );
5957 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
5964 fct_chk( outlen == 0 );
5969 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5976 fct_chk( enclen == outlen );
5979 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5986 fct_chk( outlen == 0 );
5990 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5998 #ifdef POLARSSL_AES_C
5999 #ifdef POLARSSL_CIPHER_MODE_CTR
6001 FCT_TEST_BGN(aes_encrypt_and_decrypt_2_bytes)
6003 unsigned char key[32];
6004 unsigned char iv[16];
6010 unsigned char inbuf[64];
6011 unsigned char encbuf[64];
6012 unsigned char decbuf[64];
6017 memset( key, 0, 32 );
6018 memset( iv , 0, 16 );
6020 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6021 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6023 memset( inbuf, 5, 64 );
6024 memset( encbuf, 0, 64 );
6025 memset( decbuf, 0, 64 );
6029 fct_chk( NULL != cipher_info );
6053 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6060 fct_chk( outlen == enclen );
6063 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6070 fct_chk( outlen == 0 );
6075 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6082 fct_chk( enclen == outlen );
6085 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6092 fct_chk( outlen == 0 );
6096 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6104 #ifdef POLARSSL_AES_C
6105 #ifdef POLARSSL_CIPHER_MODE_CTR
6107 FCT_TEST_BGN(aes_encrypt_and_decrypt_7_bytes)
6109 unsigned char key[32];
6110 unsigned char iv[16];
6116 unsigned char inbuf[64];
6117 unsigned char encbuf[64];
6118 unsigned char decbuf[64];
6123 memset( key, 0, 32 );
6124 memset( iv , 0, 16 );
6126 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6127 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6129 memset( inbuf, 5, 64 );
6130 memset( encbuf, 0, 64 );
6131 memset( decbuf, 0, 64 );
6135 fct_chk( NULL != cipher_info );
6159 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6166 fct_chk( outlen == enclen );
6169 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6176 fct_chk( outlen == 0 );
6181 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6188 fct_chk( enclen == outlen );
6191 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6198 fct_chk( outlen == 0 );
6202 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6210 #ifdef POLARSSL_AES_C
6211 #ifdef POLARSSL_CIPHER_MODE_CTR
6213 FCT_TEST_BGN(aes_encrypt_and_decrypt_8_bytes)
6215 unsigned char key[32];
6216 unsigned char iv[16];
6222 unsigned char inbuf[64];
6223 unsigned char encbuf[64];
6224 unsigned char decbuf[64];
6229 memset( key, 0, 32 );
6230 memset( iv , 0, 16 );
6232 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6233 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6235 memset( inbuf, 5, 64 );
6236 memset( encbuf, 0, 64 );
6237 memset( decbuf, 0, 64 );
6241 fct_chk( NULL != cipher_info );
6265 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6272 fct_chk( outlen == enclen );
6275 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6282 fct_chk( outlen == 0 );
6287 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6294 fct_chk( enclen == outlen );
6297 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6304 fct_chk( outlen == 0 );
6308 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6316 #ifdef POLARSSL_AES_C
6317 #ifdef POLARSSL_CIPHER_MODE_CTR
6319 FCT_TEST_BGN(aes_encrypt_and_decrypt_9_bytes)
6321 unsigned char key[32];
6322 unsigned char iv[16];
6328 unsigned char inbuf[64];
6329 unsigned char encbuf[64];
6330 unsigned char decbuf[64];
6335 memset( key, 0, 32 );
6336 memset( iv , 0, 16 );
6338 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6339 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6341 memset( inbuf, 5, 64 );
6342 memset( encbuf, 0, 64 );
6343 memset( decbuf, 0, 64 );
6347 fct_chk( NULL != cipher_info );
6371 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6378 fct_chk( outlen == enclen );
6381 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6388 fct_chk( outlen == 0 );
6393 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6400 fct_chk( enclen == outlen );
6403 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6410 fct_chk( outlen == 0 );
6414 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6422 #ifdef POLARSSL_AES_C
6423 #ifdef POLARSSL_CIPHER_MODE_CTR
6425 FCT_TEST_BGN(aes_encrypt_and_decrypt_15_bytes)
6427 unsigned char key[32];
6428 unsigned char iv[16];
6434 unsigned char inbuf[64];
6435 unsigned char encbuf[64];
6436 unsigned char decbuf[64];
6441 memset( key, 0, 32 );
6442 memset( iv , 0, 16 );
6444 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6445 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6447 memset( inbuf, 5, 64 );
6448 memset( encbuf, 0, 64 );
6449 memset( decbuf, 0, 64 );
6453 fct_chk( NULL != cipher_info );
6477 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6484 fct_chk( outlen == enclen );
6487 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6494 fct_chk( outlen == 0 );
6499 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6506 fct_chk( enclen == outlen );
6509 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6516 fct_chk( outlen == 0 );
6520 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6528 #ifdef POLARSSL_AES_C
6529 #ifdef POLARSSL_CIPHER_MODE_CTR
6531 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes)
6533 unsigned char key[32];
6534 unsigned char iv[16];
6540 unsigned char inbuf[64];
6541 unsigned char encbuf[64];
6542 unsigned char decbuf[64];
6547 memset( key, 0, 32 );
6548 memset( iv , 0, 16 );
6550 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6551 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6553 memset( inbuf, 5, 64 );
6554 memset( encbuf, 0, 64 );
6555 memset( decbuf, 0, 64 );
6559 fct_chk( NULL != cipher_info );
6583 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6590 fct_chk( outlen == enclen );
6593 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6600 fct_chk( outlen == 0 );
6605 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6612 fct_chk( enclen == outlen );
6615 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6622 fct_chk( outlen == 0 );
6626 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6634 #ifdef POLARSSL_AES_C
6635 #ifdef POLARSSL_CIPHER_MODE_CTR
6637 FCT_TEST_BGN(aes_encrypt_and_decrypt_17_bytes)
6639 unsigned char key[32];
6640 unsigned char iv[16];
6646 unsigned char inbuf[64];
6647 unsigned char encbuf[64];
6648 unsigned char decbuf[64];
6653 memset( key, 0, 32 );
6654 memset( iv , 0, 16 );
6656 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6657 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6659 memset( inbuf, 5, 64 );
6660 memset( encbuf, 0, 64 );
6661 memset( decbuf, 0, 64 );
6665 fct_chk( NULL != cipher_info );
6689 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6696 fct_chk( outlen == enclen );
6699 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6706 fct_chk( outlen == 0 );
6711 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6718 fct_chk( enclen == outlen );
6721 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6728 fct_chk( outlen == 0 );
6732 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6740 #ifdef POLARSSL_AES_C
6741 #ifdef POLARSSL_CIPHER_MODE_CTR
6743 FCT_TEST_BGN(aes_encrypt_and_decrypt_31_bytes)
6745 unsigned char key[32];
6746 unsigned char iv[16];
6752 unsigned char inbuf[64];
6753 unsigned char encbuf[64];
6754 unsigned char decbuf[64];
6759 memset( key, 0, 32 );
6760 memset( iv , 0, 16 );
6762 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6763 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6765 memset( inbuf, 5, 64 );
6766 memset( encbuf, 0, 64 );
6767 memset( decbuf, 0, 64 );
6771 fct_chk( NULL != cipher_info );
6795 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6802 fct_chk( outlen == enclen );
6805 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6812 fct_chk( outlen == 0 );
6817 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6824 fct_chk( enclen == outlen );
6827 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6834 fct_chk( outlen == 0 );
6838 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6846 #ifdef POLARSSL_AES_C
6847 #ifdef POLARSSL_CIPHER_MODE_CTR
6849 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes)
6851 unsigned char key[32];
6852 unsigned char iv[16];
6858 unsigned char inbuf[64];
6859 unsigned char encbuf[64];
6860 unsigned char decbuf[64];
6865 memset( key, 0, 32 );
6866 memset( iv , 0, 16 );
6868 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6869 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6871 memset( inbuf, 5, 64 );
6872 memset( encbuf, 0, 64 );
6873 memset( decbuf, 0, 64 );
6877 fct_chk( NULL != cipher_info );
6901 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6908 fct_chk( outlen == enclen );
6911 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6918 fct_chk( outlen == 0 );
6923 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6930 fct_chk( enclen == outlen );
6933 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6940 fct_chk( outlen == 0 );
6944 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6952 #ifdef POLARSSL_AES_C
6953 #ifdef POLARSSL_CIPHER_MODE_CTR
6955 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes)
6957 unsigned char key[32];
6958 unsigned char iv[16];
6964 unsigned char inbuf[64];
6965 unsigned char encbuf[64];
6966 unsigned char decbuf[64];
6971 memset( key, 0, 32 );
6972 memset( iv , 0, 16 );
6974 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6975 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6977 memset( inbuf, 5, 64 );
6978 memset( encbuf, 0, 64 );
6979 memset( decbuf, 0, 64 );
6983 fct_chk( NULL != cipher_info );
7007 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
7014 fct_chk( outlen == enclen );
7017 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
7024 fct_chk( outlen == 0 );
7029 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7036 fct_chk( enclen == outlen );
7039 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7046 fct_chk( outlen == 0 );
7050 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7058 #ifdef POLARSSL_AES_C
7059 #ifdef POLARSSL_CIPHER_MODE_CTR
7061 FCT_TEST_BGN(aes_encrypt_and_decrypt_47_bytes)
7063 unsigned char key[32];
7064 unsigned char iv[16];
7070 unsigned char inbuf[64];
7071 unsigned char encbuf[64];
7072 unsigned char decbuf[64];
7077 memset( key, 0, 32 );
7078 memset( iv , 0, 16 );
7080 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7081 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7083 memset( inbuf, 5, 64 );
7084 memset( encbuf, 0, 64 );
7085 memset( decbuf, 0, 64 );
7089 fct_chk( NULL != cipher_info );
7113 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
7120 fct_chk( outlen == enclen );
7123 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
7130 fct_chk( outlen == 0 );
7135 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7142 fct_chk( enclen == outlen );
7145 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7152 fct_chk( outlen == 0 );
7156 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7164 #ifdef POLARSSL_AES_C
7165 #ifdef POLARSSL_CIPHER_MODE_CTR
7167 FCT_TEST_BGN(aes_encrypt_and_decrypt_48_bytes)
7169 unsigned char key[32];
7170 unsigned char iv[16];
7176 unsigned char inbuf[64];
7177 unsigned char encbuf[64];
7178 unsigned char decbuf[64];
7183 memset( key, 0, 32 );
7184 memset( iv , 0, 16 );
7186 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7187 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7189 memset( inbuf, 5, 64 );
7190 memset( encbuf, 0, 64 );
7191 memset( decbuf, 0, 64 );
7195 fct_chk( NULL != cipher_info );
7219 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
7226 fct_chk( outlen == enclen );
7229 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
7236 fct_chk( outlen == 0 );
7241 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7248 fct_chk( enclen == outlen );
7251 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7258 fct_chk( outlen == 0 );
7262 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7270 #ifdef POLARSSL_AES_C
7271 #ifdef POLARSSL_CIPHER_MODE_CTR
7273 FCT_TEST_BGN(aes_encrypt_and_decrypt_49_bytes)
7275 unsigned char key[32];
7276 unsigned char iv[16];
7282 unsigned char inbuf[64];
7283 unsigned char encbuf[64];
7284 unsigned char decbuf[64];
7289 memset( key, 0, 32 );
7290 memset( iv , 0, 16 );
7292 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7293 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7295 memset( inbuf, 5, 64 );
7296 memset( encbuf, 0, 64 );
7297 memset( decbuf, 0, 64 );
7301 fct_chk( NULL != cipher_info );
7325 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
7332 fct_chk( outlen == enclen );
7335 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
7342 fct_chk( outlen == 0 );
7347 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7354 fct_chk( enclen == outlen );
7357 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7364 fct_chk( outlen == 0 );
7368 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7376 #ifdef POLARSSL_AES_C
7377 #ifdef POLARSSL_CIPHER_MODE_CTR
7379 FCT_TEST_BGN(aes_encrypt_and_decrypt_0_bytes_in_multiple_parts)
7380 size_t first_length = 0;
7381 size_t second_length = 0;
7382 size_t length = first_length + second_length;
7383 unsigned char key[32];
7384 unsigned char iv[16];
7390 unsigned char inbuf[64];
7391 unsigned char encbuf[64];
7392 unsigned char decbuf[64];
7395 size_t totaloutlen = 0;
7398 memset( key, 0, 32 );
7399 memset( iv , 0, 16 );
7401 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7402 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7404 memset( inbuf, 5, 64 );
7405 memset( encbuf, 0, 64 );
7406 memset( decbuf, 0, 64 );
7410 fct_chk( NULL != cipher_info);
7432 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7433 totaloutlen = outlen;
7434 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7435 totaloutlen += outlen;
7442 fct_chk( totaloutlen == enclen );
7444 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7445 totaloutlen += outlen;
7452 fct_chk( outlen == 0 );
7456 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7463 fct_chk( enclen == outlen );
7465 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7472 fct_chk( outlen == 0 );
7476 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7484 #ifdef POLARSSL_AES_C
7485 #ifdef POLARSSL_CIPHER_MODE_CTR
7487 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_bytes_in_multiple_parts_1)
7488 size_t first_length = 1;
7489 size_t second_length = 0;
7490 size_t length = first_length + second_length;
7491 unsigned char key[32];
7492 unsigned char iv[16];
7498 unsigned char inbuf[64];
7499 unsigned char encbuf[64];
7500 unsigned char decbuf[64];
7503 size_t totaloutlen = 0;
7506 memset( key, 0, 32 );
7507 memset( iv , 0, 16 );
7509 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7510 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7512 memset( inbuf, 5, 64 );
7513 memset( encbuf, 0, 64 );
7514 memset( decbuf, 0, 64 );
7518 fct_chk( NULL != cipher_info);
7540 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7541 totaloutlen = outlen;
7542 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7543 totaloutlen += outlen;
7550 fct_chk( totaloutlen == enclen );
7552 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7553 totaloutlen += outlen;
7560 fct_chk( outlen == 0 );
7564 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7571 fct_chk( enclen == outlen );
7573 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7580 fct_chk( outlen == 0 );
7584 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7592 #ifdef POLARSSL_AES_C
7593 #ifdef POLARSSL_CIPHER_MODE_CTR
7595 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_bytes_in_multiple_parts_2)
7596 size_t first_length = 0;
7597 size_t second_length = 1;
7598 size_t length = first_length + second_length;
7599 unsigned char key[32];
7600 unsigned char iv[16];
7606 unsigned char inbuf[64];
7607 unsigned char encbuf[64];
7608 unsigned char decbuf[64];
7611 size_t totaloutlen = 0;
7614 memset( key, 0, 32 );
7615 memset( iv , 0, 16 );
7617 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7618 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7620 memset( inbuf, 5, 64 );
7621 memset( encbuf, 0, 64 );
7622 memset( decbuf, 0, 64 );
7626 fct_chk( NULL != cipher_info);
7648 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7649 totaloutlen = outlen;
7650 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7651 totaloutlen += outlen;
7658 fct_chk( totaloutlen == enclen );
7660 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7661 totaloutlen += outlen;
7668 fct_chk( outlen == 0 );
7672 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7679 fct_chk( enclen == outlen );
7681 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7688 fct_chk( outlen == 0 );
7692 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7700 #ifdef POLARSSL_AES_C
7701 #ifdef POLARSSL_CIPHER_MODE_CTR
7703 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_1)
7704 size_t first_length = 16;
7705 size_t second_length = 0;
7706 size_t length = first_length + second_length;
7707 unsigned char key[32];
7708 unsigned char iv[16];
7714 unsigned char inbuf[64];
7715 unsigned char encbuf[64];
7716 unsigned char decbuf[64];
7719 size_t totaloutlen = 0;
7722 memset( key, 0, 32 );
7723 memset( iv , 0, 16 );
7725 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7726 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7728 memset( inbuf, 5, 64 );
7729 memset( encbuf, 0, 64 );
7730 memset( decbuf, 0, 64 );
7734 fct_chk( NULL != cipher_info);
7756 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7757 totaloutlen = outlen;
7758 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7759 totaloutlen += outlen;
7766 fct_chk( totaloutlen == enclen );
7768 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7769 totaloutlen += outlen;
7776 fct_chk( outlen == 0 );
7780 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7787 fct_chk( enclen == outlen );
7789 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7796 fct_chk( outlen == 0 );
7800 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7808 #ifdef POLARSSL_AES_C
7809 #ifdef POLARSSL_CIPHER_MODE_CTR
7811 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_2)
7812 size_t first_length = 0;
7813 size_t second_length = 16;
7814 size_t length = first_length + second_length;
7815 unsigned char key[32];
7816 unsigned char iv[16];
7822 unsigned char inbuf[64];
7823 unsigned char encbuf[64];
7824 unsigned char decbuf[64];
7827 size_t totaloutlen = 0;
7830 memset( key, 0, 32 );
7831 memset( iv , 0, 16 );
7833 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7834 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7836 memset( inbuf, 5, 64 );
7837 memset( encbuf, 0, 64 );
7838 memset( decbuf, 0, 64 );
7842 fct_chk( NULL != cipher_info);
7864 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7865 totaloutlen = outlen;
7866 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7867 totaloutlen += outlen;
7874 fct_chk( totaloutlen == enclen );
7876 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7877 totaloutlen += outlen;
7884 fct_chk( outlen == 0 );
7888 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7895 fct_chk( enclen == outlen );
7897 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7904 fct_chk( outlen == 0 );
7908 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7916 #ifdef POLARSSL_AES_C
7917 #ifdef POLARSSL_CIPHER_MODE_CTR
7919 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_3)
7920 size_t first_length = 1;
7921 size_t second_length = 15;
7922 size_t length = first_length + second_length;
7923 unsigned char key[32];
7924 unsigned char iv[16];
7930 unsigned char inbuf[64];
7931 unsigned char encbuf[64];
7932 unsigned char decbuf[64];
7935 size_t totaloutlen = 0;
7938 memset( key, 0, 32 );
7939 memset( iv , 0, 16 );
7941 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7942 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7944 memset( inbuf, 5, 64 );
7945 memset( encbuf, 0, 64 );
7946 memset( decbuf, 0, 64 );
7950 fct_chk( NULL != cipher_info);
7972 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7973 totaloutlen = outlen;
7974 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7975 totaloutlen += outlen;
7982 fct_chk( totaloutlen == enclen );
7984 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7985 totaloutlen += outlen;
7992 fct_chk( outlen == 0 );
7996 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8003 fct_chk( enclen == outlen );
8005 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8012 fct_chk( outlen == 0 );
8016 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8024 #ifdef POLARSSL_AES_C
8025 #ifdef POLARSSL_CIPHER_MODE_CTR
8027 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_4)
8028 size_t first_length = 15;
8029 size_t second_length = 1;
8030 size_t length = first_length + second_length;
8031 unsigned char key[32];
8032 unsigned char iv[16];
8038 unsigned char inbuf[64];
8039 unsigned char encbuf[64];
8040 unsigned char decbuf[64];
8043 size_t totaloutlen = 0;
8046 memset( key, 0, 32 );
8047 memset( iv , 0, 16 );
8049 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8050 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8052 memset( inbuf, 5, 64 );
8053 memset( encbuf, 0, 64 );
8054 memset( decbuf, 0, 64 );
8058 fct_chk( NULL != cipher_info);
8080 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8081 totaloutlen = outlen;
8082 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8083 totaloutlen += outlen;
8090 fct_chk( totaloutlen == enclen );
8092 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8093 totaloutlen += outlen;
8100 fct_chk( outlen == 0 );
8104 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8111 fct_chk( enclen == outlen );
8113 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8120 fct_chk( outlen == 0 );
8124 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8132 #ifdef POLARSSL_AES_C
8133 #ifdef POLARSSL_CIPHER_MODE_CTR
8135 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
8136 size_t first_length = 15;
8137 size_t second_length = 7;
8138 size_t length = first_length + second_length;
8139 unsigned char key[32];
8140 unsigned char iv[16];
8146 unsigned char inbuf[64];
8147 unsigned char encbuf[64];
8148 unsigned char decbuf[64];
8151 size_t totaloutlen = 0;
8154 memset( key, 0, 32 );
8155 memset( iv , 0, 16 );
8157 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8158 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8160 memset( inbuf, 5, 64 );
8161 memset( encbuf, 0, 64 );
8162 memset( decbuf, 0, 64 );
8166 fct_chk( NULL != cipher_info);
8188 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8189 totaloutlen = outlen;
8190 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8191 totaloutlen += outlen;
8198 fct_chk( totaloutlen == enclen );
8200 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8201 totaloutlen += outlen;
8208 fct_chk( outlen == 0 );
8212 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8219 fct_chk( enclen == outlen );
8221 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8228 fct_chk( outlen == 0 );
8232 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8240 #ifdef POLARSSL_AES_C
8241 #ifdef POLARSSL_CIPHER_MODE_CTR
8243 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
8244 size_t first_length = 16;
8245 size_t second_length = 6;
8246 size_t length = first_length + second_length;
8247 unsigned char key[32];
8248 unsigned char iv[16];
8254 unsigned char inbuf[64];
8255 unsigned char encbuf[64];
8256 unsigned char decbuf[64];
8259 size_t totaloutlen = 0;
8262 memset( key, 0, 32 );
8263 memset( iv , 0, 16 );
8265 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8266 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8268 memset( inbuf, 5, 64 );
8269 memset( encbuf, 0, 64 );
8270 memset( decbuf, 0, 64 );
8274 fct_chk( NULL != cipher_info);
8296 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8297 totaloutlen = outlen;
8298 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8299 totaloutlen += outlen;
8306 fct_chk( totaloutlen == enclen );
8308 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8309 totaloutlen += outlen;
8316 fct_chk( outlen == 0 );
8320 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8327 fct_chk( enclen == outlen );
8329 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8336 fct_chk( outlen == 0 );
8340 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8348 #ifdef POLARSSL_AES_C
8349 #ifdef POLARSSL_CIPHER_MODE_CTR
8351 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
8352 size_t first_length = 17;
8353 size_t second_length = 6;
8354 size_t length = first_length + second_length;
8355 unsigned char key[32];
8356 unsigned char iv[16];
8362 unsigned char inbuf[64];
8363 unsigned char encbuf[64];
8364 unsigned char decbuf[64];
8367 size_t totaloutlen = 0;
8370 memset( key, 0, 32 );
8371 memset( iv , 0, 16 );
8373 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8374 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8376 memset( inbuf, 5, 64 );
8377 memset( encbuf, 0, 64 );
8378 memset( decbuf, 0, 64 );
8382 fct_chk( NULL != cipher_info);
8404 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8405 totaloutlen = outlen;
8406 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8407 totaloutlen += outlen;
8414 fct_chk( totaloutlen == enclen );
8416 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8417 totaloutlen += outlen;
8424 fct_chk( outlen == 0 );
8428 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8435 fct_chk( enclen == outlen );
8437 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8444 fct_chk( outlen == 0 );
8448 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8456 #ifdef POLARSSL_AES_C
8457 #ifdef POLARSSL_CIPHER_MODE_CTR
8459 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes_in_multiple_parts_1)
8460 size_t first_length = 16;
8461 size_t second_length = 16;
8462 size_t length = first_length + second_length;
8463 unsigned char key[32];
8464 unsigned char iv[16];
8470 unsigned char inbuf[64];
8471 unsigned char encbuf[64];
8472 unsigned char decbuf[64];
8475 size_t totaloutlen = 0;
8478 memset( key, 0, 32 );
8479 memset( iv , 0, 16 );
8481 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8482 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8484 memset( inbuf, 5, 64 );
8485 memset( encbuf, 0, 64 );
8486 memset( decbuf, 0, 64 );
8490 fct_chk( NULL != cipher_info);
8512 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8513 totaloutlen = outlen;
8514 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8515 totaloutlen += outlen;
8522 fct_chk( totaloutlen == enclen );
8524 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8525 totaloutlen += outlen;
8532 fct_chk( outlen == 0 );
8536 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8543 fct_chk( enclen == outlen );
8545 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8552 fct_chk( outlen == 0 );
8556 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8564 #ifdef POLARSSL_AES_C
8566 FCT_TEST_BGN(aes_encrypt_and_decrypt_0_bytes)
8568 unsigned char key[32];
8569 unsigned char iv[16];
8575 unsigned char inbuf[64];
8576 unsigned char encbuf[64];
8577 unsigned char decbuf[64];
8582 memset( key, 0, 32 );
8583 memset( iv , 0, 16 );
8585 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8586 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8588 memset( inbuf, 5, 64 );
8589 memset( encbuf, 0, 64 );
8590 memset( decbuf, 0, 64 );
8594 fct_chk( NULL != cipher_info );
8618 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
8625 fct_chk( outlen == enclen );
8628 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
8635 fct_chk( outlen == 0 );
8640 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8647 fct_chk( enclen == outlen );
8650 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8657 fct_chk( outlen == 0 );
8661 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8668 #ifdef POLARSSL_AES_C
8670 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_byte)
8672 unsigned char key[32];
8673 unsigned char iv[16];
8679 unsigned char inbuf[64];
8680 unsigned char encbuf[64];
8681 unsigned char decbuf[64];
8686 memset( key, 0, 32 );
8687 memset( iv , 0, 16 );
8689 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8690 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8692 memset( inbuf, 5, 64 );
8693 memset( encbuf, 0, 64 );
8694 memset( decbuf, 0, 64 );
8698 fct_chk( NULL != cipher_info );
8722 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
8729 fct_chk( outlen == enclen );
8732 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
8739 fct_chk( outlen == 0 );
8744 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8751 fct_chk( enclen == outlen );
8754 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8761 fct_chk( outlen == 0 );
8765 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8772 #ifdef POLARSSL_AES_C
8774 FCT_TEST_BGN(aes_encrypt_and_decrypt_2_bytes)
8776 unsigned char key[32];
8777 unsigned char iv[16];
8783 unsigned char inbuf[64];
8784 unsigned char encbuf[64];
8785 unsigned char decbuf[64];
8790 memset( key, 0, 32 );
8791 memset( iv , 0, 16 );
8793 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8794 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8796 memset( inbuf, 5, 64 );
8797 memset( encbuf, 0, 64 );
8798 memset( decbuf, 0, 64 );
8802 fct_chk( NULL != cipher_info );
8826 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
8833 fct_chk( outlen == enclen );
8836 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
8843 fct_chk( outlen == 0 );
8848 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8855 fct_chk( enclen == outlen );
8858 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8865 fct_chk( outlen == 0 );
8869 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8876 #ifdef POLARSSL_AES_C
8878 FCT_TEST_BGN(aes_encrypt_and_decrypt_7_bytes)
8880 unsigned char key[32];
8881 unsigned char iv[16];
8887 unsigned char inbuf[64];
8888 unsigned char encbuf[64];
8889 unsigned char decbuf[64];
8894 memset( key, 0, 32 );
8895 memset( iv , 0, 16 );
8897 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8898 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8900 memset( inbuf, 5, 64 );
8901 memset( encbuf, 0, 64 );
8902 memset( decbuf, 0, 64 );
8906 fct_chk( NULL != cipher_info );
8930 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
8937 fct_chk( outlen == enclen );
8940 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
8947 fct_chk( outlen == 0 );
8952 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8959 fct_chk( enclen == outlen );
8962 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8969 fct_chk( outlen == 0 );
8973 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8980 #ifdef POLARSSL_AES_C
8982 FCT_TEST_BGN(aes_encrypt_and_decrypt_8_bytes)
8984 unsigned char key[32];
8985 unsigned char iv[16];
8991 unsigned char inbuf[64];
8992 unsigned char encbuf[64];
8993 unsigned char decbuf[64];
8998 memset( key, 0, 32 );
8999 memset( iv , 0, 16 );
9001 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
9002 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
9004 memset( inbuf, 5, 64 );
9005 memset( encbuf, 0, 64 );
9006 memset( decbuf, 0, 64 );
9010 fct_chk( NULL != cipher_info );
9034 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
9041 fct_chk( outlen == enclen );
9044 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
9051 fct_chk( outlen == 0 );
9056 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
9063 fct_chk( enclen == outlen );
9066 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
9073 fct_chk( outlen == 0 );
9077 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
9084 #ifdef POLARSSL_AES_C
9086 FCT_TEST_BGN(aes_encrypt_and_decrypt_9_bytes)
9088 unsigned char key[32];
9089 unsigned char iv[16];
9095 unsigned char inbuf[64];
9096 unsigned char encbuf[64];
9097 unsigned char decbuf[64];
9102 memset( key, 0, 32 );
9103 memset( iv , 0, 16 );
9105 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
9106 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
9108 memset( inbuf, 5, 64 );
9109 memset( encbuf, 0, 64 );
9110 memset( decbuf, 0, 64 );
9114 fct_chk( NULL != cipher_info );
9138 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
9145 fct_chk( outlen == enclen );
9148 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
9155 fct_chk( outlen == 0 );
9160 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
9167 fct_chk( enclen == outlen );
9170 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
9177 fct_chk( outlen == 0 );
9181 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
9188 #ifdef POLARSSL_AES_C
9190 FCT_TEST_BGN(aes_encrypt_and_decrypt_15_bytes)
9192 unsigned char key[32];
9193 unsigned char iv[16];
9199 unsigned char inbuf[64];
9200 unsigned char encbuf[64];
9201 unsigned char decbuf[64];
9206 memset( key, 0, 32 );
9207 memset( iv , 0, 16 );
9209 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
9210 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
9212 memset( inbuf, 5, 64 );
9213 memset( encbuf, 0, 64 );
9214 memset( decbuf, 0, 64 );
9218 fct_chk( NULL != cipher_info );
9242 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
9249 fct_chk( outlen == enclen );
9252 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
9259 fct_chk( outlen == 0 );
9264 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
9271 fct_chk( enclen == outlen );
9274 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
9281 fct_chk( outlen == 0 );
9285 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
9292 #ifdef POLARSSL_AES_C
9294 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes)
9296 unsigned char key[32];
9297 unsigned char iv[16];
9303 unsigned char inbuf[64];
9304 unsigned char encbuf[64];
9305 unsigned char decbuf[64];
9310 memset( key, 0, 32 );
9311 memset( iv , 0, 16 );
9313 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
9314 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
9316 memset( inbuf, 5, 64 );
9317 memset( encbuf, 0, 64 );
9318 memset( decbuf, 0, 64 );
9322 fct_chk( NULL != cipher_info );
9346 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
9353 fct_chk( outlen == enclen );
9356 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
9363 fct_chk( outlen == 0 );
9368 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
9375 fct_chk( enclen == outlen );
9378 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
9385 fct_chk( outlen == 0 );
9389 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
9396 #ifdef POLARSSL_AES_C
9398 FCT_TEST_BGN(aes_encrypt_and_decrypt_17_bytes)
9400 unsigned char key[32];
9401 unsigned char iv[16];
9407 unsigned char inbuf[64];
9408 unsigned char encbuf[64];
9409 unsigned char decbuf[64];
9414 memset( key, 0, 32 );
9415 memset( iv , 0, 16 );
9417 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
9418 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
9420 memset( inbuf, 5, 64 );
9421 memset( encbuf, 0, 64 );
9422 memset( decbuf, 0, 64 );
9426 fct_chk( NULL != cipher_info );
9450 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
9457 fct_chk( outlen == enclen );
9460 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
9467 fct_chk( outlen == 0 );
9472 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
9479 fct_chk( enclen == outlen );
9482 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
9489 fct_chk( outlen == 0 );
9493 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
9500 #ifdef POLARSSL_AES_C
9502 FCT_TEST_BGN(aes_encrypt_and_decrypt_31_bytes)
9504 unsigned char key[32];
9505 unsigned char iv[16];
9511 unsigned char inbuf[64];
9512 unsigned char encbuf[64];
9513 unsigned char decbuf[64];
9518 memset( key, 0, 32 );
9519 memset( iv , 0, 16 );
9521 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
9522 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
9524 memset( inbuf, 5, 64 );
9525 memset( encbuf, 0, 64 );
9526 memset( decbuf, 0, 64 );
9530 fct_chk( NULL != cipher_info );
9554 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
9561 fct_chk( outlen == enclen );
9564 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
9571 fct_chk( outlen == 0 );
9576 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
9583 fct_chk( enclen == outlen );
9586 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
9593 fct_chk( outlen == 0 );
9597 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
9604 #ifdef POLARSSL_AES_C
9606 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes)
9608 unsigned char key[32];
9609 unsigned char iv[16];
9615 unsigned char inbuf[64];
9616 unsigned char encbuf[64];
9617 unsigned char decbuf[64];
9622 memset( key, 0, 32 );
9623 memset( iv , 0, 16 );
9625 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
9626 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
9628 memset( inbuf, 5, 64 );
9629 memset( encbuf, 0, 64 );
9630 memset( decbuf, 0, 64 );
9634 fct_chk( NULL != cipher_info );
9658 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
9665 fct_chk( outlen == enclen );
9668 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
9675 fct_chk( outlen == 0 );
9680 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
9687 fct_chk( enclen == outlen );
9690 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
9697 fct_chk( outlen == 0 );
9701 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
9708 #ifdef POLARSSL_AES_C
9710 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes)
9712 unsigned char key[32];
9713 unsigned char iv[16];
9719 unsigned char inbuf[64];
9720 unsigned char encbuf[64];
9721 unsigned char decbuf[64];
9726 memset( key, 0, 32 );
9727 memset( iv , 0, 16 );
9729 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
9730 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
9732 memset( inbuf, 5, 64 );
9733 memset( encbuf, 0, 64 );
9734 memset( decbuf, 0, 64 );
9738 fct_chk( NULL != cipher_info );
9762 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
9769 fct_chk( outlen == enclen );
9772 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
9779 fct_chk( outlen == 0 );
9784 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
9791 fct_chk( enclen == outlen );
9794 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
9801 fct_chk( outlen == 0 );
9805 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
9812 #ifdef POLARSSL_AES_C
9814 FCT_TEST_BGN(aes_encrypt_and_decrypt_47_bytes)
9816 unsigned char key[32];
9817 unsigned char iv[16];
9823 unsigned char inbuf[64];
9824 unsigned char encbuf[64];
9825 unsigned char decbuf[64];
9830 memset( key, 0, 32 );
9831 memset( iv , 0, 16 );
9833 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
9834 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
9836 memset( inbuf, 5, 64 );
9837 memset( encbuf, 0, 64 );
9838 memset( decbuf, 0, 64 );
9842 fct_chk( NULL != cipher_info );
9866 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
9873 fct_chk( outlen == enclen );
9876 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
9883 fct_chk( outlen == 0 );
9888 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
9895 fct_chk( enclen == outlen );
9898 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
9905 fct_chk( outlen == 0 );
9909 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
9916 #ifdef POLARSSL_AES_C
9918 FCT_TEST_BGN(aes_encrypt_and_decrypt_48_bytes)
9920 unsigned char key[32];
9921 unsigned char iv[16];
9927 unsigned char inbuf[64];
9928 unsigned char encbuf[64];
9929 unsigned char decbuf[64];
9934 memset( key, 0, 32 );
9935 memset( iv , 0, 16 );
9937 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
9938 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
9940 memset( inbuf, 5, 64 );
9941 memset( encbuf, 0, 64 );
9942 memset( decbuf, 0, 64 );
9946 fct_chk( NULL != cipher_info );
9970 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
9977 fct_chk( outlen == enclen );
9980 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
9987 fct_chk( outlen == 0 );
9992 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
9999 fct_chk( enclen == outlen );
10002 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
10009 fct_chk( outlen == 0 );
10013 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
10020 #ifdef POLARSSL_AES_C
10022 FCT_TEST_BGN(aes_encrypt_and_decrypt_49_bytes)
10023 size_t length = 49;
10024 unsigned char key[32];
10025 unsigned char iv[16];
10031 unsigned char inbuf[64];
10032 unsigned char encbuf[64];
10033 unsigned char decbuf[64];
10038 memset( key, 0, 32 );
10039 memset( iv , 0, 16 );
10041 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
10042 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
10044 memset( inbuf, 5, 64 );
10045 memset( encbuf, 0, 64 );
10046 memset( decbuf, 0, 64 );
10050 fct_chk( NULL != cipher_info );
10074 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
10081 fct_chk( outlen == enclen );
10084 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
10091 fct_chk( outlen == 0 );
10096 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
10103 fct_chk( enclen == outlen );
10106 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
10113 fct_chk( outlen == 0 );
10117 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
10124 #ifdef POLARSSL_AES_C
10126 FCT_TEST_BGN(aes_encrypt_and_decrypt_0_bytes_in_multiple_parts)
10127 size_t first_length = 0;
10128 size_t second_length = 0;
10129 size_t length = first_length + second_length;
10130 unsigned char key[32];
10131 unsigned char iv[16];
10137 unsigned char inbuf[64];
10138 unsigned char encbuf[64];
10139 unsigned char decbuf[64];
10142 size_t totaloutlen = 0;
10145 memset( key, 0, 32 );
10146 memset( iv , 0, 16 );
10148 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
10149 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
10151 memset( inbuf, 5, 64 );
10152 memset( encbuf, 0, 64 );
10153 memset( decbuf, 0, 64 );
10157 fct_chk( NULL != cipher_info);
10179 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
10180 totaloutlen = outlen;
10181 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
10182 totaloutlen += outlen;
10189 fct_chk( totaloutlen == enclen );
10191 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
10192 totaloutlen += outlen;
10199 fct_chk( outlen == 0 );
10203 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
10210 fct_chk( enclen == outlen );
10212 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
10219 fct_chk( outlen == 0 );
10223 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
10230 #ifdef POLARSSL_AES_C
10232 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_bytes_in_multiple_parts_1)
10233 size_t first_length = 1;
10234 size_t second_length = 0;
10235 size_t length = first_length + second_length;
10236 unsigned char key[32];
10237 unsigned char iv[16];
10243 unsigned char inbuf[64];
10244 unsigned char encbuf[64];
10245 unsigned char decbuf[64];
10248 size_t totaloutlen = 0;
10251 memset( key, 0, 32 );
10252 memset( iv , 0, 16 );
10254 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
10255 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
10257 memset( inbuf, 5, 64 );
10258 memset( encbuf, 0, 64 );
10259 memset( decbuf, 0, 64 );
10263 fct_chk( NULL != cipher_info);
10285 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
10286 totaloutlen = outlen;
10287 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
10288 totaloutlen += outlen;
10295 fct_chk( totaloutlen == enclen );
10297 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
10298 totaloutlen += outlen;
10305 fct_chk( outlen == 0 );
10309 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
10316 fct_chk( enclen == outlen );
10318 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
10325 fct_chk( outlen == 0 );
10329 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
10336 #ifdef POLARSSL_AES_C
10338 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_bytes_in_multiple_parts_2)
10339 size_t first_length = 0;
10340 size_t second_length = 1;
10341 size_t length = first_length + second_length;
10342 unsigned char key[32];
10343 unsigned char iv[16];
10349 unsigned char inbuf[64];
10350 unsigned char encbuf[64];
10351 unsigned char decbuf[64];
10354 size_t totaloutlen = 0;
10357 memset( key, 0, 32 );
10358 memset( iv , 0, 16 );
10360 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
10361 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
10363 memset( inbuf, 5, 64 );
10364 memset( encbuf, 0, 64 );
10365 memset( decbuf, 0, 64 );
10369 fct_chk( NULL != cipher_info);
10391 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
10392 totaloutlen = outlen;
10393 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
10394 totaloutlen += outlen;
10401 fct_chk( totaloutlen == enclen );
10403 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
10404 totaloutlen += outlen;
10411 fct_chk( outlen == 0 );
10415 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
10422 fct_chk( enclen == outlen );
10424 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
10431 fct_chk( outlen == 0 );
10435 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
10442 #ifdef POLARSSL_AES_C
10444 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_1)
10445 size_t first_length = 16;
10446 size_t second_length = 0;
10447 size_t length = first_length + second_length;
10448 unsigned char key[32];
10449 unsigned char iv[16];
10455 unsigned char inbuf[64];
10456 unsigned char encbuf[64];
10457 unsigned char decbuf[64];
10460 size_t totaloutlen = 0;
10463 memset( key, 0, 32 );
10464 memset( iv , 0, 16 );
10466 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
10467 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
10469 memset( inbuf, 5, 64 );
10470 memset( encbuf, 0, 64 );
10471 memset( decbuf, 0, 64 );
10475 fct_chk( NULL != cipher_info);
10497 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
10498 totaloutlen = outlen;
10499 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
10500 totaloutlen += outlen;
10507 fct_chk( totaloutlen == enclen );
10509 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
10510 totaloutlen += outlen;
10517 fct_chk( outlen == 0 );
10521 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
10528 fct_chk( enclen == outlen );
10530 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
10537 fct_chk( outlen == 0 );
10541 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
10548 #ifdef POLARSSL_AES_C
10550 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_2)
10551 size_t first_length = 0;
10552 size_t second_length = 16;
10553 size_t length = first_length + second_length;
10554 unsigned char key[32];
10555 unsigned char iv[16];
10561 unsigned char inbuf[64];
10562 unsigned char encbuf[64];
10563 unsigned char decbuf[64];
10566 size_t totaloutlen = 0;
10569 memset( key, 0, 32 );
10570 memset( iv , 0, 16 );
10572 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
10573 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
10575 memset( inbuf, 5, 64 );
10576 memset( encbuf, 0, 64 );
10577 memset( decbuf, 0, 64 );
10581 fct_chk( NULL != cipher_info);
10603 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
10604 totaloutlen = outlen;
10605 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
10606 totaloutlen += outlen;
10613 fct_chk( totaloutlen == enclen );
10615 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
10616 totaloutlen += outlen;
10623 fct_chk( outlen == 0 );
10627 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
10634 fct_chk( enclen == outlen );
10636 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
10643 fct_chk( outlen == 0 );
10647 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
10654 #ifdef POLARSSL_AES_C
10656 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_3)
10657 size_t first_length = 1;
10658 size_t second_length = 15;
10659 size_t length = first_length + second_length;
10660 unsigned char key[32];
10661 unsigned char iv[16];
10667 unsigned char inbuf[64];
10668 unsigned char encbuf[64];
10669 unsigned char decbuf[64];
10672 size_t totaloutlen = 0;
10675 memset( key, 0, 32 );
10676 memset( iv , 0, 16 );
10678 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
10679 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
10681 memset( inbuf, 5, 64 );
10682 memset( encbuf, 0, 64 );
10683 memset( decbuf, 0, 64 );
10687 fct_chk( NULL != cipher_info);
10709 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
10710 totaloutlen = outlen;
10711 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
10712 totaloutlen += outlen;
10719 fct_chk( totaloutlen == enclen );
10721 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
10722 totaloutlen += outlen;
10729 fct_chk( outlen == 0 );
10733 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
10740 fct_chk( enclen == outlen );
10742 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
10749 fct_chk( outlen == 0 );
10753 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
10760 #ifdef POLARSSL_AES_C
10762 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_4)
10763 size_t first_length = 15;
10764 size_t second_length = 1;
10765 size_t length = first_length + second_length;
10766 unsigned char key[32];
10767 unsigned char iv[16];
10773 unsigned char inbuf[64];
10774 unsigned char encbuf[64];
10775 unsigned char decbuf[64];
10778 size_t totaloutlen = 0;
10781 memset( key, 0, 32 );
10782 memset( iv , 0, 16 );
10784 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
10785 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
10787 memset( inbuf, 5, 64 );
10788 memset( encbuf, 0, 64 );
10789 memset( decbuf, 0, 64 );
10793 fct_chk( NULL != cipher_info);
10815 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
10816 totaloutlen = outlen;
10817 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
10818 totaloutlen += outlen;
10825 fct_chk( totaloutlen == enclen );
10827 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
10828 totaloutlen += outlen;
10835 fct_chk( outlen == 0 );
10839 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
10846 fct_chk( enclen == outlen );
10848 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
10855 fct_chk( outlen == 0 );
10859 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
10866 #ifdef POLARSSL_AES_C
10868 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
10869 size_t first_length = 15;
10870 size_t second_length = 7;
10871 size_t length = first_length + second_length;
10872 unsigned char key[32];
10873 unsigned char iv[16];
10879 unsigned char inbuf[64];
10880 unsigned char encbuf[64];
10881 unsigned char decbuf[64];
10884 size_t totaloutlen = 0;
10887 memset( key, 0, 32 );
10888 memset( iv , 0, 16 );
10890 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
10891 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
10893 memset( inbuf, 5, 64 );
10894 memset( encbuf, 0, 64 );
10895 memset( decbuf, 0, 64 );
10899 fct_chk( NULL != cipher_info);
10921 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
10922 totaloutlen = outlen;
10923 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
10924 totaloutlen += outlen;
10931 fct_chk( totaloutlen == enclen );
10933 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
10934 totaloutlen += outlen;
10941 fct_chk( outlen == 0 );
10945 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
10952 fct_chk( enclen == outlen );
10954 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
10961 fct_chk( outlen == 0 );
10965 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
10972 #ifdef POLARSSL_AES_C
10974 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
10975 size_t first_length = 16;
10976 size_t second_length = 6;
10977 size_t length = first_length + second_length;
10978 unsigned char key[32];
10979 unsigned char iv[16];
10985 unsigned char inbuf[64];
10986 unsigned char encbuf[64];
10987 unsigned char decbuf[64];
10990 size_t totaloutlen = 0;
10993 memset( key, 0, 32 );
10994 memset( iv , 0, 16 );
10996 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
10997 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
10999 memset( inbuf, 5, 64 );
11000 memset( encbuf, 0, 64 );
11001 memset( decbuf, 0, 64 );
11005 fct_chk( NULL != cipher_info);
11027 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
11028 totaloutlen = outlen;
11029 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
11030 totaloutlen += outlen;
11037 fct_chk( totaloutlen == enclen );
11039 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
11040 totaloutlen += outlen;
11047 fct_chk( outlen == 0 );
11051 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
11058 fct_chk( enclen == outlen );
11060 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
11067 fct_chk( outlen == 0 );
11071 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
11078 #ifdef POLARSSL_AES_C
11080 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
11081 size_t first_length = 17;
11082 size_t second_length = 6;
11083 size_t length = first_length + second_length;
11084 unsigned char key[32];
11085 unsigned char iv[16];
11091 unsigned char inbuf[64];
11092 unsigned char encbuf[64];
11093 unsigned char decbuf[64];
11096 size_t totaloutlen = 0;
11099 memset( key, 0, 32 );
11100 memset( iv , 0, 16 );
11102 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
11103 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
11105 memset( inbuf, 5, 64 );
11106 memset( encbuf, 0, 64 );
11107 memset( decbuf, 0, 64 );
11111 fct_chk( NULL != cipher_info);
11133 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
11134 totaloutlen = outlen;
11135 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
11136 totaloutlen += outlen;
11143 fct_chk( totaloutlen == enclen );
11145 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
11146 totaloutlen += outlen;
11153 fct_chk( outlen == 0 );
11157 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
11164 fct_chk( enclen == outlen );
11166 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
11173 fct_chk( outlen == 0 );
11177 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
11184 #ifdef POLARSSL_AES_C
11186 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes_in_multiple_parts_1)
11187 size_t first_length = 16;
11188 size_t second_length = 16;
11189 size_t length = first_length + second_length;
11190 unsigned char key[32];
11191 unsigned char iv[16];
11197 unsigned char inbuf[64];
11198 unsigned char encbuf[64];
11199 unsigned char decbuf[64];
11202 size_t totaloutlen = 0;
11205 memset( key, 0, 32 );
11206 memset( iv , 0, 16 );
11208 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
11209 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
11211 memset( inbuf, 5, 64 );
11212 memset( encbuf, 0, 64 );
11213 memset( decbuf, 0, 64 );
11217 fct_chk( NULL != cipher_info);
11239 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
11240 totaloutlen = outlen;
11241 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
11242 totaloutlen += outlen;
11249 fct_chk( totaloutlen == enclen );
11251 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
11252 totaloutlen += outlen;
11259 fct_chk( outlen == 0 );
11263 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
11270 fct_chk( enclen == outlen );
11272 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
11279 fct_chk( outlen == 0 );
11283 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
11290 #ifdef POLARSSL_AES_C
11292 FCT_TEST_BGN(aes_encrypt_and_decrypt_0_bytes)
11294 unsigned char key[32];
11295 unsigned char iv[16];
11301 unsigned char inbuf[64];
11302 unsigned char encbuf[64];
11303 unsigned char decbuf[64];
11308 memset( key, 0, 32 );
11309 memset( iv , 0, 16 );
11311 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
11312 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
11314 memset( inbuf, 5, 64 );
11315 memset( encbuf, 0, 64 );
11316 memset( decbuf, 0, 64 );
11320 fct_chk( NULL != cipher_info );
11344 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
11351 fct_chk( outlen == enclen );
11354 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
11361 fct_chk( outlen == 0 );
11366 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
11373 fct_chk( enclen == outlen );
11376 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
11383 fct_chk( outlen == 0 );
11387 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
11394 #ifdef POLARSSL_AES_C
11396 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_byte)
11398 unsigned char key[32];
11399 unsigned char iv[16];
11405 unsigned char inbuf[64];
11406 unsigned char encbuf[64];
11407 unsigned char decbuf[64];
11412 memset( key, 0, 32 );
11413 memset( iv , 0, 16 );
11415 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
11416 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
11418 memset( inbuf, 5, 64 );
11419 memset( encbuf, 0, 64 );
11420 memset( decbuf, 0, 64 );
11424 fct_chk( NULL != cipher_info );
11448 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
11455 fct_chk( outlen == enclen );
11458 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
11465 fct_chk( outlen == 0 );
11470 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
11477 fct_chk( enclen == outlen );
11480 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
11487 fct_chk( outlen == 0 );
11491 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
11498 #ifdef POLARSSL_AES_C
11500 FCT_TEST_BGN(aes_encrypt_and_decrypt_2_bytes)
11502 unsigned char key[32];
11503 unsigned char iv[16];
11509 unsigned char inbuf[64];
11510 unsigned char encbuf[64];
11511 unsigned char decbuf[64];
11516 memset( key, 0, 32 );
11517 memset( iv , 0, 16 );
11519 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
11520 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
11522 memset( inbuf, 5, 64 );
11523 memset( encbuf, 0, 64 );
11524 memset( decbuf, 0, 64 );
11528 fct_chk( NULL != cipher_info );
11552 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
11559 fct_chk( outlen == enclen );
11562 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
11569 fct_chk( outlen == 0 );
11574 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
11581 fct_chk( enclen == outlen );
11584 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
11591 fct_chk( outlen == 0 );
11595 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
11602 #ifdef POLARSSL_AES_C
11604 FCT_TEST_BGN(aes_encrypt_and_decrypt_7_bytes)
11606 unsigned char key[32];
11607 unsigned char iv[16];
11613 unsigned char inbuf[64];
11614 unsigned char encbuf[64];
11615 unsigned char decbuf[64];
11620 memset( key, 0, 32 );
11621 memset( iv , 0, 16 );
11623 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
11624 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
11626 memset( inbuf, 5, 64 );
11627 memset( encbuf, 0, 64 );
11628 memset( decbuf, 0, 64 );
11632 fct_chk( NULL != cipher_info );
11656 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
11663 fct_chk( outlen == enclen );
11666 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
11673 fct_chk( outlen == 0 );
11678 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
11685 fct_chk( enclen == outlen );
11688 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
11695 fct_chk( outlen == 0 );
11699 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
11706 #ifdef POLARSSL_AES_C
11708 FCT_TEST_BGN(aes_encrypt_and_decrypt_8_bytes)
11710 unsigned char key[32];
11711 unsigned char iv[16];
11717 unsigned char inbuf[64];
11718 unsigned char encbuf[64];
11719 unsigned char decbuf[64];
11724 memset( key, 0, 32 );
11725 memset( iv , 0, 16 );
11727 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
11728 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
11730 memset( inbuf, 5, 64 );
11731 memset( encbuf, 0, 64 );
11732 memset( decbuf, 0, 64 );
11736 fct_chk( NULL != cipher_info );
11760 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
11767 fct_chk( outlen == enclen );
11770 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
11777 fct_chk( outlen == 0 );
11782 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
11789 fct_chk( enclen == outlen );
11792 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
11799 fct_chk( outlen == 0 );
11803 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
11810 #ifdef POLARSSL_AES_C
11812 FCT_TEST_BGN(aes_encrypt_and_decrypt_9_bytes)
11814 unsigned char key[32];
11815 unsigned char iv[16];
11821 unsigned char inbuf[64];
11822 unsigned char encbuf[64];
11823 unsigned char decbuf[64];
11828 memset( key, 0, 32 );
11829 memset( iv , 0, 16 );
11831 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
11832 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
11834 memset( inbuf, 5, 64 );
11835 memset( encbuf, 0, 64 );
11836 memset( decbuf, 0, 64 );
11840 fct_chk( NULL != cipher_info );
11864 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
11871 fct_chk( outlen == enclen );
11874 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
11881 fct_chk( outlen == 0 );
11886 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
11893 fct_chk( enclen == outlen );
11896 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
11903 fct_chk( outlen == 0 );
11907 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
11914 #ifdef POLARSSL_AES_C
11916 FCT_TEST_BGN(aes_encrypt_and_decrypt_15_bytes)
11917 size_t length = 15;
11918 unsigned char key[32];
11919 unsigned char iv[16];
11925 unsigned char inbuf[64];
11926 unsigned char encbuf[64];
11927 unsigned char decbuf[64];
11932 memset( key, 0, 32 );
11933 memset( iv , 0, 16 );
11935 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
11936 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
11938 memset( inbuf, 5, 64 );
11939 memset( encbuf, 0, 64 );
11940 memset( decbuf, 0, 64 );
11944 fct_chk( NULL != cipher_info );
11968 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
11975 fct_chk( outlen == enclen );
11978 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
11985 fct_chk( outlen == 0 );
11990 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
11997 fct_chk( enclen == outlen );
12000 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
12007 fct_chk( outlen == 0 );
12011 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
12018 #ifdef POLARSSL_AES_C
12020 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes)
12021 size_t length = 16;
12022 unsigned char key[32];
12023 unsigned char iv[16];
12029 unsigned char inbuf[64];
12030 unsigned char encbuf[64];
12031 unsigned char decbuf[64];
12036 memset( key, 0, 32 );
12037 memset( iv , 0, 16 );
12039 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
12040 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
12042 memset( inbuf, 5, 64 );
12043 memset( encbuf, 0, 64 );
12044 memset( decbuf, 0, 64 );
12048 fct_chk( NULL != cipher_info );
12072 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
12079 fct_chk( outlen == enclen );
12082 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
12089 fct_chk( outlen == 0 );
12094 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
12101 fct_chk( enclen == outlen );
12104 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
12111 fct_chk( outlen == 0 );
12115 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
12122 #ifdef POLARSSL_AES_C
12124 FCT_TEST_BGN(aes_encrypt_and_decrypt_17_bytes)
12125 size_t length = 17;
12126 unsigned char key[32];
12127 unsigned char iv[16];
12133 unsigned char inbuf[64];
12134 unsigned char encbuf[64];
12135 unsigned char decbuf[64];
12140 memset( key, 0, 32 );
12141 memset( iv , 0, 16 );
12143 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
12144 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
12146 memset( inbuf, 5, 64 );
12147 memset( encbuf, 0, 64 );
12148 memset( decbuf, 0, 64 );
12152 fct_chk( NULL != cipher_info );
12176 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
12183 fct_chk( outlen == enclen );
12186 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
12193 fct_chk( outlen == 0 );
12198 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
12205 fct_chk( enclen == outlen );
12208 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
12215 fct_chk( outlen == 0 );
12219 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
12226 #ifdef POLARSSL_AES_C
12228 FCT_TEST_BGN(aes_encrypt_and_decrypt_31_bytes)
12229 size_t length = 31;
12230 unsigned char key[32];
12231 unsigned char iv[16];
12237 unsigned char inbuf[64];
12238 unsigned char encbuf[64];
12239 unsigned char decbuf[64];
12244 memset( key, 0, 32 );
12245 memset( iv , 0, 16 );
12247 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
12248 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
12250 memset( inbuf, 5, 64 );
12251 memset( encbuf, 0, 64 );
12252 memset( decbuf, 0, 64 );
12256 fct_chk( NULL != cipher_info );
12280 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
12287 fct_chk( outlen == enclen );
12290 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
12297 fct_chk( outlen == 0 );
12302 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
12309 fct_chk( enclen == outlen );
12312 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
12319 fct_chk( outlen == 0 );
12323 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
12330 #ifdef POLARSSL_AES_C
12332 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes)
12333 size_t length = 32;
12334 unsigned char key[32];
12335 unsigned char iv[16];
12341 unsigned char inbuf[64];
12342 unsigned char encbuf[64];
12343 unsigned char decbuf[64];
12348 memset( key, 0, 32 );
12349 memset( iv , 0, 16 );
12351 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
12352 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
12354 memset( inbuf, 5, 64 );
12355 memset( encbuf, 0, 64 );
12356 memset( decbuf, 0, 64 );
12360 fct_chk( NULL != cipher_info );
12384 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
12391 fct_chk( outlen == enclen );
12394 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
12401 fct_chk( outlen == 0 );
12406 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
12413 fct_chk( enclen == outlen );
12416 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
12423 fct_chk( outlen == 0 );
12427 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
12434 #ifdef POLARSSL_AES_C
12436 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes)
12437 size_t length = 33;
12438 unsigned char key[32];
12439 unsigned char iv[16];
12445 unsigned char inbuf[64];
12446 unsigned char encbuf[64];
12447 unsigned char decbuf[64];
12452 memset( key, 0, 32 );
12453 memset( iv , 0, 16 );
12455 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
12456 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
12458 memset( inbuf, 5, 64 );
12459 memset( encbuf, 0, 64 );
12460 memset( decbuf, 0, 64 );
12464 fct_chk( NULL != cipher_info );
12488 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
12495 fct_chk( outlen == enclen );
12498 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
12505 fct_chk( outlen == 0 );
12510 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
12517 fct_chk( enclen == outlen );
12520 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
12527 fct_chk( outlen == 0 );
12531 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
12538 #ifdef POLARSSL_AES_C
12540 FCT_TEST_BGN(aes_encrypt_and_decrypt_47_bytes)
12541 size_t length = 47;
12542 unsigned char key[32];
12543 unsigned char iv[16];
12549 unsigned char inbuf[64];
12550 unsigned char encbuf[64];
12551 unsigned char decbuf[64];
12556 memset( key, 0, 32 );
12557 memset( iv , 0, 16 );
12559 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
12560 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
12562 memset( inbuf, 5, 64 );
12563 memset( encbuf, 0, 64 );
12564 memset( decbuf, 0, 64 );
12568 fct_chk( NULL != cipher_info );
12592 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
12599 fct_chk( outlen == enclen );
12602 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
12609 fct_chk( outlen == 0 );
12614 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
12621 fct_chk( enclen == outlen );
12624 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
12631 fct_chk( outlen == 0 );
12635 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
12642 #ifdef POLARSSL_AES_C
12644 FCT_TEST_BGN(aes_encrypt_and_decrypt_48_bytes)
12645 size_t length = 48;
12646 unsigned char key[32];
12647 unsigned char iv[16];
12653 unsigned char inbuf[64];
12654 unsigned char encbuf[64];
12655 unsigned char decbuf[64];
12660 memset( key, 0, 32 );
12661 memset( iv , 0, 16 );
12663 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
12664 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
12666 memset( inbuf, 5, 64 );
12667 memset( encbuf, 0, 64 );
12668 memset( decbuf, 0, 64 );
12672 fct_chk( NULL != cipher_info );
12696 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
12703 fct_chk( outlen == enclen );
12706 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
12713 fct_chk( outlen == 0 );
12718 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
12725 fct_chk( enclen == outlen );
12728 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
12735 fct_chk( outlen == 0 );
12739 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
12746 #ifdef POLARSSL_AES_C
12748 FCT_TEST_BGN(aes_encrypt_and_decrypt_49_bytes)
12749 size_t length = 49;
12750 unsigned char key[32];
12751 unsigned char iv[16];
12757 unsigned char inbuf[64];
12758 unsigned char encbuf[64];
12759 unsigned char decbuf[64];
12764 memset( key, 0, 32 );
12765 memset( iv , 0, 16 );
12767 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
12768 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
12770 memset( inbuf, 5, 64 );
12771 memset( encbuf, 0, 64 );
12772 memset( decbuf, 0, 64 );
12776 fct_chk( NULL != cipher_info );
12800 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
12807 fct_chk( outlen == enclen );
12810 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
12817 fct_chk( outlen == 0 );
12822 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
12829 fct_chk( enclen == outlen );
12832 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
12839 fct_chk( outlen == 0 );
12843 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
12850 #ifdef POLARSSL_AES_C
12852 FCT_TEST_BGN(aes_encrypt_and_decrypt_0_bytes_in_multiple_parts)
12853 size_t first_length = 0;
12854 size_t second_length = 0;
12855 size_t length = first_length + second_length;
12856 unsigned char key[32];
12857 unsigned char iv[16];
12863 unsigned char inbuf[64];
12864 unsigned char encbuf[64];
12865 unsigned char decbuf[64];
12868 size_t totaloutlen = 0;
12871 memset( key, 0, 32 );
12872 memset( iv , 0, 16 );
12874 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
12875 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
12877 memset( inbuf, 5, 64 );
12878 memset( encbuf, 0, 64 );
12879 memset( decbuf, 0, 64 );
12883 fct_chk( NULL != cipher_info);
12905 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
12906 totaloutlen = outlen;
12907 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
12908 totaloutlen += outlen;
12915 fct_chk( totaloutlen == enclen );
12917 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
12918 totaloutlen += outlen;
12925 fct_chk( outlen == 0 );
12929 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
12936 fct_chk( enclen == outlen );
12938 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
12945 fct_chk( outlen == 0 );
12949 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
12956 #ifdef POLARSSL_AES_C
12958 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_bytes_in_multiple_parts_1)
12959 size_t first_length = 1;
12960 size_t second_length = 0;
12961 size_t length = first_length + second_length;
12962 unsigned char key[32];
12963 unsigned char iv[16];
12969 unsigned char inbuf[64];
12970 unsigned char encbuf[64];
12971 unsigned char decbuf[64];
12974 size_t totaloutlen = 0;
12977 memset( key, 0, 32 );
12978 memset( iv , 0, 16 );
12980 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
12981 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
12983 memset( inbuf, 5, 64 );
12984 memset( encbuf, 0, 64 );
12985 memset( decbuf, 0, 64 );
12989 fct_chk( NULL != cipher_info);
13011 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
13012 totaloutlen = outlen;
13013 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
13014 totaloutlen += outlen;
13021 fct_chk( totaloutlen == enclen );
13023 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
13024 totaloutlen += outlen;
13031 fct_chk( outlen == 0 );
13035 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
13042 fct_chk( enclen == outlen );
13044 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
13051 fct_chk( outlen == 0 );
13055 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
13062 #ifdef POLARSSL_AES_C
13064 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_bytes_in_multiple_parts_2)
13065 size_t first_length = 0;
13066 size_t second_length = 1;
13067 size_t length = first_length + second_length;
13068 unsigned char key[32];
13069 unsigned char iv[16];
13075 unsigned char inbuf[64];
13076 unsigned char encbuf[64];
13077 unsigned char decbuf[64];
13080 size_t totaloutlen = 0;
13083 memset( key, 0, 32 );
13084 memset( iv , 0, 16 );
13086 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
13087 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
13089 memset( inbuf, 5, 64 );
13090 memset( encbuf, 0, 64 );
13091 memset( decbuf, 0, 64 );
13095 fct_chk( NULL != cipher_info);
13117 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
13118 totaloutlen = outlen;
13119 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
13120 totaloutlen += outlen;
13127 fct_chk( totaloutlen == enclen );
13129 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
13130 totaloutlen += outlen;
13137 fct_chk( outlen == 0 );
13141 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
13148 fct_chk( enclen == outlen );
13150 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
13157 fct_chk( outlen == 0 );
13161 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
13168 #ifdef POLARSSL_AES_C
13170 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_1)
13171 size_t first_length = 16;
13172 size_t second_length = 0;
13173 size_t length = first_length + second_length;
13174 unsigned char key[32];
13175 unsigned char iv[16];
13181 unsigned char inbuf[64];
13182 unsigned char encbuf[64];
13183 unsigned char decbuf[64];
13186 size_t totaloutlen = 0;
13189 memset( key, 0, 32 );
13190 memset( iv , 0, 16 );
13192 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
13193 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
13195 memset( inbuf, 5, 64 );
13196 memset( encbuf, 0, 64 );
13197 memset( decbuf, 0, 64 );
13201 fct_chk( NULL != cipher_info);
13223 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
13224 totaloutlen = outlen;
13225 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
13226 totaloutlen += outlen;
13233 fct_chk( totaloutlen == enclen );
13235 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
13236 totaloutlen += outlen;
13243 fct_chk( outlen == 0 );
13247 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
13254 fct_chk( enclen == outlen );
13256 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
13263 fct_chk( outlen == 0 );
13267 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
13274 #ifdef POLARSSL_AES_C
13276 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_2)
13277 size_t first_length = 0;
13278 size_t second_length = 16;
13279 size_t length = first_length + second_length;
13280 unsigned char key[32];
13281 unsigned char iv[16];
13287 unsigned char inbuf[64];
13288 unsigned char encbuf[64];
13289 unsigned char decbuf[64];
13292 size_t totaloutlen = 0;
13295 memset( key, 0, 32 );
13296 memset( iv , 0, 16 );
13298 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
13299 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
13301 memset( inbuf, 5, 64 );
13302 memset( encbuf, 0, 64 );
13303 memset( decbuf, 0, 64 );
13307 fct_chk( NULL != cipher_info);
13329 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
13330 totaloutlen = outlen;
13331 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
13332 totaloutlen += outlen;
13339 fct_chk( totaloutlen == enclen );
13341 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
13342 totaloutlen += outlen;
13349 fct_chk( outlen == 0 );
13353 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
13360 fct_chk( enclen == outlen );
13362 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
13369 fct_chk( outlen == 0 );
13373 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
13380 #ifdef POLARSSL_AES_C
13382 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_3)
13383 size_t first_length = 1;
13384 size_t second_length = 15;
13385 size_t length = first_length + second_length;
13386 unsigned char key[32];
13387 unsigned char iv[16];
13393 unsigned char inbuf[64];
13394 unsigned char encbuf[64];
13395 unsigned char decbuf[64];
13398 size_t totaloutlen = 0;
13401 memset( key, 0, 32 );
13402 memset( iv , 0, 16 );
13404 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
13405 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
13407 memset( inbuf, 5, 64 );
13408 memset( encbuf, 0, 64 );
13409 memset( decbuf, 0, 64 );
13413 fct_chk( NULL != cipher_info);
13435 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
13436 totaloutlen = outlen;
13437 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
13438 totaloutlen += outlen;
13445 fct_chk( totaloutlen == enclen );
13447 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
13448 totaloutlen += outlen;
13455 fct_chk( outlen == 0 );
13459 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
13466 fct_chk( enclen == outlen );
13468 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
13475 fct_chk( outlen == 0 );
13479 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
13486 #ifdef POLARSSL_AES_C
13488 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_4)
13489 size_t first_length = 15;
13490 size_t second_length = 1;
13491 size_t length = first_length + second_length;
13492 unsigned char key[32];
13493 unsigned char iv[16];
13499 unsigned char inbuf[64];
13500 unsigned char encbuf[64];
13501 unsigned char decbuf[64];
13504 size_t totaloutlen = 0;
13507 memset( key, 0, 32 );
13508 memset( iv , 0, 16 );
13510 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
13511 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
13513 memset( inbuf, 5, 64 );
13514 memset( encbuf, 0, 64 );
13515 memset( decbuf, 0, 64 );
13519 fct_chk( NULL != cipher_info);
13541 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
13542 totaloutlen = outlen;
13543 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
13544 totaloutlen += outlen;
13551 fct_chk( totaloutlen == enclen );
13553 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
13554 totaloutlen += outlen;
13561 fct_chk( outlen == 0 );
13565 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
13572 fct_chk( enclen == outlen );
13574 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
13581 fct_chk( outlen == 0 );
13585 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
13592 #ifdef POLARSSL_AES_C
13594 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
13595 size_t first_length = 15;
13596 size_t second_length = 7;
13597 size_t length = first_length + second_length;
13598 unsigned char key[32];
13599 unsigned char iv[16];
13605 unsigned char inbuf[64];
13606 unsigned char encbuf[64];
13607 unsigned char decbuf[64];
13610 size_t totaloutlen = 0;
13613 memset( key, 0, 32 );
13614 memset( iv , 0, 16 );
13616 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
13617 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
13619 memset( inbuf, 5, 64 );
13620 memset( encbuf, 0, 64 );
13621 memset( decbuf, 0, 64 );
13625 fct_chk( NULL != cipher_info);
13647 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
13648 totaloutlen = outlen;
13649 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
13650 totaloutlen += outlen;
13657 fct_chk( totaloutlen == enclen );
13659 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
13660 totaloutlen += outlen;
13667 fct_chk( outlen == 0 );
13671 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
13678 fct_chk( enclen == outlen );
13680 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
13687 fct_chk( outlen == 0 );
13691 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
13698 #ifdef POLARSSL_AES_C
13700 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
13701 size_t first_length = 16;
13702 size_t second_length = 6;
13703 size_t length = first_length + second_length;
13704 unsigned char key[32];
13705 unsigned char iv[16];
13711 unsigned char inbuf[64];
13712 unsigned char encbuf[64];
13713 unsigned char decbuf[64];
13716 size_t totaloutlen = 0;
13719 memset( key, 0, 32 );
13720 memset( iv , 0, 16 );
13722 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
13723 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
13725 memset( inbuf, 5, 64 );
13726 memset( encbuf, 0, 64 );
13727 memset( decbuf, 0, 64 );
13731 fct_chk( NULL != cipher_info);
13753 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
13754 totaloutlen = outlen;
13755 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
13756 totaloutlen += outlen;
13763 fct_chk( totaloutlen == enclen );
13765 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
13766 totaloutlen += outlen;
13773 fct_chk( outlen == 0 );
13777 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
13784 fct_chk( enclen == outlen );
13786 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
13793 fct_chk( outlen == 0 );
13797 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
13804 #ifdef POLARSSL_AES_C
13806 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
13807 size_t first_length = 17;
13808 size_t second_length = 6;
13809 size_t length = first_length + second_length;
13810 unsigned char key[32];
13811 unsigned char iv[16];
13817 unsigned char inbuf[64];
13818 unsigned char encbuf[64];
13819 unsigned char decbuf[64];
13822 size_t totaloutlen = 0;
13825 memset( key, 0, 32 );
13826 memset( iv , 0, 16 );
13828 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
13829 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
13831 memset( inbuf, 5, 64 );
13832 memset( encbuf, 0, 64 );
13833 memset( decbuf, 0, 64 );
13837 fct_chk( NULL != cipher_info);
13859 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
13860 totaloutlen = outlen;
13861 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
13862 totaloutlen += outlen;
13869 fct_chk( totaloutlen == enclen );
13871 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
13872 totaloutlen += outlen;
13879 fct_chk( outlen == 0 );
13883 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
13890 fct_chk( enclen == outlen );
13892 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
13899 fct_chk( outlen == 0 );
13903 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
13910 #ifdef POLARSSL_AES_C
13912 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes_in_multiple_parts_1)
13913 size_t first_length = 16;
13914 size_t second_length = 16;
13915 size_t length = first_length + second_length;
13916 unsigned char key[32];
13917 unsigned char iv[16];
13923 unsigned char inbuf[64];
13924 unsigned char encbuf[64];
13925 unsigned char decbuf[64];
13928 size_t totaloutlen = 0;
13931 memset( key, 0, 32 );
13932 memset( iv , 0, 16 );
13934 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
13935 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
13937 memset( inbuf, 5, 64 );
13938 memset( encbuf, 0, 64 );
13939 memset( decbuf, 0, 64 );
13943 fct_chk( NULL != cipher_info);
13965 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
13966 totaloutlen = outlen;
13967 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
13968 totaloutlen += outlen;
13975 fct_chk( totaloutlen == enclen );
13977 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
13978 totaloutlen += outlen;
13985 fct_chk( outlen == 0 );
13989 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
13996 fct_chk( enclen == outlen );
13998 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
14005 fct_chk( outlen == 0 );
14009 fct_chk( 0 == memcmp(inbuf, decbuf, length) );