Rename mbedtls_platform_gmtime() to mbedtls_platform_gmtime_r()
For consistency, also rename MBEDTLS_PLATFORM_GMTIME_ALT to MBEDTLS_PLATFORM_GMTIME_R_ALT.
This commit is contained in:
parent
be2e4bddd5
commit
6a739789f3
6 changed files with 37 additions and 37 deletions
|
@ -137,7 +137,7 @@
|
|||
/**
|
||||
* \def MBEDTLS_HAVE_TIME_DATE
|
||||
*
|
||||
* System has time.h, time(), an implementation for mbedtls_platform_gmtime()
|
||||
* System has time.h, time(), an implementation for mbedtls_platform_gmtime_r()
|
||||
* (see below), and the clock is correct.
|
||||
* The time needs to be correct (not necesarily very accurate, but at least
|
||||
* the date should be correct). This is used to verify the validity period of
|
||||
|
@ -145,17 +145,17 @@
|
|||
*
|
||||
* Comment if your system does not have a correct clock.
|
||||
*
|
||||
* \note mbedtls_platform_gmtime() is an abstraction in platform_util.h that
|
||||
* \note mbedtls_platform_gmtime_r() is an abstraction in platform_util.h that
|
||||
* when called behaves similarly to the gmtime() function from the C standard,
|
||||
* but is thread safe. Mbed TLS will try to identify the underlying platform
|
||||
* and configure an appropriate underlying implementation (e.g. gmtime_r() for
|
||||
* POSIX and gmtime_s() for Windows). If this is not possible, then
|
||||
* gmtime() will be used. Refer to the documentation for
|
||||
* mbedtls_platform_gmtime() for more information.
|
||||
* mbedtls_platform_gmtime_r() for more information.
|
||||
*
|
||||
* \note It is possible to configure an implementation for
|
||||
* mbedtls_platform_gmtime() at compile-time by using the macro
|
||||
* MBEDTLS_PLATFORM_GMTIME_ALT.
|
||||
* mbedtls_platform_gmtime_r() at compile-time by using the macro
|
||||
* MBEDTLS_PLATFORM_GMTIME_R_ALT.
|
||||
*/
|
||||
#define MBEDTLS_HAVE_TIME_DATE
|
||||
|
||||
|
@ -3098,22 +3098,22 @@
|
|||
|
||||
/**
|
||||
* Uncomment the macro to let Mbed TLS use your alternate implementation of
|
||||
* mbedtls_platform_gmtime(). This replaces the default implementation in
|
||||
* mbedtls_platform_gmtime_r(). This replaces the default implementation in
|
||||
* platform_util.c.
|
||||
*
|
||||
* gmtime() is not a thread safe function as defined in the C standard. The
|
||||
* library will try to use safer implementations of this function, such as
|
||||
* gmtime_r() when available. However, if Mbed TLS cannot identify the target
|
||||
* system, the implementation of mbedtls_platform_gmtime() will default to
|
||||
* system, the implementation of mbedtls_platform_gmtime_r() will default to
|
||||
* using the standard gmtime(). In this case, calls from the library to
|
||||
* gmtime() will be guarded by the global mutex mbedtls_threading_gmtime_mutex
|
||||
* if MBEDTLS_THREADING_C is enable. It is advised that calls from outside the
|
||||
* library are also guarded with this mutex to avoid race conditions. However,
|
||||
* if the macro MBEDTLS_PLATFORM_GMTIME_ALT is defined, Mbed TLS will
|
||||
* unconditionally use the implementation for mbedtls_platform_time() supplied
|
||||
* at compile time.
|
||||
* if the macro MBEDTLS_PLATFORM_GMTIME_R_ALT is defined, Mbed TLS will
|
||||
* unconditionally use the implementation for mbedtls_platform_gmtime_r()
|
||||
* supplied at compile time.
|
||||
*/
|
||||
//#define MBEDTLS_PLATFORM_GMTIME_ALT
|
||||
//#define MBEDTLS_PLATFORM_GMTIME_R_ALT
|
||||
|
||||
/* \} name SECTION: Customisation configuration options */
|
||||
|
||||
|
|
|
@ -68,24 +68,24 @@ void mbedtls_platform_zeroize( void *buf, size_t len );
|
|||
|
||||
#if defined(MBEDTLS_HAVE_TIME_DATE)
|
||||
/**
|
||||
* \brief Thread safe implementation of gmtime()
|
||||
* \brief Thread safe implementation of gmtime()
|
||||
*
|
||||
* The function is an abstraction that when called behaves similar
|
||||
* to the gmtime() function from the C standard, but is thread
|
||||
* safe.
|
||||
* The function is an abstraction that when called behaves similar
|
||||
* to the gmtime() function from the C standard, but is thread
|
||||
* safe.
|
||||
*
|
||||
* Mbed TLS will try to identify the underlying platform and
|
||||
* configure an appropriate underlying implementation (e.g.
|
||||
* gmtime_r() for POSIX and gmtime_s() for Windows). If this is
|
||||
* not possible, then gmtime() will be used. In this case, calls
|
||||
* from the library to gmtime() will be guarded by the mutex
|
||||
* mbedtls_threading_gmtime_mutex if MBEDTLS_THREADING_C is
|
||||
* enabled. It is recommended that calls from outside the library
|
||||
* are also guarded by this mutex.
|
||||
* Mbed TLS will try to identify the underlying platform and
|
||||
* configure an appropriate underlying implementation (e.g.
|
||||
* gmtime_r() for POSIX and gmtime_s() for Windows). If this is
|
||||
* not possible, then gmtime() will be used. In this case, calls
|
||||
* from the library to gmtime() will be guarded by the mutex
|
||||
* mbedtls_threading_gmtime_mutex if MBEDTLS_THREADING_C is
|
||||
* enabled. It is recommended that calls from outside the library
|
||||
* are also guarded by this mutex.
|
||||
*
|
||||
* If MBEDTLS_PLATFORM_GMTIME_ALT is defined, then Mbed TLS will
|
||||
* unconditionally use the alternative implementation for
|
||||
* mbedtls_platform_gmtime() supplied by the user at compile time
|
||||
* If MBEDTLS_PLATFORM_GMTIME_R_ALT is defined, then Mbed TLS will
|
||||
* unconditionally use the alternative implementation for
|
||||
* mbedtls_platform_gmtime_r() supplied by the user at compile time.
|
||||
*
|
||||
* \param tt Pointer to an object containing time (in seconds) since the
|
||||
* Epoc to be converted
|
||||
|
@ -94,8 +94,8 @@ void mbedtls_platform_zeroize( void *buf, size_t len );
|
|||
* \return Pointer to an object of type struct tm on success, otherwise
|
||||
* NULL
|
||||
*/
|
||||
struct tm *mbedtls_platform_gmtime( const mbedtls_time_t *tt,
|
||||
struct tm *tm_buf );
|
||||
struct tm *mbedtls_platform_gmtime_r( const mbedtls_time_t *tt,
|
||||
struct tm *tm_buf );
|
||||
#endif /* MBEDTLS_HAVE_TIME_DATE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -107,7 +107,7 @@ extern int (*mbedtls_mutex_unlock)( mbedtls_threading_mutex_t *mutex );
|
|||
#if defined(MBEDTLS_FS_IO)
|
||||
extern mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex;
|
||||
#endif
|
||||
#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_ALT)
|
||||
#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_R_ALT)
|
||||
#if !defined(_WIN32) && (defined(unix) || \
|
||||
defined(__unix) || defined(__unix__) || (defined(__APPLE__) && \
|
||||
defined(__MACH__)))
|
||||
|
@ -122,7 +122,7 @@ extern mbedtls_threading_mutex_t mbedtls_threading_gmtime_mutex;
|
|||
#endif /* !_POSIX_VERSION || 200112L > _POSIX_THREAD_SAFE_FUNCTIONS */
|
||||
#endif /* !_WIN32 && (unix || __unix || __unix__ ||
|
||||
* (__APPLE__ && __MACH__)) */
|
||||
#endif /* MBEDTLS_HAVE_TIME_DATE && !MBEDTLS_PLATFORM_GMTIME_ALT */
|
||||
#endif /* MBEDTLS_HAVE_TIME_DATE && !MBEDTLS_PLATFORM_GMTIME_R_ALT */
|
||||
#endif /* MBEDTLS_THREADING_C */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -75,7 +75,7 @@ void mbedtls_platform_zeroize( void *buf, size_t len )
|
|||
}
|
||||
#endif /* MBEDTLS_PLATFORM_ZEROIZE_ALT */
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_ALT)
|
||||
#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_R_ALT)
|
||||
#include <time.h>
|
||||
#if !defined(_WIN32) && (defined(unix) || \
|
||||
defined(__unix) || defined(__unix__) || (defined(__APPLE__) && \
|
||||
|
@ -94,8 +94,8 @@ void mbedtls_platform_zeroize( void *buf, size_t len )
|
|||
#endif /* !_WIN32 && (unix || __unix || __unix__ ||
|
||||
* (__APPLE__ && __MACH__)) */
|
||||
|
||||
struct tm *mbedtls_platform_gmtime( const mbedtls_time_t *tt,
|
||||
struct tm *tm_buf )
|
||||
struct tm *mbedtls_platform_gmtime_r( const mbedtls_time_t *tt,
|
||||
struct tm *tm_buf )
|
||||
{
|
||||
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
|
||||
return( ( gmtime_s( tm_buf, tt ) == 0 ) ? tm_buf : NULL );
|
||||
|
@ -124,4 +124,4 @@ struct tm *mbedtls_platform_gmtime( const mbedtls_time_t *tt,
|
|||
return( ( lt == NULL ) ? NULL : tm_buf );
|
||||
#endif /* _WIN32 && !EFIX64 && !EFI32 */
|
||||
}
|
||||
#endif /* MBEDTLS_HAVE_TIME_DATE && MBEDTLS_PLATFORM_GMTIME_ALT */
|
||||
#endif /* MBEDTLS_HAVE_TIME_DATE && MBEDTLS_PLATFORM_GMTIME_R_ALT */
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include "mbedtls/threading.h"
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_ALT)
|
||||
#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_PLATFORM_GMTIME_R_ALT)
|
||||
#if !defined(_WIN32) && (defined(unix) || \
|
||||
defined(__unix) || defined(__unix__) || (defined(__APPLE__) && \
|
||||
defined(__MACH__)))
|
||||
|
@ -54,7 +54,7 @@
|
|||
#endif /* !_POSIX_VERSION || 200112L > _POSIX_THREAD_SAFE_FUNCTIONS */
|
||||
#endif /* !_WIN32 && (unix || __unix || __unix__ ||
|
||||
* (__APPLE__ && __MACH__)) */
|
||||
#endif /* MBEDTLS_HAVE_TIME_DATE && !MBEDTLS_PLATFORM_GMTIME_ALT */
|
||||
#endif /* MBEDTLS_HAVE_TIME_DATE && !MBEDTLS_PLATFORM_GMTIME_R_ALT */
|
||||
|
||||
#if defined(MBEDTLS_THREADING_PTHREAD)
|
||||
static void threading_mutex_init_pthread( mbedtls_threading_mutex_t *mutex )
|
||||
|
|
|
@ -898,7 +898,7 @@ static int x509_get_current_time( mbedtls_x509_time *now )
|
|||
int ret = 0;
|
||||
|
||||
tt = mbedtls_time( NULL );
|
||||
lt = mbedtls_platform_gmtime( &tt, &tm_buf );
|
||||
lt = mbedtls_platform_gmtime_r( &tt, &tm_buf );
|
||||
|
||||
if( lt == NULL )
|
||||
ret = -1;
|
||||
|
|
Loading…
Reference in a new issue