mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-21 21:36:21 +01:00
modify library/memory_buffer_alloc.c, benchmark.c and the tests main code to use polarssl_exit
This commit is contained in:
parent
c39cb4986b
commit
77d3638497
3 changed files with 42 additions and 26 deletions
|
|
@ -31,6 +31,7 @@
|
|||
#else
|
||||
#define polarssl_snprintf snprintf
|
||||
#define polarssl_printf printf
|
||||
#define polarssl_exit exit
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
|
@ -428,17 +429,17 @@ int main( int argc, char *argv[] )
|
|||
ctr_drbg_context ctr_drbg;
|
||||
|
||||
if( ctr_drbg_init( &ctr_drbg, myrand, NULL, NULL, 0 ) != 0 )
|
||||
exit(1);
|
||||
polarssl_exit(1);
|
||||
TIME_AND_TSC( "CTR_DRBG (NOPR)",
|
||||
if( ctr_drbg_random( &ctr_drbg, buf, BUFSIZE ) != 0 )
|
||||
exit(1) );
|
||||
polarssl_exit(1) );
|
||||
|
||||
if( ctr_drbg_init( &ctr_drbg, myrand, NULL, NULL, 0 ) != 0 )
|
||||
exit(1);
|
||||
polarssl_exit(1);
|
||||
ctr_drbg_set_prediction_resistance( &ctr_drbg, CTR_DRBG_PR_ON );
|
||||
TIME_AND_TSC( "CTR_DRBG (PR)",
|
||||
if( ctr_drbg_random( &ctr_drbg, buf, BUFSIZE ) != 0 )
|
||||
exit(1) );
|
||||
polarssl_exit(1) );
|
||||
ctr_drbg_free( &ctr_drbg );
|
||||
}
|
||||
#endif
|
||||
|
|
@ -451,43 +452,43 @@ int main( int argc, char *argv[] )
|
|||
|
||||
#if defined(POLARSSL_SHA1_C)
|
||||
if( ( md_info = md_info_from_type( POLARSSL_MD_SHA1 ) ) == NULL )
|
||||
exit(1);
|
||||
polarssl_exit(1);
|
||||
|
||||
if( hmac_drbg_init( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 )
|
||||
exit(1);
|
||||
polarssl_exit(1);
|
||||
TIME_AND_TSC( "HMAC_DRBG SHA-1 (NOPR)",
|
||||
if( hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 )
|
||||
exit(1) );
|
||||
polarssl_exit(1) );
|
||||
hmac_drbg_free( &hmac_drbg );
|
||||
|
||||
if( hmac_drbg_init( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 )
|
||||
exit(1);
|
||||
polarssl_exit(1);
|
||||
hmac_drbg_set_prediction_resistance( &hmac_drbg,
|
||||
POLARSSL_HMAC_DRBG_PR_ON );
|
||||
TIME_AND_TSC( "HMAC_DRBG SHA-1 (PR)",
|
||||
if( hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 )
|
||||
exit(1) );
|
||||
polarssl_exit(1) );
|
||||
hmac_drbg_free( &hmac_drbg );
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_SHA256_C)
|
||||
if( ( md_info = md_info_from_type( POLARSSL_MD_SHA256 ) ) == NULL )
|
||||
exit(1);
|
||||
polarssl_exit(1);
|
||||
|
||||
if( hmac_drbg_init( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 )
|
||||
exit(1);
|
||||
polarssl_exit(1);
|
||||
TIME_AND_TSC( "HMAC_DRBG SHA-256 (NOPR)",
|
||||
if( hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 )
|
||||
exit(1) );
|
||||
polarssl_exit(1) );
|
||||
hmac_drbg_free( &hmac_drbg );
|
||||
|
||||
if( hmac_drbg_init( &hmac_drbg, md_info, myrand, NULL, NULL, 0 ) != 0 )
|
||||
exit(1);
|
||||
polarssl_exit(1);
|
||||
hmac_drbg_set_prediction_resistance( &hmac_drbg,
|
||||
POLARSSL_HMAC_DRBG_PR_ON );
|
||||
TIME_AND_TSC( "HMAC_DRBG SHA-256 (PR)",
|
||||
if( hmac_drbg_random( &hmac_drbg, buf, BUFSIZE ) != 0 )
|
||||
exit(1) );
|
||||
polarssl_exit(1) );
|
||||
hmac_drbg_free( &hmac_drbg );
|
||||
#endif
|
||||
}
|
||||
|
|
@ -542,13 +543,13 @@ int main( int argc, char *argv[] )
|
|||
if( mpi_read_string( &dhm.P, 16, dhm_P[i] ) != 0 ||
|
||||
mpi_read_string( &dhm.G, 16, dhm_G[i] ) != 0 )
|
||||
{
|
||||
exit( 1 );
|
||||
polarssl_exit( 1 );
|
||||
}
|
||||
|
||||
dhm.len = mpi_size( &dhm.P );
|
||||
dhm_make_public( &dhm, (int) dhm.len, buf, dhm.len, myrand, NULL );
|
||||
if( mpi_copy( &dhm.GY, &dhm.GX ) != 0 )
|
||||
exit( 1 );
|
||||
polarssl_exit( 1 );
|
||||
|
||||
polarssl_snprintf( title, sizeof( title ), "DHE-%d", dhm_sizes[i] );
|
||||
TIME_PUBLIC( title, "handshake",
|
||||
|
|
@ -583,7 +584,7 @@ int main( int argc, char *argv[] )
|
|||
ecdsa_init( &ecdsa );
|
||||
|
||||
if( ecdsa_genkey( &ecdsa, curve_info->grp_id, myrand, NULL ) != 0 )
|
||||
exit( 1 );
|
||||
polarssl_exit( 1 );
|
||||
|
||||
polarssl_snprintf( title, sizeof( title ), "ECDSA-%s",
|
||||
curve_info->name );
|
||||
|
|
@ -618,7 +619,7 @@ int main( int argc, char *argv[] )
|
|||
myrand, NULL ) != 0 ||
|
||||
ecp_copy( &ecdh.Qp, &ecdh.Q ) != 0 )
|
||||
{
|
||||
exit( 1 );
|
||||
polarssl_exit( 1 );
|
||||
}
|
||||
|
||||
polarssl_snprintf( title, sizeof( title ), "ECDHE-%s",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue