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_DES_C
285 FCT_TEST_BGN(des_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_DES_C
389 FCT_TEST_BGN(des_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_DES_C
493 FCT_TEST_BGN(des_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_DES_C
597 FCT_TEST_BGN(des_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_DES_C
701 FCT_TEST_BGN(des_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_DES_C
805 FCT_TEST_BGN(des_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_DES_C
909 FCT_TEST_BGN(des_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_DES_C
1013 FCT_TEST_BGN(des_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_DES_C
1117 FCT_TEST_BGN(des_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_DES_C
1221 FCT_TEST_BGN(des_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_DES_C
1325 FCT_TEST_BGN(des_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_DES_C
1429 FCT_TEST_BGN(des_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_DES_C
1533 FCT_TEST_BGN(des_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_DES_C
1637 FCT_TEST_BGN(des_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_DES_C
1741 FCT_TEST_BGN(des_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_DES_C
1845 FCT_TEST_BGN(des_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_DES_C
1951 FCT_TEST_BGN(des_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_DES_C
2057 FCT_TEST_BGN(des_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_DES_C
2163 FCT_TEST_BGN(des_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_DES_C
2269 FCT_TEST_BGN(des_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_DES_C
2375 FCT_TEST_BGN(des_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_DES_C
2481 FCT_TEST_BGN(des_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_DES_C
2587 FCT_TEST_BGN(des_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_DES_C
2693 FCT_TEST_BGN(des_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_DES_C
2799 FCT_TEST_BGN(des_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_DES_C
2905 FCT_TEST_BGN(des_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_DES_C
3011 FCT_TEST_BGN(des_encrypt_and_decrypt_0_bytes)
3013 unsigned char key[32];
3014 unsigned char iv[16];
3020 unsigned char inbuf[64];
3021 unsigned char encbuf[64];
3022 unsigned char decbuf[64];
3027 memset( key, 0, 32 );
3028 memset( iv , 0, 16 );
3030 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3031 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3033 memset( inbuf, 5, 64 );
3034 memset( encbuf, 0, 64 );
3035 memset( decbuf, 0, 64 );
3039 fct_chk( NULL != cipher_info );
3063 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3070 fct_chk( outlen == enclen );
3073 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3080 fct_chk( outlen == 0 );
3085 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3092 fct_chk( enclen == outlen );
3095 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3102 fct_chk( outlen == 0 );
3106 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3113 #ifdef POLARSSL_DES_C
3115 FCT_TEST_BGN(des3_encrypt_and_decrypt_1_byte)
3117 unsigned char key[32];
3118 unsigned char iv[16];
3124 unsigned char inbuf[64];
3125 unsigned char encbuf[64];
3126 unsigned char decbuf[64];
3131 memset( key, 0, 32 );
3132 memset( iv , 0, 16 );
3134 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3135 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3137 memset( inbuf, 5, 64 );
3138 memset( encbuf, 0, 64 );
3139 memset( decbuf, 0, 64 );
3143 fct_chk( NULL != cipher_info );
3167 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3174 fct_chk( outlen == enclen );
3177 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3184 fct_chk( outlen == 0 );
3189 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3196 fct_chk( enclen == outlen );
3199 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3206 fct_chk( outlen == 0 );
3210 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3217 #ifdef POLARSSL_DES_C
3219 FCT_TEST_BGN(des3_encrypt_and_decrypt_2_bytes)
3221 unsigned char key[32];
3222 unsigned char iv[16];
3228 unsigned char inbuf[64];
3229 unsigned char encbuf[64];
3230 unsigned char decbuf[64];
3235 memset( key, 0, 32 );
3236 memset( iv , 0, 16 );
3238 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3239 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3241 memset( inbuf, 5, 64 );
3242 memset( encbuf, 0, 64 );
3243 memset( decbuf, 0, 64 );
3247 fct_chk( NULL != cipher_info );
3271 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3278 fct_chk( outlen == enclen );
3281 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3288 fct_chk( outlen == 0 );
3293 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3300 fct_chk( enclen == outlen );
3303 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3310 fct_chk( outlen == 0 );
3314 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3321 #ifdef POLARSSL_DES_C
3323 FCT_TEST_BGN(des3_encrypt_and_decrypt_7_bytes)
3325 unsigned char key[32];
3326 unsigned char iv[16];
3332 unsigned char inbuf[64];
3333 unsigned char encbuf[64];
3334 unsigned char decbuf[64];
3339 memset( key, 0, 32 );
3340 memset( iv , 0, 16 );
3342 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3343 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3345 memset( inbuf, 5, 64 );
3346 memset( encbuf, 0, 64 );
3347 memset( decbuf, 0, 64 );
3351 fct_chk( NULL != cipher_info );
3375 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3382 fct_chk( outlen == enclen );
3385 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3392 fct_chk( outlen == 0 );
3397 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3404 fct_chk( enclen == outlen );
3407 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3414 fct_chk( outlen == 0 );
3418 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3425 #ifdef POLARSSL_DES_C
3427 FCT_TEST_BGN(des3_encrypt_and_decrypt_8_bytes)
3429 unsigned char key[32];
3430 unsigned char iv[16];
3436 unsigned char inbuf[64];
3437 unsigned char encbuf[64];
3438 unsigned char decbuf[64];
3443 memset( key, 0, 32 );
3444 memset( iv , 0, 16 );
3446 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3447 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3449 memset( inbuf, 5, 64 );
3450 memset( encbuf, 0, 64 );
3451 memset( decbuf, 0, 64 );
3455 fct_chk( NULL != cipher_info );
3479 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3486 fct_chk( outlen == enclen );
3489 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3496 fct_chk( outlen == 0 );
3501 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3508 fct_chk( enclen == outlen );
3511 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3518 fct_chk( outlen == 0 );
3522 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3529 #ifdef POLARSSL_DES_C
3531 FCT_TEST_BGN(des3_encrypt_and_decrypt_9_bytes)
3533 unsigned char key[32];
3534 unsigned char iv[16];
3540 unsigned char inbuf[64];
3541 unsigned char encbuf[64];
3542 unsigned char decbuf[64];
3547 memset( key, 0, 32 );
3548 memset( iv , 0, 16 );
3550 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3551 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3553 memset( inbuf, 5, 64 );
3554 memset( encbuf, 0, 64 );
3555 memset( decbuf, 0, 64 );
3559 fct_chk( NULL != cipher_info );
3583 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3590 fct_chk( outlen == enclen );
3593 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3600 fct_chk( outlen == 0 );
3605 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3612 fct_chk( enclen == outlen );
3615 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3622 fct_chk( outlen == 0 );
3626 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3633 #ifdef POLARSSL_DES_C
3635 FCT_TEST_BGN(des3_encrypt_and_decrypt_15_bytes)
3637 unsigned char key[32];
3638 unsigned char iv[16];
3644 unsigned char inbuf[64];
3645 unsigned char encbuf[64];
3646 unsigned char decbuf[64];
3651 memset( key, 0, 32 );
3652 memset( iv , 0, 16 );
3654 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3655 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3657 memset( inbuf, 5, 64 );
3658 memset( encbuf, 0, 64 );
3659 memset( decbuf, 0, 64 );
3663 fct_chk( NULL != cipher_info );
3687 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3694 fct_chk( outlen == enclen );
3697 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3704 fct_chk( outlen == 0 );
3709 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3716 fct_chk( enclen == outlen );
3719 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3726 fct_chk( outlen == 0 );
3730 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3737 #ifdef POLARSSL_DES_C
3739 FCT_TEST_BGN(des3_encrypt_and_decrypt_16_bytes)
3741 unsigned char key[32];
3742 unsigned char iv[16];
3748 unsigned char inbuf[64];
3749 unsigned char encbuf[64];
3750 unsigned char decbuf[64];
3755 memset( key, 0, 32 );
3756 memset( iv , 0, 16 );
3758 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3759 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3761 memset( inbuf, 5, 64 );
3762 memset( encbuf, 0, 64 );
3763 memset( decbuf, 0, 64 );
3767 fct_chk( NULL != cipher_info );
3791 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3798 fct_chk( outlen == enclen );
3801 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3808 fct_chk( outlen == 0 );
3813 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3820 fct_chk( enclen == outlen );
3823 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3830 fct_chk( outlen == 0 );
3834 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3841 #ifdef POLARSSL_DES_C
3843 FCT_TEST_BGN(des3_encrypt_and_decrypt_17_bytes)
3845 unsigned char key[32];
3846 unsigned char iv[16];
3852 unsigned char inbuf[64];
3853 unsigned char encbuf[64];
3854 unsigned char decbuf[64];
3859 memset( key, 0, 32 );
3860 memset( iv , 0, 16 );
3862 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3863 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3865 memset( inbuf, 5, 64 );
3866 memset( encbuf, 0, 64 );
3867 memset( decbuf, 0, 64 );
3871 fct_chk( NULL != cipher_info );
3895 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
3902 fct_chk( outlen == enclen );
3905 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
3912 fct_chk( outlen == 0 );
3917 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
3924 fct_chk( enclen == outlen );
3927 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
3934 fct_chk( outlen == 0 );
3938 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
3945 #ifdef POLARSSL_DES_C
3947 FCT_TEST_BGN(des3_encrypt_and_decrypt_31_bytes)
3949 unsigned char key[32];
3950 unsigned char iv[16];
3956 unsigned char inbuf[64];
3957 unsigned char encbuf[64];
3958 unsigned char decbuf[64];
3963 memset( key, 0, 32 );
3964 memset( iv , 0, 16 );
3966 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
3967 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
3969 memset( inbuf, 5, 64 );
3970 memset( encbuf, 0, 64 );
3971 memset( decbuf, 0, 64 );
3975 fct_chk( NULL != cipher_info );
3999 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4006 fct_chk( outlen == enclen );
4009 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4016 fct_chk( outlen == 0 );
4021 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4028 fct_chk( enclen == outlen );
4031 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4038 fct_chk( outlen == 0 );
4042 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4049 #ifdef POLARSSL_DES_C
4051 FCT_TEST_BGN(des3_encrypt_and_decrypt_32_bytes)
4053 unsigned char key[32];
4054 unsigned char iv[16];
4060 unsigned char inbuf[64];
4061 unsigned char encbuf[64];
4062 unsigned char decbuf[64];
4067 memset( key, 0, 32 );
4068 memset( iv , 0, 16 );
4070 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4071 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4073 memset( inbuf, 5, 64 );
4074 memset( encbuf, 0, 64 );
4075 memset( decbuf, 0, 64 );
4079 fct_chk( NULL != cipher_info );
4103 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4110 fct_chk( outlen == enclen );
4113 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4120 fct_chk( outlen == 0 );
4125 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4132 fct_chk( enclen == outlen );
4135 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4142 fct_chk( outlen == 0 );
4146 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4153 #ifdef POLARSSL_DES_C
4155 FCT_TEST_BGN(des3_encrypt_and_decrypt_32_bytes)
4157 unsigned char key[32];
4158 unsigned char iv[16];
4164 unsigned char inbuf[64];
4165 unsigned char encbuf[64];
4166 unsigned char decbuf[64];
4171 memset( key, 0, 32 );
4172 memset( iv , 0, 16 );
4174 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4175 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4177 memset( inbuf, 5, 64 );
4178 memset( encbuf, 0, 64 );
4179 memset( decbuf, 0, 64 );
4183 fct_chk( NULL != cipher_info );
4207 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4214 fct_chk( outlen == enclen );
4217 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4224 fct_chk( outlen == 0 );
4229 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4236 fct_chk( enclen == outlen );
4239 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4246 fct_chk( outlen == 0 );
4250 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4257 #ifdef POLARSSL_DES_C
4259 FCT_TEST_BGN(des3_encrypt_and_decrypt_47_bytes)
4261 unsigned char key[32];
4262 unsigned char iv[16];
4268 unsigned char inbuf[64];
4269 unsigned char encbuf[64];
4270 unsigned char decbuf[64];
4275 memset( key, 0, 32 );
4276 memset( iv , 0, 16 );
4278 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4279 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4281 memset( inbuf, 5, 64 );
4282 memset( encbuf, 0, 64 );
4283 memset( decbuf, 0, 64 );
4287 fct_chk( NULL != cipher_info );
4311 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4318 fct_chk( outlen == enclen );
4321 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4328 fct_chk( outlen == 0 );
4333 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4340 fct_chk( enclen == outlen );
4343 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4350 fct_chk( outlen == 0 );
4354 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4361 #ifdef POLARSSL_DES_C
4363 FCT_TEST_BGN(des3_encrypt_and_decrypt_48_bytes)
4365 unsigned char key[32];
4366 unsigned char iv[16];
4372 unsigned char inbuf[64];
4373 unsigned char encbuf[64];
4374 unsigned char decbuf[64];
4379 memset( key, 0, 32 );
4380 memset( iv , 0, 16 );
4382 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4383 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4385 memset( inbuf, 5, 64 );
4386 memset( encbuf, 0, 64 );
4387 memset( decbuf, 0, 64 );
4391 fct_chk( NULL != cipher_info );
4415 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4422 fct_chk( outlen == enclen );
4425 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4432 fct_chk( outlen == 0 );
4437 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4444 fct_chk( enclen == outlen );
4447 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4454 fct_chk( outlen == 0 );
4458 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4465 #ifdef POLARSSL_DES_C
4467 FCT_TEST_BGN(des3_encrypt_and_decrypt_49_bytes)
4469 unsigned char key[32];
4470 unsigned char iv[16];
4476 unsigned char inbuf[64];
4477 unsigned char encbuf[64];
4478 unsigned char decbuf[64];
4483 memset( key, 0, 32 );
4484 memset( iv , 0, 16 );
4486 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4487 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4489 memset( inbuf, 5, 64 );
4490 memset( encbuf, 0, 64 );
4491 memset( decbuf, 0, 64 );
4495 fct_chk( NULL != cipher_info );
4519 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
4526 fct_chk( outlen == enclen );
4529 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
4536 fct_chk( outlen == 0 );
4541 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4548 fct_chk( enclen == outlen );
4551 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4558 fct_chk( outlen == 0 );
4562 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4569 #ifdef POLARSSL_DES_C
4571 FCT_TEST_BGN(des3_encrypt_and_decrypt_0_bytes_in_multiple_parts)
4572 size_t first_length = 0;
4573 size_t second_length = 0;
4574 size_t length = first_length + second_length;
4575 unsigned char key[32];
4576 unsigned char iv[16];
4582 unsigned char inbuf[64];
4583 unsigned char encbuf[64];
4584 unsigned char decbuf[64];
4587 size_t totaloutlen = 0;
4590 memset( key, 0, 32 );
4591 memset( iv , 0, 16 );
4593 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4594 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4596 memset( inbuf, 5, 64 );
4597 memset( encbuf, 0, 64 );
4598 memset( decbuf, 0, 64 );
4602 fct_chk( NULL != cipher_info);
4624 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4625 totaloutlen = outlen;
4626 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4627 totaloutlen += outlen;
4634 fct_chk( totaloutlen == enclen );
4636 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4637 totaloutlen += outlen;
4644 fct_chk( outlen == 0 );
4648 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4655 fct_chk( enclen == outlen );
4657 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4664 fct_chk( outlen == 0 );
4668 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4675 #ifdef POLARSSL_DES_C
4677 FCT_TEST_BGN(des3_encrypt_and_decrypt_1_bytes_in_multiple_parts_1)
4678 size_t first_length = 1;
4679 size_t second_length = 0;
4680 size_t length = first_length + second_length;
4681 unsigned char key[32];
4682 unsigned char iv[16];
4688 unsigned char inbuf[64];
4689 unsigned char encbuf[64];
4690 unsigned char decbuf[64];
4693 size_t totaloutlen = 0;
4696 memset( key, 0, 32 );
4697 memset( iv , 0, 16 );
4699 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4700 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4702 memset( inbuf, 5, 64 );
4703 memset( encbuf, 0, 64 );
4704 memset( decbuf, 0, 64 );
4708 fct_chk( NULL != cipher_info);
4730 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4731 totaloutlen = outlen;
4732 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4733 totaloutlen += outlen;
4740 fct_chk( totaloutlen == enclen );
4742 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4743 totaloutlen += outlen;
4750 fct_chk( outlen == 0 );
4754 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4761 fct_chk( enclen == outlen );
4763 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4770 fct_chk( outlen == 0 );
4774 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4781 #ifdef POLARSSL_DES_C
4783 FCT_TEST_BGN(des3_encrypt_and_decrypt_1_bytes_in_multiple_parts_2)
4784 size_t first_length = 0;
4785 size_t second_length = 1;
4786 size_t length = first_length + second_length;
4787 unsigned char key[32];
4788 unsigned char iv[16];
4794 unsigned char inbuf[64];
4795 unsigned char encbuf[64];
4796 unsigned char decbuf[64];
4799 size_t totaloutlen = 0;
4802 memset( key, 0, 32 );
4803 memset( iv , 0, 16 );
4805 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4806 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4808 memset( inbuf, 5, 64 );
4809 memset( encbuf, 0, 64 );
4810 memset( decbuf, 0, 64 );
4814 fct_chk( NULL != cipher_info);
4836 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4837 totaloutlen = outlen;
4838 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4839 totaloutlen += outlen;
4846 fct_chk( totaloutlen == enclen );
4848 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4849 totaloutlen += outlen;
4856 fct_chk( outlen == 0 );
4860 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4867 fct_chk( enclen == outlen );
4869 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4876 fct_chk( outlen == 0 );
4880 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4887 #ifdef POLARSSL_DES_C
4889 FCT_TEST_BGN(des3_encrypt_and_decrypt_16_bytes_in_multiple_parts_1)
4890 size_t first_length = 16;
4891 size_t second_length = 0;
4892 size_t length = first_length + second_length;
4893 unsigned char key[32];
4894 unsigned char iv[16];
4900 unsigned char inbuf[64];
4901 unsigned char encbuf[64];
4902 unsigned char decbuf[64];
4905 size_t totaloutlen = 0;
4908 memset( key, 0, 32 );
4909 memset( iv , 0, 16 );
4911 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
4912 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
4914 memset( inbuf, 5, 64 );
4915 memset( encbuf, 0, 64 );
4916 memset( decbuf, 0, 64 );
4920 fct_chk( NULL != cipher_info);
4942 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
4943 totaloutlen = outlen;
4944 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
4945 totaloutlen += outlen;
4952 fct_chk( totaloutlen == enclen );
4954 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
4955 totaloutlen += outlen;
4962 fct_chk( outlen == 0 );
4966 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
4973 fct_chk( enclen == outlen );
4975 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
4982 fct_chk( outlen == 0 );
4986 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
4993 #ifdef POLARSSL_DES_C
4995 FCT_TEST_BGN(des3_encrypt_and_decrypt_16_bytes_in_multiple_parts_2)
4996 size_t first_length = 0;
4997 size_t second_length = 16;
4998 size_t length = first_length + second_length;
4999 unsigned char key[32];
5000 unsigned char iv[16];
5006 unsigned char inbuf[64];
5007 unsigned char encbuf[64];
5008 unsigned char decbuf[64];
5011 size_t totaloutlen = 0;
5014 memset( key, 0, 32 );
5015 memset( iv , 0, 16 );
5017 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5018 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5020 memset( inbuf, 5, 64 );
5021 memset( encbuf, 0, 64 );
5022 memset( decbuf, 0, 64 );
5026 fct_chk( NULL != cipher_info);
5048 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5049 totaloutlen = outlen;
5050 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5051 totaloutlen += outlen;
5058 fct_chk( totaloutlen == enclen );
5060 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5061 totaloutlen += outlen;
5068 fct_chk( outlen == 0 );
5072 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5079 fct_chk( enclen == outlen );
5081 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5088 fct_chk( outlen == 0 );
5092 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5099 #ifdef POLARSSL_DES_C
5101 FCT_TEST_BGN(des3_encrypt_and_decrypt_16_bytes_in_multiple_parts_3)
5102 size_t first_length = 1;
5103 size_t second_length = 15;
5104 size_t length = first_length + second_length;
5105 unsigned char key[32];
5106 unsigned char iv[16];
5112 unsigned char inbuf[64];
5113 unsigned char encbuf[64];
5114 unsigned char decbuf[64];
5117 size_t totaloutlen = 0;
5120 memset( key, 0, 32 );
5121 memset( iv , 0, 16 );
5123 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5124 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5126 memset( inbuf, 5, 64 );
5127 memset( encbuf, 0, 64 );
5128 memset( decbuf, 0, 64 );
5132 fct_chk( NULL != cipher_info);
5154 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5155 totaloutlen = outlen;
5156 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5157 totaloutlen += outlen;
5164 fct_chk( totaloutlen == enclen );
5166 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5167 totaloutlen += outlen;
5174 fct_chk( outlen == 0 );
5178 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5185 fct_chk( enclen == outlen );
5187 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5194 fct_chk( outlen == 0 );
5198 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5205 #ifdef POLARSSL_DES_C
5207 FCT_TEST_BGN(des3_encrypt_and_decrypt_16_bytes_in_multiple_parts_4)
5208 size_t first_length = 15;
5209 size_t second_length = 1;
5210 size_t length = first_length + second_length;
5211 unsigned char key[32];
5212 unsigned char iv[16];
5218 unsigned char inbuf[64];
5219 unsigned char encbuf[64];
5220 unsigned char decbuf[64];
5223 size_t totaloutlen = 0;
5226 memset( key, 0, 32 );
5227 memset( iv , 0, 16 );
5229 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5230 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5232 memset( inbuf, 5, 64 );
5233 memset( encbuf, 0, 64 );
5234 memset( decbuf, 0, 64 );
5238 fct_chk( NULL != cipher_info);
5260 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5261 totaloutlen = outlen;
5262 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5263 totaloutlen += outlen;
5270 fct_chk( totaloutlen == enclen );
5272 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5273 totaloutlen += outlen;
5280 fct_chk( outlen == 0 );
5284 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5291 fct_chk( enclen == outlen );
5293 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5300 fct_chk( outlen == 0 );
5304 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5311 #ifdef POLARSSL_DES_C
5313 FCT_TEST_BGN(des3_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
5314 size_t first_length = 15;
5315 size_t second_length = 7;
5316 size_t length = first_length + second_length;
5317 unsigned char key[32];
5318 unsigned char iv[16];
5324 unsigned char inbuf[64];
5325 unsigned char encbuf[64];
5326 unsigned char decbuf[64];
5329 size_t totaloutlen = 0;
5332 memset( key, 0, 32 );
5333 memset( iv , 0, 16 );
5335 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5336 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5338 memset( inbuf, 5, 64 );
5339 memset( encbuf, 0, 64 );
5340 memset( decbuf, 0, 64 );
5344 fct_chk( NULL != cipher_info);
5366 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5367 totaloutlen = outlen;
5368 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5369 totaloutlen += outlen;
5376 fct_chk( totaloutlen == enclen );
5378 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5379 totaloutlen += outlen;
5386 fct_chk( outlen == 0 );
5390 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5397 fct_chk( enclen == outlen );
5399 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5406 fct_chk( outlen == 0 );
5410 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5417 #ifdef POLARSSL_DES_C
5419 FCT_TEST_BGN(des3_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
5420 size_t first_length = 16;
5421 size_t second_length = 6;
5422 size_t length = first_length + second_length;
5423 unsigned char key[32];
5424 unsigned char iv[16];
5430 unsigned char inbuf[64];
5431 unsigned char encbuf[64];
5432 unsigned char decbuf[64];
5435 size_t totaloutlen = 0;
5438 memset( key, 0, 32 );
5439 memset( iv , 0, 16 );
5441 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5442 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5444 memset( inbuf, 5, 64 );
5445 memset( encbuf, 0, 64 );
5446 memset( decbuf, 0, 64 );
5450 fct_chk( NULL != cipher_info);
5472 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5473 totaloutlen = outlen;
5474 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5475 totaloutlen += outlen;
5482 fct_chk( totaloutlen == enclen );
5484 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5485 totaloutlen += outlen;
5492 fct_chk( outlen == 0 );
5496 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5503 fct_chk( enclen == outlen );
5505 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5512 fct_chk( outlen == 0 );
5516 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5523 #ifdef POLARSSL_DES_C
5525 FCT_TEST_BGN(des3_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
5526 size_t first_length = 17;
5527 size_t second_length = 6;
5528 size_t length = first_length + second_length;
5529 unsigned char key[32];
5530 unsigned char iv[16];
5536 unsigned char inbuf[64];
5537 unsigned char encbuf[64];
5538 unsigned char decbuf[64];
5541 size_t totaloutlen = 0;
5544 memset( key, 0, 32 );
5545 memset( iv , 0, 16 );
5547 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5548 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5550 memset( inbuf, 5, 64 );
5551 memset( encbuf, 0, 64 );
5552 memset( decbuf, 0, 64 );
5556 fct_chk( NULL != cipher_info);
5578 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5579 totaloutlen = outlen;
5580 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5581 totaloutlen += outlen;
5588 fct_chk( totaloutlen == enclen );
5590 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5591 totaloutlen += outlen;
5598 fct_chk( outlen == 0 );
5602 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5609 fct_chk( enclen == outlen );
5611 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5618 fct_chk( outlen == 0 );
5622 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5629 #ifdef POLARSSL_DES_C
5631 FCT_TEST_BGN(des3_encrypt_and_decrypt_32_bytes_in_multiple_parts_1)
5632 size_t first_length = 16;
5633 size_t second_length = 16;
5634 size_t length = first_length + second_length;
5635 unsigned char key[32];
5636 unsigned char iv[16];
5642 unsigned char inbuf[64];
5643 unsigned char encbuf[64];
5644 unsigned char decbuf[64];
5647 size_t totaloutlen = 0;
5650 memset( key, 0, 32 );
5651 memset( iv , 0, 16 );
5653 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5654 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5656 memset( inbuf, 5, 64 );
5657 memset( encbuf, 0, 64 );
5658 memset( decbuf, 0, 64 );
5662 fct_chk( NULL != cipher_info);
5684 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
5685 totaloutlen = outlen;
5686 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
5687 totaloutlen += outlen;
5694 fct_chk( totaloutlen == enclen );
5696 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
5697 totaloutlen += outlen;
5704 fct_chk( outlen == 0 );
5708 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5715 fct_chk( enclen == outlen );
5717 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5724 fct_chk( outlen == 0 );
5728 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5735 #ifdef POLARSSL_DES_C
5737 FCT_TEST_BGN(des3_encrypt_and_decrypt_0_bytes)
5739 unsigned char key[32];
5740 unsigned char iv[16];
5746 unsigned char inbuf[64];
5747 unsigned char encbuf[64];
5748 unsigned char decbuf[64];
5753 memset( key, 0, 32 );
5754 memset( iv , 0, 16 );
5756 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5757 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5759 memset( inbuf, 5, 64 );
5760 memset( encbuf, 0, 64 );
5761 memset( decbuf, 0, 64 );
5765 fct_chk( NULL != cipher_info );
5789 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
5796 fct_chk( outlen == enclen );
5799 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
5806 fct_chk( outlen == 0 );
5811 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5818 fct_chk( enclen == outlen );
5821 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5828 fct_chk( outlen == 0 );
5832 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5839 #ifdef POLARSSL_DES_C
5841 FCT_TEST_BGN(des3_encrypt_and_decrypt_1_byte)
5843 unsigned char key[32];
5844 unsigned char iv[16];
5850 unsigned char inbuf[64];
5851 unsigned char encbuf[64];
5852 unsigned char decbuf[64];
5857 memset( key, 0, 32 );
5858 memset( iv , 0, 16 );
5860 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5861 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5863 memset( inbuf, 5, 64 );
5864 memset( encbuf, 0, 64 );
5865 memset( decbuf, 0, 64 );
5869 fct_chk( NULL != cipher_info );
5893 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
5900 fct_chk( outlen == enclen );
5903 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
5910 fct_chk( outlen == 0 );
5915 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
5922 fct_chk( enclen == outlen );
5925 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
5932 fct_chk( outlen == 0 );
5936 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
5943 #ifdef POLARSSL_DES_C
5945 FCT_TEST_BGN(des3_encrypt_and_decrypt_2_bytes)
5947 unsigned char key[32];
5948 unsigned char iv[16];
5954 unsigned char inbuf[64];
5955 unsigned char encbuf[64];
5956 unsigned char decbuf[64];
5961 memset( key, 0, 32 );
5962 memset( iv , 0, 16 );
5964 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
5965 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
5967 memset( inbuf, 5, 64 );
5968 memset( encbuf, 0, 64 );
5969 memset( decbuf, 0, 64 );
5973 fct_chk( NULL != cipher_info );
5997 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6004 fct_chk( outlen == enclen );
6007 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6014 fct_chk( outlen == 0 );
6019 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6026 fct_chk( enclen == outlen );
6029 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6036 fct_chk( outlen == 0 );
6040 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6047 #ifdef POLARSSL_DES_C
6049 FCT_TEST_BGN(des3_encrypt_and_decrypt_7_bytes)
6051 unsigned char key[32];
6052 unsigned char iv[16];
6058 unsigned char inbuf[64];
6059 unsigned char encbuf[64];
6060 unsigned char decbuf[64];
6065 memset( key, 0, 32 );
6066 memset( iv , 0, 16 );
6068 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6069 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6071 memset( inbuf, 5, 64 );
6072 memset( encbuf, 0, 64 );
6073 memset( decbuf, 0, 64 );
6077 fct_chk( NULL != cipher_info );
6101 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6108 fct_chk( outlen == enclen );
6111 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6118 fct_chk( outlen == 0 );
6123 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6130 fct_chk( enclen == outlen );
6133 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6140 fct_chk( outlen == 0 );
6144 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6151 #ifdef POLARSSL_DES_C
6153 FCT_TEST_BGN(des3_encrypt_and_decrypt_8_bytes)
6155 unsigned char key[32];
6156 unsigned char iv[16];
6162 unsigned char inbuf[64];
6163 unsigned char encbuf[64];
6164 unsigned char decbuf[64];
6169 memset( key, 0, 32 );
6170 memset( iv , 0, 16 );
6172 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6173 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6175 memset( inbuf, 5, 64 );
6176 memset( encbuf, 0, 64 );
6177 memset( decbuf, 0, 64 );
6181 fct_chk( NULL != cipher_info );
6205 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6212 fct_chk( outlen == enclen );
6215 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6222 fct_chk( outlen == 0 );
6227 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6234 fct_chk( enclen == outlen );
6237 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6244 fct_chk( outlen == 0 );
6248 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6255 #ifdef POLARSSL_DES_C
6257 FCT_TEST_BGN(des3_encrypt_and_decrypt_9_bytes)
6259 unsigned char key[32];
6260 unsigned char iv[16];
6266 unsigned char inbuf[64];
6267 unsigned char encbuf[64];
6268 unsigned char decbuf[64];
6273 memset( key, 0, 32 );
6274 memset( iv , 0, 16 );
6276 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6277 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6279 memset( inbuf, 5, 64 );
6280 memset( encbuf, 0, 64 );
6281 memset( decbuf, 0, 64 );
6285 fct_chk( NULL != cipher_info );
6309 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6316 fct_chk( outlen == enclen );
6319 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6326 fct_chk( outlen == 0 );
6331 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6338 fct_chk( enclen == outlen );
6341 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6348 fct_chk( outlen == 0 );
6352 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6359 #ifdef POLARSSL_DES_C
6361 FCT_TEST_BGN(des3_encrypt_and_decrypt_15_bytes)
6363 unsigned char key[32];
6364 unsigned char iv[16];
6370 unsigned char inbuf[64];
6371 unsigned char encbuf[64];
6372 unsigned char decbuf[64];
6377 memset( key, 0, 32 );
6378 memset( iv , 0, 16 );
6380 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6381 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6383 memset( inbuf, 5, 64 );
6384 memset( encbuf, 0, 64 );
6385 memset( decbuf, 0, 64 );
6389 fct_chk( NULL != cipher_info );
6413 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6420 fct_chk( outlen == enclen );
6423 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6430 fct_chk( outlen == 0 );
6435 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6442 fct_chk( enclen == outlen );
6445 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6452 fct_chk( outlen == 0 );
6456 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6463 #ifdef POLARSSL_DES_C
6465 FCT_TEST_BGN(des3_encrypt_and_decrypt_16_bytes)
6467 unsigned char key[32];
6468 unsigned char iv[16];
6474 unsigned char inbuf[64];
6475 unsigned char encbuf[64];
6476 unsigned char decbuf[64];
6481 memset( key, 0, 32 );
6482 memset( iv , 0, 16 );
6484 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6485 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6487 memset( inbuf, 5, 64 );
6488 memset( encbuf, 0, 64 );
6489 memset( decbuf, 0, 64 );
6493 fct_chk( NULL != cipher_info );
6517 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6524 fct_chk( outlen == enclen );
6527 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6534 fct_chk( outlen == 0 );
6539 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6546 fct_chk( enclen == outlen );
6549 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6556 fct_chk( outlen == 0 );
6560 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6567 #ifdef POLARSSL_DES_C
6569 FCT_TEST_BGN(des3_encrypt_and_decrypt_17_bytes)
6571 unsigned char key[32];
6572 unsigned char iv[16];
6578 unsigned char inbuf[64];
6579 unsigned char encbuf[64];
6580 unsigned char decbuf[64];
6585 memset( key, 0, 32 );
6586 memset( iv , 0, 16 );
6588 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6589 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6591 memset( inbuf, 5, 64 );
6592 memset( encbuf, 0, 64 );
6593 memset( decbuf, 0, 64 );
6597 fct_chk( NULL != cipher_info );
6621 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6628 fct_chk( outlen == enclen );
6631 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6638 fct_chk( outlen == 0 );
6643 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6650 fct_chk( enclen == outlen );
6653 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6660 fct_chk( outlen == 0 );
6664 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6671 #ifdef POLARSSL_DES_C
6673 FCT_TEST_BGN(des3_encrypt_and_decrypt_31_bytes)
6675 unsigned char key[32];
6676 unsigned char iv[16];
6682 unsigned char inbuf[64];
6683 unsigned char encbuf[64];
6684 unsigned char decbuf[64];
6689 memset( key, 0, 32 );
6690 memset( iv , 0, 16 );
6692 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6693 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6695 memset( inbuf, 5, 64 );
6696 memset( encbuf, 0, 64 );
6697 memset( decbuf, 0, 64 );
6701 fct_chk( NULL != cipher_info );
6725 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6732 fct_chk( outlen == enclen );
6735 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6742 fct_chk( outlen == 0 );
6747 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6754 fct_chk( enclen == outlen );
6757 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6764 fct_chk( outlen == 0 );
6768 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6775 #ifdef POLARSSL_DES_C
6777 FCT_TEST_BGN(des3_encrypt_and_decrypt_32_bytes)
6779 unsigned char key[32];
6780 unsigned char iv[16];
6786 unsigned char inbuf[64];
6787 unsigned char encbuf[64];
6788 unsigned char decbuf[64];
6793 memset( key, 0, 32 );
6794 memset( iv , 0, 16 );
6796 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6797 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6799 memset( inbuf, 5, 64 );
6800 memset( encbuf, 0, 64 );
6801 memset( decbuf, 0, 64 );
6805 fct_chk( NULL != cipher_info );
6829 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6836 fct_chk( outlen == enclen );
6839 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6846 fct_chk( outlen == 0 );
6851 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6858 fct_chk( enclen == outlen );
6861 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6868 fct_chk( outlen == 0 );
6872 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6879 #ifdef POLARSSL_DES_C
6881 FCT_TEST_BGN(des3_encrypt_and_decrypt_32_bytes)
6883 unsigned char key[32];
6884 unsigned char iv[16];
6890 unsigned char inbuf[64];
6891 unsigned char encbuf[64];
6892 unsigned char decbuf[64];
6897 memset( key, 0, 32 );
6898 memset( iv , 0, 16 );
6900 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
6901 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
6903 memset( inbuf, 5, 64 );
6904 memset( encbuf, 0, 64 );
6905 memset( decbuf, 0, 64 );
6909 fct_chk( NULL != cipher_info );
6933 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
6940 fct_chk( outlen == enclen );
6943 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
6950 fct_chk( outlen == 0 );
6955 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
6962 fct_chk( enclen == outlen );
6965 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
6972 fct_chk( outlen == 0 );
6976 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
6983 #ifdef POLARSSL_DES_C
6985 FCT_TEST_BGN(des3_encrypt_and_decrypt_47_bytes)
6987 unsigned char key[32];
6988 unsigned char iv[16];
6994 unsigned char inbuf[64];
6995 unsigned char encbuf[64];
6996 unsigned char decbuf[64];
7001 memset( key, 0, 32 );
7002 memset( iv , 0, 16 );
7004 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7005 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7007 memset( inbuf, 5, 64 );
7008 memset( encbuf, 0, 64 );
7009 memset( decbuf, 0, 64 );
7013 fct_chk( NULL != cipher_info );
7037 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
7044 fct_chk( outlen == enclen );
7047 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
7054 fct_chk( outlen == 0 );
7059 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7066 fct_chk( enclen == outlen );
7069 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7076 fct_chk( outlen == 0 );
7080 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7087 #ifdef POLARSSL_DES_C
7089 FCT_TEST_BGN(des3_encrypt_and_decrypt_48_bytes)
7091 unsigned char key[32];
7092 unsigned char iv[16];
7098 unsigned char inbuf[64];
7099 unsigned char encbuf[64];
7100 unsigned char decbuf[64];
7105 memset( key, 0, 32 );
7106 memset( iv , 0, 16 );
7108 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7109 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7111 memset( inbuf, 5, 64 );
7112 memset( encbuf, 0, 64 );
7113 memset( decbuf, 0, 64 );
7117 fct_chk( NULL != cipher_info );
7141 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
7148 fct_chk( outlen == enclen );
7151 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
7158 fct_chk( outlen == 0 );
7163 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7170 fct_chk( enclen == outlen );
7173 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7180 fct_chk( outlen == 0 );
7184 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7191 #ifdef POLARSSL_DES_C
7193 FCT_TEST_BGN(des3_encrypt_and_decrypt_49_bytes)
7195 unsigned char key[32];
7196 unsigned char iv[16];
7202 unsigned char inbuf[64];
7203 unsigned char encbuf[64];
7204 unsigned char decbuf[64];
7209 memset( key, 0, 32 );
7210 memset( iv , 0, 16 );
7212 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7213 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7215 memset( inbuf, 5, 64 );
7216 memset( encbuf, 0, 64 );
7217 memset( decbuf, 0, 64 );
7221 fct_chk( NULL != cipher_info );
7245 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, length, encbuf, &outlen ) );
7252 fct_chk( outlen == enclen );
7255 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + outlen, &outlen ) );
7262 fct_chk( outlen == 0 );
7267 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7274 fct_chk( enclen == outlen );
7277 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7284 fct_chk( outlen == 0 );
7288 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7295 #ifdef POLARSSL_DES_C
7297 FCT_TEST_BGN(des3_encrypt_and_decrypt_0_bytes_in_multiple_parts)
7298 size_t first_length = 0;
7299 size_t second_length = 0;
7300 size_t length = first_length + second_length;
7301 unsigned char key[32];
7302 unsigned char iv[16];
7308 unsigned char inbuf[64];
7309 unsigned char encbuf[64];
7310 unsigned char decbuf[64];
7313 size_t totaloutlen = 0;
7316 memset( key, 0, 32 );
7317 memset( iv , 0, 16 );
7319 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7320 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7322 memset( inbuf, 5, 64 );
7323 memset( encbuf, 0, 64 );
7324 memset( decbuf, 0, 64 );
7328 fct_chk( NULL != cipher_info);
7350 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7351 totaloutlen = outlen;
7352 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7353 totaloutlen += outlen;
7360 fct_chk( totaloutlen == enclen );
7362 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7363 totaloutlen += outlen;
7370 fct_chk( outlen == 0 );
7374 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7381 fct_chk( enclen == outlen );
7383 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7390 fct_chk( outlen == 0 );
7394 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7401 #ifdef POLARSSL_DES_C
7403 FCT_TEST_BGN(des3_encrypt_and_decrypt_1_bytes_in_multiple_parts_1)
7404 size_t first_length = 1;
7405 size_t second_length = 0;
7406 size_t length = first_length + second_length;
7407 unsigned char key[32];
7408 unsigned char iv[16];
7414 unsigned char inbuf[64];
7415 unsigned char encbuf[64];
7416 unsigned char decbuf[64];
7419 size_t totaloutlen = 0;
7422 memset( key, 0, 32 );
7423 memset( iv , 0, 16 );
7425 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7426 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7428 memset( inbuf, 5, 64 );
7429 memset( encbuf, 0, 64 );
7430 memset( decbuf, 0, 64 );
7434 fct_chk( NULL != cipher_info);
7456 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7457 totaloutlen = outlen;
7458 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7459 totaloutlen += outlen;
7466 fct_chk( totaloutlen == enclen );
7468 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7469 totaloutlen += outlen;
7476 fct_chk( outlen == 0 );
7480 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7487 fct_chk( enclen == outlen );
7489 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7496 fct_chk( outlen == 0 );
7500 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7507 #ifdef POLARSSL_DES_C
7509 FCT_TEST_BGN(des3_encrypt_and_decrypt_1_bytes_in_multiple_parts_2)
7510 size_t first_length = 0;
7511 size_t second_length = 1;
7512 size_t length = first_length + second_length;
7513 unsigned char key[32];
7514 unsigned char iv[16];
7520 unsigned char inbuf[64];
7521 unsigned char encbuf[64];
7522 unsigned char decbuf[64];
7525 size_t totaloutlen = 0;
7528 memset( key, 0, 32 );
7529 memset( iv , 0, 16 );
7531 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7532 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7534 memset( inbuf, 5, 64 );
7535 memset( encbuf, 0, 64 );
7536 memset( decbuf, 0, 64 );
7540 fct_chk( NULL != cipher_info);
7562 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7563 totaloutlen = outlen;
7564 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7565 totaloutlen += outlen;
7572 fct_chk( totaloutlen == enclen );
7574 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7575 totaloutlen += outlen;
7582 fct_chk( outlen == 0 );
7586 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7593 fct_chk( enclen == outlen );
7595 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7602 fct_chk( outlen == 0 );
7606 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7613 #ifdef POLARSSL_DES_C
7615 FCT_TEST_BGN(des3_encrypt_and_decrypt_16_bytes_in_multiple_parts_1)
7616 size_t first_length = 16;
7617 size_t second_length = 0;
7618 size_t length = first_length + second_length;
7619 unsigned char key[32];
7620 unsigned char iv[16];
7626 unsigned char inbuf[64];
7627 unsigned char encbuf[64];
7628 unsigned char decbuf[64];
7631 size_t totaloutlen = 0;
7634 memset( key, 0, 32 );
7635 memset( iv , 0, 16 );
7637 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7638 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7640 memset( inbuf, 5, 64 );
7641 memset( encbuf, 0, 64 );
7642 memset( decbuf, 0, 64 );
7646 fct_chk( NULL != cipher_info);
7668 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7669 totaloutlen = outlen;
7670 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7671 totaloutlen += outlen;
7678 fct_chk( totaloutlen == enclen );
7680 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7681 totaloutlen += outlen;
7688 fct_chk( outlen == 0 );
7692 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7699 fct_chk( enclen == outlen );
7701 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7708 fct_chk( outlen == 0 );
7712 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7719 #ifdef POLARSSL_DES_C
7721 FCT_TEST_BGN(des3_encrypt_and_decrypt_16_bytes_in_multiple_parts_2)
7722 size_t first_length = 0;
7723 size_t second_length = 16;
7724 size_t length = first_length + second_length;
7725 unsigned char key[32];
7726 unsigned char iv[16];
7732 unsigned char inbuf[64];
7733 unsigned char encbuf[64];
7734 unsigned char decbuf[64];
7737 size_t totaloutlen = 0;
7740 memset( key, 0, 32 );
7741 memset( iv , 0, 16 );
7743 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7744 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7746 memset( inbuf, 5, 64 );
7747 memset( encbuf, 0, 64 );
7748 memset( decbuf, 0, 64 );
7752 fct_chk( NULL != cipher_info);
7774 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7775 totaloutlen = outlen;
7776 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7777 totaloutlen += outlen;
7784 fct_chk( totaloutlen == enclen );
7786 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7787 totaloutlen += outlen;
7794 fct_chk( outlen == 0 );
7798 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7805 fct_chk( enclen == outlen );
7807 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7814 fct_chk( outlen == 0 );
7818 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7825 #ifdef POLARSSL_DES_C
7827 FCT_TEST_BGN(des3_encrypt_and_decrypt_16_bytes_in_multiple_parts_3)
7828 size_t first_length = 1;
7829 size_t second_length = 15;
7830 size_t length = first_length + second_length;
7831 unsigned char key[32];
7832 unsigned char iv[16];
7838 unsigned char inbuf[64];
7839 unsigned char encbuf[64];
7840 unsigned char decbuf[64];
7843 size_t totaloutlen = 0;
7846 memset( key, 0, 32 );
7847 memset( iv , 0, 16 );
7849 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7850 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7852 memset( inbuf, 5, 64 );
7853 memset( encbuf, 0, 64 );
7854 memset( decbuf, 0, 64 );
7858 fct_chk( NULL != cipher_info);
7880 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7881 totaloutlen = outlen;
7882 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7883 totaloutlen += outlen;
7890 fct_chk( totaloutlen == enclen );
7892 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7893 totaloutlen += outlen;
7900 fct_chk( outlen == 0 );
7904 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
7911 fct_chk( enclen == outlen );
7913 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
7920 fct_chk( outlen == 0 );
7924 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
7931 #ifdef POLARSSL_DES_C
7933 FCT_TEST_BGN(des3_encrypt_and_decrypt_16_bytes_in_multiple_parts_4)
7934 size_t first_length = 15;
7935 size_t second_length = 1;
7936 size_t length = first_length + second_length;
7937 unsigned char key[32];
7938 unsigned char iv[16];
7944 unsigned char inbuf[64];
7945 unsigned char encbuf[64];
7946 unsigned char decbuf[64];
7949 size_t totaloutlen = 0;
7952 memset( key, 0, 32 );
7953 memset( iv , 0, 16 );
7955 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
7956 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
7958 memset( inbuf, 5, 64 );
7959 memset( encbuf, 0, 64 );
7960 memset( decbuf, 0, 64 );
7964 fct_chk( NULL != cipher_info);
7986 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
7987 totaloutlen = outlen;
7988 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
7989 totaloutlen += outlen;
7996 fct_chk( totaloutlen == enclen );
7998 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
7999 totaloutlen += outlen;
8006 fct_chk( outlen == 0 );
8010 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8017 fct_chk( enclen == outlen );
8019 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8026 fct_chk( outlen == 0 );
8030 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8037 #ifdef POLARSSL_DES_C
8039 FCT_TEST_BGN(des3_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
8040 size_t first_length = 15;
8041 size_t second_length = 7;
8042 size_t length = first_length + second_length;
8043 unsigned char key[32];
8044 unsigned char iv[16];
8050 unsigned char inbuf[64];
8051 unsigned char encbuf[64];
8052 unsigned char decbuf[64];
8055 size_t totaloutlen = 0;
8058 memset( key, 0, 32 );
8059 memset( iv , 0, 16 );
8061 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8062 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8064 memset( inbuf, 5, 64 );
8065 memset( encbuf, 0, 64 );
8066 memset( decbuf, 0, 64 );
8070 fct_chk( NULL != cipher_info);
8092 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8093 totaloutlen = outlen;
8094 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8095 totaloutlen += outlen;
8102 fct_chk( totaloutlen == enclen );
8104 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8105 totaloutlen += outlen;
8112 fct_chk( outlen == 0 );
8116 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8123 fct_chk( enclen == outlen );
8125 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8132 fct_chk( outlen == 0 );
8136 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8143 #ifdef POLARSSL_DES_C
8145 FCT_TEST_BGN(des3_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
8146 size_t first_length = 16;
8147 size_t second_length = 6;
8148 size_t length = first_length + second_length;
8149 unsigned char key[32];
8150 unsigned char iv[16];
8156 unsigned char inbuf[64];
8157 unsigned char encbuf[64];
8158 unsigned char decbuf[64];
8161 size_t totaloutlen = 0;
8164 memset( key, 0, 32 );
8165 memset( iv , 0, 16 );
8167 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8168 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8170 memset( inbuf, 5, 64 );
8171 memset( encbuf, 0, 64 );
8172 memset( decbuf, 0, 64 );
8176 fct_chk( NULL != cipher_info);
8198 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8199 totaloutlen = outlen;
8200 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8201 totaloutlen += outlen;
8208 fct_chk( totaloutlen == enclen );
8210 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8211 totaloutlen += outlen;
8218 fct_chk( outlen == 0 );
8222 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8229 fct_chk( enclen == outlen );
8231 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8238 fct_chk( outlen == 0 );
8242 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8249 #ifdef POLARSSL_DES_C
8251 FCT_TEST_BGN(des3_encrypt_and_decrypt_22_bytes_in_multiple_parts_1)
8252 size_t first_length = 17;
8253 size_t second_length = 6;
8254 size_t length = first_length + second_length;
8255 unsigned char key[32];
8256 unsigned char iv[16];
8262 unsigned char inbuf[64];
8263 unsigned char encbuf[64];
8264 unsigned char decbuf[64];
8267 size_t totaloutlen = 0;
8270 memset( key, 0, 32 );
8271 memset( iv , 0, 16 );
8273 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8274 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8276 memset( inbuf, 5, 64 );
8277 memset( encbuf, 0, 64 );
8278 memset( decbuf, 0, 64 );
8282 fct_chk( NULL != cipher_info);
8304 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8305 totaloutlen = outlen;
8306 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8307 totaloutlen += outlen;
8314 fct_chk( totaloutlen == enclen );
8316 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8317 totaloutlen += outlen;
8324 fct_chk( outlen == 0 );
8328 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8335 fct_chk( enclen == outlen );
8337 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8344 fct_chk( outlen == 0 );
8348 fct_chk( 0 == memcmp(inbuf, decbuf, length) );
8355 #ifdef POLARSSL_DES_C
8357 FCT_TEST_BGN(des3_encrypt_and_decrypt_32_bytes_in_multiple_parts_1)
8358 size_t first_length = 16;
8359 size_t second_length = 16;
8360 size_t length = first_length + second_length;
8361 unsigned char key[32];
8362 unsigned char iv[16];
8368 unsigned char inbuf[64];
8369 unsigned char encbuf[64];
8370 unsigned char decbuf[64];
8373 size_t totaloutlen = 0;
8376 memset( key, 0, 32 );
8377 memset( iv , 0, 16 );
8379 memset( &ctx_dec, 0,
sizeof( ctx_dec ) );
8380 memset( &ctx_enc, 0,
sizeof( ctx_enc ) );
8382 memset( inbuf, 5, 64 );
8383 memset( encbuf, 0, 64 );
8384 memset( decbuf, 0, 64 );
8388 fct_chk( NULL != cipher_info);
8410 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf, first_length, encbuf, &outlen ) );
8411 totaloutlen = outlen;
8412 fct_chk( 0 ==
cipher_update( &ctx_enc, inbuf + first_length, second_length, encbuf + totaloutlen, &outlen ) );
8413 totaloutlen += outlen;
8420 fct_chk( totaloutlen == enclen );
8422 fct_chk( 0 ==
cipher_finish( &ctx_enc, encbuf + totaloutlen, &outlen ) );
8423 totaloutlen += outlen;
8430 fct_chk( outlen == 0 );
8434 fct_chk( 0 ==
cipher_update( &ctx_dec, encbuf, enclen, decbuf, &outlen ) );
8441 fct_chk( enclen == outlen );
8443 fct_chk( 0 ==
cipher_finish( &ctx_dec, decbuf + outlen, &outlen ) );
8450 fct_chk( outlen == 0 );
8454 fct_chk( 0 == memcmp(inbuf, decbuf, length) );