mirror of
https://github.com/libretro/RetroArch
synced 2025-02-20 15:40:44 +00:00
(Mbedtls) Assume HAVE_TIME
This commit is contained in:
parent
adb203fd3e
commit
af5eacf9d0
4
deps/mbedtls/mbedtls/check_config.h
vendored
4
deps/mbedtls/mbedtls/check_config.h
vendored
@ -43,10 +43,6 @@
|
||||
#error "The NET and TIMING modules are not available for mbed OS - please use the network and timing functions provided by mbed OS"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME_DATE) && !defined(MBEDTLS_HAVE_TIME)
|
||||
#error "MBEDTLS_HAVE_TIME_DATE without MBEDTLS_HAVE_TIME does not make sense"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_AESNI_C) && !defined(MBEDTLS_HAVE_ASM)
|
||||
#error "MBEDTLS_AESNI_C defined, but not all prerequisites"
|
||||
#endif
|
||||
|
3
deps/mbedtls/mbedtls/compat-1.3.h
vendored
3
deps/mbedtls/mbedtls/compat-1.3.h
vendored
@ -204,9 +204,6 @@
|
||||
#if defined MBEDTLS_HAVE_SSE2
|
||||
#define POLARSSL_HAVE_SSE2 MBEDTLS_HAVE_SSE2
|
||||
#endif
|
||||
#if defined MBEDTLS_HAVE_TIME
|
||||
#define POLARSSL_HAVE_TIME MBEDTLS_HAVE_TIME
|
||||
#endif
|
||||
#if defined MBEDTLS_HMAC_DRBG_C
|
||||
#define POLARSSL_HMAC_DRBG_C MBEDTLS_HMAC_DRBG_C
|
||||
#endif
|
||||
|
15
deps/mbedtls/mbedtls/config.h
vendored
15
deps/mbedtls/mbedtls/config.h
vendored
@ -97,21 +97,6 @@
|
||||
#define MBEDTLS_HAVE_SSE2
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_HAVE_TIME
|
||||
*
|
||||
* System has time.h and time().
|
||||
* The time does not need to be correct, only time differences are used,
|
||||
* by contrast with MBEDTLS_HAVE_TIME_DATE
|
||||
*
|
||||
* Defining MBEDTLS_HAVE_TIME allows you to specify MBEDTLS_PLATFORM_TIME_ALT,
|
||||
* MBEDTLS_PLATFORM_TIME_MACRO, MBEDTLS_PLATFORM_TIME_TYPE_MACRO and
|
||||
* MBEDTLS_PLATFORM_STD_TIME.
|
||||
*
|
||||
* Comment if your system does not support time functions
|
||||
*/
|
||||
#define MBEDTLS_HAVE_TIME
|
||||
|
||||
/**
|
||||
* \def MBEDTLS_HAVE_TIME_DATE
|
||||
*
|
||||
|
4
deps/mbedtls/mbedtls/platform.h
vendored
4
deps/mbedtls/mbedtls/platform.h
vendored
@ -29,9 +29,7 @@
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
#include "platform_time.h"
|
||||
#endif
|
||||
#include <time.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
81
deps/mbedtls/mbedtls/platform_time.h
vendored
81
deps/mbedtls/mbedtls/platform_time.h
vendored
@ -1,81 +0,0 @@
|
||||
/**
|
||||
* \file platform_time.h
|
||||
*
|
||||
* \brief mbed TLS Platform time abstraction
|
||||
*
|
||||
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||
*/
|
||||
#ifndef MBEDTLS_PLATFORM_TIME_H
|
||||
#define MBEDTLS_PLATFORM_TIME_H
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \name SECTION: Module settings
|
||||
*
|
||||
* The configuration options you can set for this module are in this section.
|
||||
* Either change them in config.h or define them on the compiler command line.
|
||||
* \{
|
||||
*/
|
||||
|
||||
/*
|
||||
* The time_t datatype
|
||||
*/
|
||||
#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO)
|
||||
typedef MBEDTLS_PLATFORM_TIME_TYPE_MACRO mbedtls_time_t;
|
||||
#else
|
||||
/* For time_t */
|
||||
#include <time.h>
|
||||
typedef time_t mbedtls_time_t;
|
||||
#endif /* MBEDTLS_PLATFORM_TIME_TYPE_MACRO */
|
||||
|
||||
/*
|
||||
* The function pointers for time
|
||||
*/
|
||||
#if defined(MBEDTLS_PLATFORM_TIME_ALT)
|
||||
extern mbedtls_time_t (*mbedtls_time)( mbedtls_time_t* time );
|
||||
|
||||
/**
|
||||
* \brief Set your own time function pointer
|
||||
*
|
||||
* \param time_func the time function implementation
|
||||
*
|
||||
* \return 0
|
||||
*/
|
||||
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
|
||||
#else
|
||||
#define mbedtls_time time
|
||||
#endif /* MBEDTLS_PLATFORM_TIME_MACRO */
|
||||
#endif /* MBEDTLS_PLATFORM_TIME_ALT */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* platform_time.h */
|
8
deps/mbedtls/mbedtls/ssl.h
vendored
8
deps/mbedtls/mbedtls/ssl.h
vendored
@ -47,9 +47,7 @@
|
||||
#include "ecdh.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
#include "platform_time.h"
|
||||
#endif
|
||||
#include <time.h>
|
||||
|
||||
/*
|
||||
* SSL Error codes
|
||||
@ -543,9 +541,7 @@ typedef struct mbedtls_ssl_flight_item mbedtls_ssl_flight_item;
|
||||
*/
|
||||
struct mbedtls_ssl_session
|
||||
{
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
mbedtls_time_t start; /*!< starting time */
|
||||
#endif
|
||||
time_t start; /*!< starting time */
|
||||
int ciphersuite; /*!< chosen ciphersuite */
|
||||
int compression; /*!< chosen compression */
|
||||
size_t id_len; /*!< session id length */
|
||||
|
6
deps/mbedtls/mbedtls/ssl_cache.h
vendored
6
deps/mbedtls/mbedtls/ssl_cache.h
vendored
@ -59,9 +59,7 @@ typedef struct mbedtls_ssl_cache_entry mbedtls_ssl_cache_entry;
|
||||
*/
|
||||
struct mbedtls_ssl_cache_entry
|
||||
{
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
mbedtls_time_t timestamp; /*!< entry timestamp */
|
||||
#endif
|
||||
time_t timestamp; /*!< entry timestamp */
|
||||
mbedtls_ssl_session session; /*!< entry session */
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
mbedtls_x509_buf peer_cert; /*!< entry peer_cert */
|
||||
@ -107,7 +105,6 @@ int mbedtls_ssl_cache_get( void *data, mbedtls_ssl_session *session );
|
||||
*/
|
||||
int mbedtls_ssl_cache_set( void *data, const mbedtls_ssl_session *session );
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
/**
|
||||
* \brief Set the cache timeout
|
||||
* (Default: MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT (1 day))
|
||||
@ -118,7 +115,6 @@ int mbedtls_ssl_cache_set( void *data, const mbedtls_ssl_session *session );
|
||||
* \param timeout cache entry timeout in seconds
|
||||
*/
|
||||
void mbedtls_ssl_cache_set_timeout( mbedtls_ssl_cache_context *cache, int timeout );
|
||||
#endif /* MBEDTLS_HAVE_TIME */
|
||||
|
||||
/**
|
||||
* \brief Set the maximum number of cache entries
|
||||
|
3
deps/mbedtls/mbedtls/ssl_cookie.h
vendored
3
deps/mbedtls/mbedtls/ssl_cookie.h
vendored
@ -52,9 +52,6 @@ extern "C" {
|
||||
typedef struct
|
||||
{
|
||||
mbedtls_md_context_t hmac_ctx; /*!< context for the HMAC portion */
|
||||
#if !defined(MBEDTLS_HAVE_TIME)
|
||||
unsigned long serial; /*!< serial number for expiration */
|
||||
#endif
|
||||
unsigned long timeout; /*!< timeout delay, in seconds if HAVE_TIME,
|
||||
or in number of tickets issued */
|
||||
|
||||
|
47
deps/mbedtls/ssl_cache.c
vendored
47
deps/mbedtls/ssl_cache.c
vendored
@ -50,10 +50,8 @@ void mbedtls_ssl_cache_init( mbedtls_ssl_cache_context *cache )
|
||||
|
||||
int mbedtls_ssl_cache_get( void *data, mbedtls_ssl_session *session )
|
||||
{
|
||||
int ret = 1;
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
mbedtls_time_t t = mbedtls_time( NULL );
|
||||
#endif
|
||||
int ret = 1;
|
||||
time_t t = time( NULL );
|
||||
mbedtls_ssl_cache_context *cache = (mbedtls_ssl_cache_context *) data;
|
||||
mbedtls_ssl_cache_entry *cur, *entry;
|
||||
|
||||
@ -70,11 +68,9 @@ int mbedtls_ssl_cache_get( void *data, mbedtls_ssl_session *session )
|
||||
entry = cur;
|
||||
cur = cur->next;
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
if( cache->timeout != 0 &&
|
||||
(int) ( t - entry->timestamp ) > cache->timeout )
|
||||
continue;
|
||||
#endif
|
||||
|
||||
if( session->ciphersuite != entry->session.ciphersuite ||
|
||||
session->compression != entry->session.compression ||
|
||||
@ -129,11 +125,9 @@ exit:
|
||||
|
||||
int mbedtls_ssl_cache_set( void *data, const mbedtls_ssl_session *session )
|
||||
{
|
||||
int ret = 1;
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
mbedtls_time_t t = time( NULL ), oldest = 0;
|
||||
mbedtls_ssl_cache_entry *old = NULL;
|
||||
#endif
|
||||
int ret = 1;
|
||||
time_t t = time( NULL ), oldest = 0;
|
||||
mbedtls_ssl_cache_entry *old = NULL;
|
||||
mbedtls_ssl_cache_context *cache = (mbedtls_ssl_cache_context *) data;
|
||||
mbedtls_ssl_cache_entry *cur, *prv;
|
||||
int count = 0;
|
||||
@ -150,25 +144,21 @@ int mbedtls_ssl_cache_set( void *data, const mbedtls_ssl_session *session )
|
||||
{
|
||||
count++;
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
if( cache->timeout != 0 &&
|
||||
(int) ( t - cur->timestamp ) > cache->timeout )
|
||||
{
|
||||
cur->timestamp = t;
|
||||
break; /* expired, reuse this slot, update timestamp */
|
||||
}
|
||||
#endif
|
||||
|
||||
if( memcmp( session->id, cur->session.id, cur->session.id_len ) == 0 )
|
||||
break; /* client reconnected, keep timestamp for session id */
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
if( oldest == 0 || cur->timestamp < oldest )
|
||||
{
|
||||
oldest = cur->timestamp;
|
||||
old = cur;
|
||||
}
|
||||
#endif
|
||||
|
||||
prv = cur;
|
||||
cur = cur->next;
|
||||
@ -176,7 +166,6 @@ int mbedtls_ssl_cache_set( void *data, const mbedtls_ssl_session *session )
|
||||
|
||||
if( cur == NULL )
|
||||
{
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
/*
|
||||
* Reuse oldest entry if max_entries reached
|
||||
*/
|
||||
@ -190,25 +179,6 @@ int mbedtls_ssl_cache_set( void *data, const mbedtls_ssl_session *session )
|
||||
|
||||
cur = old;
|
||||
}
|
||||
#else /* MBEDTLS_HAVE_TIME */
|
||||
/*
|
||||
* Reuse first entry in chain if max_entries reached,
|
||||
* but move to last place
|
||||
*/
|
||||
if( count >= cache->max_entries )
|
||||
{
|
||||
if( cache->chain == NULL )
|
||||
{
|
||||
ret = 1;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
cur = cache->chain;
|
||||
cache->chain = cur->next;
|
||||
cur->next = NULL;
|
||||
prv->next = cur;
|
||||
}
|
||||
#endif /* MBEDTLS_HAVE_TIME */
|
||||
else
|
||||
{
|
||||
/*
|
||||
@ -229,9 +199,7 @@ int mbedtls_ssl_cache_set( void *data, const mbedtls_ssl_session *session )
|
||||
prv->next = cur;
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
cur->timestamp = t;
|
||||
#endif
|
||||
}
|
||||
|
||||
memcpy( &cur->session, session, sizeof( mbedtls_ssl_session ) );
|
||||
@ -278,14 +246,13 @@ exit:
|
||||
return( ret );
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
void mbedtls_ssl_cache_set_timeout( mbedtls_ssl_cache_context *cache, int timeout )
|
||||
{
|
||||
if( timeout < 0 ) timeout = 0;
|
||||
if( timeout < 0 )
|
||||
timeout = 0;
|
||||
|
||||
cache->timeout = timeout;
|
||||
}
|
||||
#endif /* MBEDTLS_HAVE_TIME */
|
||||
|
||||
void mbedtls_ssl_cache_set_max_entries( mbedtls_ssl_cache_context *cache, int max )
|
||||
{
|
||||
|
31
deps/mbedtls/ssl_cli.c
vendored
31
deps/mbedtls/ssl_cli.c
vendored
@ -35,9 +35,7 @@
|
||||
#include "mbedtls/ssl.h"
|
||||
#include "mbedtls/ssl_internal.h"
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
#include "mbedtls/platform_time.h"
|
||||
#endif
|
||||
#include <time.h>
|
||||
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||
#include "arc4_alt.h"
|
||||
@ -659,9 +657,7 @@ static int ssl_generate_random( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
int ret;
|
||||
unsigned char *p = ssl->handshake->randbytes;
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
mbedtls_time_t t;
|
||||
#endif
|
||||
time_t t;
|
||||
|
||||
/*
|
||||
* When responding to a verify request, MUST reuse random (RFC 6347 4.2.1)
|
||||
@ -669,25 +665,16 @@ static int ssl_generate_random( mbedtls_ssl_context *ssl )
|
||||
#if defined(MBEDTLS_SSL_PROTO_DTLS)
|
||||
if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM &&
|
||||
ssl->handshake->verify_cookie != NULL )
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
t = mbedtls_time( NULL );
|
||||
t = time( NULL );
|
||||
*p++ = (unsigned char)( t >> 24 );
|
||||
*p++ = (unsigned char)( t >> 16 );
|
||||
*p++ = (unsigned char)( t >> 8 );
|
||||
*p++ = (unsigned char)( t );
|
||||
|
||||
MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, current time: %lu", t ) );
|
||||
#else
|
||||
if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, p, 4 ) ) != 0 )
|
||||
return( ret );
|
||||
|
||||
p += 4;
|
||||
#endif /* MBEDTLS_HAVE_TIME */
|
||||
|
||||
if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, p, 28 ) ) != 0 )
|
||||
return( ret );
|
||||
@ -1549,19 +1536,17 @@ static int ssl_parse_server_hello( mbedtls_ssl_context *ssl )
|
||||
#if defined(MBEDTLS_SSL_RENEGOTIATION)
|
||||
ssl->renego_status != MBEDTLS_SSL_INITIAL_HANDSHAKE ||
|
||||
#endif
|
||||
ssl->session_negotiate->ciphersuite != i ||
|
||||
ssl->session_negotiate->ciphersuite != i ||
|
||||
ssl->session_negotiate->compression != comp ||
|
||||
ssl->session_negotiate->id_len != n ||
|
||||
ssl->session_negotiate->id_len != n ||
|
||||
memcmp( ssl->session_negotiate->id, buf + 35, n ) != 0 )
|
||||
{
|
||||
ssl->state++;
|
||||
ssl->handshake->resume = 0;
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
ssl->session_negotiate->start = mbedtls_time( NULL );
|
||||
#endif
|
||||
ssl->handshake->resume = 0;
|
||||
ssl->session_negotiate->start = time( NULL );
|
||||
ssl->session_negotiate->ciphersuite = i;
|
||||
ssl->session_negotiate->compression = comp;
|
||||
ssl->session_negotiate->id_len = n;
|
||||
ssl->session_negotiate->id_len = n;
|
||||
memcpy( ssl->session_negotiate->id, buf + 35, n );
|
||||
}
|
||||
else
|
||||
|
24
deps/mbedtls/ssl_cookie.c
vendored
24
deps/mbedtls/ssl_cookie.c
vendored
@ -68,9 +68,6 @@
|
||||
void mbedtls_ssl_cookie_init( mbedtls_ssl_cookie_ctx *ctx )
|
||||
{
|
||||
mbedtls_md_init( &ctx->hmac_ctx );
|
||||
#if !defined(MBEDTLS_HAVE_TIME)
|
||||
ctx->serial = 0;
|
||||
#endif
|
||||
ctx->timeout = MBEDTLS_SSL_COOKIE_TIMEOUT;
|
||||
|
||||
#if defined(MBEDTLS_THREADING_C)
|
||||
@ -148,12 +145,12 @@ static int ssl_cookie_hmac( mbedtls_md_context_t *hmac_ctx,
|
||||
* Generate cookie for DTLS ClientHello verification
|
||||
*/
|
||||
int mbedtls_ssl_cookie_write( void *p_ctx,
|
||||
unsigned char **p, unsigned char *end,
|
||||
const unsigned char *cli_id, size_t cli_id_len )
|
||||
unsigned char **p, unsigned char *end,
|
||||
const unsigned char *cli_id, size_t cli_id_len )
|
||||
{
|
||||
int ret;
|
||||
mbedtls_ssl_cookie_ctx *ctx = (mbedtls_ssl_cookie_ctx *) p_ctx;
|
||||
unsigned long t;
|
||||
mbedtls_ssl_cookie_ctx *ctx = (mbedtls_ssl_cookie_ctx *) p_ctx;
|
||||
|
||||
if( ctx == NULL || cli_id == NULL )
|
||||
return( MBEDTLS_ERR_SSL_BAD_INPUT_DATA );
|
||||
@ -161,11 +158,7 @@ int mbedtls_ssl_cookie_write( void *p_ctx,
|
||||
if( (size_t)( end - *p ) < COOKIE_LEN )
|
||||
return( MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL );
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
t = (unsigned long) mbedtls_time( NULL );
|
||||
#else
|
||||
t = ctx->serial++;
|
||||
#endif
|
||||
t = (unsigned long)time( NULL );
|
||||
|
||||
(*p)[0] = (unsigned char)( t >> 24 );
|
||||
(*p)[1] = (unsigned char)( t >> 16 );
|
||||
@ -228,14 +221,11 @@ int mbedtls_ssl_cookie_check( void *p_ctx,
|
||||
if( ret != 0 )
|
||||
return( ret );
|
||||
|
||||
if( mbedtls_ssl_safer_memcmp( cookie + 4, ref_hmac, sizeof( ref_hmac ) ) != 0 )
|
||||
if( mbedtls_ssl_safer_memcmp(
|
||||
cookie + 4, ref_hmac, sizeof( ref_hmac ) ) != 0 )
|
||||
return( -1 );
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
cur_time = (unsigned long) mbedtls_time( NULL );
|
||||
#else
|
||||
cur_time = ctx->serial;
|
||||
#endif
|
||||
cur_time = (unsigned long)time( NULL );
|
||||
|
||||
cookie_time = ( (unsigned long) cookie[0] << 24 ) |
|
||||
( (unsigned long) cookie[1] << 16 ) |
|
||||
|
21
deps/mbedtls/ssl_srv.c
vendored
21
deps/mbedtls/ssl_srv.c
vendored
@ -38,9 +38,7 @@
|
||||
#include "mbedtls/ecp.h"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
#include "mbedtls/platform_time.h"
|
||||
#endif
|
||||
#include <time.h>
|
||||
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||
#include "arc4_alt.h"
|
||||
@ -2284,10 +2282,8 @@ 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)
|
||||
mbedtls_time_t t;
|
||||
#endif
|
||||
int ret;
|
||||
time_t t;
|
||||
size_t olen, ext_len = 0, n;
|
||||
unsigned char *buf, *p;
|
||||
|
||||
@ -2327,20 +2323,13 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl )
|
||||
MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, chosen version: [%d:%d]",
|
||||
buf[4], buf[5] ) );
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
t = mbedtls_time( NULL );
|
||||
t = time( NULL );
|
||||
*p++ = (unsigned char)( t >> 24 );
|
||||
*p++ = (unsigned char)( t >> 16 );
|
||||
*p++ = (unsigned char)( t >> 8 );
|
||||
*p++ = (unsigned char)( t );
|
||||
|
||||
MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, current time: %lu", t ) );
|
||||
#else
|
||||
if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, p, 4 ) ) != 0 )
|
||||
return( ret );
|
||||
|
||||
p += 4;
|
||||
#endif /* MBEDTLS_HAVE_TIME */
|
||||
|
||||
if( ( ret = ssl->conf->f_rng( ssl->conf->p_rng, p, 28 ) ) != 0 )
|
||||
return( ret );
|
||||
@ -2376,9 +2365,7 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl )
|
||||
*/
|
||||
ssl->state++;
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
ssl->session_negotiate->start = mbedtls_time( NULL );
|
||||
#endif
|
||||
ssl->session_negotiate->start = time( NULL );
|
||||
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||
if( ssl->handshake->new_session_ticket != 0 )
|
||||
|
21
deps/mbedtls/ssl_ticket.c
vendored
21
deps/mbedtls/ssl_ticket.c
vendored
@ -59,9 +59,7 @@ static int ssl_ticket_gen_key( mbedtls_ssl_ticket_context *ctx,
|
||||
unsigned char buf[MAX_KEY_BYTES];
|
||||
mbedtls_ssl_ticket_key *key = ctx->keys + index;
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
key->generation_time = (uint32_t) mbedtls_time( NULL );
|
||||
#endif
|
||||
key->generation_time = (uint32_t)time( NULL );
|
||||
|
||||
if( ( ret = ctx->f_rng( ctx->p_rng, key->name, sizeof( key->name ) ) ) != 0 )
|
||||
return( ret );
|
||||
@ -84,27 +82,20 @@ static int ssl_ticket_gen_key( mbedtls_ssl_ticket_context *ctx,
|
||||
*/
|
||||
static int ssl_ticket_update_keys( mbedtls_ssl_ticket_context *ctx )
|
||||
{
|
||||
#if !defined(MBEDTLS_HAVE_TIME)
|
||||
((void) ctx);
|
||||
#else
|
||||
if( ctx->ticket_lifetime != 0 )
|
||||
{
|
||||
uint32_t current_time = (uint32_t) mbedtls_time( NULL );
|
||||
uint32_t key_time = ctx->keys[ctx->active].generation_time;
|
||||
uint32_t current_time = (uint32_t)time( NULL );
|
||||
uint32_t key_time = ctx->keys[ctx->active].generation_time;
|
||||
|
||||
if( current_time > key_time &&
|
||||
current_time - key_time < ctx->ticket_lifetime )
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
ctx->active = 1 - ctx->active;
|
||||
|
||||
return( ssl_ticket_gen_key( ctx, ctx->active ) );
|
||||
}
|
||||
else
|
||||
#endif /* MBEDTLS_HAVE_TIME */
|
||||
return( 0 );
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
@ -439,10 +430,9 @@ int mbedtls_ssl_ticket_parse( void *p_ticket,
|
||||
if( ( ret = ssl_load_session( session, ticket, clear_len ) ) != 0 )
|
||||
goto cleanup;
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
{
|
||||
/* Check for expiration */
|
||||
mbedtls_time_t current_time = mbedtls_time( NULL );
|
||||
time_t current_time = time( NULL );
|
||||
|
||||
if( current_time < session->start ||
|
||||
(uint32_t)( current_time - session->start ) > ctx->ticket_lifetime )
|
||||
@ -451,7 +441,6 @@ int mbedtls_ssl_ticket_parse( void *p_ticket,
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
cleanup:
|
||||
#if defined(MBEDTLS_THREADING_C)
|
||||
|
9
deps/mbedtls/x509.c
vendored
9
deps/mbedtls/x509.c
vendored
@ -51,10 +51,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#if defined(MBEDTLS_HAVE_TIME)
|
||||
#include "mbedtls/platform_time.h"
|
||||
#endif
|
||||
#include <time.h>
|
||||
|
||||
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
|
||||
#include <windows.h>
|
||||
@ -909,7 +906,7 @@ static int x509_get_current_time( mbedtls_x509_time *now )
|
||||
static int x509_get_current_time( mbedtls_x509_time *now )
|
||||
{
|
||||
struct tm *lt;
|
||||
mbedtls_time_t tt;
|
||||
time_t tt;
|
||||
int ret = 0;
|
||||
|
||||
#if defined(MBEDTLS_THREADING_C)
|
||||
@ -917,7 +914,7 @@ static int x509_get_current_time( mbedtls_x509_time *now )
|
||||
return( MBEDTLS_ERR_THREADING_MUTEX_ERROR );
|
||||
#endif
|
||||
|
||||
tt = mbedtls_time( NULL );
|
||||
tt = time( NULL );
|
||||
lt = gmtime( &tt );
|
||||
|
||||
if( lt == NULL )
|
||||
|
Loading…
x
Reference in New Issue
Block a user