9 typedef UINT32 uint32_t;
18 #define GET_ULONG_BE(n,b,i) \
20 (n) = ( (unsigned long) (b)[(i) ] << 24 ) \
21 | ( (unsigned long) (b)[(i) + 1] << 16 ) \
22 | ( (unsigned long) (b)[(i) + 2] << 8 ) \
23 | ( (unsigned long) (b)[(i) + 3] ); \
28 #define PUT_ULONG_BE(n,b,i) \
30 (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
31 (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
32 (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
33 (b)[(i) + 3] = (unsigned char) ( (n) ); \
37 int unhexify(
unsigned char *obuf,
const char *ibuf)
40 int len = strlen(ibuf) / 2;
41 assert(!(strlen(ibuf) %1));
46 if( c >=
'0' && c <=
'9' )
48 else if( c >=
'a' && c <=
'f' )
50 else if( c >=
'A' && c <=
'F' )
56 if( c2 >=
'0' && c2 <=
'9' )
58 else if( c2 >=
'a' && c2 <=
'f' )
60 else if( c2 >=
'A' && c2 <=
'F' )
65 *obuf++ = ( c << 4 ) | c2;
71 void hexify(
unsigned char *obuf,
const unsigned char *ibuf,
int len)
83 *obuf++ =
'a' + h - 10;
88 *obuf++ =
'a' + l - 10;
104 static int rnd_std_rand(
void *rng_state,
unsigned char *output,
size_t len )
108 if( rng_state != NULL )
111 for( i = 0; i < len; ++i )
122 static int rnd_zero_rand(
void *rng_state,
unsigned char *output,
size_t len )
124 if( rng_state != NULL )
127 memset( output, 0, len );
154 if( rng_state == NULL )
163 memcpy( output, info->
buf, use_len );
164 info->
buf += use_len;
168 if( len - use_len > 0 )
169 return(
rnd_std_rand( NULL, output + use_len, len - use_len ) );
198 uint32_t i, *k, sum, delta=0x9E3779B9;
199 unsigned char result[4];
201 if( rng_state == NULL )
208 size_t use_len = ( len > 4 ) ? 4 : len;
211 for( i = 0; i < 32; i++ )
213 info->
v0 += (((info->
v1 << 4) ^ (info->
v1 >> 5)) + info->
v1) ^ (sum + k[sum & 3]);
215 info->
v1 += (((info->
v0 << 4) ^ (info->
v0 >> 5)) + info->
v0) ^ (sum + k[(sum>>11) & 3]);
219 memcpy( output, result, use_len );
229 #ifdef POLARSSL_CIPHER_C
232 FCT_SUITE_BGN(test_suite_cipher)
234 #ifdef POLARSSL_SELF_TEST
236 FCT_TEST_BGN(cipher_selftest)
244 FCT_TEST_BGN(decrypt_empty_buffer)
245 unsigned char key[32];
246 unsigned char iv[16];
251 unsigned char encbuf[64];
252 unsigned char decbuf[64];
256 memset( key, 0, 32 );
257 memset( iv , 0, 16 );
259 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
261 memset( encbuf, 0, 64 );
262 memset( decbuf, 0, 64 );
266 fct_chk( NULL != cipher_info);
275 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, 0, decbuf, &outlen ) );
276 fct_chk( 0 == outlen );
278 fct_chk( 0 == outlen );
283 #ifdef POLARSSL_AES_C
285 FCT_TEST_BGN(aes_encrypt_and_decrypt_0_bytes)
287 unsigned char key[32];
288 unsigned char iv[16];
294 unsigned char inbuf[64];
295 unsigned char encbuf[64];
296 unsigned char decbuf[64];
301 memset( key, 0, 32 );
302 memset( iv , 0, 16 );
304 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
305 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
307 memset( inbuf, 5, 64 );
308 memset( encbuf, 0, 64 );
309 memset( decbuf, 0, 64 );
313 fct_chk( NULL != cipher_info );
337 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
344 fct_chk( outlen == enclen );
347 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
354 fct_chk( outlen == 0 );
359 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
366 fct_chk( enclen == outlen );
369 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
376 fct_chk( outlen == 0 );
380 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
387 #ifdef POLARSSL_AES_C
389 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_byte)
391 unsigned char key[32];
392 unsigned char iv[16];
398 unsigned char inbuf[64];
399 unsigned char encbuf[64];
400 unsigned char decbuf[64];
405 memset( key, 0, 32 );
406 memset( iv , 0, 16 );
408 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
409 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
411 memset( inbuf, 5, 64 );
412 memset( encbuf, 0, 64 );
413 memset( decbuf, 0, 64 );
417 fct_chk( NULL != cipher_info );
441 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
448 fct_chk( outlen == enclen );
451 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
458 fct_chk( outlen == 0 );
463 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
470 fct_chk( enclen == outlen );
473 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
480 fct_chk( outlen == 0 );
484 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
491 #ifdef POLARSSL_AES_C
493 FCT_TEST_BGN(aes_encrypt_and_decrypt_2_bytes)
495 unsigned char key[32];
496 unsigned char iv[16];
502 unsigned char inbuf[64];
503 unsigned char encbuf[64];
504 unsigned char decbuf[64];
509 memset( key, 0, 32 );
510 memset( iv , 0, 16 );
512 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
513 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
515 memset( inbuf, 5, 64 );
516 memset( encbuf, 0, 64 );
517 memset( decbuf, 0, 64 );
521 fct_chk( NULL != cipher_info );
545 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
552 fct_chk( outlen == enclen );
555 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
562 fct_chk( outlen == 0 );
567 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
574 fct_chk( enclen == outlen );
577 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
584 fct_chk( outlen == 0 );
588 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
595 #ifdef POLARSSL_AES_C
597 FCT_TEST_BGN(aes_encrypt_and_decrypt_7_bytes)
599 unsigned char key[32];
600 unsigned char iv[16];
606 unsigned char inbuf[64];
607 unsigned char encbuf[64];
608 unsigned char decbuf[64];
613 memset( key, 0, 32 );
614 memset( iv , 0, 16 );
616 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
617 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
619 memset( inbuf, 5, 64 );
620 memset( encbuf, 0, 64 );
621 memset( decbuf, 0, 64 );
625 fct_chk( NULL != cipher_info );
649 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
656 fct_chk( outlen == enclen );
659 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
666 fct_chk( outlen == 0 );
671 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
678 fct_chk( enclen == outlen );
681 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
688 fct_chk( outlen == 0 );
692 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
699 #ifdef POLARSSL_AES_C
701 FCT_TEST_BGN(aes_encrypt_and_decrypt_8_bytes)
703 unsigned char key[32];
704 unsigned char iv[16];
710 unsigned char inbuf[64];
711 unsigned char encbuf[64];
712 unsigned char decbuf[64];
717 memset( key, 0, 32 );
718 memset( iv , 0, 16 );
720 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
721 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
723 memset( inbuf, 5, 64 );
724 memset( encbuf, 0, 64 );
725 memset( decbuf, 0, 64 );
729 fct_chk( NULL != cipher_info );
753 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
760 fct_chk( outlen == enclen );
763 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
770 fct_chk( outlen == 0 );
775 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
782 fct_chk( enclen == outlen );
785 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
792 fct_chk( outlen == 0 );
796 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
803 #ifdef POLARSSL_AES_C
805 FCT_TEST_BGN(aes_encrypt_and_decrypt_9_bytes)
807 unsigned char key[32];
808 unsigned char iv[16];
814 unsigned char inbuf[64];
815 unsigned char encbuf[64];
816 unsigned char decbuf[64];
821 memset( key, 0, 32 );
822 memset( iv , 0, 16 );
824 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
825 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
827 memset( inbuf, 5, 64 );
828 memset( encbuf, 0, 64 );
829 memset( decbuf, 0, 64 );
833 fct_chk( NULL != cipher_info );
857 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
864 fct_chk( outlen == enclen );
867 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
874 fct_chk( outlen == 0 );
879 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
886 fct_chk( enclen == outlen );
889 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
896 fct_chk( outlen == 0 );
900 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
907 #ifdef POLARSSL_AES_C
909 FCT_TEST_BGN(aes_encrypt_and_decrypt_15_bytes)
911 unsigned char key[32];
912 unsigned char iv[16];
918 unsigned char inbuf[64];
919 unsigned char encbuf[64];
920 unsigned char decbuf[64];
925 memset( key, 0, 32 );
926 memset( iv , 0, 16 );
928 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
929 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
931 memset( inbuf, 5, 64 );
932 memset( encbuf, 0, 64 );
933 memset( decbuf, 0, 64 );
937 fct_chk( NULL != cipher_info );
961 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
968 fct_chk( outlen == enclen );
971 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
978 fct_chk( outlen == 0 );
983 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
990 fct_chk( enclen == outlen );
993 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1000 fct_chk( outlen == 0 );
1004 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1011 #ifdef POLARSSL_AES_C
1013 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes)
1015 unsigned char key[32];
1016 unsigned char iv[16];
1022 unsigned char inbuf[64];
1023 unsigned char encbuf[64];
1024 unsigned char decbuf[64];
1029 memset( key, 0, 32 );
1030 memset( iv , 0, 16 );
1032 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1033 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1035 memset( inbuf, 5, 64 );
1036 memset( encbuf, 0, 64 );
1037 memset( decbuf, 0, 64 );
1041 fct_chk( NULL != cipher_info );
1065 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1072 fct_chk( outlen == enclen );
1075 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1082 fct_chk( outlen == 0 );
1087 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1094 fct_chk( enclen == outlen );
1097 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1104 fct_chk( outlen == 0 );
1108 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1115 #ifdef POLARSSL_AES_C
1117 FCT_TEST_BGN(aes_encrypt_and_decrypt_17_bytes)
1119 unsigned char key[32];
1120 unsigned char iv[16];
1126 unsigned char inbuf[64];
1127 unsigned char encbuf[64];
1128 unsigned char decbuf[64];
1133 memset( key, 0, 32 );
1134 memset( iv , 0, 16 );
1136 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1137 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1139 memset( inbuf, 5, 64 );
1140 memset( encbuf, 0, 64 );
1141 memset( decbuf, 0, 64 );
1145 fct_chk( NULL != cipher_info );
1169 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1176 fct_chk( outlen == enclen );
1179 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1186 fct_chk( outlen == 0 );
1191 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1198 fct_chk( enclen == outlen );
1201 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1208 fct_chk( outlen == 0 );
1212 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1219 #ifdef POLARSSL_AES_C
1221 FCT_TEST_BGN(aes_encrypt_and_decrypt_31_bytes)
1223 unsigned char key[32];
1224 unsigned char iv[16];
1230 unsigned char inbuf[64];
1231 unsigned char encbuf[64];
1232 unsigned char decbuf[64];
1237 memset( key, 0, 32 );
1238 memset( iv , 0, 16 );
1240 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1241 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1243 memset( inbuf, 5, 64 );
1244 memset( encbuf, 0, 64 );
1245 memset( decbuf, 0, 64 );
1249 fct_chk( NULL != cipher_info );
1273 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1280 fct_chk( outlen == enclen );
1283 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1290 fct_chk( outlen == 0 );
1295 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1302 fct_chk( enclen == outlen );
1305 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1312 fct_chk( outlen == 0 );
1316 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1323 #ifdef POLARSSL_AES_C
1325 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes)
1327 unsigned char key[32];
1328 unsigned char iv[16];
1334 unsigned char inbuf[64];
1335 unsigned char encbuf[64];
1336 unsigned char decbuf[64];
1341 memset( key, 0, 32 );
1342 memset( iv , 0, 16 );
1344 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1345 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1347 memset( inbuf, 5, 64 );
1348 memset( encbuf, 0, 64 );
1349 memset( decbuf, 0, 64 );
1353 fct_chk( NULL != cipher_info );
1377 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1384 fct_chk( outlen == enclen );
1387 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1394 fct_chk( outlen == 0 );
1399 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1406 fct_chk( enclen == outlen );
1409 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1416 fct_chk( outlen == 0 );
1420 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1427 #ifdef POLARSSL_AES_C
1429 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes)
1431 unsigned char key[32];
1432 unsigned char iv[16];
1438 unsigned char inbuf[64];
1439 unsigned char encbuf[64];
1440 unsigned char decbuf[64];
1445 memset( key, 0, 32 );
1446 memset( iv , 0, 16 );
1448 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1449 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1451 memset( inbuf, 5, 64 );
1452 memset( encbuf, 0, 64 );
1453 memset( decbuf, 0, 64 );
1457 fct_chk( NULL != cipher_info );
1481 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1488 fct_chk( outlen == enclen );
1491 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1498 fct_chk( outlen == 0 );
1503 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1510 fct_chk( enclen == outlen );
1513 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1520 fct_chk( outlen == 0 );
1524 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1531 #ifdef POLARSSL_AES_C
1533 FCT_TEST_BGN(aes_encrypt_and_decrypt_47_bytes)
1535 unsigned char key[32];
1536 unsigned char iv[16];
1542 unsigned char inbuf[64];
1543 unsigned char encbuf[64];
1544 unsigned char decbuf[64];
1549 memset( key, 0, 32 );
1550 memset( iv , 0, 16 );
1552 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1553 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1555 memset( inbuf, 5, 64 );
1556 memset( encbuf, 0, 64 );
1557 memset( decbuf, 0, 64 );
1561 fct_chk( NULL != cipher_info );
1585 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1592 fct_chk( outlen == enclen );
1595 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1602 fct_chk( outlen == 0 );
1607 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1614 fct_chk( enclen == outlen );
1617 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1624 fct_chk( outlen == 0 );
1628 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1635 #ifdef POLARSSL_AES_C
1637 FCT_TEST_BGN(aes_encrypt_and_decrypt_48_bytes)
1639 unsigned char key[32];
1640 unsigned char iv[16];
1646 unsigned char inbuf[64];
1647 unsigned char encbuf[64];
1648 unsigned char decbuf[64];
1653 memset( key, 0, 32 );
1654 memset( iv , 0, 16 );
1656 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1657 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1659 memset( inbuf, 5, 64 );
1660 memset( encbuf, 0, 64 );
1661 memset( decbuf, 0, 64 );
1665 fct_chk( NULL != cipher_info );
1689 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1696 fct_chk( outlen == enclen );
1699 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1706 fct_chk( outlen == 0 );
1711 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1718 fct_chk( enclen == outlen );
1721 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1728 fct_chk( outlen == 0 );
1732 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1739 #ifdef POLARSSL_AES_C
1741 FCT_TEST_BGN(aes_encrypt_and_decrypt_49_bytes)
1743 unsigned char key[32];
1744 unsigned char iv[16];
1750 unsigned char inbuf[64];
1751 unsigned char encbuf[64];
1752 unsigned char decbuf[64];
1757 memset( key, 0, 32 );
1758 memset( iv , 0, 16 );
1760 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1761 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1763 memset( inbuf, 5, 64 );
1764 memset( encbuf, 0, 64 );
1765 memset( decbuf, 0, 64 );
1769 fct_chk( NULL != cipher_info );
1793 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
1800 fct_chk( outlen == enclen );
1803 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
1810 fct_chk( outlen == 0 );
1815 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1822 fct_chk( enclen == outlen );
1825 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1832 fct_chk( outlen == 0 );
1836 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1843 #ifdef POLARSSL_AES_C
1845 FCT_TEST_BGN(aes_encrypt_and_decrypt_0_bytes_in_multiple_parts)
1846 size_t first_length = 0;
1847 size_t second_length = 0;
1848 size_t length = first_length + second_length;
1849 unsigned char key[32];
1850 unsigned char iv[16];
1856 unsigned char inbuf[64];
1857 unsigned char encbuf[64];
1858 unsigned char decbuf[64];
1861 size_t totaloutlen = 0;
1864 memset( key, 0, 32 );
1865 memset( iv , 0, 16 );
1867 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1868 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1870 memset( inbuf, 5, 64 );
1871 memset( encbuf, 0, 64 );
1872 memset( decbuf, 0, 64 );
1876 fct_chk( NULL != cipher_info);
1898 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
1899 totaloutlen = outlen;
1900 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
1901 totaloutlen += outlen;
1908 fct_chk( totaloutlen == enclen );
1910 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
1911 totaloutlen += outlen;
1918 fct_chk( outlen == 0 );
1922 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
1929 fct_chk( enclen == outlen );
1931 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
1938 fct_chk( outlen == 0 );
1942 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
1949 #ifdef POLARSSL_AES_C
1951 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_bytes_in_multiple_parts_1)
1952 size_t first_length = 1;
1953 size_t second_length = 0;
1954 size_t length = first_length + second_length;
1955 unsigned char key[32];
1956 unsigned char iv[16];
1962 unsigned char inbuf[64];
1963 unsigned char encbuf[64];
1964 unsigned char decbuf[64];
1967 size_t totaloutlen = 0;
1970 memset( key, 0, 32 );
1971 memset( iv , 0, 16 );
1973 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
1974 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
1976 memset( inbuf, 5, 64 );
1977 memset( encbuf, 0, 64 );
1978 memset( decbuf, 0, 64 );
1982 fct_chk( NULL != cipher_info);
2004 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2005 totaloutlen = outlen;
2006 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2007 totaloutlen += outlen;
2014 fct_chk( totaloutlen == enclen );
2016 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2017 totaloutlen += outlen;
2024 fct_chk( outlen == 0 );
2028 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2035 fct_chk( enclen == outlen );
2037 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2044 fct_chk( outlen == 0 );
2048 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2055 #ifdef POLARSSL_AES_C
2057 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_bytes_in_multiple_parts_2)
2058 size_t first_length = 0;
2059 size_t second_length = 1;
2060 size_t length = first_length + second_length;
2061 unsigned char key[32];
2062 unsigned char iv[16];
2068 unsigned char inbuf[64];
2069 unsigned char encbuf[64];
2070 unsigned char decbuf[64];
2073 size_t totaloutlen = 0;
2076 memset( key, 0, 32 );
2077 memset( iv , 0, 16 );
2079 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2080 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2082 memset( inbuf, 5, 64 );
2083 memset( encbuf, 0, 64 );
2084 memset( decbuf, 0, 64 );
2088 fct_chk( NULL != cipher_info);
2110 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2111 totaloutlen = outlen;
2112 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2113 totaloutlen += outlen;
2120 fct_chk( totaloutlen == enclen );
2122 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2123 totaloutlen += outlen;
2130 fct_chk( outlen == 0 );
2134 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2141 fct_chk( enclen == outlen );
2143 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2150 fct_chk( outlen == 0 );
2154 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2161 #ifdef POLARSSL_AES_C
2163 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_1)
2164 size_t first_length = 16;
2165 size_t second_length = 0;
2166 size_t length = first_length + second_length;
2167 unsigned char key[32];
2168 unsigned char iv[16];
2174 unsigned char inbuf[64];
2175 unsigned char encbuf[64];
2176 unsigned char decbuf[64];
2179 size_t totaloutlen = 0;
2182 memset( key, 0, 32 );
2183 memset( iv , 0, 16 );
2185 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2186 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2188 memset( inbuf, 5, 64 );
2189 memset( encbuf, 0, 64 );
2190 memset( decbuf, 0, 64 );
2194 fct_chk( NULL != cipher_info);
2216 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2217 totaloutlen = outlen;
2218 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2219 totaloutlen += outlen;
2226 fct_chk( totaloutlen == enclen );
2228 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2229 totaloutlen += outlen;
2236 fct_chk( outlen == 0 );
2240 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2247 fct_chk( enclen == outlen );
2249 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2256 fct_chk( outlen == 0 );
2260 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2267 #ifdef POLARSSL_AES_C
2269 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_2)
2270 size_t first_length = 0;
2271 size_t second_length = 16;
2272 size_t length = first_length + second_length;
2273 unsigned char key[32];
2274 unsigned char iv[16];
2280 unsigned char inbuf[64];
2281 unsigned char encbuf[64];
2282 unsigned char decbuf[64];
2285 size_t totaloutlen = 0;
2288 memset( key, 0, 32 );
2289 memset( iv , 0, 16 );
2291 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2292 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2294 memset( inbuf, 5, 64 );
2295 memset( encbuf, 0, 64 );
2296 memset( decbuf, 0, 64 );
2300 fct_chk( NULL != cipher_info);
2322 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2323 totaloutlen = outlen;
2324 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2325 totaloutlen += outlen;
2332 fct_chk( totaloutlen == enclen );
2334 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2335 totaloutlen += outlen;
2342 fct_chk( outlen == 0 );
2346 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2353 fct_chk( enclen == outlen );
2355 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2362 fct_chk( outlen == 0 );
2366 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2373 #ifdef POLARSSL_AES_C
2375 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_3)
2376 size_t first_length = 1;
2377 size_t second_length = 15;
2378 size_t length = first_length + second_length;
2379 unsigned char key[32];
2380 unsigned char iv[16];
2386 unsigned char inbuf[64];
2387 unsigned char encbuf[64];
2388 unsigned char decbuf[64];
2391 size_t totaloutlen = 0;
2394 memset( key, 0, 32 );
2395 memset( iv , 0, 16 );
2397 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2398 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2400 memset( inbuf, 5, 64 );
2401 memset( encbuf, 0, 64 );
2402 memset( decbuf, 0, 64 );
2406 fct_chk( NULL != cipher_info);
2428 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2429 totaloutlen = outlen;
2430 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2431 totaloutlen += outlen;
2438 fct_chk( totaloutlen == enclen );
2440 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2441 totaloutlen += outlen;
2448 fct_chk( outlen == 0 );
2452 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2459 fct_chk( enclen == outlen );
2461 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2468 fct_chk( outlen == 0 );
2472 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2479 #ifdef POLARSSL_AES_C
2481 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_4)
2482 size_t first_length = 15;
2483 size_t second_length = 1;
2484 size_t length = first_length + second_length;
2485 unsigned char key[32];
2486 unsigned char iv[16];
2492 unsigned char inbuf[64];
2493 unsigned char encbuf[64];
2494 unsigned char decbuf[64];
2497 size_t totaloutlen = 0;
2500 memset( key, 0, 32 );
2501 memset( iv , 0, 16 );
2503 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2504 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2506 memset( inbuf, 5, 64 );
2507 memset( encbuf, 0, 64 );
2508 memset( decbuf, 0, 64 );
2512 fct_chk( NULL != cipher_info);
2534 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2535 totaloutlen = outlen;
2536 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2537 totaloutlen += outlen;
2544 fct_chk( totaloutlen == enclen );
2546 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2547 totaloutlen += outlen;
2554 fct_chk( outlen == 0 );
2558 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2565 fct_chk( enclen == outlen );
2567 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2574 fct_chk( outlen == 0 );
2578 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2585 #ifdef POLARSSL_AES_C
2587 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
2588 size_t first_length = 15;
2589 size_t second_length = 7;
2590 size_t length = first_length + second_length;
2591 unsigned char key[32];
2592 unsigned char iv[16];
2598 unsigned char inbuf[64];
2599 unsigned char encbuf[64];
2600 unsigned char decbuf[64];
2603 size_t totaloutlen = 0;
2606 memset( key, 0, 32 );
2607 memset( iv , 0, 16 );
2609 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2610 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2612 memset( inbuf, 5, 64 );
2613 memset( encbuf, 0, 64 );
2614 memset( decbuf, 0, 64 );
2618 fct_chk( NULL != cipher_info);
2640 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2641 totaloutlen = outlen;
2642 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2643 totaloutlen += outlen;
2650 fct_chk( totaloutlen == enclen );
2652 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2653 totaloutlen += outlen;
2660 fct_chk( outlen == 0 );
2664 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2671 fct_chk( enclen == outlen );
2673 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2680 fct_chk( outlen == 0 );
2684 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2691 #ifdef POLARSSL_AES_C
2693 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
2694 size_t first_length = 16;
2695 size_t second_length = 6;
2696 size_t length = first_length + second_length;
2697 unsigned char key[32];
2698 unsigned char iv[16];
2704 unsigned char inbuf[64];
2705 unsigned char encbuf[64];
2706 unsigned char decbuf[64];
2709 size_t totaloutlen = 0;
2712 memset( key, 0, 32 );
2713 memset( iv , 0, 16 );
2715 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2716 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2718 memset( inbuf, 5, 64 );
2719 memset( encbuf, 0, 64 );
2720 memset( decbuf, 0, 64 );
2724 fct_chk( NULL != cipher_info);
2746 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2747 totaloutlen = outlen;
2748 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2749 totaloutlen += outlen;
2756 fct_chk( totaloutlen == enclen );
2758 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2759 totaloutlen += outlen;
2766 fct_chk( outlen == 0 );
2770 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2777 fct_chk( enclen == outlen );
2779 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2786 fct_chk( outlen == 0 );
2790 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2797 #ifdef POLARSSL_AES_C
2799 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
2800 size_t first_length = 17;
2801 size_t second_length = 6;
2802 size_t length = first_length + second_length;
2803 unsigned char key[32];
2804 unsigned char iv[16];
2810 unsigned char inbuf[64];
2811 unsigned char encbuf[64];
2812 unsigned char decbuf[64];
2815 size_t totaloutlen = 0;
2818 memset( key, 0, 32 );
2819 memset( iv , 0, 16 );
2821 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2822 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2824 memset( inbuf, 5, 64 );
2825 memset( encbuf, 0, 64 );
2826 memset( decbuf, 0, 64 );
2830 fct_chk( NULL != cipher_info);
2852 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2853 totaloutlen = outlen;
2854 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2855 totaloutlen += outlen;
2862 fct_chk( totaloutlen == enclen );
2864 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2865 totaloutlen += outlen;
2872 fct_chk( outlen == 0 );
2876 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2883 fct_chk( enclen == outlen );
2885 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2892 fct_chk( outlen == 0 );
2896 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
2903 #ifdef POLARSSL_AES_C
2905 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes_in_multiple_parts_1)
2906 size_t first_length = 16;
2907 size_t second_length = 16;
2908 size_t length = first_length + second_length;
2909 unsigned char key[32];
2910 unsigned char iv[16];
2916 unsigned char inbuf[64];
2917 unsigned char encbuf[64];
2918 unsigned char decbuf[64];
2921 size_t totaloutlen = 0;
2924 memset( key, 0, 32 );
2925 memset( iv , 0, 16 );
2927 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
2928 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
2930 memset( inbuf, 5, 64 );
2931 memset( encbuf, 0, 64 );
2932 memset( decbuf, 0, 64 );
2936 fct_chk( NULL != cipher_info);
2958 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
2959 totaloutlen = outlen;
2960 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
2961 totaloutlen += outlen;
2968 fct_chk( totaloutlen == enclen );
2970 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
2971 totaloutlen += outlen;
2978 fct_chk( outlen == 0 );
2982 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
2989 fct_chk( enclen == outlen );
2991 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
2998 fct_chk( outlen == 0 );
3002 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3009 #ifdef POLARSSL_AES_C
3010 #ifdef POLARSSL_CIPHER_MODE_CFB
3012 FCT_TEST_BGN(aes_encrypt_and_decrypt_0_bytes)
3014 unsigned char key[32];
3015 unsigned char iv[16];
3021 unsigned char inbuf[64];
3022 unsigned char encbuf[64];
3023 unsigned char decbuf[64];
3028 memset( key, 0, 32 );
3029 memset( iv , 0, 16 );
3031 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3032 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3034 memset( inbuf, 5, 64 );
3035 memset( encbuf, 0, 64 );
3036 memset( decbuf, 0, 64 );
3040 fct_chk( NULL != cipher_info );
3064 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3071 fct_chk( outlen == enclen );
3074 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3081 fct_chk( outlen == 0 );
3086 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3093 fct_chk( enclen == outlen );
3096 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3103 fct_chk( outlen == 0 );
3107 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3115 #ifdef POLARSSL_AES_C
3116 #ifdef POLARSSL_CIPHER_MODE_CFB
3118 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_byte)
3120 unsigned char key[32];
3121 unsigned char iv[16];
3127 unsigned char inbuf[64];
3128 unsigned char encbuf[64];
3129 unsigned char decbuf[64];
3134 memset( key, 0, 32 );
3135 memset( iv , 0, 16 );
3137 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3138 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3140 memset( inbuf, 5, 64 );
3141 memset( encbuf, 0, 64 );
3142 memset( decbuf, 0, 64 );
3146 fct_chk( NULL != cipher_info );
3170 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3177 fct_chk( outlen == enclen );
3180 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3187 fct_chk( outlen == 0 );
3192 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3199 fct_chk( enclen == outlen );
3202 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3209 fct_chk( outlen == 0 );
3213 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3221 #ifdef POLARSSL_AES_C
3222 #ifdef POLARSSL_CIPHER_MODE_CFB
3224 FCT_TEST_BGN(aes_encrypt_and_decrypt_2_bytes)
3226 unsigned char key[32];
3227 unsigned char iv[16];
3233 unsigned char inbuf[64];
3234 unsigned char encbuf[64];
3235 unsigned char decbuf[64];
3240 memset( key, 0, 32 );
3241 memset( iv , 0, 16 );
3243 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3244 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3246 memset( inbuf, 5, 64 );
3247 memset( encbuf, 0, 64 );
3248 memset( decbuf, 0, 64 );
3252 fct_chk( NULL != cipher_info );
3276 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3283 fct_chk( outlen == enclen );
3286 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3293 fct_chk( outlen == 0 );
3298 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3305 fct_chk( enclen == outlen );
3308 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3315 fct_chk( outlen == 0 );
3319 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3327 #ifdef POLARSSL_AES_C
3328 #ifdef POLARSSL_CIPHER_MODE_CFB
3330 FCT_TEST_BGN(aes_encrypt_and_decrypt_7_bytes)
3332 unsigned char key[32];
3333 unsigned char iv[16];
3339 unsigned char inbuf[64];
3340 unsigned char encbuf[64];
3341 unsigned char decbuf[64];
3346 memset( key, 0, 32 );
3347 memset( iv , 0, 16 );
3349 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3350 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3352 memset( inbuf, 5, 64 );
3353 memset( encbuf, 0, 64 );
3354 memset( decbuf, 0, 64 );
3358 fct_chk( NULL != cipher_info );
3382 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3389 fct_chk( outlen == enclen );
3392 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3399 fct_chk( outlen == 0 );
3404 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3411 fct_chk( enclen == outlen );
3414 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3421 fct_chk( outlen == 0 );
3425 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3433 #ifdef POLARSSL_AES_C
3434 #ifdef POLARSSL_CIPHER_MODE_CFB
3436 FCT_TEST_BGN(aes_encrypt_and_decrypt_8_bytes)
3438 unsigned char key[32];
3439 unsigned char iv[16];
3445 unsigned char inbuf[64];
3446 unsigned char encbuf[64];
3447 unsigned char decbuf[64];
3452 memset( key, 0, 32 );
3453 memset( iv , 0, 16 );
3455 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3456 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3458 memset( inbuf, 5, 64 );
3459 memset( encbuf, 0, 64 );
3460 memset( decbuf, 0, 64 );
3464 fct_chk( NULL != cipher_info );
3488 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3495 fct_chk( outlen == enclen );
3498 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3505 fct_chk( outlen == 0 );
3510 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3517 fct_chk( enclen == outlen );
3520 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3527 fct_chk( outlen == 0 );
3531 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3539 #ifdef POLARSSL_AES_C
3540 #ifdef POLARSSL_CIPHER_MODE_CFB
3542 FCT_TEST_BGN(aes_encrypt_and_decrypt_9_bytes)
3544 unsigned char key[32];
3545 unsigned char iv[16];
3551 unsigned char inbuf[64];
3552 unsigned char encbuf[64];
3553 unsigned char decbuf[64];
3558 memset( key, 0, 32 );
3559 memset( iv , 0, 16 );
3561 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3562 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3564 memset( inbuf, 5, 64 );
3565 memset( encbuf, 0, 64 );
3566 memset( decbuf, 0, 64 );
3570 fct_chk( NULL != cipher_info );
3594 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3601 fct_chk( outlen == enclen );
3604 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3611 fct_chk( outlen == 0 );
3616 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3623 fct_chk( enclen == outlen );
3626 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3633 fct_chk( outlen == 0 );
3637 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3645 #ifdef POLARSSL_AES_C
3646 #ifdef POLARSSL_CIPHER_MODE_CFB
3648 FCT_TEST_BGN(aes_encrypt_and_decrypt_15_bytes)
3650 unsigned char key[32];
3651 unsigned char iv[16];
3657 unsigned char inbuf[64];
3658 unsigned char encbuf[64];
3659 unsigned char decbuf[64];
3664 memset( key, 0, 32 );
3665 memset( iv , 0, 16 );
3667 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3668 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3670 memset( inbuf, 5, 64 );
3671 memset( encbuf, 0, 64 );
3672 memset( decbuf, 0, 64 );
3676 fct_chk( NULL != cipher_info );
3700 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3707 fct_chk( outlen == enclen );
3710 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3717 fct_chk( outlen == 0 );
3722 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3729 fct_chk( enclen == outlen );
3732 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3739 fct_chk( outlen == 0 );
3743 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3751 #ifdef POLARSSL_AES_C
3752 #ifdef POLARSSL_CIPHER_MODE_CFB
3754 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes)
3756 unsigned char key[32];
3757 unsigned char iv[16];
3763 unsigned char inbuf[64];
3764 unsigned char encbuf[64];
3765 unsigned char decbuf[64];
3770 memset( key, 0, 32 );
3771 memset( iv , 0, 16 );
3773 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3774 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3776 memset( inbuf, 5, 64 );
3777 memset( encbuf, 0, 64 );
3778 memset( decbuf, 0, 64 );
3782 fct_chk( NULL != cipher_info );
3806 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3813 fct_chk( outlen == enclen );
3816 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3823 fct_chk( outlen == 0 );
3828 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3835 fct_chk( enclen == outlen );
3838 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3845 fct_chk( outlen == 0 );
3849 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3857 #ifdef POLARSSL_AES_C
3858 #ifdef POLARSSL_CIPHER_MODE_CFB
3860 FCT_TEST_BGN(aes_encrypt_and_decrypt_17_bytes)
3862 unsigned char key[32];
3863 unsigned char iv[16];
3869 unsigned char inbuf[64];
3870 unsigned char encbuf[64];
3871 unsigned char decbuf[64];
3876 memset( key, 0, 32 );
3877 memset( iv , 0, 16 );
3879 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3880 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3882 memset( inbuf, 5, 64 );
3883 memset( encbuf, 0, 64 );
3884 memset( decbuf, 0, 64 );
3888 fct_chk( NULL != cipher_info );
3912 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3919 fct_chk( outlen == enclen );
3922 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3929 fct_chk( outlen == 0 );
3934 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3941 fct_chk( enclen == outlen );
3944 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3951 fct_chk( outlen == 0 );
3955 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3963 #ifdef POLARSSL_AES_C
3964 #ifdef POLARSSL_CIPHER_MODE_CFB
3966 FCT_TEST_BGN(aes_encrypt_and_decrypt_31_bytes)
3968 unsigned char key[32];
3969 unsigned char iv[16];
3975 unsigned char inbuf[64];
3976 unsigned char encbuf[64];
3977 unsigned char decbuf[64];
3982 memset( key, 0, 32 );
3983 memset( iv , 0, 16 );
3985 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3986 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3988 memset( inbuf, 5, 64 );
3989 memset( encbuf, 0, 64 );
3990 memset( decbuf, 0, 64 );
3994 fct_chk( NULL != cipher_info );
4018 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4025 fct_chk( outlen == enclen );
4028 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4035 fct_chk( outlen == 0 );
4040 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4047 fct_chk( enclen == outlen );
4050 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4057 fct_chk( outlen == 0 );
4061 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4069 #ifdef POLARSSL_AES_C
4070 #ifdef POLARSSL_CIPHER_MODE_CFB
4072 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes)
4074 unsigned char key[32];
4075 unsigned char iv[16];
4081 unsigned char inbuf[64];
4082 unsigned char encbuf[64];
4083 unsigned char decbuf[64];
4088 memset( key, 0, 32 );
4089 memset( iv , 0, 16 );
4091 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4092 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4094 memset( inbuf, 5, 64 );
4095 memset( encbuf, 0, 64 );
4096 memset( decbuf, 0, 64 );
4100 fct_chk( NULL != cipher_info );
4124 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4131 fct_chk( outlen == enclen );
4134 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4141 fct_chk( outlen == 0 );
4146 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4153 fct_chk( enclen == outlen );
4156 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4163 fct_chk( outlen == 0 );
4167 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4175 #ifdef POLARSSL_AES_C
4176 #ifdef POLARSSL_CIPHER_MODE_CFB
4178 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes)
4180 unsigned char key[32];
4181 unsigned char iv[16];
4187 unsigned char inbuf[64];
4188 unsigned char encbuf[64];
4189 unsigned char decbuf[64];
4194 memset( key, 0, 32 );
4195 memset( iv , 0, 16 );
4197 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4198 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4200 memset( inbuf, 5, 64 );
4201 memset( encbuf, 0, 64 );
4202 memset( decbuf, 0, 64 );
4206 fct_chk( NULL != cipher_info );
4230 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4237 fct_chk( outlen == enclen );
4240 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4247 fct_chk( outlen == 0 );
4252 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4259 fct_chk( enclen == outlen );
4262 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4269 fct_chk( outlen == 0 );
4273 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4281 #ifdef POLARSSL_AES_C
4282 #ifdef POLARSSL_CIPHER_MODE_CFB
4284 FCT_TEST_BGN(aes_encrypt_and_decrypt_47_bytes)
4286 unsigned char key[32];
4287 unsigned char iv[16];
4293 unsigned char inbuf[64];
4294 unsigned char encbuf[64];
4295 unsigned char decbuf[64];
4300 memset( key, 0, 32 );
4301 memset( iv , 0, 16 );
4303 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4304 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4306 memset( inbuf, 5, 64 );
4307 memset( encbuf, 0, 64 );
4308 memset( decbuf, 0, 64 );
4312 fct_chk( NULL != cipher_info );
4336 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4343 fct_chk( outlen == enclen );
4346 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4353 fct_chk( outlen == 0 );
4358 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4365 fct_chk( enclen == outlen );
4368 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4375 fct_chk( outlen == 0 );
4379 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4387 #ifdef POLARSSL_AES_C
4388 #ifdef POLARSSL_CIPHER_MODE_CFB
4390 FCT_TEST_BGN(aes_encrypt_and_decrypt_48_bytes)
4392 unsigned char key[32];
4393 unsigned char iv[16];
4399 unsigned char inbuf[64];
4400 unsigned char encbuf[64];
4401 unsigned char decbuf[64];
4406 memset( key, 0, 32 );
4407 memset( iv , 0, 16 );
4409 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4410 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4412 memset( inbuf, 5, 64 );
4413 memset( encbuf, 0, 64 );
4414 memset( decbuf, 0, 64 );
4418 fct_chk( NULL != cipher_info );
4442 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4449 fct_chk( outlen == enclen );
4452 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4459 fct_chk( outlen == 0 );
4464 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4471 fct_chk( enclen == outlen );
4474 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4481 fct_chk( outlen == 0 );
4485 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4493 #ifdef POLARSSL_AES_C
4494 #ifdef POLARSSL_CIPHER_MODE_CFB
4496 FCT_TEST_BGN(aes_encrypt_and_decrypt_49_bytes)
4498 unsigned char key[32];
4499 unsigned char iv[16];
4505 unsigned char inbuf[64];
4506 unsigned char encbuf[64];
4507 unsigned char decbuf[64];
4512 memset( key, 0, 32 );
4513 memset( iv , 0, 16 );
4515 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4516 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4518 memset( inbuf, 5, 64 );
4519 memset( encbuf, 0, 64 );
4520 memset( decbuf, 0, 64 );
4524 fct_chk( NULL != cipher_info );
4548 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4555 fct_chk( outlen == enclen );
4558 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4565 fct_chk( outlen == 0 );
4570 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4577 fct_chk( enclen == outlen );
4580 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4587 fct_chk( outlen == 0 );
4591 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4599 #ifdef POLARSSL_AES_C
4600 #ifdef POLARSSL_CIPHER_MODE_CFB
4602 FCT_TEST_BGN(aes_encrypt_and_decrypt_0_bytes_in_multiple_parts)
4603 size_t first_length = 0;
4604 size_t second_length = 0;
4605 size_t length = first_length + second_length;
4606 unsigned char key[32];
4607 unsigned char iv[16];
4613 unsigned char inbuf[64];
4614 unsigned char encbuf[64];
4615 unsigned char decbuf[64];
4618 size_t totaloutlen = 0;
4621 memset( key, 0, 32 );
4622 memset( iv , 0, 16 );
4624 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4625 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4627 memset( inbuf, 5, 64 );
4628 memset( encbuf, 0, 64 );
4629 memset( decbuf, 0, 64 );
4633 fct_chk( NULL != cipher_info);
4655 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4656 totaloutlen = outlen;
4657 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4658 totaloutlen += outlen;
4665 fct_chk( totaloutlen == enclen );
4667 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4668 totaloutlen += outlen;
4675 fct_chk( outlen == 0 );
4679 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4686 fct_chk( enclen == outlen );
4688 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4695 fct_chk( outlen == 0 );
4699 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4707 #ifdef POLARSSL_AES_C
4708 #ifdef POLARSSL_CIPHER_MODE_CFB
4710 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_bytes_in_multiple_parts_1)
4711 size_t first_length = 1;
4712 size_t second_length = 0;
4713 size_t length = first_length + second_length;
4714 unsigned char key[32];
4715 unsigned char iv[16];
4721 unsigned char inbuf[64];
4722 unsigned char encbuf[64];
4723 unsigned char decbuf[64];
4726 size_t totaloutlen = 0;
4729 memset( key, 0, 32 );
4730 memset( iv , 0, 16 );
4732 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4733 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4735 memset( inbuf, 5, 64 );
4736 memset( encbuf, 0, 64 );
4737 memset( decbuf, 0, 64 );
4741 fct_chk( NULL != cipher_info);
4763 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4764 totaloutlen = outlen;
4765 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4766 totaloutlen += outlen;
4773 fct_chk( totaloutlen == enclen );
4775 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4776 totaloutlen += outlen;
4783 fct_chk( outlen == 0 );
4787 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4794 fct_chk( enclen == outlen );
4796 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4803 fct_chk( outlen == 0 );
4807 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4815 #ifdef POLARSSL_AES_C
4816 #ifdef POLARSSL_CIPHER_MODE_CFB
4818 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_bytes_in_multiple_parts_2)
4819 size_t first_length = 0;
4820 size_t second_length = 1;
4821 size_t length = first_length + second_length;
4822 unsigned char key[32];
4823 unsigned char iv[16];
4829 unsigned char inbuf[64];
4830 unsigned char encbuf[64];
4831 unsigned char decbuf[64];
4834 size_t totaloutlen = 0;
4837 memset( key, 0, 32 );
4838 memset( iv , 0, 16 );
4840 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4841 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4843 memset( inbuf, 5, 64 );
4844 memset( encbuf, 0, 64 );
4845 memset( decbuf, 0, 64 );
4849 fct_chk( NULL != cipher_info);
4871 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4872 totaloutlen = outlen;
4873 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4874 totaloutlen += outlen;
4881 fct_chk( totaloutlen == enclen );
4883 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4884 totaloutlen += outlen;
4891 fct_chk( outlen == 0 );
4895 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4902 fct_chk( enclen == outlen );
4904 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4911 fct_chk( outlen == 0 );
4915 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4923 #ifdef POLARSSL_AES_C
4924 #ifdef POLARSSL_CIPHER_MODE_CFB
4926 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_1)
4927 size_t first_length = 16;
4928 size_t second_length = 0;
4929 size_t length = first_length + second_length;
4930 unsigned char key[32];
4931 unsigned char iv[16];
4937 unsigned char inbuf[64];
4938 unsigned char encbuf[64];
4939 unsigned char decbuf[64];
4942 size_t totaloutlen = 0;
4945 memset( key, 0, 32 );
4946 memset( iv , 0, 16 );
4948 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4949 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4951 memset( inbuf, 5, 64 );
4952 memset( encbuf, 0, 64 );
4953 memset( decbuf, 0, 64 );
4957 fct_chk( NULL != cipher_info);
4979 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4980 totaloutlen = outlen;
4981 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4982 totaloutlen += outlen;
4989 fct_chk( totaloutlen == enclen );
4991 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4992 totaloutlen += outlen;
4999 fct_chk( outlen == 0 );
5003 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5010 fct_chk( enclen == outlen );
5012 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5019 fct_chk( outlen == 0 );
5023 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5031 #ifdef POLARSSL_AES_C
5032 #ifdef POLARSSL_CIPHER_MODE_CFB
5034 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_2)
5035 size_t first_length = 0;
5036 size_t second_length = 16;
5037 size_t length = first_length + second_length;
5038 unsigned char key[32];
5039 unsigned char iv[16];
5045 unsigned char inbuf[64];
5046 unsigned char encbuf[64];
5047 unsigned char decbuf[64];
5050 size_t totaloutlen = 0;
5053 memset( key, 0, 32 );
5054 memset( iv , 0, 16 );
5056 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5057 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5059 memset( inbuf, 5, 64 );
5060 memset( encbuf, 0, 64 );
5061 memset( decbuf, 0, 64 );
5065 fct_chk( NULL != cipher_info);
5087 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5088 totaloutlen = outlen;
5089 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5090 totaloutlen += outlen;
5097 fct_chk( totaloutlen == enclen );
5099 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5100 totaloutlen += outlen;
5107 fct_chk( outlen == 0 );
5111 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5118 fct_chk( enclen == outlen );
5120 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5127 fct_chk( outlen == 0 );
5131 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5139 #ifdef POLARSSL_AES_C
5140 #ifdef POLARSSL_CIPHER_MODE_CFB
5142 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_3)
5143 size_t first_length = 1;
5144 size_t second_length = 15;
5145 size_t length = first_length + second_length;
5146 unsigned char key[32];
5147 unsigned char iv[16];
5153 unsigned char inbuf[64];
5154 unsigned char encbuf[64];
5155 unsigned char decbuf[64];
5158 size_t totaloutlen = 0;
5161 memset( key, 0, 32 );
5162 memset( iv , 0, 16 );
5164 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5165 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5167 memset( inbuf, 5, 64 );
5168 memset( encbuf, 0, 64 );
5169 memset( decbuf, 0, 64 );
5173 fct_chk( NULL != cipher_info);
5195 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5196 totaloutlen = outlen;
5197 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5198 totaloutlen += outlen;
5205 fct_chk( totaloutlen == enclen );
5207 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5208 totaloutlen += outlen;
5215 fct_chk( outlen == 0 );
5219 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5226 fct_chk( enclen == outlen );
5228 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5235 fct_chk( outlen == 0 );
5239 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5247 #ifdef POLARSSL_AES_C
5248 #ifdef POLARSSL_CIPHER_MODE_CFB
5250 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_4)
5251 size_t first_length = 15;
5252 size_t second_length = 1;
5253 size_t length = first_length + second_length;
5254 unsigned char key[32];
5255 unsigned char iv[16];
5261 unsigned char inbuf[64];
5262 unsigned char encbuf[64];
5263 unsigned char decbuf[64];
5266 size_t totaloutlen = 0;
5269 memset( key, 0, 32 );
5270 memset( iv , 0, 16 );
5272 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5273 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5275 memset( inbuf, 5, 64 );
5276 memset( encbuf, 0, 64 );
5277 memset( decbuf, 0, 64 );
5281 fct_chk( NULL != cipher_info);
5303 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5304 totaloutlen = outlen;
5305 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5306 totaloutlen += outlen;
5313 fct_chk( totaloutlen == enclen );
5315 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5316 totaloutlen += outlen;
5323 fct_chk( outlen == 0 );
5327 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5334 fct_chk( enclen == outlen );
5336 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5343 fct_chk( outlen == 0 );
5347 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5355 #ifdef POLARSSL_AES_C
5356 #ifdef POLARSSL_CIPHER_MODE_CFB
5358 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
5359 size_t first_length = 15;
5360 size_t second_length = 7;
5361 size_t length = first_length + second_length;
5362 unsigned char key[32];
5363 unsigned char iv[16];
5369 unsigned char inbuf[64];
5370 unsigned char encbuf[64];
5371 unsigned char decbuf[64];
5374 size_t totaloutlen = 0;
5377 memset( key, 0, 32 );
5378 memset( iv , 0, 16 );
5380 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5381 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5383 memset( inbuf, 5, 64 );
5384 memset( encbuf, 0, 64 );
5385 memset( decbuf, 0, 64 );
5389 fct_chk( NULL != cipher_info);
5411 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5412 totaloutlen = outlen;
5413 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5414 totaloutlen += outlen;
5421 fct_chk( totaloutlen == enclen );
5423 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5424 totaloutlen += outlen;
5431 fct_chk( outlen == 0 );
5435 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5442 fct_chk( enclen == outlen );
5444 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5451 fct_chk( outlen == 0 );
5455 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5463 #ifdef POLARSSL_AES_C
5464 #ifdef POLARSSL_CIPHER_MODE_CFB
5466 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
5467 size_t first_length = 16;
5468 size_t second_length = 6;
5469 size_t length = first_length + second_length;
5470 unsigned char key[32];
5471 unsigned char iv[16];
5477 unsigned char inbuf[64];
5478 unsigned char encbuf[64];
5479 unsigned char decbuf[64];
5482 size_t totaloutlen = 0;
5485 memset( key, 0, 32 );
5486 memset( iv , 0, 16 );
5488 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5489 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5491 memset( inbuf, 5, 64 );
5492 memset( encbuf, 0, 64 );
5493 memset( decbuf, 0, 64 );
5497 fct_chk( NULL != cipher_info);
5519 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5520 totaloutlen = outlen;
5521 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5522 totaloutlen += outlen;
5529 fct_chk( totaloutlen == enclen );
5531 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5532 totaloutlen += outlen;
5539 fct_chk( outlen == 0 );
5543 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5550 fct_chk( enclen == outlen );
5552 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5559 fct_chk( outlen == 0 );
5563 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5571 #ifdef POLARSSL_AES_C
5572 #ifdef POLARSSL_CIPHER_MODE_CFB
5574 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
5575 size_t first_length = 17;
5576 size_t second_length = 6;
5577 size_t length = first_length + second_length;
5578 unsigned char key[32];
5579 unsigned char iv[16];
5585 unsigned char inbuf[64];
5586 unsigned char encbuf[64];
5587 unsigned char decbuf[64];
5590 size_t totaloutlen = 0;
5593 memset( key, 0, 32 );
5594 memset( iv , 0, 16 );
5596 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5597 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5599 memset( inbuf, 5, 64 );
5600 memset( encbuf, 0, 64 );
5601 memset( decbuf, 0, 64 );
5605 fct_chk( NULL != cipher_info);
5627 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5628 totaloutlen = outlen;
5629 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5630 totaloutlen += outlen;
5637 fct_chk( totaloutlen == enclen );
5639 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5640 totaloutlen += outlen;
5647 fct_chk( outlen == 0 );
5651 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5658 fct_chk( enclen == outlen );
5660 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5667 fct_chk( outlen == 0 );
5671 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5679 #ifdef POLARSSL_AES_C
5680 #ifdef POLARSSL_CIPHER_MODE_CFB
5682 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes_in_multiple_parts_1)
5683 size_t first_length = 16;
5684 size_t second_length = 16;
5685 size_t length = first_length + second_length;
5686 unsigned char key[32];
5687 unsigned char iv[16];
5693 unsigned char inbuf[64];
5694 unsigned char encbuf[64];
5695 unsigned char decbuf[64];
5698 size_t totaloutlen = 0;
5701 memset( key, 0, 32 );
5702 memset( iv , 0, 16 );
5704 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5705 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5707 memset( inbuf, 5, 64 );
5708 memset( encbuf, 0, 64 );
5709 memset( decbuf, 0, 64 );
5713 fct_chk( NULL != cipher_info);
5735 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5736 totaloutlen = outlen;
5737 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5738 totaloutlen += outlen;
5745 fct_chk( totaloutlen == enclen );
5747 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5748 totaloutlen += outlen;
5755 fct_chk( outlen == 0 );
5759 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5766 fct_chk( enclen == outlen );
5768 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5775 fct_chk( outlen == 0 );
5779 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5787 #ifdef POLARSSL_AES_C
5788 #ifdef POLARSSL_CIPHER_MODE_CTR
5790 FCT_TEST_BGN(aes_encrypt_and_decrypt_0_bytes)
5792 unsigned char key[32];
5793 unsigned char iv[16];
5799 unsigned char inbuf[64];
5800 unsigned char encbuf[64];
5801 unsigned char decbuf[64];
5806 memset( key, 0, 32 );
5807 memset( iv , 0, 16 );
5809 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5810 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5812 memset( inbuf, 5, 64 );
5813 memset( encbuf, 0, 64 );
5814 memset( decbuf, 0, 64 );
5818 fct_chk( NULL != cipher_info );
5842 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
5849 fct_chk( outlen == enclen );
5852 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
5859 fct_chk( outlen == 0 );
5864 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5871 fct_chk( enclen == outlen );
5874 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5881 fct_chk( outlen == 0 );
5885 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5893 #ifdef POLARSSL_AES_C
5894 #ifdef POLARSSL_CIPHER_MODE_CTR
5896 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_byte)
5898 unsigned char key[32];
5899 unsigned char iv[16];
5905 unsigned char inbuf[64];
5906 unsigned char encbuf[64];
5907 unsigned char decbuf[64];
5912 memset( key, 0, 32 );
5913 memset( iv , 0, 16 );
5915 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5916 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5918 memset( inbuf, 5, 64 );
5919 memset( encbuf, 0, 64 );
5920 memset( decbuf, 0, 64 );
5924 fct_chk( NULL != cipher_info );
5948 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
5955 fct_chk( outlen == enclen );
5958 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
5965 fct_chk( outlen == 0 );
5970 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5977 fct_chk( enclen == outlen );
5980 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5987 fct_chk( outlen == 0 );
5991 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5999 #ifdef POLARSSL_AES_C
6000 #ifdef POLARSSL_CIPHER_MODE_CTR
6002 FCT_TEST_BGN(aes_encrypt_and_decrypt_2_bytes)
6004 unsigned char key[32];
6005 unsigned char iv[16];
6011 unsigned char inbuf[64];
6012 unsigned char encbuf[64];
6013 unsigned char decbuf[64];
6018 memset( key, 0, 32 );
6019 memset( iv , 0, 16 );
6021 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6022 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6024 memset( inbuf, 5, 64 );
6025 memset( encbuf, 0, 64 );
6026 memset( decbuf, 0, 64 );
6030 fct_chk( NULL != cipher_info );
6054 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6061 fct_chk( outlen == enclen );
6064 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6071 fct_chk( outlen == 0 );
6076 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6083 fct_chk( enclen == outlen );
6086 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6093 fct_chk( outlen == 0 );
6097 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6105 #ifdef POLARSSL_AES_C
6106 #ifdef POLARSSL_CIPHER_MODE_CTR
6108 FCT_TEST_BGN(aes_encrypt_and_decrypt_7_bytes)
6110 unsigned char key[32];
6111 unsigned char iv[16];
6117 unsigned char inbuf[64];
6118 unsigned char encbuf[64];
6119 unsigned char decbuf[64];
6124 memset( key, 0, 32 );
6125 memset( iv , 0, 16 );
6127 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6128 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6130 memset( inbuf, 5, 64 );
6131 memset( encbuf, 0, 64 );
6132 memset( decbuf, 0, 64 );
6136 fct_chk( NULL != cipher_info );
6160 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6167 fct_chk( outlen == enclen );
6170 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6177 fct_chk( outlen == 0 );
6182 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6189 fct_chk( enclen == outlen );
6192 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6199 fct_chk( outlen == 0 );
6203 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6211 #ifdef POLARSSL_AES_C
6212 #ifdef POLARSSL_CIPHER_MODE_CTR
6214 FCT_TEST_BGN(aes_encrypt_and_decrypt_8_bytes)
6216 unsigned char key[32];
6217 unsigned char iv[16];
6223 unsigned char inbuf[64];
6224 unsigned char encbuf[64];
6225 unsigned char decbuf[64];
6230 memset( key, 0, 32 );
6231 memset( iv , 0, 16 );
6233 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6234 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6236 memset( inbuf, 5, 64 );
6237 memset( encbuf, 0, 64 );
6238 memset( decbuf, 0, 64 );
6242 fct_chk( NULL != cipher_info );
6266 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6273 fct_chk( outlen == enclen );
6276 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6283 fct_chk( outlen == 0 );
6288 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6295 fct_chk( enclen == outlen );
6298 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6305 fct_chk( outlen == 0 );
6309 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6317 #ifdef POLARSSL_AES_C
6318 #ifdef POLARSSL_CIPHER_MODE_CTR
6320 FCT_TEST_BGN(aes_encrypt_and_decrypt_9_bytes)
6322 unsigned char key[32];
6323 unsigned char iv[16];
6329 unsigned char inbuf[64];
6330 unsigned char encbuf[64];
6331 unsigned char decbuf[64];
6336 memset( key, 0, 32 );
6337 memset( iv , 0, 16 );
6339 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6340 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6342 memset( inbuf, 5, 64 );
6343 memset( encbuf, 0, 64 );
6344 memset( decbuf, 0, 64 );
6348 fct_chk( NULL != cipher_info );
6372 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6379 fct_chk( outlen == enclen );
6382 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6389 fct_chk( outlen == 0 );
6394 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6401 fct_chk( enclen == outlen );
6404 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6411 fct_chk( outlen == 0 );
6415 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6423 #ifdef POLARSSL_AES_C
6424 #ifdef POLARSSL_CIPHER_MODE_CTR
6426 FCT_TEST_BGN(aes_encrypt_and_decrypt_15_bytes)
6428 unsigned char key[32];
6429 unsigned char iv[16];
6435 unsigned char inbuf[64];
6436 unsigned char encbuf[64];
6437 unsigned char decbuf[64];
6442 memset( key, 0, 32 );
6443 memset( iv , 0, 16 );
6445 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6446 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6448 memset( inbuf, 5, 64 );
6449 memset( encbuf, 0, 64 );
6450 memset( decbuf, 0, 64 );
6454 fct_chk( NULL != cipher_info );
6478 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6485 fct_chk( outlen == enclen );
6488 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6495 fct_chk( outlen == 0 );
6500 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6507 fct_chk( enclen == outlen );
6510 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6517 fct_chk( outlen == 0 );
6521 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6529 #ifdef POLARSSL_AES_C
6530 #ifdef POLARSSL_CIPHER_MODE_CTR
6532 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes)
6534 unsigned char key[32];
6535 unsigned char iv[16];
6541 unsigned char inbuf[64];
6542 unsigned char encbuf[64];
6543 unsigned char decbuf[64];
6548 memset( key, 0, 32 );
6549 memset( iv , 0, 16 );
6551 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6552 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6554 memset( inbuf, 5, 64 );
6555 memset( encbuf, 0, 64 );
6556 memset( decbuf, 0, 64 );
6560 fct_chk( NULL != cipher_info );
6584 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6591 fct_chk( outlen == enclen );
6594 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6601 fct_chk( outlen == 0 );
6606 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6613 fct_chk( enclen == outlen );
6616 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6623 fct_chk( outlen == 0 );
6627 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6635 #ifdef POLARSSL_AES_C
6636 #ifdef POLARSSL_CIPHER_MODE_CTR
6638 FCT_TEST_BGN(aes_encrypt_and_decrypt_17_bytes)
6640 unsigned char key[32];
6641 unsigned char iv[16];
6647 unsigned char inbuf[64];
6648 unsigned char encbuf[64];
6649 unsigned char decbuf[64];
6654 memset( key, 0, 32 );
6655 memset( iv , 0, 16 );
6657 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6658 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6660 memset( inbuf, 5, 64 );
6661 memset( encbuf, 0, 64 );
6662 memset( decbuf, 0, 64 );
6666 fct_chk( NULL != cipher_info );
6690 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6697 fct_chk( outlen == enclen );
6700 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6707 fct_chk( outlen == 0 );
6712 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6719 fct_chk( enclen == outlen );
6722 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6729 fct_chk( outlen == 0 );
6733 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6741 #ifdef POLARSSL_AES_C
6742 #ifdef POLARSSL_CIPHER_MODE_CTR
6744 FCT_TEST_BGN(aes_encrypt_and_decrypt_31_bytes)
6746 unsigned char key[32];
6747 unsigned char iv[16];
6753 unsigned char inbuf[64];
6754 unsigned char encbuf[64];
6755 unsigned char decbuf[64];
6760 memset( key, 0, 32 );
6761 memset( iv , 0, 16 );
6763 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6764 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6766 memset( inbuf, 5, 64 );
6767 memset( encbuf, 0, 64 );
6768 memset( decbuf, 0, 64 );
6772 fct_chk( NULL != cipher_info );
6796 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6803 fct_chk( outlen == enclen );
6806 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6813 fct_chk( outlen == 0 );
6818 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6825 fct_chk( enclen == outlen );
6828 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6835 fct_chk( outlen == 0 );
6839 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6847 #ifdef POLARSSL_AES_C
6848 #ifdef POLARSSL_CIPHER_MODE_CTR
6850 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes)
6852 unsigned char key[32];
6853 unsigned char iv[16];
6859 unsigned char inbuf[64];
6860 unsigned char encbuf[64];
6861 unsigned char decbuf[64];
6866 memset( key, 0, 32 );
6867 memset( iv , 0, 16 );
6869 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6870 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6872 memset( inbuf, 5, 64 );
6873 memset( encbuf, 0, 64 );
6874 memset( decbuf, 0, 64 );
6878 fct_chk( NULL != cipher_info );
6902 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6909 fct_chk( outlen == enclen );
6912 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6919 fct_chk( outlen == 0 );
6924 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6931 fct_chk( enclen == outlen );
6934 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6941 fct_chk( outlen == 0 );
6945 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6953 #ifdef POLARSSL_AES_C
6954 #ifdef POLARSSL_CIPHER_MODE_CTR
6956 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes)
6958 unsigned char key[32];
6959 unsigned char iv[16];
6965 unsigned char inbuf[64];
6966 unsigned char encbuf[64];
6967 unsigned char decbuf[64];
6972 memset( key, 0, 32 );
6973 memset( iv , 0, 16 );
6975 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6976 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6978 memset( inbuf, 5, 64 );
6979 memset( encbuf, 0, 64 );
6980 memset( decbuf, 0, 64 );
6984 fct_chk( NULL != cipher_info );
7008 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
7015 fct_chk( outlen == enclen );
7018 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
7025 fct_chk( outlen == 0 );
7030 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7037 fct_chk( enclen == outlen );
7040 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7047 fct_chk( outlen == 0 );
7051 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7059 #ifdef POLARSSL_AES_C
7060 #ifdef POLARSSL_CIPHER_MODE_CTR
7062 FCT_TEST_BGN(aes_encrypt_and_decrypt_47_bytes)
7064 unsigned char key[32];
7065 unsigned char iv[16];
7071 unsigned char inbuf[64];
7072 unsigned char encbuf[64];
7073 unsigned char decbuf[64];
7078 memset( key, 0, 32 );
7079 memset( iv , 0, 16 );
7081 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7082 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7084 memset( inbuf, 5, 64 );
7085 memset( encbuf, 0, 64 );
7086 memset( decbuf, 0, 64 );
7090 fct_chk( NULL != cipher_info );
7114 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
7121 fct_chk( outlen == enclen );
7124 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
7131 fct_chk( outlen == 0 );
7136 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7143 fct_chk( enclen == outlen );
7146 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7153 fct_chk( outlen == 0 );
7157 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7165 #ifdef POLARSSL_AES_C
7166 #ifdef POLARSSL_CIPHER_MODE_CTR
7168 FCT_TEST_BGN(aes_encrypt_and_decrypt_48_bytes)
7170 unsigned char key[32];
7171 unsigned char iv[16];
7177 unsigned char inbuf[64];
7178 unsigned char encbuf[64];
7179 unsigned char decbuf[64];
7184 memset( key, 0, 32 );
7185 memset( iv , 0, 16 );
7187 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7188 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7190 memset( inbuf, 5, 64 );
7191 memset( encbuf, 0, 64 );
7192 memset( decbuf, 0, 64 );
7196 fct_chk( NULL != cipher_info );
7220 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
7227 fct_chk( outlen == enclen );
7230 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
7237 fct_chk( outlen == 0 );
7242 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7249 fct_chk( enclen == outlen );
7252 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7259 fct_chk( outlen == 0 );
7263 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7271 #ifdef POLARSSL_AES_C
7272 #ifdef POLARSSL_CIPHER_MODE_CTR
7274 FCT_TEST_BGN(aes_encrypt_and_decrypt_49_bytes)
7276 unsigned char key[32];
7277 unsigned char iv[16];
7283 unsigned char inbuf[64];
7284 unsigned char encbuf[64];
7285 unsigned char decbuf[64];
7290 memset( key, 0, 32 );
7291 memset( iv , 0, 16 );
7293 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7294 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7296 memset( inbuf, 5, 64 );
7297 memset( encbuf, 0, 64 );
7298 memset( decbuf, 0, 64 );
7302 fct_chk( NULL != cipher_info );
7326 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
7333 fct_chk( outlen == enclen );
7336 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
7343 fct_chk( outlen == 0 );
7348 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7355 fct_chk( enclen == outlen );
7358 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7365 fct_chk( outlen == 0 );
7369 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7377 #ifdef POLARSSL_AES_C
7378 #ifdef POLARSSL_CIPHER_MODE_CTR
7380 FCT_TEST_BGN(aes_encrypt_and_decrypt_0_bytes_in_multiple_parts)
7381 size_t first_length = 0;
7382 size_t second_length = 0;
7383 size_t length = first_length + second_length;
7384 unsigned char key[32];
7385 unsigned char iv[16];
7391 unsigned char inbuf[64];
7392 unsigned char encbuf[64];
7393 unsigned char decbuf[64];
7396 size_t totaloutlen = 0;
7399 memset( key, 0, 32 );
7400 memset( iv , 0, 16 );
7402 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7403 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7405 memset( inbuf, 5, 64 );
7406 memset( encbuf, 0, 64 );
7407 memset( decbuf, 0, 64 );
7411 fct_chk( NULL != cipher_info);
7433 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7434 totaloutlen = outlen;
7435 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7436 totaloutlen += outlen;
7443 fct_chk( totaloutlen == enclen );
7445 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7446 totaloutlen += outlen;
7453 fct_chk( outlen == 0 );
7457 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7464 fct_chk( enclen == outlen );
7466 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7473 fct_chk( outlen == 0 );
7477 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7485 #ifdef POLARSSL_AES_C
7486 #ifdef POLARSSL_CIPHER_MODE_CTR
7488 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_bytes_in_multiple_parts_1)
7489 size_t first_length = 1;
7490 size_t second_length = 0;
7491 size_t length = first_length + second_length;
7492 unsigned char key[32];
7493 unsigned char iv[16];
7499 unsigned char inbuf[64];
7500 unsigned char encbuf[64];
7501 unsigned char decbuf[64];
7504 size_t totaloutlen = 0;
7507 memset( key, 0, 32 );
7508 memset( iv , 0, 16 );
7510 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7511 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7513 memset( inbuf, 5, 64 );
7514 memset( encbuf, 0, 64 );
7515 memset( decbuf, 0, 64 );
7519 fct_chk( NULL != cipher_info);
7541 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7542 totaloutlen = outlen;
7543 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7544 totaloutlen += outlen;
7551 fct_chk( totaloutlen == enclen );
7553 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7554 totaloutlen += outlen;
7561 fct_chk( outlen == 0 );
7565 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7572 fct_chk( enclen == outlen );
7574 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7581 fct_chk( outlen == 0 );
7585 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7593 #ifdef POLARSSL_AES_C
7594 #ifdef POLARSSL_CIPHER_MODE_CTR
7596 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_bytes_in_multiple_parts_2)
7597 size_t first_length = 0;
7598 size_t second_length = 1;
7599 size_t length = first_length + second_length;
7600 unsigned char key[32];
7601 unsigned char iv[16];
7607 unsigned char inbuf[64];
7608 unsigned char encbuf[64];
7609 unsigned char decbuf[64];
7612 size_t totaloutlen = 0;
7615 memset( key, 0, 32 );
7616 memset( iv , 0, 16 );
7618 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7619 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7621 memset( inbuf, 5, 64 );
7622 memset( encbuf, 0, 64 );
7623 memset( decbuf, 0, 64 );
7627 fct_chk( NULL != cipher_info);
7649 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7650 totaloutlen = outlen;
7651 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7652 totaloutlen += outlen;
7659 fct_chk( totaloutlen == enclen );
7661 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7662 totaloutlen += outlen;
7669 fct_chk( outlen == 0 );
7673 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7680 fct_chk( enclen == outlen );
7682 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7689 fct_chk( outlen == 0 );
7693 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7701 #ifdef POLARSSL_AES_C
7702 #ifdef POLARSSL_CIPHER_MODE_CTR
7704 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_1)
7705 size_t first_length = 16;
7706 size_t second_length = 0;
7707 size_t length = first_length + second_length;
7708 unsigned char key[32];
7709 unsigned char iv[16];
7715 unsigned char inbuf[64];
7716 unsigned char encbuf[64];
7717 unsigned char decbuf[64];
7720 size_t totaloutlen = 0;
7723 memset( key, 0, 32 );
7724 memset( iv , 0, 16 );
7726 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7727 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7729 memset( inbuf, 5, 64 );
7730 memset( encbuf, 0, 64 );
7731 memset( decbuf, 0, 64 );
7735 fct_chk( NULL != cipher_info);
7757 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7758 totaloutlen = outlen;
7759 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7760 totaloutlen += outlen;
7767 fct_chk( totaloutlen == enclen );
7769 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7770 totaloutlen += outlen;
7777 fct_chk( outlen == 0 );
7781 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7788 fct_chk( enclen == outlen );
7790 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7797 fct_chk( outlen == 0 );
7801 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7809 #ifdef POLARSSL_AES_C
7810 #ifdef POLARSSL_CIPHER_MODE_CTR
7812 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_2)
7813 size_t first_length = 0;
7814 size_t second_length = 16;
7815 size_t length = first_length + second_length;
7816 unsigned char key[32];
7817 unsigned char iv[16];
7823 unsigned char inbuf[64];
7824 unsigned char encbuf[64];
7825 unsigned char decbuf[64];
7828 size_t totaloutlen = 0;
7831 memset( key, 0, 32 );
7832 memset( iv , 0, 16 );
7834 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7835 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7837 memset( inbuf, 5, 64 );
7838 memset( encbuf, 0, 64 );
7839 memset( decbuf, 0, 64 );
7843 fct_chk( NULL != cipher_info);
7865 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7866 totaloutlen = outlen;
7867 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7868 totaloutlen += outlen;
7875 fct_chk( totaloutlen == enclen );
7877 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7878 totaloutlen += outlen;
7885 fct_chk( outlen == 0 );
7889 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7896 fct_chk( enclen == outlen );
7898 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7905 fct_chk( outlen == 0 );
7909 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7917 #ifdef POLARSSL_AES_C
7918 #ifdef POLARSSL_CIPHER_MODE_CTR
7920 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_3)
7921 size_t first_length = 1;
7922 size_t second_length = 15;
7923 size_t length = first_length + second_length;
7924 unsigned char key[32];
7925 unsigned char iv[16];
7931 unsigned char inbuf[64];
7932 unsigned char encbuf[64];
7933 unsigned char decbuf[64];
7936 size_t totaloutlen = 0;
7939 memset( key, 0, 32 );
7940 memset( iv , 0, 16 );
7942 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7943 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7945 memset( inbuf, 5, 64 );
7946 memset( encbuf, 0, 64 );
7947 memset( decbuf, 0, 64 );
7951 fct_chk( NULL != cipher_info);
7973 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7974 totaloutlen = outlen;
7975 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7976 totaloutlen += outlen;
7983 fct_chk( totaloutlen == enclen );
7985 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7986 totaloutlen += outlen;
7993 fct_chk( outlen == 0 );
7997 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8004 fct_chk( enclen == outlen );
8006 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8013 fct_chk( outlen == 0 );
8017 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8025 #ifdef POLARSSL_AES_C
8026 #ifdef POLARSSL_CIPHER_MODE_CTR
8028 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_4)
8029 size_t first_length = 15;
8030 size_t second_length = 1;
8031 size_t length = first_length + second_length;
8032 unsigned char key[32];
8033 unsigned char iv[16];
8039 unsigned char inbuf[64];
8040 unsigned char encbuf[64];
8041 unsigned char decbuf[64];
8044 size_t totaloutlen = 0;
8047 memset( key, 0, 32 );
8048 memset( iv , 0, 16 );
8050 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8051 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8053 memset( inbuf, 5, 64 );
8054 memset( encbuf, 0, 64 );
8055 memset( decbuf, 0, 64 );
8059 fct_chk( NULL != cipher_info);
8081 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8082 totaloutlen = outlen;
8083 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8084 totaloutlen += outlen;
8091 fct_chk( totaloutlen == enclen );
8093 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8094 totaloutlen += outlen;
8101 fct_chk( outlen == 0 );
8105 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8112 fct_chk( enclen == outlen );
8114 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8121 fct_chk( outlen == 0 );
8125 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8133 #ifdef POLARSSL_AES_C
8134 #ifdef POLARSSL_CIPHER_MODE_CTR
8136 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
8137 size_t first_length = 15;
8138 size_t second_length = 7;
8139 size_t length = first_length + second_length;
8140 unsigned char key[32];
8141 unsigned char iv[16];
8147 unsigned char inbuf[64];
8148 unsigned char encbuf[64];
8149 unsigned char decbuf[64];
8152 size_t totaloutlen = 0;
8155 memset( key, 0, 32 );
8156 memset( iv , 0, 16 );
8158 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8159 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8161 memset( inbuf, 5, 64 );
8162 memset( encbuf, 0, 64 );
8163 memset( decbuf, 0, 64 );
8167 fct_chk( NULL != cipher_info);
8189 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8190 totaloutlen = outlen;
8191 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8192 totaloutlen += outlen;
8199 fct_chk( totaloutlen == enclen );
8201 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8202 totaloutlen += outlen;
8209 fct_chk( outlen == 0 );
8213 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8220 fct_chk( enclen == outlen );
8222 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8229 fct_chk( outlen == 0 );
8233 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8241 #ifdef POLARSSL_AES_C
8242 #ifdef POLARSSL_CIPHER_MODE_CTR
8244 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
8245 size_t first_length = 16;
8246 size_t second_length = 6;
8247 size_t length = first_length + second_length;
8248 unsigned char key[32];
8249 unsigned char iv[16];
8255 unsigned char inbuf[64];
8256 unsigned char encbuf[64];
8257 unsigned char decbuf[64];
8260 size_t totaloutlen = 0;
8263 memset( key, 0, 32 );
8264 memset( iv , 0, 16 );
8266 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8267 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8269 memset( inbuf, 5, 64 );
8270 memset( encbuf, 0, 64 );
8271 memset( decbuf, 0, 64 );
8275 fct_chk( NULL != cipher_info);
8297 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8298 totaloutlen = outlen;
8299 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8300 totaloutlen += outlen;
8307 fct_chk( totaloutlen == enclen );
8309 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8310 totaloutlen += outlen;
8317 fct_chk( outlen == 0 );
8321 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8328 fct_chk( enclen == outlen );
8330 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8337 fct_chk( outlen == 0 );
8341 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8349 #ifdef POLARSSL_AES_C
8350 #ifdef POLARSSL_CIPHER_MODE_CTR
8352 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
8353 size_t first_length = 17;
8354 size_t second_length = 6;
8355 size_t length = first_length + second_length;
8356 unsigned char key[32];
8357 unsigned char iv[16];
8363 unsigned char inbuf[64];
8364 unsigned char encbuf[64];
8365 unsigned char decbuf[64];
8368 size_t totaloutlen = 0;
8371 memset( key, 0, 32 );
8372 memset( iv , 0, 16 );
8374 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8375 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8377 memset( inbuf, 5, 64 );
8378 memset( encbuf, 0, 64 );
8379 memset( decbuf, 0, 64 );
8383 fct_chk( NULL != cipher_info);
8405 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8406 totaloutlen = outlen;
8407 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8408 totaloutlen += outlen;
8415 fct_chk( totaloutlen == enclen );
8417 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8418 totaloutlen += outlen;
8425 fct_chk( outlen == 0 );
8429 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8436 fct_chk( enclen == outlen );
8438 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8445 fct_chk( outlen == 0 );
8449 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8457 #ifdef POLARSSL_AES_C
8458 #ifdef POLARSSL_CIPHER_MODE_CTR
8460 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes_in_multiple_parts_1)
8461 size_t first_length = 16;
8462 size_t second_length = 16;
8463 size_t length = first_length + second_length;
8464 unsigned char key[32];
8465 unsigned char iv[16];
8471 unsigned char inbuf[64];
8472 unsigned char encbuf[64];
8473 unsigned char decbuf[64];
8476 size_t totaloutlen = 0;
8479 memset( key, 0, 32 );
8480 memset( iv , 0, 16 );
8482 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8483 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8485 memset( inbuf, 5, 64 );
8486 memset( encbuf, 0, 64 );
8487 memset( decbuf, 0, 64 );
8491 fct_chk( NULL != cipher_info);
8513 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8514 totaloutlen = outlen;
8515 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8516 totaloutlen += outlen;
8523 fct_chk( totaloutlen == enclen );
8525 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8526 totaloutlen += outlen;
8533 fct_chk( outlen == 0 );
8537 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8544 fct_chk( enclen == outlen );
8546 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8553 fct_chk( outlen == 0 );
8557 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8565 #ifdef POLARSSL_AES_C
8567 FCT_TEST_BGN(aes_encrypt_and_decrypt_0_bytes)
8569 unsigned char key[32];
8570 unsigned char iv[16];
8576 unsigned char inbuf[64];
8577 unsigned char encbuf[64];
8578 unsigned char decbuf[64];
8583 memset( key, 0, 32 );
8584 memset( iv , 0, 16 );
8586 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8587 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8589 memset( inbuf, 5, 64 );
8590 memset( encbuf, 0, 64 );
8591 memset( decbuf, 0, 64 );
8595 fct_chk( NULL != cipher_info );
8619 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
8626 fct_chk( outlen == enclen );
8629 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
8636 fct_chk( outlen == 0 );
8641 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8648 fct_chk( enclen == outlen );
8651 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8658 fct_chk( outlen == 0 );
8662 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8669 #ifdef POLARSSL_AES_C
8671 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_byte)
8673 unsigned char key[32];
8674 unsigned char iv[16];
8680 unsigned char inbuf[64];
8681 unsigned char encbuf[64];
8682 unsigned char decbuf[64];
8687 memset( key, 0, 32 );
8688 memset( iv , 0, 16 );
8690 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8691 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8693 memset( inbuf, 5, 64 );
8694 memset( encbuf, 0, 64 );
8695 memset( decbuf, 0, 64 );
8699 fct_chk( NULL != cipher_info );
8723 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
8730 fct_chk( outlen == enclen );
8733 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
8740 fct_chk( outlen == 0 );
8745 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8752 fct_chk( enclen == outlen );
8755 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8762 fct_chk( outlen == 0 );
8766 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8773 #ifdef POLARSSL_AES_C
8775 FCT_TEST_BGN(aes_encrypt_and_decrypt_2_bytes)
8777 unsigned char key[32];
8778 unsigned char iv[16];
8784 unsigned char inbuf[64];
8785 unsigned char encbuf[64];
8786 unsigned char decbuf[64];
8791 memset( key, 0, 32 );
8792 memset( iv , 0, 16 );
8794 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8795 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8797 memset( inbuf, 5, 64 );
8798 memset( encbuf, 0, 64 );
8799 memset( decbuf, 0, 64 );
8803 fct_chk( NULL != cipher_info );
8827 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
8834 fct_chk( outlen == enclen );
8837 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
8844 fct_chk( outlen == 0 );
8849 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8856 fct_chk( enclen == outlen );
8859 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8866 fct_chk( outlen == 0 );
8870 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8877 #ifdef POLARSSL_AES_C
8879 FCT_TEST_BGN(aes_encrypt_and_decrypt_7_bytes)
8881 unsigned char key[32];
8882 unsigned char iv[16];
8888 unsigned char inbuf[64];
8889 unsigned char encbuf[64];
8890 unsigned char decbuf[64];
8895 memset( key, 0, 32 );
8896 memset( iv , 0, 16 );
8898 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8899 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8901 memset( inbuf, 5, 64 );
8902 memset( encbuf, 0, 64 );
8903 memset( decbuf, 0, 64 );
8907 fct_chk( NULL != cipher_info );
8931 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
8938 fct_chk( outlen == enclen );
8941 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
8948 fct_chk( outlen == 0 );
8953 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8960 fct_chk( enclen == outlen );
8963 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8970 fct_chk( outlen == 0 );
8974 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8981 #ifdef POLARSSL_AES_C
8983 FCT_TEST_BGN(aes_encrypt_and_decrypt_8_bytes)
8985 unsigned char key[32];
8986 unsigned char iv[16];
8992 unsigned char inbuf[64];
8993 unsigned char encbuf[64];
8994 unsigned char decbuf[64];
8999 memset( key, 0, 32 );
9000 memset( iv , 0, 16 );
9002 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
9003 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
9005 memset( inbuf, 5, 64 );
9006 memset( encbuf, 0, 64 );
9007 memset( decbuf, 0, 64 );
9011 fct_chk( NULL != cipher_info );
9035 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
9042 fct_chk( outlen == enclen );
9045 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
9052 fct_chk( outlen == 0 );
9057 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
9064 fct_chk( enclen == outlen );
9067 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
9074 fct_chk( outlen == 0 );
9078 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
9085 #ifdef POLARSSL_AES_C
9087 FCT_TEST_BGN(aes_encrypt_and_decrypt_9_bytes)
9089 unsigned char key[32];
9090 unsigned char iv[16];
9096 unsigned char inbuf[64];
9097 unsigned char encbuf[64];
9098 unsigned char decbuf[64];
9103 memset( key, 0, 32 );
9104 memset( iv , 0, 16 );
9106 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
9107 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
9109 memset( inbuf, 5, 64 );
9110 memset( encbuf, 0, 64 );
9111 memset( decbuf, 0, 64 );
9115 fct_chk( NULL != cipher_info );
9139 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
9146 fct_chk( outlen == enclen );
9149 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
9156 fct_chk( outlen == 0 );
9161 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
9168 fct_chk( enclen == outlen );
9171 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
9178 fct_chk( outlen == 0 );
9182 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
9189 #ifdef POLARSSL_AES_C
9191 FCT_TEST_BGN(aes_encrypt_and_decrypt_15_bytes)
9193 unsigned char key[32];
9194 unsigned char iv[16];
9200 unsigned char inbuf[64];
9201 unsigned char encbuf[64];
9202 unsigned char decbuf[64];
9207 memset( key, 0, 32 );
9208 memset( iv , 0, 16 );
9210 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
9211 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
9213 memset( inbuf, 5, 64 );
9214 memset( encbuf, 0, 64 );
9215 memset( decbuf, 0, 64 );
9219 fct_chk( NULL != cipher_info );
9243 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
9250 fct_chk( outlen == enclen );
9253 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
9260 fct_chk( outlen == 0 );
9265 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
9272 fct_chk( enclen == outlen );
9275 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
9282 fct_chk( outlen == 0 );
9286 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
9293 #ifdef POLARSSL_AES_C
9295 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes)
9297 unsigned char key[32];
9298 unsigned char iv[16];
9304 unsigned char inbuf[64];
9305 unsigned char encbuf[64];
9306 unsigned char decbuf[64];
9311 memset( key, 0, 32 );
9312 memset( iv , 0, 16 );
9314 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
9315 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
9317 memset( inbuf, 5, 64 );
9318 memset( encbuf, 0, 64 );
9319 memset( decbuf, 0, 64 );
9323 fct_chk( NULL != cipher_info );
9347 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
9354 fct_chk( outlen == enclen );
9357 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
9364 fct_chk( outlen == 0 );
9369 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
9376 fct_chk( enclen == outlen );
9379 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
9386 fct_chk( outlen == 0 );
9390 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
9397 #ifdef POLARSSL_AES_C
9399 FCT_TEST_BGN(aes_encrypt_and_decrypt_17_bytes)
9401 unsigned char key[32];
9402 unsigned char iv[16];
9408 unsigned char inbuf[64];
9409 unsigned char encbuf[64];
9410 unsigned char decbuf[64];
9415 memset( key, 0, 32 );
9416 memset( iv , 0, 16 );
9418 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
9419 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
9421 memset( inbuf, 5, 64 );
9422 memset( encbuf, 0, 64 );
9423 memset( decbuf, 0, 64 );
9427 fct_chk( NULL != cipher_info );
9451 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
9458 fct_chk( outlen == enclen );
9461 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
9468 fct_chk( outlen == 0 );
9473 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
9480 fct_chk( enclen == outlen );
9483 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
9490 fct_chk( outlen == 0 );
9494 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
9501 #ifdef POLARSSL_AES_C
9503 FCT_TEST_BGN(aes_encrypt_and_decrypt_31_bytes)
9505 unsigned char key[32];
9506 unsigned char iv[16];
9512 unsigned char inbuf[64];
9513 unsigned char encbuf[64];
9514 unsigned char decbuf[64];
9519 memset( key, 0, 32 );
9520 memset( iv , 0, 16 );
9522 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
9523 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
9525 memset( inbuf, 5, 64 );
9526 memset( encbuf, 0, 64 );
9527 memset( decbuf, 0, 64 );
9531 fct_chk( NULL != cipher_info );
9555 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
9562 fct_chk( outlen == enclen );
9565 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
9572 fct_chk( outlen == 0 );
9577 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
9584 fct_chk( enclen == outlen );
9587 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
9594 fct_chk( outlen == 0 );
9598 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
9605 #ifdef POLARSSL_AES_C
9607 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes)
9609 unsigned char key[32];
9610 unsigned char iv[16];
9616 unsigned char inbuf[64];
9617 unsigned char encbuf[64];
9618 unsigned char decbuf[64];
9623 memset( key, 0, 32 );
9624 memset( iv , 0, 16 );
9626 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
9627 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
9629 memset( inbuf, 5, 64 );
9630 memset( encbuf, 0, 64 );
9631 memset( decbuf, 0, 64 );
9635 fct_chk( NULL != cipher_info );
9659 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
9666 fct_chk( outlen == enclen );
9669 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
9676 fct_chk( outlen == 0 );
9681 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
9688 fct_chk( enclen == outlen );
9691 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
9698 fct_chk( outlen == 0 );
9702 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
9709 #ifdef POLARSSL_AES_C
9711 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes)
9713 unsigned char key[32];
9714 unsigned char iv[16];
9720 unsigned char inbuf[64];
9721 unsigned char encbuf[64];
9722 unsigned char decbuf[64];
9727 memset( key, 0, 32 );
9728 memset( iv , 0, 16 );
9730 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
9731 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
9733 memset( inbuf, 5, 64 );
9734 memset( encbuf, 0, 64 );
9735 memset( decbuf, 0, 64 );
9739 fct_chk( NULL != cipher_info );
9763 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
9770 fct_chk( outlen == enclen );
9773 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
9780 fct_chk( outlen == 0 );
9785 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
9792 fct_chk( enclen == outlen );
9795 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
9802 fct_chk( outlen == 0 );
9806 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
9813 #ifdef POLARSSL_AES_C
9815 FCT_TEST_BGN(aes_encrypt_and_decrypt_47_bytes)
9817 unsigned char key[32];
9818 unsigned char iv[16];
9824 unsigned char inbuf[64];
9825 unsigned char encbuf[64];
9826 unsigned char decbuf[64];
9831 memset( key, 0, 32 );
9832 memset( iv , 0, 16 );
9834 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
9835 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
9837 memset( inbuf, 5, 64 );
9838 memset( encbuf, 0, 64 );
9839 memset( decbuf, 0, 64 );
9843 fct_chk( NULL != cipher_info );
9867 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
9874 fct_chk( outlen == enclen );
9877 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
9884 fct_chk( outlen == 0 );
9889 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
9896 fct_chk( enclen == outlen );
9899 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
9906 fct_chk( outlen == 0 );
9910 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
9917 #ifdef POLARSSL_AES_C
9919 FCT_TEST_BGN(aes_encrypt_and_decrypt_48_bytes)
9921 unsigned char key[32];
9922 unsigned char iv[16];
9928 unsigned char inbuf[64];
9929 unsigned char encbuf[64];
9930 unsigned char decbuf[64];
9935 memset( key, 0, 32 );
9936 memset( iv , 0, 16 );
9938 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
9939 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
9941 memset( inbuf, 5, 64 );
9942 memset( encbuf, 0, 64 );
9943 memset( decbuf, 0, 64 );
9947 fct_chk( NULL != cipher_info );
9971 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
9978 fct_chk( outlen == enclen );
9981 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
9988 fct_chk( outlen == 0 );
9993 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
10000 fct_chk( enclen == outlen );
10003 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
10010 fct_chk( outlen == 0 );
10014 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
10021 #ifdef POLARSSL_AES_C
10023 FCT_TEST_BGN(aes_encrypt_and_decrypt_49_bytes)
10024 size_t length = 49;
10025 unsigned char key[32];
10026 unsigned char iv[16];
10032 unsigned char inbuf[64];
10033 unsigned char encbuf[64];
10034 unsigned char decbuf[64];
10039 memset( key, 0, 32 );
10040 memset( iv , 0, 16 );
10042 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
10043 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
10045 memset( inbuf, 5, 64 );
10046 memset( encbuf, 0, 64 );
10047 memset( decbuf, 0, 64 );
10051 fct_chk( NULL != cipher_info );
10075 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
10082 fct_chk( outlen == enclen );
10085 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
10092 fct_chk( outlen == 0 );
10097 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
10104 fct_chk( enclen == outlen );
10107 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
10114 fct_chk( outlen == 0 );
10118 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
10125 #ifdef POLARSSL_AES_C
10127 FCT_TEST_BGN(aes_encrypt_and_decrypt_0_bytes_in_multiple_parts)
10128 size_t first_length = 0;
10129 size_t second_length = 0;
10130 size_t length = first_length + second_length;
10131 unsigned char key[32];
10132 unsigned char iv[16];
10138 unsigned char inbuf[64];
10139 unsigned char encbuf[64];
10140 unsigned char decbuf[64];
10143 size_t totaloutlen = 0;
10146 memset( key, 0, 32 );
10147 memset( iv , 0, 16 );
10149 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
10150 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
10152 memset( inbuf, 5, 64 );
10153 memset( encbuf, 0, 64 );
10154 memset( decbuf, 0, 64 );
10158 fct_chk( NULL != cipher_info);
10180 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
10181 totaloutlen = outlen;
10182 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
10183 totaloutlen += outlen;
10190 fct_chk( totaloutlen == enclen );
10192 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
10193 totaloutlen += outlen;
10200 fct_chk( outlen == 0 );
10204 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
10211 fct_chk( enclen == outlen );
10213 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
10220 fct_chk( outlen == 0 );
10224 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
10231 #ifdef POLARSSL_AES_C
10233 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_bytes_in_multiple_parts_1)
10234 size_t first_length = 1;
10235 size_t second_length = 0;
10236 size_t length = first_length + second_length;
10237 unsigned char key[32];
10238 unsigned char iv[16];
10244 unsigned char inbuf[64];
10245 unsigned char encbuf[64];
10246 unsigned char decbuf[64];
10249 size_t totaloutlen = 0;
10252 memset( key, 0, 32 );
10253 memset( iv , 0, 16 );
10255 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
10256 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
10258 memset( inbuf, 5, 64 );
10259 memset( encbuf, 0, 64 );
10260 memset( decbuf, 0, 64 );
10264 fct_chk( NULL != cipher_info);
10286 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
10287 totaloutlen = outlen;
10288 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
10289 totaloutlen += outlen;
10296 fct_chk( totaloutlen == enclen );
10298 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
10299 totaloutlen += outlen;
10306 fct_chk( outlen == 0 );
10310 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
10317 fct_chk( enclen == outlen );
10319 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
10326 fct_chk( outlen == 0 );
10330 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
10337 #ifdef POLARSSL_AES_C
10339 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_bytes_in_multiple_parts_2)
10340 size_t first_length = 0;
10341 size_t second_length = 1;
10342 size_t length = first_length + second_length;
10343 unsigned char key[32];
10344 unsigned char iv[16];
10350 unsigned char inbuf[64];
10351 unsigned char encbuf[64];
10352 unsigned char decbuf[64];
10355 size_t totaloutlen = 0;
10358 memset( key, 0, 32 );
10359 memset( iv , 0, 16 );
10361 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
10362 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
10364 memset( inbuf, 5, 64 );
10365 memset( encbuf, 0, 64 );
10366 memset( decbuf, 0, 64 );
10370 fct_chk( NULL != cipher_info);
10392 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
10393 totaloutlen = outlen;
10394 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
10395 totaloutlen += outlen;
10402 fct_chk( totaloutlen == enclen );
10404 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
10405 totaloutlen += outlen;
10412 fct_chk( outlen == 0 );
10416 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
10423 fct_chk( enclen == outlen );
10425 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
10432 fct_chk( outlen == 0 );
10436 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
10443 #ifdef POLARSSL_AES_C
10445 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_1)
10446 size_t first_length = 16;
10447 size_t second_length = 0;
10448 size_t length = first_length + second_length;
10449 unsigned char key[32];
10450 unsigned char iv[16];
10456 unsigned char inbuf[64];
10457 unsigned char encbuf[64];
10458 unsigned char decbuf[64];
10461 size_t totaloutlen = 0;
10464 memset( key, 0, 32 );
10465 memset( iv , 0, 16 );
10467 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
10468 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
10470 memset( inbuf, 5, 64 );
10471 memset( encbuf, 0, 64 );
10472 memset( decbuf, 0, 64 );
10476 fct_chk( NULL != cipher_info);
10498 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
10499 totaloutlen = outlen;
10500 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
10501 totaloutlen += outlen;
10508 fct_chk( totaloutlen == enclen );
10510 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
10511 totaloutlen += outlen;
10518 fct_chk( outlen == 0 );
10522 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
10529 fct_chk( enclen == outlen );
10531 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
10538 fct_chk( outlen == 0 );
10542 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
10549 #ifdef POLARSSL_AES_C
10551 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_2)
10552 size_t first_length = 0;
10553 size_t second_length = 16;
10554 size_t length = first_length + second_length;
10555 unsigned char key[32];
10556 unsigned char iv[16];
10562 unsigned char inbuf[64];
10563 unsigned char encbuf[64];
10564 unsigned char decbuf[64];
10567 size_t totaloutlen = 0;
10570 memset( key, 0, 32 );
10571 memset( iv , 0, 16 );
10573 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
10574 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
10576 memset( inbuf, 5, 64 );
10577 memset( encbuf, 0, 64 );
10578 memset( decbuf, 0, 64 );
10582 fct_chk( NULL != cipher_info);
10604 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
10605 totaloutlen = outlen;
10606 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
10607 totaloutlen += outlen;
10614 fct_chk( totaloutlen == enclen );
10616 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
10617 totaloutlen += outlen;
10624 fct_chk( outlen == 0 );
10628 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
10635 fct_chk( enclen == outlen );
10637 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
10644 fct_chk( outlen == 0 );
10648 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
10655 #ifdef POLARSSL_AES_C
10657 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_3)
10658 size_t first_length = 1;
10659 size_t second_length = 15;
10660 size_t length = first_length + second_length;
10661 unsigned char key[32];
10662 unsigned char iv[16];
10668 unsigned char inbuf[64];
10669 unsigned char encbuf[64];
10670 unsigned char decbuf[64];
10673 size_t totaloutlen = 0;
10676 memset( key, 0, 32 );
10677 memset( iv , 0, 16 );
10679 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
10680 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
10682 memset( inbuf, 5, 64 );
10683 memset( encbuf, 0, 64 );
10684 memset( decbuf, 0, 64 );
10688 fct_chk( NULL != cipher_info);
10710 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
10711 totaloutlen = outlen;
10712 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
10713 totaloutlen += outlen;
10720 fct_chk( totaloutlen == enclen );
10722 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
10723 totaloutlen += outlen;
10730 fct_chk( outlen == 0 );
10734 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
10741 fct_chk( enclen == outlen );
10743 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
10750 fct_chk( outlen == 0 );
10754 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
10761 #ifdef POLARSSL_AES_C
10763 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_4)
10764 size_t first_length = 15;
10765 size_t second_length = 1;
10766 size_t length = first_length + second_length;
10767 unsigned char key[32];
10768 unsigned char iv[16];
10774 unsigned char inbuf[64];
10775 unsigned char encbuf[64];
10776 unsigned char decbuf[64];
10779 size_t totaloutlen = 0;
10782 memset( key, 0, 32 );
10783 memset( iv , 0, 16 );
10785 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
10786 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
10788 memset( inbuf, 5, 64 );
10789 memset( encbuf, 0, 64 );
10790 memset( decbuf, 0, 64 );
10794 fct_chk( NULL != cipher_info);
10816 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
10817 totaloutlen = outlen;
10818 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
10819 totaloutlen += outlen;
10826 fct_chk( totaloutlen == enclen );
10828 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
10829 totaloutlen += outlen;
10836 fct_chk( outlen == 0 );
10840 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
10847 fct_chk( enclen == outlen );
10849 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
10856 fct_chk( outlen == 0 );
10860 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
10867 #ifdef POLARSSL_AES_C
10869 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
10870 size_t first_length = 15;
10871 size_t second_length = 7;
10872 size_t length = first_length + second_length;
10873 unsigned char key[32];
10874 unsigned char iv[16];
10880 unsigned char inbuf[64];
10881 unsigned char encbuf[64];
10882 unsigned char decbuf[64];
10885 size_t totaloutlen = 0;
10888 memset( key, 0, 32 );
10889 memset( iv , 0, 16 );
10891 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
10892 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
10894 memset( inbuf, 5, 64 );
10895 memset( encbuf, 0, 64 );
10896 memset( decbuf, 0, 64 );
10900 fct_chk( NULL != cipher_info);
10922 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
10923 totaloutlen = outlen;
10924 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
10925 totaloutlen += outlen;
10932 fct_chk( totaloutlen == enclen );
10934 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
10935 totaloutlen += outlen;
10942 fct_chk( outlen == 0 );
10946 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
10953 fct_chk( enclen == outlen );
10955 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
10962 fct_chk( outlen == 0 );
10966 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
10973 #ifdef POLARSSL_AES_C
10975 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
10976 size_t first_length = 16;
10977 size_t second_length = 6;
10978 size_t length = first_length + second_length;
10979 unsigned char key[32];
10980 unsigned char iv[16];
10986 unsigned char inbuf[64];
10987 unsigned char encbuf[64];
10988 unsigned char decbuf[64];
10991 size_t totaloutlen = 0;
10994 memset( key, 0, 32 );
10995 memset( iv , 0, 16 );
10997 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
10998 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
11000 memset( inbuf, 5, 64 );
11001 memset( encbuf, 0, 64 );
11002 memset( decbuf, 0, 64 );
11006 fct_chk( NULL != cipher_info);
11028 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
11029 totaloutlen = outlen;
11030 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
11031 totaloutlen += outlen;
11038 fct_chk( totaloutlen == enclen );
11040 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
11041 totaloutlen += outlen;
11048 fct_chk( outlen == 0 );
11052 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
11059 fct_chk( enclen == outlen );
11061 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
11068 fct_chk( outlen == 0 );
11072 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
11079 #ifdef POLARSSL_AES_C
11081 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
11082 size_t first_length = 17;
11083 size_t second_length = 6;
11084 size_t length = first_length + second_length;
11085 unsigned char key[32];
11086 unsigned char iv[16];
11092 unsigned char inbuf[64];
11093 unsigned char encbuf[64];
11094 unsigned char decbuf[64];
11097 size_t totaloutlen = 0;
11100 memset( key, 0, 32 );
11101 memset( iv , 0, 16 );
11103 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
11104 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
11106 memset( inbuf, 5, 64 );
11107 memset( encbuf, 0, 64 );
11108 memset( decbuf, 0, 64 );
11112 fct_chk( NULL != cipher_info);
11134 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
11135 totaloutlen = outlen;
11136 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
11137 totaloutlen += outlen;
11144 fct_chk( totaloutlen == enclen );
11146 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
11147 totaloutlen += outlen;
11154 fct_chk( outlen == 0 );
11158 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
11165 fct_chk( enclen == outlen );
11167 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
11174 fct_chk( outlen == 0 );
11178 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
11185 #ifdef POLARSSL_AES_C
11187 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes_in_multiple_parts_1)
11188 size_t first_length = 16;
11189 size_t second_length = 16;
11190 size_t length = first_length + second_length;
11191 unsigned char key[32];
11192 unsigned char iv[16];
11198 unsigned char inbuf[64];
11199 unsigned char encbuf[64];
11200 unsigned char decbuf[64];
11203 size_t totaloutlen = 0;
11206 memset( key, 0, 32 );
11207 memset( iv , 0, 16 );
11209 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
11210 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
11212 memset( inbuf, 5, 64 );
11213 memset( encbuf, 0, 64 );
11214 memset( decbuf, 0, 64 );
11218 fct_chk( NULL != cipher_info);
11240 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
11241 totaloutlen = outlen;
11242 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
11243 totaloutlen += outlen;
11250 fct_chk( totaloutlen == enclen );
11252 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
11253 totaloutlen += outlen;
11260 fct_chk( outlen == 0 );
11264 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
11271 fct_chk( enclen == outlen );
11273 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
11280 fct_chk( outlen == 0 );
11284 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
11291 #ifdef POLARSSL_AES_C
11293 FCT_TEST_BGN(aes_encrypt_and_decrypt_0_bytes)
11295 unsigned char key[32];
11296 unsigned char iv[16];
11302 unsigned char inbuf[64];
11303 unsigned char encbuf[64];
11304 unsigned char decbuf[64];
11309 memset( key, 0, 32 );
11310 memset( iv , 0, 16 );
11312 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
11313 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
11315 memset( inbuf, 5, 64 );
11316 memset( encbuf, 0, 64 );
11317 memset( decbuf, 0, 64 );
11321 fct_chk( NULL != cipher_info );
11345 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
11352 fct_chk( outlen == enclen );
11355 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
11362 fct_chk( outlen == 0 );
11367 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
11374 fct_chk( enclen == outlen );
11377 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
11384 fct_chk( outlen == 0 );
11388 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
11395 #ifdef POLARSSL_AES_C
11397 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_byte)
11399 unsigned char key[32];
11400 unsigned char iv[16];
11406 unsigned char inbuf[64];
11407 unsigned char encbuf[64];
11408 unsigned char decbuf[64];
11413 memset( key, 0, 32 );
11414 memset( iv , 0, 16 );
11416 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
11417 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
11419 memset( inbuf, 5, 64 );
11420 memset( encbuf, 0, 64 );
11421 memset( decbuf, 0, 64 );
11425 fct_chk( NULL != cipher_info );
11449 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
11456 fct_chk( outlen == enclen );
11459 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
11466 fct_chk( outlen == 0 );
11471 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
11478 fct_chk( enclen == outlen );
11481 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
11488 fct_chk( outlen == 0 );
11492 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
11499 #ifdef POLARSSL_AES_C
11501 FCT_TEST_BGN(aes_encrypt_and_decrypt_2_bytes)
11503 unsigned char key[32];
11504 unsigned char iv[16];
11510 unsigned char inbuf[64];
11511 unsigned char encbuf[64];
11512 unsigned char decbuf[64];
11517 memset( key, 0, 32 );
11518 memset( iv , 0, 16 );
11520 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
11521 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
11523 memset( inbuf, 5, 64 );
11524 memset( encbuf, 0, 64 );
11525 memset( decbuf, 0, 64 );
11529 fct_chk( NULL != cipher_info );
11553 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
11560 fct_chk( outlen == enclen );
11563 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
11570 fct_chk( outlen == 0 );
11575 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
11582 fct_chk( enclen == outlen );
11585 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
11592 fct_chk( outlen == 0 );
11596 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
11603 #ifdef POLARSSL_AES_C
11605 FCT_TEST_BGN(aes_encrypt_and_decrypt_7_bytes)
11607 unsigned char key[32];
11608 unsigned char iv[16];
11614 unsigned char inbuf[64];
11615 unsigned char encbuf[64];
11616 unsigned char decbuf[64];
11621 memset( key, 0, 32 );
11622 memset( iv , 0, 16 );
11624 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
11625 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
11627 memset( inbuf, 5, 64 );
11628 memset( encbuf, 0, 64 );
11629 memset( decbuf, 0, 64 );
11633 fct_chk( NULL != cipher_info );
11657 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
11664 fct_chk( outlen == enclen );
11667 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
11674 fct_chk( outlen == 0 );
11679 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
11686 fct_chk( enclen == outlen );
11689 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
11696 fct_chk( outlen == 0 );
11700 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
11707 #ifdef POLARSSL_AES_C
11709 FCT_TEST_BGN(aes_encrypt_and_decrypt_8_bytes)
11711 unsigned char key[32];
11712 unsigned char iv[16];
11718 unsigned char inbuf[64];
11719 unsigned char encbuf[64];
11720 unsigned char decbuf[64];
11725 memset( key, 0, 32 );
11726 memset( iv , 0, 16 );
11728 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
11729 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
11731 memset( inbuf, 5, 64 );
11732 memset( encbuf, 0, 64 );
11733 memset( decbuf, 0, 64 );
11737 fct_chk( NULL != cipher_info );
11761 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
11768 fct_chk( outlen == enclen );
11771 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
11778 fct_chk( outlen == 0 );
11783 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
11790 fct_chk( enclen == outlen );
11793 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
11800 fct_chk( outlen == 0 );
11804 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
11811 #ifdef POLARSSL_AES_C
11813 FCT_TEST_BGN(aes_encrypt_and_decrypt_9_bytes)
11815 unsigned char key[32];
11816 unsigned char iv[16];
11822 unsigned char inbuf[64];
11823 unsigned char encbuf[64];
11824 unsigned char decbuf[64];
11829 memset( key, 0, 32 );
11830 memset( iv , 0, 16 );
11832 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
11833 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
11835 memset( inbuf, 5, 64 );
11836 memset( encbuf, 0, 64 );
11837 memset( decbuf, 0, 64 );
11841 fct_chk( NULL != cipher_info );
11865 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
11872 fct_chk( outlen == enclen );
11875 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
11882 fct_chk( outlen == 0 );
11887 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
11894 fct_chk( enclen == outlen );
11897 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
11904 fct_chk( outlen == 0 );
11908 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
11915 #ifdef POLARSSL_AES_C
11917 FCT_TEST_BGN(aes_encrypt_and_decrypt_15_bytes)
11918 size_t length = 15;
11919 unsigned char key[32];
11920 unsigned char iv[16];
11926 unsigned char inbuf[64];
11927 unsigned char encbuf[64];
11928 unsigned char decbuf[64];
11933 memset( key, 0, 32 );
11934 memset( iv , 0, 16 );
11936 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
11937 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
11939 memset( inbuf, 5, 64 );
11940 memset( encbuf, 0, 64 );
11941 memset( decbuf, 0, 64 );
11945 fct_chk( NULL != cipher_info );
11969 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
11976 fct_chk( outlen == enclen );
11979 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
11986 fct_chk( outlen == 0 );
11991 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
11998 fct_chk( enclen == outlen );
12001 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
12008 fct_chk( outlen == 0 );
12012 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
12019 #ifdef POLARSSL_AES_C
12021 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes)
12022 size_t length = 16;
12023 unsigned char key[32];
12024 unsigned char iv[16];
12030 unsigned char inbuf[64];
12031 unsigned char encbuf[64];
12032 unsigned char decbuf[64];
12037 memset( key, 0, 32 );
12038 memset( iv , 0, 16 );
12040 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
12041 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
12043 memset( inbuf, 5, 64 );
12044 memset( encbuf, 0, 64 );
12045 memset( decbuf, 0, 64 );
12049 fct_chk( NULL != cipher_info );
12073 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
12080 fct_chk( outlen == enclen );
12083 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
12090 fct_chk( outlen == 0 );
12095 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
12102 fct_chk( enclen == outlen );
12105 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
12112 fct_chk( outlen == 0 );
12116 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
12123 #ifdef POLARSSL_AES_C
12125 FCT_TEST_BGN(aes_encrypt_and_decrypt_17_bytes)
12126 size_t length = 17;
12127 unsigned char key[32];
12128 unsigned char iv[16];
12134 unsigned char inbuf[64];
12135 unsigned char encbuf[64];
12136 unsigned char decbuf[64];
12141 memset( key, 0, 32 );
12142 memset( iv , 0, 16 );
12144 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
12145 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
12147 memset( inbuf, 5, 64 );
12148 memset( encbuf, 0, 64 );
12149 memset( decbuf, 0, 64 );
12153 fct_chk( NULL != cipher_info );
12177 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
12184 fct_chk( outlen == enclen );
12187 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
12194 fct_chk( outlen == 0 );
12199 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
12206 fct_chk( enclen == outlen );
12209 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
12216 fct_chk( outlen == 0 );
12220 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
12227 #ifdef POLARSSL_AES_C
12229 FCT_TEST_BGN(aes_encrypt_and_decrypt_31_bytes)
12230 size_t length = 31;
12231 unsigned char key[32];
12232 unsigned char iv[16];
12238 unsigned char inbuf[64];
12239 unsigned char encbuf[64];
12240 unsigned char decbuf[64];
12245 memset( key, 0, 32 );
12246 memset( iv , 0, 16 );
12248 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
12249 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
12251 memset( inbuf, 5, 64 );
12252 memset( encbuf, 0, 64 );
12253 memset( decbuf, 0, 64 );
12257 fct_chk( NULL != cipher_info );
12281 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
12288 fct_chk( outlen == enclen );
12291 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
12298 fct_chk( outlen == 0 );
12303 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
12310 fct_chk( enclen == outlen );
12313 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
12320 fct_chk( outlen == 0 );
12324 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
12331 #ifdef POLARSSL_AES_C
12333 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes)
12334 size_t length = 32;
12335 unsigned char key[32];
12336 unsigned char iv[16];
12342 unsigned char inbuf[64];
12343 unsigned char encbuf[64];
12344 unsigned char decbuf[64];
12349 memset( key, 0, 32 );
12350 memset( iv , 0, 16 );
12352 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
12353 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
12355 memset( inbuf, 5, 64 );
12356 memset( encbuf, 0, 64 );
12357 memset( decbuf, 0, 64 );
12361 fct_chk( NULL != cipher_info );
12385 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
12392 fct_chk( outlen == enclen );
12395 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
12402 fct_chk( outlen == 0 );
12407 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
12414 fct_chk( enclen == outlen );
12417 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
12424 fct_chk( outlen == 0 );
12428 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
12435 #ifdef POLARSSL_AES_C
12437 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes)
12438 size_t length = 33;
12439 unsigned char key[32];
12440 unsigned char iv[16];
12446 unsigned char inbuf[64];
12447 unsigned char encbuf[64];
12448 unsigned char decbuf[64];
12453 memset( key, 0, 32 );
12454 memset( iv , 0, 16 );
12456 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
12457 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
12459 memset( inbuf, 5, 64 );
12460 memset( encbuf, 0, 64 );
12461 memset( decbuf, 0, 64 );
12465 fct_chk( NULL != cipher_info );
12489 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
12496 fct_chk( outlen == enclen );
12499 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
12506 fct_chk( outlen == 0 );
12511 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
12518 fct_chk( enclen == outlen );
12521 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
12528 fct_chk( outlen == 0 );
12532 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
12539 #ifdef POLARSSL_AES_C
12541 FCT_TEST_BGN(aes_encrypt_and_decrypt_47_bytes)
12542 size_t length = 47;
12543 unsigned char key[32];
12544 unsigned char iv[16];
12550 unsigned char inbuf[64];
12551 unsigned char encbuf[64];
12552 unsigned char decbuf[64];
12557 memset( key, 0, 32 );
12558 memset( iv , 0, 16 );
12560 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
12561 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
12563 memset( inbuf, 5, 64 );
12564 memset( encbuf, 0, 64 );
12565 memset( decbuf, 0, 64 );
12569 fct_chk( NULL != cipher_info );
12593 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
12600 fct_chk( outlen == enclen );
12603 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
12610 fct_chk( outlen == 0 );
12615 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
12622 fct_chk( enclen == outlen );
12625 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
12632 fct_chk( outlen == 0 );
12636 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
12643 #ifdef POLARSSL_AES_C
12645 FCT_TEST_BGN(aes_encrypt_and_decrypt_48_bytes)
12646 size_t length = 48;
12647 unsigned char key[32];
12648 unsigned char iv[16];
12654 unsigned char inbuf[64];
12655 unsigned char encbuf[64];
12656 unsigned char decbuf[64];
12661 memset( key, 0, 32 );
12662 memset( iv , 0, 16 );
12664 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
12665 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
12667 memset( inbuf, 5, 64 );
12668 memset( encbuf, 0, 64 );
12669 memset( decbuf, 0, 64 );
12673 fct_chk( NULL != cipher_info );
12697 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
12704 fct_chk( outlen == enclen );
12707 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
12714 fct_chk( outlen == 0 );
12719 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
12726 fct_chk( enclen == outlen );
12729 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
12736 fct_chk( outlen == 0 );
12740 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
12747 #ifdef POLARSSL_AES_C
12749 FCT_TEST_BGN(aes_encrypt_and_decrypt_49_bytes)
12750 size_t length = 49;
12751 unsigned char key[32];
12752 unsigned char iv[16];
12758 unsigned char inbuf[64];
12759 unsigned char encbuf[64];
12760 unsigned char decbuf[64];
12765 memset( key, 0, 32 );
12766 memset( iv , 0, 16 );
12768 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
12769 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
12771 memset( inbuf, 5, 64 );
12772 memset( encbuf, 0, 64 );
12773 memset( decbuf, 0, 64 );
12777 fct_chk( NULL != cipher_info );
12801 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
12808 fct_chk( outlen == enclen );
12811 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
12818 fct_chk( outlen == 0 );
12823 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
12830 fct_chk( enclen == outlen );
12833 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
12840 fct_chk( outlen == 0 );
12844 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
12851 #ifdef POLARSSL_AES_C
12853 FCT_TEST_BGN(aes_encrypt_and_decrypt_0_bytes_in_multiple_parts)
12854 size_t first_length = 0;
12855 size_t second_length = 0;
12856 size_t length = first_length + second_length;
12857 unsigned char key[32];
12858 unsigned char iv[16];
12864 unsigned char inbuf[64];
12865 unsigned char encbuf[64];
12866 unsigned char decbuf[64];
12869 size_t totaloutlen = 0;
12872 memset( key, 0, 32 );
12873 memset( iv , 0, 16 );
12875 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
12876 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
12878 memset( inbuf, 5, 64 );
12879 memset( encbuf, 0, 64 );
12880 memset( decbuf, 0, 64 );
12884 fct_chk( NULL != cipher_info);
12906 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
12907 totaloutlen = outlen;
12908 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
12909 totaloutlen += outlen;
12916 fct_chk( totaloutlen == enclen );
12918 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
12919 totaloutlen += outlen;
12926 fct_chk( outlen == 0 );
12930 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
12937 fct_chk( enclen == outlen );
12939 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
12946 fct_chk( outlen == 0 );
12950 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
12957 #ifdef POLARSSL_AES_C
12959 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_bytes_in_multiple_parts_1)
12960 size_t first_length = 1;
12961 size_t second_length = 0;
12962 size_t length = first_length + second_length;
12963 unsigned char key[32];
12964 unsigned char iv[16];
12970 unsigned char inbuf[64];
12971 unsigned char encbuf[64];
12972 unsigned char decbuf[64];
12975 size_t totaloutlen = 0;
12978 memset( key, 0, 32 );
12979 memset( iv , 0, 16 );
12981 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
12982 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
12984 memset( inbuf, 5, 64 );
12985 memset( encbuf, 0, 64 );
12986 memset( decbuf, 0, 64 );
12990 fct_chk( NULL != cipher_info);
13012 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
13013 totaloutlen = outlen;
13014 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
13015 totaloutlen += outlen;
13022 fct_chk( totaloutlen == enclen );
13024 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
13025 totaloutlen += outlen;
13032 fct_chk( outlen == 0 );
13036 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
13043 fct_chk( enclen == outlen );
13045 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
13052 fct_chk( outlen == 0 );
13056 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
13063 #ifdef POLARSSL_AES_C
13065 FCT_TEST_BGN(aes_encrypt_and_decrypt_1_bytes_in_multiple_parts_2)
13066 size_t first_length = 0;
13067 size_t second_length = 1;
13068 size_t length = first_length + second_length;
13069 unsigned char key[32];
13070 unsigned char iv[16];
13076 unsigned char inbuf[64];
13077 unsigned char encbuf[64];
13078 unsigned char decbuf[64];
13081 size_t totaloutlen = 0;
13084 memset( key, 0, 32 );
13085 memset( iv , 0, 16 );
13087 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
13088 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
13090 memset( inbuf, 5, 64 );
13091 memset( encbuf, 0, 64 );
13092 memset( decbuf, 0, 64 );
13096 fct_chk( NULL != cipher_info);
13118 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
13119 totaloutlen = outlen;
13120 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
13121 totaloutlen += outlen;
13128 fct_chk( totaloutlen == enclen );
13130 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
13131 totaloutlen += outlen;
13138 fct_chk( outlen == 0 );
13142 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
13149 fct_chk( enclen == outlen );
13151 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
13158 fct_chk( outlen == 0 );
13162 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
13169 #ifdef POLARSSL_AES_C
13171 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_1)
13172 size_t first_length = 16;
13173 size_t second_length = 0;
13174 size_t length = first_length + second_length;
13175 unsigned char key[32];
13176 unsigned char iv[16];
13182 unsigned char inbuf[64];
13183 unsigned char encbuf[64];
13184 unsigned char decbuf[64];
13187 size_t totaloutlen = 0;
13190 memset( key, 0, 32 );
13191 memset( iv , 0, 16 );
13193 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
13194 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
13196 memset( inbuf, 5, 64 );
13197 memset( encbuf, 0, 64 );
13198 memset( decbuf, 0, 64 );
13202 fct_chk( NULL != cipher_info);
13224 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
13225 totaloutlen = outlen;
13226 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
13227 totaloutlen += outlen;
13234 fct_chk( totaloutlen == enclen );
13236 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
13237 totaloutlen += outlen;
13244 fct_chk( outlen == 0 );
13248 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
13255 fct_chk( enclen == outlen );
13257 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
13264 fct_chk( outlen == 0 );
13268 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
13275 #ifdef POLARSSL_AES_C
13277 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_2)
13278 size_t first_length = 0;
13279 size_t second_length = 16;
13280 size_t length = first_length + second_length;
13281 unsigned char key[32];
13282 unsigned char iv[16];
13288 unsigned char inbuf[64];
13289 unsigned char encbuf[64];
13290 unsigned char decbuf[64];
13293 size_t totaloutlen = 0;
13296 memset( key, 0, 32 );
13297 memset( iv , 0, 16 );
13299 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
13300 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
13302 memset( inbuf, 5, 64 );
13303 memset( encbuf, 0, 64 );
13304 memset( decbuf, 0, 64 );
13308 fct_chk( NULL != cipher_info);
13330 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
13331 totaloutlen = outlen;
13332 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
13333 totaloutlen += outlen;
13340 fct_chk( totaloutlen == enclen );
13342 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
13343 totaloutlen += outlen;
13350 fct_chk( outlen == 0 );
13354 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
13361 fct_chk( enclen == outlen );
13363 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
13370 fct_chk( outlen == 0 );
13374 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
13381 #ifdef POLARSSL_AES_C
13383 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_3)
13384 size_t first_length = 1;
13385 size_t second_length = 15;
13386 size_t length = first_length + second_length;
13387 unsigned char key[32];
13388 unsigned char iv[16];
13394 unsigned char inbuf[64];
13395 unsigned char encbuf[64];
13396 unsigned char decbuf[64];
13399 size_t totaloutlen = 0;
13402 memset( key, 0, 32 );
13403 memset( iv , 0, 16 );
13405 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
13406 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
13408 memset( inbuf, 5, 64 );
13409 memset( encbuf, 0, 64 );
13410 memset( decbuf, 0, 64 );
13414 fct_chk( NULL != cipher_info);
13436 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
13437 totaloutlen = outlen;
13438 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
13439 totaloutlen += outlen;
13446 fct_chk( totaloutlen == enclen );
13448 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
13449 totaloutlen += outlen;
13456 fct_chk( outlen == 0 );
13460 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
13467 fct_chk( enclen == outlen );
13469 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
13476 fct_chk( outlen == 0 );
13480 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
13487 #ifdef POLARSSL_AES_C
13489 FCT_TEST_BGN(aes_encrypt_and_decrypt_16_bytes_in_multiple_parts_4)
13490 size_t first_length = 15;
13491 size_t second_length = 1;
13492 size_t length = first_length + second_length;
13493 unsigned char key[32];
13494 unsigned char iv[16];
13500 unsigned char inbuf[64];
13501 unsigned char encbuf[64];
13502 unsigned char decbuf[64];
13505 size_t totaloutlen = 0;
13508 memset( key, 0, 32 );
13509 memset( iv , 0, 16 );
13511 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
13512 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
13514 memset( inbuf, 5, 64 );
13515 memset( encbuf, 0, 64 );
13516 memset( decbuf, 0, 64 );
13520 fct_chk( NULL != cipher_info);
13542 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
13543 totaloutlen = outlen;
13544 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
13545 totaloutlen += outlen;
13552 fct_chk( totaloutlen == enclen );
13554 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
13555 totaloutlen += outlen;
13562 fct_chk( outlen == 0 );
13566 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
13573 fct_chk( enclen == outlen );
13575 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
13582 fct_chk( outlen == 0 );
13586 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
13593 #ifdef POLARSSL_AES_C
13595 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
13596 size_t first_length = 15;
13597 size_t second_length = 7;
13598 size_t length = first_length + second_length;
13599 unsigned char key[32];
13600 unsigned char iv[16];
13606 unsigned char inbuf[64];
13607 unsigned char encbuf[64];
13608 unsigned char decbuf[64];
13611 size_t totaloutlen = 0;
13614 memset( key, 0, 32 );
13615 memset( iv , 0, 16 );
13617 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
13618 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
13620 memset( inbuf, 5, 64 );
13621 memset( encbuf, 0, 64 );
13622 memset( decbuf, 0, 64 );
13626 fct_chk( NULL != cipher_info);
13648 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
13649 totaloutlen = outlen;
13650 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
13651 totaloutlen += outlen;
13658 fct_chk( totaloutlen == enclen );
13660 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
13661 totaloutlen += outlen;
13668 fct_chk( outlen == 0 );
13672 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
13679 fct_chk( enclen == outlen );
13681 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
13688 fct_chk( outlen == 0 );
13692 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
13699 #ifdef POLARSSL_AES_C
13701 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
13702 size_t first_length = 16;
13703 size_t second_length = 6;
13704 size_t length = first_length + second_length;
13705 unsigned char key[32];
13706 unsigned char iv[16];
13712 unsigned char inbuf[64];
13713 unsigned char encbuf[64];
13714 unsigned char decbuf[64];
13717 size_t totaloutlen = 0;
13720 memset( key, 0, 32 );
13721 memset( iv , 0, 16 );
13723 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
13724 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
13726 memset( inbuf, 5, 64 );
13727 memset( encbuf, 0, 64 );
13728 memset( decbuf, 0, 64 );
13732 fct_chk( NULL != cipher_info);
13754 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
13755 totaloutlen = outlen;
13756 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
13757 totaloutlen += outlen;
13764 fct_chk( totaloutlen == enclen );
13766 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
13767 totaloutlen += outlen;
13774 fct_chk( outlen == 0 );
13778 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
13785 fct_chk( enclen == outlen );
13787 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
13794 fct_chk( outlen == 0 );
13798 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
13805 #ifdef POLARSSL_AES_C
13807 FCT_TEST_BGN(aes_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
13808 size_t first_length = 17;
13809 size_t second_length = 6;
13810 size_t length = first_length + second_length;
13811 unsigned char key[32];
13812 unsigned char iv[16];
13818 unsigned char inbuf[64];
13819 unsigned char encbuf[64];
13820 unsigned char decbuf[64];
13823 size_t totaloutlen = 0;
13826 memset( key, 0, 32 );
13827 memset( iv , 0, 16 );
13829 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
13830 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
13832 memset( inbuf, 5, 64 );
13833 memset( encbuf, 0, 64 );
13834 memset( decbuf, 0, 64 );
13838 fct_chk( NULL != cipher_info);
13860 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
13861 totaloutlen = outlen;
13862 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
13863 totaloutlen += outlen;
13870 fct_chk( totaloutlen == enclen );
13872 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
13873 totaloutlen += outlen;
13880 fct_chk( outlen == 0 );
13884 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
13891 fct_chk( enclen == outlen );
13893 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
13900 fct_chk( outlen == 0 );
13904 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
13911 #ifdef POLARSSL_AES_C
13913 FCT_TEST_BGN(aes_encrypt_and_decrypt_32_bytes_in_multiple_parts_1)
13914 size_t first_length = 16;
13915 size_t second_length = 16;
13916 size_t length = first_length + second_length;
13917 unsigned char key[32];
13918 unsigned char iv[16];
13924 unsigned char inbuf[64];
13925 unsigned char encbuf[64];
13926 unsigned char decbuf[64];
13929 size_t totaloutlen = 0;
13932 memset( key, 0, 32 );
13933 memset( iv , 0, 16 );
13935 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
13936 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
13938 memset( inbuf, 5, 64 );
13939 memset( encbuf, 0, 64 );
13940 memset( decbuf, 0, 64 );
13944 fct_chk( NULL != cipher_info);
13966 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
13967 totaloutlen = outlen;
13968 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
13969 totaloutlen += outlen;
13976 fct_chk( totaloutlen == enclen );
13978 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
13979 totaloutlen += outlen;
13986 fct_chk( outlen == 0 );
13990 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
13997 fct_chk( enclen == outlen );
13999 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
14006 fct_chk( outlen == 0 );
14010 fct_chk( 0 == memcmp(inbuf, decbuf, length) );