Remove timing_m_sleep() -> net_usleep()

parent e94bfe6c
......@@ -73,6 +73,8 @@ Removals
mbedtls_ecp_muladd().
* Removed individual mdX_hmac and shaX_hmac functions (use generic
md_hmac functions from md.h)
* Removed mbedtls_timing_msleep(). Use mbedtls_timing_usleep() or a custom
waiting function.
* Removed the PBKDF2 module (use PKCS5).
* Removed POLARSSL_ERROR_STRERROR_BC (use mbedtls_strerror()).
* Removed compat-1.2.h (helper for migrating from 1.2 to 1.3).
......
......@@ -2049,7 +2049,6 @@
#define hmac_drbg_write_seed_file mbedtls_hmac_drbg_write_seed_file
#define hr_time mbedtls_timing_hr_time
#define key_exchange_type_t mbedtls_key_exchange_type_t
#define m_sleep mbedtls_timing_m_sleep
#define md mbedtls_md
#define md2 mbedtls_md2
#define md2_context mbedtls_md2_context
......
......@@ -183,7 +183,7 @@
* \def MBEDTLS_TIMING_ALT
*
* Uncomment to provide your own alternate implementation for mbedtls_timing_hardclock(),
* mbedtls_timing_get_timer(), mbedtls_set_alarm() and mbedtls_timing_m_sleep().
* mbedtls_timing_get_timer(), mbedtls_set_alarm(), mbedtls_set/get_delay()
*
* Only works if you have MBEDTLS_TIMING_C enabled.
*
......
......@@ -84,13 +84,6 @@ unsigned long mbedtls_timing_get_timer( struct mbedtls_timing_hr_time *val, int
*/
void mbedtls_set_alarm( int seconds );
/**
* \brief Sleep for a certain amount of time
*
* \param milliseconds delay in milliseconds
*/
void mbedtls_timing_m_sleep( int milliseconds );
/**
* \brief Set a pair of delays to watch
* (See \c mbedtls_timing_get_delay().)
......
......@@ -273,11 +273,6 @@ void mbedtls_set_alarm( int seconds )
CloseHandle( CreateThread( NULL, 0, TimerProc, NULL, 0, &ThreadId ) );
}
void mbedtls_timing_m_sleep( int milliseconds )
{
Sleep( milliseconds );
}
#else /* _WIN32 && !EFIX64 && !EFI32 */
unsigned long mbedtls_timing_get_timer( struct mbedtls_timing_hr_time *val, int reset )
......@@ -301,14 +296,6 @@ unsigned long mbedtls_timing_get_timer( struct mbedtls_timing_hr_time *val, int
return( delta );
}
#if defined(INTEGRITY)
void mbedtls_timing_m_sleep( int milliseconds )
{
usleep( milliseconds * 1000 );
}
#else /* INTEGRITY */
static void sighandler( int signum )
{
mbedtls_timing_alarmed = 1;
......@@ -322,17 +309,6 @@ void mbedtls_set_alarm( int seconds )
alarm( seconds );
}
void mbedtls_timing_m_sleep( int milliseconds )
{
struct timeval tv;
tv.tv_sec = milliseconds / 1000;
tv.tv_usec = ( milliseconds % 1000 ) * 1000;
select( 0, NULL, NULL, NULL, &tv );
}
#endif /* INTEGRITY */
#endif /* _WIN32 && !EFIX64 && !EFI32 */
/*
......@@ -425,31 +401,9 @@ int mbedtls_timing_self_test( int verbose )
if( verbose != 0 )
mbedtls_printf( " TIMING tests note: will take some time!\n" );
if( verbose != 0 )
mbedtls_printf( " TIMING test #1 (m_sleep / get_timer): " );
for( secs = 1; secs <= 3; secs++ )
{
(void) mbedtls_timing_get_timer( &hires, 1 );
mbedtls_timing_m_sleep( (int)( 500 * secs ) );
millisecs = mbedtls_timing_get_timer( &hires, 0 );
if( millisecs < 450 * secs || millisecs > 550 * secs )
{
if( verbose != 0 )
mbedtls_printf( "failed\n" );
return( 1 );
}
}
if( verbose != 0 )
mbedtls_printf( "passed\n" );
if( verbose != 0 )
mbedtls_printf( " TIMING test #2 (set_alarm / get_timer): " );
mbedtls_printf( " TIMING test #1 (set_alarm / get_timer): " );
for( secs = 1; secs <= 3; secs++ )
{
......@@ -474,7 +428,7 @@ int mbedtls_timing_self_test( int verbose )
mbedtls_printf( "passed\n" );
if( verbose != 0 )
mbedtls_printf( " TIMING test #3 (hardclock / get_timer): " );
mbedtls_printf( " TIMING test #2 (hardclock / get_timer): " );
/*
* Allow one failure for possible counter wrapping.
......@@ -519,7 +473,7 @@ hard_test:
mbedtls_printf( "passed\n" );
if( verbose != 0 )
mbedtls_printf( " TIMING test #4 (m_sleep / delay ): " );
mbedtls_printf( " TIMING test #3 (set/get_delay ): " );
for( a = 100; a <= 200; a += 100 )
{
......@@ -527,26 +481,26 @@ hard_test:
{
mbedtls_timing_set_delay( &ctx, a, a + b );
mbedtls_timing_m_sleep( (int)( a - a / 10 ) );
busy_msleep( a - a / 10 );
if( mbedtls_timing_get_delay( &ctx ) != 0 )
FAIL;
mbedtls_timing_m_sleep( (int)( a / 5 ) );
busy_msleep( a / 5 );
if( mbedtls_timing_get_delay( &ctx ) != 1 )
FAIL;
mbedtls_timing_m_sleep( (int)( b - a / 5 ) );
busy_msleep( b - a / 5 );
if( mbedtls_timing_get_delay( &ctx ) != 1 )
FAIL;
mbedtls_timing_m_sleep( (int)( b / 5 ) );
busy_msleep( b / 5 );
if( mbedtls_timing_get_delay( &ctx ) != 2 )
FAIL;
}
}
mbedtls_timing_set_delay( &ctx, 0, 0 );
mbedtls_timing_m_sleep( 200 );
busy_msleep( 200 );
if( mbedtls_timing_get_delay( &ctx ) != -1 )
FAIL;
......@@ -555,7 +509,7 @@ hard_test:
#if defined(MBEDTLS_NET_C) && defined(MBEDTLS_HAVE_TIME)
if( verbose != 0 )
mbedtls_printf( " TIMING test #5 (net_usleep/ get_timer): " );
mbedtls_printf( " TIMING test #4 (net_usleep/ get_timer): " );
for( secs = 1; secs <= 3; secs++ )
{
......
......@@ -1494,7 +1494,7 @@ reconnect:
#if defined(MBEDTLS_TIMING_C)
if( opt.reco_delay > 0 )
mbedtls_timing_m_sleep( 1000 * opt.reco_delay );
mbedtls_net_usleep( 1000000 * opt.reco_delay );
#endif
mbedtls_printf( " . Reconnecting with saved session..." );
......
......@@ -373,7 +373,7 @@ int main( void )
len = ret;
mbedtls_printf( " %d bytes written\n\n%s\n", len, (char *) buf );
mbedtls_timing_m_sleep( 1000 );
mbedtls_net_usleep( 1000000 );
}
mbedtls_ssl_close_notify( &ssl );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment