mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
move TimeNowInMilliseconds from tls13.c to internal,c; now WOLFSSL_API
This commit is contained in:
585
src/internal.c
585
src/internal.c
@ -238,6 +238,591 @@ enum processReply {
|
|||||||
runProcessingOneMessage
|
runProcessingOneMessage
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef WOLFSSL_32BIT_MILLI_TIME
|
||||||
|
#ifndef NO_ASN_TIME
|
||||||
|
#if defined(USER_TICKS)
|
||||||
|
#if 0
|
||||||
|
word32 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
write your own clock tick function if don't want gettimeofday()
|
||||||
|
needs millisecond accuracy but doesn't have to correlated to EPOCH
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined(TIME_OVERRIDES)
|
||||||
|
#if !defined(NO_ASN) && !defined(NO_ASN_TIME)
|
||||||
|
word32 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return (word32) wc_Time(0) * 1000;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#ifndef HAVE_TIME_T_TYPE
|
||||||
|
typedef long time_t;
|
||||||
|
#endif
|
||||||
|
extern time_t XTIME(time_t * timer);
|
||||||
|
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 32-bit value.
|
||||||
|
*/
|
||||||
|
word32 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return (word32) XTIME(0) * 1000;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined(XTIME_MS)
|
||||||
|
word32 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return (word32)XTIME_MS(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(USE_WINDOWS_API)
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 32-bit value.
|
||||||
|
*/
|
||||||
|
word32 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
static int init = 0;
|
||||||
|
static LARGE_INTEGER freq;
|
||||||
|
LARGE_INTEGER count;
|
||||||
|
|
||||||
|
if (!init) {
|
||||||
|
QueryPerformanceFrequency(&freq);
|
||||||
|
init = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
QueryPerformanceCounter(&count);
|
||||||
|
|
||||||
|
return (word32)(count.QuadPart / (freq.QuadPart / 1000));
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(HAVE_RTP_SYS)
|
||||||
|
#include "rtptime.h"
|
||||||
|
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 32-bit value.
|
||||||
|
*/
|
||||||
|
word32 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return (word32)rtp_get_system_sec() * 1000;
|
||||||
|
}
|
||||||
|
#elif defined(WOLFSSL_DEOS)
|
||||||
|
word32 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
const word32 systemTickTimeInHz = 1000000 / systemTickInMicroseconds();
|
||||||
|
word32 *systemTickPtr = systemTickPointer();
|
||||||
|
|
||||||
|
return (word32) (*systemTickPtr/systemTickTimeInHz) * 1000;
|
||||||
|
}
|
||||||
|
#elif defined(MICRIUM)
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 32-bit value.
|
||||||
|
*/
|
||||||
|
word32 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
OS_TICK ticks = 0;
|
||||||
|
OS_ERR err;
|
||||||
|
|
||||||
|
ticks = OSTimeGet(&err);
|
||||||
|
|
||||||
|
return (word32) (ticks / OSCfg_TickRate_Hz) * 1000;
|
||||||
|
}
|
||||||
|
#elif defined(MICROCHIP_TCPIP_V5)
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 32-bit value.
|
||||||
|
*/
|
||||||
|
word32 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return (word32) (TickGet() / (TICKS_PER_SECOND / 1000));
|
||||||
|
}
|
||||||
|
#elif defined(MICROCHIP_TCPIP)
|
||||||
|
#if defined(MICROCHIP_MPLAB_HARMONY)
|
||||||
|
#include <system/tmr/sys_tmr.h>
|
||||||
|
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 32-bit value.
|
||||||
|
*/
|
||||||
|
word32 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return (word32)(SYS_TMR_TickCountGet() /
|
||||||
|
(SYS_TMR_TickCounterFrequencyGet() / 1000));
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 32-bit value.
|
||||||
|
*/
|
||||||
|
word32 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return (word32)(SYS_TICK_Get() / (SYS_TICK_TicksPerSecondGet() / 1000));
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 32-bit value.
|
||||||
|
*/
|
||||||
|
word32 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
TIME_STRUCT mqxTime;
|
||||||
|
|
||||||
|
_time_get_elapsed(&mqxTime);
|
||||||
|
|
||||||
|
return (word32) mqxTime.SECONDS * 1000;
|
||||||
|
}
|
||||||
|
#elif defined(FREESCALE_FREE_RTOS) || defined(FREESCALE_KSDK_FREERTOS)
|
||||||
|
#include "include/task.h"
|
||||||
|
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 32-bit value.
|
||||||
|
*/
|
||||||
|
word32 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return (unsigned int)(((float)xTaskGetTickCount()) /
|
||||||
|
(configTICK_RATE_HZ / 1000));
|
||||||
|
}
|
||||||
|
#elif defined(FREESCALE_KSDK_BM)
|
||||||
|
#include "lwip/sys.h" /* lwIP */
|
||||||
|
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 32-bit value.
|
||||||
|
*/
|
||||||
|
word32 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return sys_now();
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(WOLFSSL_CMSIS_RTOS) || defined(WOLFSSL_CMSIS_RTOSv2)
|
||||||
|
|
||||||
|
word32 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return (word32)osKernelGetTickCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(WOLFSSL_TIRTOS)
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 32-bit value.
|
||||||
|
*/
|
||||||
|
word32 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return (word32) Seconds_get() * 1000;
|
||||||
|
}
|
||||||
|
#elif defined(WOLFSSL_UTASKER)
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 32-bit value.
|
||||||
|
*/
|
||||||
|
word32 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return (word32)(uTaskerSystemTick / (TICK_RESOLUTION / 1000));
|
||||||
|
}
|
||||||
|
#elif defined(WOLFSSL_LINUXKM)
|
||||||
|
word32 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
s64 t;
|
||||||
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
|
||||||
|
struct timespec ts;
|
||||||
|
getnstimeofday(&ts);
|
||||||
|
t = ts.tv_sec * (s64)1000;
|
||||||
|
t += ts.tv_nsec / (s64)1000000;
|
||||||
|
#else
|
||||||
|
struct timespec64 ts;
|
||||||
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
|
||||||
|
ts = current_kernel_time64();
|
||||||
|
#else
|
||||||
|
ktime_get_coarse_real_ts64(&ts);
|
||||||
|
#endif
|
||||||
|
t = ts.tv_sec * 1000L;
|
||||||
|
t += ts.tv_nsec / 1000000L;
|
||||||
|
#endif
|
||||||
|
return (word32)t;
|
||||||
|
}
|
||||||
|
#elif defined(WOLFSSL_QNX_CAAM)
|
||||||
|
word32 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
struct timespec now;
|
||||||
|
clock_gettime(CLOCK_REALTIME, &now);
|
||||||
|
return (word32)(now.tv_sec * 1000 + now.tv_nsec / 1000000);
|
||||||
|
}
|
||||||
|
#elif defined(FUSION_RTOS)
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 32-bit value.
|
||||||
|
*/
|
||||||
|
word32 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
struct timeval now;
|
||||||
|
if (FCL_GETTIMEOFDAY(&now, 0) < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Convert to milliseconds number. */
|
||||||
|
return (word32)(now.tv_sec * 1000 + now.tv_usec / 1000);
|
||||||
|
}
|
||||||
|
#elif defined(WOLFSSL_ZEPHYR)
|
||||||
|
word32 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
#if defined(CONFIG_ARCH_POSIX)
|
||||||
|
k_cpu_idle();
|
||||||
|
#endif
|
||||||
|
return (word32)k_uptime_get() / 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 32-bit value.
|
||||||
|
*/
|
||||||
|
word32 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
struct timeval now;
|
||||||
|
|
||||||
|
if (gettimeofday(&now, 0) < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Convert to milliseconds number. */
|
||||||
|
return (word32)(now.tv_sec * 1000 + now.tv_usec / 1000);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
/* user must supply time in milliseconds function:
|
||||||
|
* word32 TimeNowInMilliseconds(void);
|
||||||
|
* The response is milliseconds elapsed
|
||||||
|
*/
|
||||||
|
#endif /* !NO_ASN_TIME */
|
||||||
|
#else
|
||||||
|
#ifndef NO_ASN_TIME
|
||||||
|
#if defined(USER_TICKS)
|
||||||
|
#if 0
|
||||||
|
sword64 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
write your own clock tick function if don't want gettimeofday()
|
||||||
|
needs millisecond accuracy but doesn't have to correlated to EPOCH
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined(TIME_OVERRIDES)
|
||||||
|
#if !defined(NO_ASN) && !defined(NO_ASN_TIME)
|
||||||
|
sword64 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return (sword64) wc_Time(0) * 1000;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#ifndef HAVE_TIME_T_TYPE
|
||||||
|
typedef long time_t;
|
||||||
|
#endif
|
||||||
|
extern time_t XTIME(time_t * timer);
|
||||||
|
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 32-bit value.
|
||||||
|
*/
|
||||||
|
sword64 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return (sword64) XTIME(0) * 1000;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined(XTIME_MS)
|
||||||
|
sword64 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return (sword64)XTIME_MS(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(USE_WINDOWS_API)
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 64-bit value.
|
||||||
|
*/
|
||||||
|
sword64 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
static int init = 0;
|
||||||
|
static LARGE_INTEGER freq;
|
||||||
|
LARGE_INTEGER count;
|
||||||
|
|
||||||
|
if (!init) {
|
||||||
|
QueryPerformanceFrequency(&freq);
|
||||||
|
init = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
QueryPerformanceCounter(&count);
|
||||||
|
|
||||||
|
return (sword64)(count.QuadPart / (freq.QuadPart / 1000));
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(HAVE_RTP_SYS)
|
||||||
|
#include "rtptime.h"
|
||||||
|
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 64-bit value.
|
||||||
|
*/
|
||||||
|
sword64 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return (sword64)rtp_get_system_sec() * 1000;
|
||||||
|
}
|
||||||
|
#elif defined(WOLFSSL_DEOS)
|
||||||
|
sword64 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
const word32 systemTickTimeInHz = 1000000 / systemTickInMicroseconds();
|
||||||
|
word32 *systemTickPtr = systemTickPointer();
|
||||||
|
|
||||||
|
return (sword64) (*systemTickPtr/systemTickTimeInHz) * 1000;
|
||||||
|
}
|
||||||
|
#elif defined(MICRIUM)
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 64-bit value.
|
||||||
|
*/
|
||||||
|
sword64 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
OS_TICK ticks = 0;
|
||||||
|
OS_ERR err;
|
||||||
|
|
||||||
|
ticks = OSTimeGet(&err);
|
||||||
|
|
||||||
|
return (sword64) (ticks / OSCfg_TickRate_Hz) * 1000;
|
||||||
|
}
|
||||||
|
#elif defined(MICROCHIP_TCPIP_V5)
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 64-bit value.
|
||||||
|
*/
|
||||||
|
sword64 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return (sword64) (TickGet() / (TICKS_PER_SECOND / 1000));
|
||||||
|
}
|
||||||
|
#elif defined(MICROCHIP_TCPIP)
|
||||||
|
#if defined(MICROCHIP_MPLAB_HARMONY)
|
||||||
|
#include <system/tmr/sys_tmr.h>
|
||||||
|
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 64-bit value.
|
||||||
|
*/
|
||||||
|
sword64 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return (sword64)SYS_TMR_TickCountGet() /
|
||||||
|
(SYS_TMR_TickCounterFrequencyGet() / 1000);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 64-bit value.
|
||||||
|
*/
|
||||||
|
sword64 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return (sword64)SYS_TICK_Get() / (SYS_TICK_TicksPerSecondGet() / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 64-bit value.
|
||||||
|
*/
|
||||||
|
sword64 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
TIME_STRUCT mqxTime;
|
||||||
|
|
||||||
|
_time_get_elapsed(&mqxTime);
|
||||||
|
|
||||||
|
return (sword64) mqxTime.SECONDS * 1000;
|
||||||
|
}
|
||||||
|
#elif defined(FREESCALE_FREE_RTOS) || defined(FREESCALE_KSDK_FREERTOS)
|
||||||
|
#include "include/task.h"
|
||||||
|
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 64-bit value.
|
||||||
|
*/
|
||||||
|
sword64 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return (sword64)xTaskGetTickCount() / (configTICK_RATE_HZ / 1000);
|
||||||
|
}
|
||||||
|
#elif defined(FREESCALE_KSDK_BM)
|
||||||
|
#include "lwip/sys.h" /* lwIP */
|
||||||
|
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 64-bit value.
|
||||||
|
*/
|
||||||
|
sword64 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return sys_now();
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(WOLFSSL_CMSIS_RTOS) || defined(WOLFSSL_CMSIS_RTOSv2)
|
||||||
|
|
||||||
|
sword64 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return (sword64)osKernelGetTickCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(WOLFSSL_TIRTOS)
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 64-bit value.
|
||||||
|
*/
|
||||||
|
sword64 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return (sword64) Seconds_get() * 1000;
|
||||||
|
}
|
||||||
|
#elif defined(WOLFSSL_UTASKER)
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 64-bit value.
|
||||||
|
*/
|
||||||
|
sword64 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
return (sword64)(uTaskerSystemTick / (TICK_RESOLUTION / 1000));
|
||||||
|
}
|
||||||
|
#elif defined(WOLFSSL_LINUXKM)
|
||||||
|
sword64 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
s64 t;
|
||||||
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
|
||||||
|
struct timespec ts;
|
||||||
|
getnstimeofday(&ts);
|
||||||
|
t = ts.tv_sec * (s64)1000;
|
||||||
|
t += ts.tv_nsec / (s64)1000000;
|
||||||
|
#else
|
||||||
|
struct timespec64 ts;
|
||||||
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
|
||||||
|
ts = current_kernel_time64();
|
||||||
|
#else
|
||||||
|
ktime_get_coarse_real_ts64(&ts);
|
||||||
|
#endif
|
||||||
|
t = ts.tv_sec * 1000L;
|
||||||
|
t += ts.tv_nsec / 1000000L;
|
||||||
|
#endif
|
||||||
|
return (sword64)t;
|
||||||
|
}
|
||||||
|
#elif defined(WOLFSSL_QNX_CAAM)
|
||||||
|
sword64 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
struct timespec now;
|
||||||
|
clock_gettime(CLOCK_REALTIME, &now);
|
||||||
|
return (sword64)(now.tv_sec * 1000 + now.tv_nsec / 1000000);
|
||||||
|
}
|
||||||
|
#elif defined(FUSION_RTOS)
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 64-bit value.
|
||||||
|
*/
|
||||||
|
sword64 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
struct timeval now;
|
||||||
|
if (FCL_GETTIMEOFDAY(&now, 0) < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Convert to milliseconds number. */
|
||||||
|
return (sword64)now.tv_sec * 1000 + now.tv_usec / 1000;
|
||||||
|
}
|
||||||
|
#elif defined(WOLFSSL_ZEPHYR)
|
||||||
|
sword64 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
#if defined(CONFIG_ARCH_POSIX)
|
||||||
|
k_cpu_idle();
|
||||||
|
#endif
|
||||||
|
return (sword64)k_uptime_get() / 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
/* The time in milliseconds.
|
||||||
|
* Used for tickets to represent difference between when first seen and when
|
||||||
|
* sending.
|
||||||
|
*
|
||||||
|
* returns the time in milliseconds as a 64-bit value.
|
||||||
|
*/
|
||||||
|
|
||||||
|
sword64 TimeNowInMilliseconds(void)
|
||||||
|
{
|
||||||
|
struct timeval now;
|
||||||
|
|
||||||
|
if (gettimeofday(&now, 0) < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Convert to milliseconds number. */
|
||||||
|
return (sword64)(now.tv_sec * 1000 + now.tv_usec / 1000);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
/* user must supply time in milliseconds function:
|
||||||
|
* sword64 TimeNowInMilliseconds(void);
|
||||||
|
* The response is milliseconds elapsed
|
||||||
|
*/
|
||||||
|
#endif /* !NO_ASN_TIME */
|
||||||
|
#endif /* WOLFSSL_32BIT_MILLI_TIME */
|
||||||
|
|
||||||
#ifndef WOLFSSL_NO_TLS12
|
#ifndef WOLFSSL_NO_TLS12
|
||||||
#if !defined(NO_WOLFSSL_SERVER) || !defined(NO_WOLFSSL_CLIENT)
|
#if !defined(NO_WOLFSSL_SERVER) || !defined(NO_WOLFSSL_CLIENT)
|
||||||
|
587
src/tls13.c
587
src/tls13.c
@ -1627,593 +1627,6 @@ end:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (defined(HAVE_SESSION_TICKET) || !defined(NO_PSK))
|
|
||||||
#ifdef WOLFSSL_32BIT_MILLI_TIME
|
|
||||||
#ifndef NO_ASN_TIME
|
|
||||||
#if defined(USER_TICKS)
|
|
||||||
#if 0
|
|
||||||
word32 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
write your own clock tick function if don't want gettimeofday()
|
|
||||||
needs millisecond accuracy but doesn't have to correlated to EPOCH
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif defined(TIME_OVERRIDES)
|
|
||||||
#if !defined(NO_ASN) && !defined(NO_ASN_TIME)
|
|
||||||
word32 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return (word32) wc_Time(0) * 1000;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#ifndef HAVE_TIME_T_TYPE
|
|
||||||
typedef long time_t;
|
|
||||||
#endif
|
|
||||||
extern time_t XTIME(time_t * timer);
|
|
||||||
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 32-bit value.
|
|
||||||
*/
|
|
||||||
word32 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return (word32) XTIME(0) * 1000;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif defined(XTIME_MS)
|
|
||||||
word32 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return (word32)XTIME_MS(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(USE_WINDOWS_API)
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 32-bit value.
|
|
||||||
*/
|
|
||||||
word32 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
static int init = 0;
|
|
||||||
static LARGE_INTEGER freq;
|
|
||||||
LARGE_INTEGER count;
|
|
||||||
|
|
||||||
if (!init) {
|
|
||||||
QueryPerformanceFrequency(&freq);
|
|
||||||
init = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
QueryPerformanceCounter(&count);
|
|
||||||
|
|
||||||
return (word32)(count.QuadPart / (freq.QuadPart / 1000));
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(HAVE_RTP_SYS)
|
|
||||||
#include "rtptime.h"
|
|
||||||
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 32-bit value.
|
|
||||||
*/
|
|
||||||
word32 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return (word32)rtp_get_system_sec() * 1000;
|
|
||||||
}
|
|
||||||
#elif defined(WOLFSSL_DEOS)
|
|
||||||
word32 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
const word32 systemTickTimeInHz = 1000000 / systemTickInMicroseconds();
|
|
||||||
word32 *systemTickPtr = systemTickPointer();
|
|
||||||
|
|
||||||
return (word32) (*systemTickPtr/systemTickTimeInHz) * 1000;
|
|
||||||
}
|
|
||||||
#elif defined(MICRIUM)
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 32-bit value.
|
|
||||||
*/
|
|
||||||
word32 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
OS_TICK ticks = 0;
|
|
||||||
OS_ERR err;
|
|
||||||
|
|
||||||
ticks = OSTimeGet(&err);
|
|
||||||
|
|
||||||
return (word32) (ticks / OSCfg_TickRate_Hz) * 1000;
|
|
||||||
}
|
|
||||||
#elif defined(MICROCHIP_TCPIP_V5)
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 32-bit value.
|
|
||||||
*/
|
|
||||||
word32 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return (word32) (TickGet() / (TICKS_PER_SECOND / 1000));
|
|
||||||
}
|
|
||||||
#elif defined(MICROCHIP_TCPIP)
|
|
||||||
#if defined(MICROCHIP_MPLAB_HARMONY)
|
|
||||||
#include <system/tmr/sys_tmr.h>
|
|
||||||
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 32-bit value.
|
|
||||||
*/
|
|
||||||
word32 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return (word32)(SYS_TMR_TickCountGet() /
|
|
||||||
(SYS_TMR_TickCounterFrequencyGet() / 1000));
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 32-bit value.
|
|
||||||
*/
|
|
||||||
word32 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return (word32)(SYS_TICK_Get() / (SYS_TICK_TicksPerSecondGet() / 1000));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 32-bit value.
|
|
||||||
*/
|
|
||||||
word32 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
TIME_STRUCT mqxTime;
|
|
||||||
|
|
||||||
_time_get_elapsed(&mqxTime);
|
|
||||||
|
|
||||||
return (word32) mqxTime.SECONDS * 1000;
|
|
||||||
}
|
|
||||||
#elif defined(FREESCALE_FREE_RTOS) || defined(FREESCALE_KSDK_FREERTOS)
|
|
||||||
#include "include/task.h"
|
|
||||||
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 32-bit value.
|
|
||||||
*/
|
|
||||||
word32 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return (unsigned int)(((float)xTaskGetTickCount()) /
|
|
||||||
(configTICK_RATE_HZ / 1000));
|
|
||||||
}
|
|
||||||
#elif defined(FREESCALE_KSDK_BM)
|
|
||||||
#include "lwip/sys.h" /* lwIP */
|
|
||||||
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 32-bit value.
|
|
||||||
*/
|
|
||||||
word32 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return sys_now();
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(WOLFSSL_CMSIS_RTOS) || defined(WOLFSSL_CMSIS_RTOSv2)
|
|
||||||
|
|
||||||
word32 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return (word32)osKernelGetTickCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(WOLFSSL_TIRTOS)
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 32-bit value.
|
|
||||||
*/
|
|
||||||
word32 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return (word32) Seconds_get() * 1000;
|
|
||||||
}
|
|
||||||
#elif defined(WOLFSSL_UTASKER)
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 32-bit value.
|
|
||||||
*/
|
|
||||||
word32 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return (word32)(uTaskerSystemTick / (TICK_RESOLUTION / 1000));
|
|
||||||
}
|
|
||||||
#elif defined(WOLFSSL_LINUXKM)
|
|
||||||
word32 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
s64 t;
|
|
||||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
|
|
||||||
struct timespec ts;
|
|
||||||
getnstimeofday(&ts);
|
|
||||||
t = ts.tv_sec * (s64)1000;
|
|
||||||
t += ts.tv_nsec / (s64)1000000;
|
|
||||||
#else
|
|
||||||
struct timespec64 ts;
|
|
||||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
|
|
||||||
ts = current_kernel_time64();
|
|
||||||
#else
|
|
||||||
ktime_get_coarse_real_ts64(&ts);
|
|
||||||
#endif
|
|
||||||
t = ts.tv_sec * 1000L;
|
|
||||||
t += ts.tv_nsec / 1000000L;
|
|
||||||
#endif
|
|
||||||
return (word32)t;
|
|
||||||
}
|
|
||||||
#elif defined(WOLFSSL_QNX_CAAM)
|
|
||||||
word32 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
struct timespec now;
|
|
||||||
clock_gettime(CLOCK_REALTIME, &now);
|
|
||||||
return (word32)(now.tv_sec * 1000 + now.tv_nsec / 1000000);
|
|
||||||
}
|
|
||||||
#elif defined(FUSION_RTOS)
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 32-bit value.
|
|
||||||
*/
|
|
||||||
word32 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
struct timeval now;
|
|
||||||
if (FCL_GETTIMEOFDAY(&now, 0) < 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Convert to milliseconds number. */
|
|
||||||
return (word32)(now.tv_sec * 1000 + now.tv_usec / 1000);
|
|
||||||
}
|
|
||||||
#elif defined(WOLFSSL_ZEPHYR)
|
|
||||||
word32 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
#if defined(CONFIG_ARCH_POSIX)
|
|
||||||
k_cpu_idle();
|
|
||||||
#endif
|
|
||||||
return (word32)k_uptime_get() / 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 32-bit value.
|
|
||||||
*/
|
|
||||||
word32 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
struct timeval now;
|
|
||||||
|
|
||||||
if (gettimeofday(&now, 0) < 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Convert to milliseconds number. */
|
|
||||||
return (word32)(now.tv_sec * 1000 + now.tv_usec / 1000);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
/* user must supply time in milliseconds function:
|
|
||||||
* word32 TimeNowInMilliseconds(void);
|
|
||||||
* The response is milliseconds elapsed
|
|
||||||
*/
|
|
||||||
#endif /* !NO_ASN_TIME */
|
|
||||||
#else
|
|
||||||
#ifndef NO_ASN_TIME
|
|
||||||
#if defined(USER_TICKS)
|
|
||||||
#if 0
|
|
||||||
sword64 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
write your own clock tick function if don't want gettimeofday()
|
|
||||||
needs millisecond accuracy but doesn't have to correlated to EPOCH
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif defined(TIME_OVERRIDES)
|
|
||||||
#if !defined(NO_ASN) && !defined(NO_ASN_TIME)
|
|
||||||
sword64 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return (sword64) wc_Time(0) * 1000;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#ifndef HAVE_TIME_T_TYPE
|
|
||||||
typedef long time_t;
|
|
||||||
#endif
|
|
||||||
extern time_t XTIME(time_t * timer);
|
|
||||||
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 32-bit value.
|
|
||||||
*/
|
|
||||||
sword64 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return (sword64) XTIME(0) * 1000;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif defined(XTIME_MS)
|
|
||||||
sword64 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return (sword64)XTIME_MS(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(USE_WINDOWS_API)
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 64-bit value.
|
|
||||||
*/
|
|
||||||
sword64 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
static int init = 0;
|
|
||||||
static LARGE_INTEGER freq;
|
|
||||||
LARGE_INTEGER count;
|
|
||||||
|
|
||||||
if (!init) {
|
|
||||||
QueryPerformanceFrequency(&freq);
|
|
||||||
init = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
QueryPerformanceCounter(&count);
|
|
||||||
|
|
||||||
return (sword64)(count.QuadPart / (freq.QuadPart / 1000));
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(HAVE_RTP_SYS)
|
|
||||||
#include "rtptime.h"
|
|
||||||
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 64-bit value.
|
|
||||||
*/
|
|
||||||
sword64 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return (sword64)rtp_get_system_sec() * 1000;
|
|
||||||
}
|
|
||||||
#elif defined(WOLFSSL_DEOS)
|
|
||||||
sword64 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
const word32 systemTickTimeInHz = 1000000 / systemTickInMicroseconds();
|
|
||||||
word32 *systemTickPtr = systemTickPointer();
|
|
||||||
|
|
||||||
return (sword64) (*systemTickPtr/systemTickTimeInHz) * 1000;
|
|
||||||
}
|
|
||||||
#elif defined(MICRIUM)
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 64-bit value.
|
|
||||||
*/
|
|
||||||
sword64 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
OS_TICK ticks = 0;
|
|
||||||
OS_ERR err;
|
|
||||||
|
|
||||||
ticks = OSTimeGet(&err);
|
|
||||||
|
|
||||||
return (sword64) (ticks / OSCfg_TickRate_Hz) * 1000;
|
|
||||||
}
|
|
||||||
#elif defined(MICROCHIP_TCPIP_V5)
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 64-bit value.
|
|
||||||
*/
|
|
||||||
sword64 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return (sword64) (TickGet() / (TICKS_PER_SECOND / 1000));
|
|
||||||
}
|
|
||||||
#elif defined(MICROCHIP_TCPIP)
|
|
||||||
#if defined(MICROCHIP_MPLAB_HARMONY)
|
|
||||||
#include <system/tmr/sys_tmr.h>
|
|
||||||
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 64-bit value.
|
|
||||||
*/
|
|
||||||
sword64 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return (sword64)SYS_TMR_TickCountGet() /
|
|
||||||
(SYS_TMR_TickCounterFrequencyGet() / 1000);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 64-bit value.
|
|
||||||
*/
|
|
||||||
sword64 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return (sword64)SYS_TICK_Get() / (SYS_TICK_TicksPerSecondGet() / 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 64-bit value.
|
|
||||||
*/
|
|
||||||
sword64 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
TIME_STRUCT mqxTime;
|
|
||||||
|
|
||||||
_time_get_elapsed(&mqxTime);
|
|
||||||
|
|
||||||
return (sword64) mqxTime.SECONDS * 1000;
|
|
||||||
}
|
|
||||||
#elif defined(FREESCALE_FREE_RTOS) || defined(FREESCALE_KSDK_FREERTOS)
|
|
||||||
#include "include/task.h"
|
|
||||||
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 64-bit value.
|
|
||||||
*/
|
|
||||||
sword64 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return (sword64)xTaskGetTickCount() / (configTICK_RATE_HZ / 1000);
|
|
||||||
}
|
|
||||||
#elif defined(FREESCALE_KSDK_BM)
|
|
||||||
#include "lwip/sys.h" /* lwIP */
|
|
||||||
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 64-bit value.
|
|
||||||
*/
|
|
||||||
sword64 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return sys_now();
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(WOLFSSL_CMSIS_RTOS) || defined(WOLFSSL_CMSIS_RTOSv2)
|
|
||||||
|
|
||||||
sword64 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return (sword64)osKernelGetTickCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(WOLFSSL_TIRTOS)
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 64-bit value.
|
|
||||||
*/
|
|
||||||
sword64 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return (sword64) Seconds_get() * 1000;
|
|
||||||
}
|
|
||||||
#elif defined(WOLFSSL_UTASKER)
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 64-bit value.
|
|
||||||
*/
|
|
||||||
sword64 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
return (sword64)(uTaskerSystemTick / (TICK_RESOLUTION / 1000));
|
|
||||||
}
|
|
||||||
#elif defined(WOLFSSL_LINUXKM)
|
|
||||||
sword64 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
s64 t;
|
|
||||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
|
|
||||||
struct timespec ts;
|
|
||||||
getnstimeofday(&ts);
|
|
||||||
t = ts.tv_sec * (s64)1000;
|
|
||||||
t += ts.tv_nsec / (s64)1000000;
|
|
||||||
#else
|
|
||||||
struct timespec64 ts;
|
|
||||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
|
|
||||||
ts = current_kernel_time64();
|
|
||||||
#else
|
|
||||||
ktime_get_coarse_real_ts64(&ts);
|
|
||||||
#endif
|
|
||||||
t = ts.tv_sec * 1000L;
|
|
||||||
t += ts.tv_nsec / 1000000L;
|
|
||||||
#endif
|
|
||||||
return (sword64)t;
|
|
||||||
}
|
|
||||||
#elif defined(WOLFSSL_QNX_CAAM)
|
|
||||||
sword64 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
struct timespec now;
|
|
||||||
clock_gettime(CLOCK_REALTIME, &now);
|
|
||||||
return (sword64)(now.tv_sec * 1000 + now.tv_nsec / 1000000);
|
|
||||||
}
|
|
||||||
#elif defined(FUSION_RTOS)
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 64-bit value.
|
|
||||||
*/
|
|
||||||
sword64 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
struct timeval now;
|
|
||||||
if (FCL_GETTIMEOFDAY(&now, 0) < 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Convert to milliseconds number. */
|
|
||||||
return (sword64)now.tv_sec * 1000 + now.tv_usec / 1000;
|
|
||||||
}
|
|
||||||
#elif defined(WOLFSSL_ZEPHYR)
|
|
||||||
sword64 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
#if defined(CONFIG_ARCH_POSIX)
|
|
||||||
k_cpu_idle();
|
|
||||||
#endif
|
|
||||||
return (sword64)k_uptime_get() / 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
/* The time in milliseconds.
|
|
||||||
* Used for tickets to represent difference between when first seen and when
|
|
||||||
* sending.
|
|
||||||
*
|
|
||||||
* returns the time in milliseconds as a 64-bit value.
|
|
||||||
*/
|
|
||||||
sword64 TimeNowInMilliseconds(void)
|
|
||||||
{
|
|
||||||
struct timeval now;
|
|
||||||
|
|
||||||
if (gettimeofday(&now, 0) < 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Convert to milliseconds number. */
|
|
||||||
return (sword64)now.tv_sec * 1000 + now.tv_usec / 1000;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
/* user must supply time in milliseconds function:
|
|
||||||
* sword64 TimeNowInMilliseconds(void);
|
|
||||||
* The response is milliseconds elapsed
|
|
||||||
*/
|
|
||||||
#endif /* !NO_ASN_TIME */
|
|
||||||
#endif /* WOLFSSL_32BIT_MILLI_TIME */
|
|
||||||
#endif /* HAVE_SESSION_TICKET || !NO_PSK */
|
|
||||||
|
|
||||||
|
|
||||||
/* Extract the handshake header information.
|
/* Extract the handshake header information.
|
||||||
*
|
*
|
||||||
|
@ -6287,14 +6287,12 @@ WOLFSSL_LOCAL int cipherExtraData(WOLFSSL* ssl);
|
|||||||
|
|
||||||
WOLFSSL_LOCAL void WriteSEQ(WOLFSSL* ssl, int verifyOrder, byte* out);
|
WOLFSSL_LOCAL void WriteSEQ(WOLFSSL* ssl, int verifyOrder, byte* out);
|
||||||
|
|
||||||
#if defined(WOLFSSL_TLS13) && (defined(HAVE_SESSION_TICKET) || !defined(NO_PSK))
|
|
||||||
#ifdef WOLFSSL_32BIT_MILLI_TIME
|
#ifdef WOLFSSL_32BIT_MILLI_TIME
|
||||||
WOLFSSL_LOCAL word32 TimeNowInMilliseconds(void);
|
WOLFSSL_API word32 TimeNowInMilliseconds(void);
|
||||||
#else
|
#else
|
||||||
WOLFSSL_LOCAL sword64 TimeNowInMilliseconds(void);
|
WOLFSSL_API sword64 TimeNowInMilliseconds(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
|
||||||
WOLFSSL_LOCAL word32 LowResTimer(void);
|
WOLFSSL_LOCAL word32 LowResTimer(void);
|
||||||
|
|
||||||
WOLFSSL_LOCAL int FindSuiteSSL(const WOLFSSL* ssl, byte* suite);
|
WOLFSSL_LOCAL int FindSuiteSSL(const WOLFSSL* ssl, byte* suite);
|
||||||
|
Reference in New Issue
Block a user