Remove timing_m_sleep() -> net_usleep()
diff --git a/ChangeLog b/ChangeLog
index 9df31f9..a1b5e8a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -73,6 +73,8 @@
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).
diff --git a/include/mbedtls/compat-1.3.h b/include/mbedtls/compat-1.3.h
index 9276eae..d19e04a 100644
--- a/include/mbedtls/compat-1.3.h
+++ b/include/mbedtls/compat-1.3.h
@@ -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
diff --git a/include/mbedtls/config.h b/include/mbedtls/config.h
index 34d0bc2..e6b0cd5 100644
--- a/include/mbedtls/config.h
+++ b/include/mbedtls/config.h
@@ -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.
*
diff --git a/include/mbedtls/timing.h b/include/mbedtls/timing.h
index efcc5dc..6598c1a 100644
--- a/include/mbedtls/timing.h
+++ b/include/mbedtls/timing.h
@@ -85,13 +85,6 @@
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().)
*
diff --git a/library/timing.c b/library/timing.c
index 8ce9753..e83b74e 100644
--- a/library/timing.c
+++ b/library/timing.c
@@ -273,11 +273,6 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
{
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 @@
#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++ )
{
diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c
index 1b4d654..b140263 100644
--- a/programs/ssl/ssl_client2.c
+++ b/programs/ssl/ssl_client2.c
@@ -1494,7 +1494,7 @@
#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..." );
diff --git a/programs/ssl/ssl_fork_server.c b/programs/ssl/ssl_fork_server.c
index 1df814b..06c479e 100644
--- a/programs/ssl/ssl_fork_server.c
+++ b/programs/ssl/ssl_fork_server.c
@@ -373,7 +373,7 @@
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 );