diff --git a/ChangeLog b/ChangeLog index 128113838..3e2ea6b5c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,10 @@ mbed TLS ChangeLog (Sorted per branch, date) = mbed TLS 2.x branch +Features + * Support for platform abstraction of the standard C library time() + function. + Bugfix * Fix bug in mbedtls_mpi_add_mpi() that caused wrong results when the three arguments where the same (in-place doubling). Found and fixed by Janos diff --git a/include/mbedtls/platform.h b/include/mbedtls/platform.h index 7922e8c75..69a6afda4 100644 --- a/include/mbedtls/platform.h +++ b/include/mbedtls/platform.h @@ -44,6 +44,7 @@ extern "C" { #if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) #include #include +#include #if !defined(MBEDTLS_PLATFORM_STD_SNPRINTF) #if defined(_WIN32) #define MBEDTLS_PLATFORM_STD_SNPRINTF mbedtls_platform_win32_snprintf /**< Default snprintf to use */ @@ -243,7 +244,7 @@ int mbedtls_platform_set_exit( void (*exit_func)( int status ) ); * The function pointers for time */ #if defined(MBEDTLS_PLATFORM_TIME_ALT) -extern time_t (*mbedtls_time)( mbedtls_time_t* time ); +extern mbedtls_time_t (*mbedtls_time)( mbedtls_time_t* time ); /** * \brief Set your own time function pointer @@ -252,7 +253,7 @@ extern time_t (*mbedtls_time)( mbedtls_time_t* time ); * * \return 0 */ -int mbedtls_platform_set_time( mbedtls_time_t (*time_func)( mbedtls_time_t time ) ); +int mbedtls_platform_set_time( mbedtls_time_t (*time_func)( mbedtls_time_t* time ) ); #else #if defined(MBEDTLS_PLATFORM_TIME_MACRO) #define mbedtls_time MBEDTLS_PLATFORM_TIME_MACRO diff --git a/library/platform.c b/library/platform.c index e7ec0ad6a..89a2bd65d 100644 --- a/library/platform.c +++ b/library/platform.c @@ -198,15 +198,15 @@ int mbedtls_platform_set_exit( void (*exit_func)( int status ) ) static mbedtls_time_t platform_time_uninit( mbedtls_time_t* timer ) { ((void) timer); - return( NULL ); + return( 0 ); } #define MBEDTLS_PLATFORM_STD_TIME platform_time_uninit #endif /* !MBEDTLS_PLATFORM_STD_TIME */ -time_t (*mbedtls_time)( mbedtls_time_t* timer ) = MBEDTLS_PLATFORM_STD_TIME; +mbedtls_time_t (*mbedtls_time)( mbedtls_time_t* timer ) = MBEDTLS_PLATFORM_STD_TIME; -int mbedtls_platform_set_exit( mbedtls_time_t (*time_func)( mbedtls_time_t timer ) ) +int mbedtls_platform_set_time( mbedtls_time_t (*time_func)( mbedtls_time_t* timer ) ) { mbedtls_time = time_func; return( 0 ); diff --git a/library/version_features.c b/library/version_features.c index 1575e093e..b852ca81a 100644 --- a/library/version_features.c +++ b/library/version_features.c @@ -54,6 +54,9 @@ static const char *features[] = { #if defined(MBEDTLS_PLATFORM_EXIT_ALT) "MBEDTLS_PLATFORM_EXIT_ALT", #endif /* MBEDTLS_PLATFORM_EXIT_ALT */ +#if defined(MBEDTLS_PLATFORM_TIME_ALT) + "MBEDTLS_PLATFORM_TIME_ALT", +#endif /* MBEDTLS_PLATFORM_TIME_ALT */ #if defined(MBEDTLS_PLATFORM_FPRINTF_ALT) "MBEDTLS_PLATFORM_FPRINTF_ALT", #endif /* MBEDTLS_PLATFORM_FPRINTF_ALT */