Abstracts away time()/stdlib.h into platform
Substitutes time() into a configurable platform interface to allow it to be easily substituted.
This commit is contained in:
parent
1594210a49
commit
d5800b7761
16 changed files with 159 additions and 63 deletions
|
@ -27,6 +27,16 @@
|
|||
|
||||
#if defined(MBEDTLS_SSL_SRV_C)
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
#include "mbedtls/platform.h"
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#define mbedtls_calloc calloc
|
||||
#define mbedtls_free free
|
||||
#define mbedtls_time time
|
||||
#define mbedtls_time_t time_t
|
||||
#endif
|
||||
|
||||
#include "mbedtls/debug.h"
|
||||
#include "mbedtls/ssl.h"
|
||||
#include "mbedtls/ssl_internal.h"
|
||||
|
@ -37,14 +47,6 @@
|
|||
#include "mbedtls/ecp.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PLATFORM_C)
|
||||
#include "mbedtls/platform.h"
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#define mbedtls_calloc calloc
|
||||
#define mbedtls_free free
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
@ -2210,7 +2212,7 @@ static int ssl_write_hello_verify_request( mbedtls_ssl_context *ssl )
|
|||
static int ssl_write_server_hello( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
time_t t;
|
||||
mbedtls_time_t t;
|
||||
#endif
|
||||
int ret;
|
||||
size_t olen, ext_len = 0, n;
|
||||
|
@ -2253,7 +2255,7 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl )
|
|||
buf[4], buf[5] ) );
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
t = time( NULL );
|
||||
t = mbedtls_time( NULL );
|
||||
*p++ = (unsigned char)( t >> 24 );
|
||||
*p++ = (unsigned char)( t >> 16 );
|
||||
*p++ = (unsigned char)( t >> 8 );
|
||||
|
@ -2302,7 +2304,7 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl )
|
|||
ssl->state++;
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
ssl->session_negotiate->start = time( NULL );
|
||||
ssl->session_negotiate->start = mbedtls_time( NULL );
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue