1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

Merge pull request #4640 from TRodziewicz/move_part_of_timing_module_out_of_the_library_and_to_test

Move part of timing module out of the library
This commit is contained in:
Dave Rodgman
2021-06-18 16:35:58 +01:00
committed by GitHub
13 changed files with 286 additions and 532 deletions

View File

@ -47,7 +47,6 @@
*
* Used in:
* library/aria.c
* library/timing.c
* library/bn_mul.h
*
* Required by:
@ -268,7 +267,7 @@
/**
* \def MBEDTLS_TIMING_ALT
*
* Uncomment to provide your own alternate implementation for mbedtls_timing_hardclock(),
* Uncomment to provide your own alternate implementation for
* mbedtls_timing_get_timer(), mbedtls_set_alarm(), mbedtls_set/get_delay()
*
* Only works if you have MBEDTLS_TIMING_C enabled.
@ -1014,8 +1013,7 @@
/**
* \def MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES
*
* Do not add default entropy sources. These are the platform specific
* or mbedtls_timing_hardclock poll function.
* Do not add default entropy sources in mbedtls_entropy_init().
*
* This is useful to have more control over the added entropy sources in an
* application.

View File

@ -61,51 +61,9 @@ typedef struct mbedtls_timing_delay_context
#include "timing_alt.h"
#endif /* MBEDTLS_TIMING_ALT */
extern volatile int mbedtls_timing_alarmed;
/**
* \brief Return the CPU cycle counter value
*
* \warning This is only a best effort! Do not rely on this!
* In particular, it is known to be unreliable on virtual
* machines.
*
* \note This value starts at an unspecified origin and
* may wrap around.
*/
unsigned long mbedtls_timing_hardclock( void );
/**
* \brief Return the elapsed time in milliseconds
*
* \param val points to a timer structure
* \param reset If 0, query the elapsed time. Otherwise (re)start the timer.
*
* \return Elapsed time since the previous reset in ms. When
* restarting, this is always 0.
*
* \note To initialize a timer, call this function with reset=1.
*
* Determining the elapsed time and resetting the timer is not
* atomic on all platforms, so after the sequence
* `{ get_timer(1); ...; time1 = get_timer(1); ...; time2 =
* get_timer(0) }` the value time1+time2 is only approximately
* the delay since the first reset.
*/
/* Internal use */
unsigned long mbedtls_timing_get_timer( struct mbedtls_timing_hr_time *val, int reset );
/**
* \brief Setup an alarm clock
*
* \param seconds delay before the "mbedtls_timing_alarmed" flag is set
* (must be >=0)
*
* \warning Only one alarm at a time is supported. In a threaded
* context, this means one for the whole process, not one per
* thread.
*/
void mbedtls_set_alarm( int seconds );
/**
* \brief Set a pair of delays to watch
* (See \c mbedtls_timing_get_delay().)
@ -136,15 +94,6 @@ void mbedtls_timing_set_delay( void *data, uint32_t int_ms, uint32_t fin_ms );
*/
int mbedtls_timing_get_delay( void *data );
#if defined(MBEDTLS_SELF_TEST)
/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if a test failed
*/
int mbedtls_timing_self_test( int verbose );
#endif
#ifdef __cplusplus
}
#endif