1 #if !defined(POLARSSL_CONFIG_FILE)
4 #include POLARSSL_CONFIG_FILE
11 #define POLARSSL_ECP_PF_UNKNOWN -1
15 #if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
19 #if defined(POLARSSL_PLATFORM_C)
22 #define polarssl_malloc malloc
23 #define polarssl_free free
28 typedef UINT32 uint32_t;
41 #define GET_UINT32_BE(n,b,i) \
43 (n) = ( (uint32_t) (b)[(i) ] << 24 ) \
44 | ( (uint32_t) (b)[(i) + 1] << 16 ) \
45 | ( (uint32_t) (b)[(i) + 2] << 8 ) \
46 | ( (uint32_t) (b)[(i) + 3] ); \
51 #define PUT_UINT32_BE(n,b,i) \
53 (b)[(i) ] = (unsigned char) ( (n) >> 24 ); \
54 (b)[(i) + 1] = (unsigned char) ( (n) >> 16 ); \
55 (b)[(i) + 2] = (unsigned char) ( (n) >> 8 ); \
56 (b)[(i) + 3] = (unsigned char) ( (n) ); \
60 static int unhexify(
unsigned char *obuf,
const char *ibuf)
63 int len = strlen(ibuf) / 2;
64 assert(!(strlen(ibuf) %1));
69 if( c >=
'0' && c <=
'9' )
71 else if( c >=
'a' && c <=
'f' )
73 else if( c >=
'A' && c <=
'F' )
79 if( c2 >=
'0' && c2 <=
'9' )
81 else if( c2 >=
'a' && c2 <=
'f' )
83 else if( c2 >=
'A' && c2 <=
'F' )
88 *obuf++ = ( c << 4 ) | c2;
94 static void hexify(
unsigned char *obuf,
const unsigned char *ibuf,
int len)
106 *obuf++ =
'a' + h - 10;
111 *obuf++ =
'a' + l - 10;
128 size_t actual_len = len != 0 ? len : 1;
133 memset( p, 0x00, actual_len );
152 *olen = strlen(ibuf) / 2;
158 assert( obuf != NULL );
174 static int rnd_std_rand(
void *rng_state,
unsigned char *output,
size_t len )
176 #if !defined(__OpenBSD__)
179 if( rng_state != NULL )
182 for( i = 0; i < len; ++i )
185 if( rng_state != NULL )
188 arc4random_buf( output, len );
199 static int rnd_zero_rand(
void *rng_state,
unsigned char *output,
size_t len )
201 if( rng_state != NULL )
204 memset( output, 0, len );
231 if( rng_state == NULL )
240 memcpy( output, info->
buf, use_len );
241 info->
buf += use_len;
245 if( len - use_len > 0 )
246 return(
rnd_std_rand( NULL, output + use_len, len - use_len ) );
275 uint32_t i, *k, sum, delta=0x9E3779B9;
276 unsigned char result[4], *out = output;
278 if( rng_state == NULL )
285 size_t use_len = ( len > 4 ) ? 4 : len;
288 for( i = 0; i < 32; i++ )
290 info->
v0 += (((info->
v1 << 4) ^ (info->
v1 >> 5)) + info->
v1) ^ (sum + k[sum & 3]);
292 info->
v1 += (((info->
v0 << 4) ^ (info->
v0 >> 5)) + info->
v0) ^ (sum + k[(sum>>11) & 3]);
296 memcpy( out, result, use_len );
308 #if defined(POLARSSL_PLATFORM_C)
311 #define polarssl_printf printf
312 #define polarssl_malloc malloc
313 #define polarssl_free free
318 #ifdef POLARSSL_ECP_C
320 #define TEST_SUITE_ACTIVE
322 static int test_assert(
int correct,
const char *test )
329 printf(
"FAILED\n" );
330 printf(
" %s\n", test );
335 #define TEST_ASSERT( TEST ) \
336 do { test_assert( (TEST) ? 1 : 0, #TEST ); \
337 if( test_errors) goto exit; \
342 if( (*str)[0] !=
'"' ||
343 (*str)[strlen( *str ) - 1] !=
'"' )
345 printf(
"Expected string (with \"\") for parameter and got: %s\n", *str );
350 (*str)[strlen( *str ) - 1] =
'\0';
362 for( i = 0; i < strlen( str ); i++ )
364 if( i == 0 && str[i] ==
'-' )
370 if( ( ( minus && i == 2 ) || ( !minus && i == 1 ) ) &&
371 str[i - 1] ==
'0' && str[i] ==
'x' )
377 if( ! ( ( str[i] >=
'0' && str[i] <=
'9' ) ||
378 ( hex && ( ( str[i] >=
'a' && str[i] <=
'f' ) ||
379 ( str[i] >=
'A' && str[i] <=
'F' ) ) ) ) )
389 *value = strtol( str, NULL, 16 );
391 *value = strtol( str, NULL, 10 );
396 if( strcmp( str,
"POLARSSL_ECP_DP_SECP192K1" ) == 0 )
401 if( strcmp( str,
"POLARSSL_ERR_ECP_INVALID_KEY" ) == 0 )
406 if( strcmp( str,
"POLARSSL_ECP_DP_SECP224K1" ) == 0 )
411 if( strcmp( str,
"-1" ) == 0 )
416 if( strcmp( str,
"POLARSSL_ECP_PF_UNCOMPRESSED" ) == 0 )
421 if( strcmp( str,
"POLARSSL_ERR_ECP_BAD_INPUT_DATA" ) == 0 )
426 if( strcmp( str,
"POLARSSL_ECP_PF_UNKNOWN" ) == 0 )
428 *value = ( POLARSSL_ECP_PF_UNKNOWN );
431 if( strcmp( str,
"POLARSSL_ECP_DP_SECP256R1" ) == 0 )
436 if( strcmp( str,
"POLARSSL_ECP_DP_SECP521R1" ) == 0 )
441 if( strcmp( str,
"POLARSSL_ECP_DP_BP256R1" ) == 0 )
446 if( strcmp( str,
"POLARSSL_ERR_ECP_BUFFER_TOO_SMALL" ) == 0 )
451 if( strcmp( str,
"POLARSSL_ECP_DP_SECP224R1" ) == 0 )
456 if( strcmp( str,
"POLARSSL_ECP_DP_SECP256K1" ) == 0 )
461 if( strcmp( str,
"POLARSSL_ECP_DP_SECP384R1" ) == 0 )
466 if( strcmp( str,
"POLARSSL_ECP_DP_BP384R1" ) == 0 )
471 if( strcmp( str,
"POLARSSL_ECP_DP_BP512R1" ) == 0 )
476 if( strcmp( str,
"POLARSSL_ECP_DP_M255" ) == 0 )
481 if( strcmp( str,
"POLARSSL_ERR_ECP_FEATURE_UNAVAILABLE" ) == 0 )
486 if( strcmp( str,
"POLARSSL_ECP_DP_SECP192R1" ) == 0 )
491 if( strcmp( str,
"POLARSSL_ECP_PF_COMPRESSED" ) == 0 )
498 printf(
"Expected integer for parameter and got: %s\n", str );
502 void test_suite_ecp_curve_info(
int id,
int tls_id,
int size,
char *name )
522 void test_suite_ecp_small_add(
int a_zero,
char *x_a,
char *y_a,
int b_zero,
char *x_b,
523 char *y_b,
int c_zero,
int x_c,
int y_c )
532 "47",
"4",
"17",
"42",
"13" ) == 0 );
569 void test_suite_ecp_small_sub(
int a_zero,
char *x_a,
char *y_a,
int b_zero,
char *x_b,
570 char *y_b,
int c_zero,
int x_c,
int y_c )
579 "47",
"4",
"17",
"42",
"13" ) == 0 );
606 void test_suite_ecp_small_mul(
int m_str,
int r_zero,
int x_r,
int y_r,
int ret )
619 "47",
"4",
"17",
"42",
"13" ) == 0 );
659 void test_suite_ecp_small_check_pub(
int x,
int y,
int z,
int ret )
668 "47",
"4",
"17",
"42",
"13" ) == 0 );
681 void test_suite_ecp_check_pub_mx(
int grp_id,
char *key_hex,
int ret )
701 void test_suite_ecp_test_vect(
int id,
char *dA_str,
char *xA_str,
char *yA_str,
702 char *dB_str,
char *xB_str,
char *yB_str,
char *xZ_str,
707 mpi dA, xA, yA, dB, xB, yB, xZ, yZ;
754 void test_suite_ecp_test_vec_x(
int id,
char *dA_hex,
char *xA_hex,
755 char *dB_hex,
char *xB_hex,
char *xS_hex )
759 mpi dA, xA, dB, xB, xS;
803 void test_suite_ecp_fast_mod(
int id,
char *N_str )
834 void test_suite_ecp_write_binary(
int id,
char *x,
char *y,
char *z,
int format,
835 char *out,
int blen,
int ret )
839 unsigned char buf[256], str[512];
842 memset( buf, 0,
sizeof( buf ) );
843 memset( str, 0,
sizeof( str ) );
854 &olen, buf, blen ) == ret );
859 TEST_ASSERT( strcasecmp( (
char *) str, out ) == 0 );
866 void test_suite_ecp_read_binary(
int id,
char *input,
char *x,
char *y,
char *z,
873 unsigned char buf[256];
875 memset( buf, 0,
sizeof( buf ) );
902 void test_suite_ecp_tls_read_point(
int id,
char *input,
char *x,
char *y,
char *z,
909 unsigned char buf[256];
910 const unsigned char *vbuf = buf;
912 memset( buf, 0,
sizeof( buf ) );
940 void test_suite_ecp_tls_write_read_point(
int id )
944 unsigned char buf[256];
945 const unsigned char *vbuf;
953 memset( buf, 0x00,
sizeof( buf ) ); vbuf = buf;
960 memset( buf, 0x00,
sizeof( buf ) ); vbuf = buf;
969 memset( buf, 0x00,
sizeof( buf ) ); vbuf = buf;
977 memset( buf, 0x00,
sizeof( buf ) ); vbuf = buf;
990 void test_suite_ecp_tls_read_group(
char *record,
int result,
int bits )
993 unsigned char buf[10];
994 const unsigned char *vbuf = buf;
998 memset( buf, 0x00,
sizeof( buf ) );
1015 void test_suite_ecp_tls_write_read_group(
int id )
1018 unsigned char buf[10];
1019 const unsigned char *vbuf = buf;
1025 memset( buf, 0x00,
sizeof( buf ) );
1044 void test_suite_ecp_check_privkey(
int id,
char *key_hex,
int ret )
1062 void test_suite_ecp_gen_keypair(
int id )
1088 void test_suite_ecp_gen_key(
int id )
1105 #ifdef POLARSSL_SELF_TEST
1106 void test_suite_ecp_selftest()
1124 if( strcmp( str,
"POLARSSL_ECP_DP_BP512R1_ENABLED" ) == 0 )
1126 #if defined(POLARSSL_ECP_DP_BP512R1_ENABLED)
1132 if( strcmp( str,
"POLARSSL_ECP_DP_SECP521R1_ENABLED" ) == 0 )
1134 #if defined(POLARSSL_ECP_DP_SECP521R1_ENABLED)
1140 if( strcmp( str,
"POLARSSL_ECP_DP_SECP256K1_ENABLED" ) == 0 )
1142 #if defined(POLARSSL_ECP_DP_SECP256K1_ENABLED)
1148 if( strcmp( str,
"POLARSSL_ECP_DP_BP384R1_ENABLED" ) == 0 )
1150 #if defined(POLARSSL_ECP_DP_BP384R1_ENABLED)
1156 if( strcmp( str,
"POLARSSL_ECP_DP_SECP224K1_ENABLED" ) == 0 )
1158 #if defined(POLARSSL_ECP_DP_SECP224K1_ENABLED)
1164 if( strcmp( str,
"POLARSSL_ECP_DP_SECP384R1_ENABLED" ) == 0 )
1166 #if defined(POLARSSL_ECP_DP_SECP384R1_ENABLED)
1172 if( strcmp( str,
"POLARSSL_ECP_DP_SECP192K1_ENABLED" ) == 0 )
1174 #if defined(POLARSSL_ECP_DP_SECP192K1_ENABLED)
1180 if( strcmp( str,
"POLARSSL_ECP_DP_BP256R1_ENABLED" ) == 0 )
1182 #if defined(POLARSSL_ECP_DP_BP256R1_ENABLED)
1188 if( strcmp( str,
"POLARSSL_ECP_DP_SECP224R1_ENABLED" ) == 0 )
1190 #if defined(POLARSSL_ECP_DP_SECP224R1_ENABLED)
1196 if( strcmp( str,
"POLARSSL_ECP_DP_SECP256R1_ENABLED" ) == 0 )
1198 #if defined(POLARSSL_ECP_DP_SECP256R1_ENABLED)
1204 if( strcmp( str,
"POLARSSL_ECP_DP_M255_ENABLED" ) == 0 )
1206 #if defined(POLARSSL_ECP_DP_M255_ENABLED)
1212 if( strcmp( str,
"POLARSSL_ECP_DP_SECP192R1_ENABLED" ) == 0 )
1214 #if defined(POLARSSL_ECP_DP_SECP192R1_ENABLED)
1231 #if defined(TEST_SUITE_ACTIVE)
1232 if( strcmp( params[0],
"ecp_curve_info" ) == 0 )
1238 char *param4 = params[4];
1242 fprintf( stderr,
"\nIncorrect argument count (%d != %d)\n", cnt, 5 );
1246 if(
verify_int( params[1], ¶m1 ) != 0 )
return( 2 );
1247 if(
verify_int( params[2], ¶m2 ) != 0 )
return( 2 );
1248 if(
verify_int( params[3], ¶m3 ) != 0 )
return( 2 );
1251 test_suite_ecp_curve_info( param1, param2, param3, param4 );
1257 if( strcmp( params[0],
"ecp_small_add" ) == 0 )
1261 char *param2 = params[2];
1262 char *param3 = params[3];
1264 char *param5 = params[5];
1265 char *param6 = params[6];
1272 fprintf( stderr,
"\nIncorrect argument count (%d != %d)\n", cnt, 10 );
1276 if(
verify_int( params[1], ¶m1 ) != 0 )
return( 2 );
1279 if(
verify_int( params[4], ¶m4 ) != 0 )
return( 2 );
1282 if(
verify_int( params[7], ¶m7 ) != 0 )
return( 2 );
1283 if(
verify_int( params[8], ¶m8 ) != 0 )
return( 2 );
1284 if(
verify_int( params[9], ¶m9 ) != 0 )
return( 2 );
1286 test_suite_ecp_small_add( param1, param2, param3, param4, param5, param6, param7, param8, param9 );
1292 if( strcmp( params[0],
"ecp_small_sub" ) == 0 )
1296 char *param2 = params[2];
1297 char *param3 = params[3];
1299 char *param5 = params[5];
1300 char *param6 = params[6];
1307 fprintf( stderr,
"\nIncorrect argument count (%d != %d)\n", cnt, 10 );
1311 if(
verify_int( params[1], ¶m1 ) != 0 )
return( 2 );
1314 if(
verify_int( params[4], ¶m4 ) != 0 )
return( 2 );
1317 if(
verify_int( params[7], ¶m7 ) != 0 )
return( 2 );
1318 if(
verify_int( params[8], ¶m8 ) != 0 )
return( 2 );
1319 if(
verify_int( params[9], ¶m9 ) != 0 )
return( 2 );
1321 test_suite_ecp_small_sub( param1, param2, param3, param4, param5, param6, param7, param8, param9 );
1327 if( strcmp( params[0],
"ecp_small_mul" ) == 0 )
1338 fprintf( stderr,
"\nIncorrect argument count (%d != %d)\n", cnt, 6 );
1342 if(
verify_int( params[1], ¶m1 ) != 0 )
return( 2 );
1343 if(
verify_int( params[2], ¶m2 ) != 0 )
return( 2 );
1344 if(
verify_int( params[3], ¶m3 ) != 0 )
return( 2 );
1345 if(
verify_int( params[4], ¶m4 ) != 0 )
return( 2 );
1346 if(
verify_int( params[5], ¶m5 ) != 0 )
return( 2 );
1348 test_suite_ecp_small_mul( param1, param2, param3, param4, param5 );
1354 if( strcmp( params[0],
"ecp_small_check_pub" ) == 0 )
1364 fprintf( stderr,
"\nIncorrect argument count (%d != %d)\n", cnt, 5 );
1368 if(
verify_int( params[1], ¶m1 ) != 0 )
return( 2 );
1369 if(
verify_int( params[2], ¶m2 ) != 0 )
return( 2 );
1370 if(
verify_int( params[3], ¶m3 ) != 0 )
return( 2 );
1371 if(
verify_int( params[4], ¶m4 ) != 0 )
return( 2 );
1373 test_suite_ecp_small_check_pub( param1, param2, param3, param4 );
1379 if( strcmp( params[0],
"ecp_check_pub_mx" ) == 0 )
1383 char *param2 = params[2];
1388 fprintf( stderr,
"\nIncorrect argument count (%d != %d)\n", cnt, 4 );
1392 if(
verify_int( params[1], ¶m1 ) != 0 )
return( 2 );
1394 if(
verify_int( params[3], ¶m3 ) != 0 )
return( 2 );
1396 test_suite_ecp_check_pub_mx( param1, param2, param3 );
1402 if( strcmp( params[0],
"ecp_test_vect" ) == 0 )
1406 char *param2 = params[2];
1407 char *param3 = params[3];
1408 char *param4 = params[4];
1409 char *param5 = params[5];
1410 char *param6 = params[6];
1411 char *param7 = params[7];
1412 char *param8 = params[8];
1413 char *param9 = params[9];
1417 fprintf( stderr,
"\nIncorrect argument count (%d != %d)\n", cnt, 10 );
1421 if(
verify_int( params[1], ¶m1 ) != 0 )
return( 2 );
1431 test_suite_ecp_test_vect( param1, param2, param3, param4, param5, param6, param7, param8, param9 );
1437 if( strcmp( params[0],
"ecp_test_vec_x" ) == 0 )
1441 char *param2 = params[2];
1442 char *param3 = params[3];
1443 char *param4 = params[4];
1444 char *param5 = params[5];
1445 char *param6 = params[6];
1449 fprintf( stderr,
"\nIncorrect argument count (%d != %d)\n", cnt, 7 );
1453 if(
verify_int( params[1], ¶m1 ) != 0 )
return( 2 );
1460 test_suite_ecp_test_vec_x( param1, param2, param3, param4, param5, param6 );
1466 if( strcmp( params[0],
"ecp_fast_mod" ) == 0 )
1470 char *param2 = params[2];
1474 fprintf( stderr,
"\nIncorrect argument count (%d != %d)\n", cnt, 3 );
1478 if(
verify_int( params[1], ¶m1 ) != 0 )
return( 2 );
1481 test_suite_ecp_fast_mod( param1, param2 );
1487 if( strcmp( params[0],
"ecp_write_binary" ) == 0 )
1491 char *param2 = params[2];
1492 char *param3 = params[3];
1493 char *param4 = params[4];
1495 char *param6 = params[6];
1501 fprintf( stderr,
"\nIncorrect argument count (%d != %d)\n", cnt, 9 );
1505 if(
verify_int( params[1], ¶m1 ) != 0 )
return( 2 );
1509 if(
verify_int( params[5], ¶m5 ) != 0 )
return( 2 );
1511 if(
verify_int( params[7], ¶m7 ) != 0 )
return( 2 );
1512 if(
verify_int( params[8], ¶m8 ) != 0 )
return( 2 );
1514 test_suite_ecp_write_binary( param1, param2, param3, param4, param5, param6, param7, param8 );
1520 if( strcmp( params[0],
"ecp_read_binary" ) == 0 )
1524 char *param2 = params[2];
1525 char *param3 = params[3];
1526 char *param4 = params[4];
1527 char *param5 = params[5];
1532 fprintf( stderr,
"\nIncorrect argument count (%d != %d)\n", cnt, 7 );
1536 if(
verify_int( params[1], ¶m1 ) != 0 )
return( 2 );
1541 if(
verify_int( params[6], ¶m6 ) != 0 )
return( 2 );
1543 test_suite_ecp_read_binary( param1, param2, param3, param4, param5, param6 );
1549 if( strcmp( params[0],
"ecp_tls_read_point" ) == 0 )
1553 char *param2 = params[2];
1554 char *param3 = params[3];
1555 char *param4 = params[4];
1556 char *param5 = params[5];
1561 fprintf( stderr,
"\nIncorrect argument count (%d != %d)\n", cnt, 7 );
1565 if(
verify_int( params[1], ¶m1 ) != 0 )
return( 2 );
1570 if(
verify_int( params[6], ¶m6 ) != 0 )
return( 2 );
1572 test_suite_ecp_tls_read_point( param1, param2, param3, param4, param5, param6 );
1578 if( strcmp( params[0],
"ecp_tls_write_read_point" ) == 0 )
1585 fprintf( stderr,
"\nIncorrect argument count (%d != %d)\n", cnt, 2 );
1589 if(
verify_int( params[1], ¶m1 ) != 0 )
return( 2 );
1591 test_suite_ecp_tls_write_read_point( param1 );
1597 if( strcmp( params[0],
"ecp_tls_read_group" ) == 0 )
1600 char *param1 = params[1];
1606 fprintf( stderr,
"\nIncorrect argument count (%d != %d)\n", cnt, 4 );
1611 if(
verify_int( params[2], ¶m2 ) != 0 )
return( 2 );
1612 if(
verify_int( params[3], ¶m3 ) != 0 )
return( 2 );
1614 test_suite_ecp_tls_read_group( param1, param2, param3 );
1620 if( strcmp( params[0],
"ecp_tls_write_read_group" ) == 0 )
1627 fprintf( stderr,
"\nIncorrect argument count (%d != %d)\n", cnt, 2 );
1631 if(
verify_int( params[1], ¶m1 ) != 0 )
return( 2 );
1633 test_suite_ecp_tls_write_read_group( param1 );
1639 if( strcmp( params[0],
"ecp_check_privkey" ) == 0 )
1643 char *param2 = params[2];
1648 fprintf( stderr,
"\nIncorrect argument count (%d != %d)\n", cnt, 4 );
1652 if(
verify_int( params[1], ¶m1 ) != 0 )
return( 2 );
1654 if(
verify_int( params[3], ¶m3 ) != 0 )
return( 2 );
1656 test_suite_ecp_check_privkey( param1, param2, param3 );
1662 if( strcmp( params[0],
"ecp_gen_keypair" ) == 0 )
1669 fprintf( stderr,
"\nIncorrect argument count (%d != %d)\n", cnt, 2 );
1673 if(
verify_int( params[1], ¶m1 ) != 0 )
return( 2 );
1675 test_suite_ecp_gen_keypair( param1 );
1681 if( strcmp( params[0],
"ecp_gen_key" ) == 0 )
1688 fprintf( stderr,
"\nIncorrect argument count (%d != %d)\n", cnt, 2 );
1692 if(
verify_int( params[1], ¶m1 ) != 0 )
return( 2 );
1694 test_suite_ecp_gen_key( param1 );
1700 if( strcmp( params[0],
"ecp_selftest" ) == 0 )
1702 #ifdef POLARSSL_SELF_TEST
1707 fprintf( stderr,
"\nIncorrect argument count (%d != %d)\n", cnt, 1 );
1712 test_suite_ecp_selftest( );
1721 fprintf( stdout,
"FAILED\nSkipping unknown test function '%s'\n", params[0] );
1735 ret = fgets( buf, len, f );
1739 if( strlen( buf ) && buf[strlen(buf) - 1] ==
'\n' )
1740 buf[strlen(buf) - 1] =
'\0';
1741 if( strlen( buf ) && buf[strlen(buf) - 1] ==
'\r' )
1742 buf[strlen(buf) - 1] =
'\0';
1753 params[cnt++] = cur;
1755 while( *p !=
'\0' && p < buf + len )
1765 if( p + 1 < buf + len )
1768 params[cnt++] = cur;
1777 for( i = 0; i < cnt; i++ )
1784 if( *p ==
'\\' && *(p + 1) ==
'n' )
1789 else if( *p ==
'\\' && *(p + 1) ==
':' )
1794 else if( *p ==
'\\' && *(p + 1) ==
'?' )
1810 int ret, i, cnt, total_errors = 0, total_tests = 0, total_skipped = 0;
1811 const char *filename =
"/tmp/B.9R4AfU/BUILD/polarssl-1.3.9/tests/suites/test_suite_ecp.data";
1816 #if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
1817 unsigned char alloc_buf[1000000];
1821 file = fopen( filename,
"r" );
1824 fprintf( stderr,
"Failed to open\n" );
1828 while( !feof( file ) )
1832 if( ( ret =
get_line( file, buf,
sizeof(buf) ) ) != 0 )
1834 fprintf( stdout,
"%s%.66s",
test_errors ?
"\n" :
"", buf );
1835 fprintf( stdout,
" " );
1836 for( i = strlen( buf ) + 1; i < 67; i++ )
1837 fprintf( stdout,
"." );
1838 fprintf( stdout,
" " );
1843 if( ( ret =
get_line( file, buf,
sizeof(buf) ) ) != 0 )
1847 if( strcmp( params[0],
"depends_on" ) == 0 )
1849 for( i = 1; i < cnt; i++ )
1853 if( ( ret =
get_line( file, buf,
sizeof(buf) ) ) != 0 )
1864 if( skip == 1 || ret == 3 )
1867 fprintf( stdout,
"----\n" );
1872 fprintf( stdout,
"PASS\n" );
1877 fprintf( stderr,
"FAILED: FATAL PARSE ERROR\n" );
1884 if( ( ret =
get_line( file, buf,
sizeof(buf) ) ) != 0 )
1886 if( strlen(buf) != 0 )
1888 fprintf( stderr,
"Should be empty %d\n", (
int) strlen(buf) );
1894 fprintf( stdout,
"\n----------------------------------------------------------------------------\n\n");
1895 if( total_errors == 0 )
1896 fprintf( stdout,
"PASSED" );
1898 fprintf( stdout,
"FAILED" );
1900 fprintf( stdout,
" (%d / %d tests (%d skipped))\n",
1901 total_tests - total_errors, total_tests, total_skipped );
1903 #if defined(POLARSSL_MEMORY_BUFFER_ALLOC_C)
1904 #if defined(POLARSSL_MEMORY_DEBUG)
1905 memory_buffer_alloc_status();
1910 return( total_errors != 0 );