mirror of https://github.com/wolfSSL/wolfssl
Merge pull request #261 from dgarske/AsnIoCleanup
asm.c time cleanup and io.c include cleanup
This commit is contained in:
commit
6856e5bbe6
58
src/io.c
58
src/io.c
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
/* if user writes own I/O callbacks they can define WOLFSSL_USER_IO to remove
|
/* if user writes own I/O callbacks they can define WOLFSSL_USER_IO to remove
|
||||||
automatic setting of default I/O functions EmbedSend() and EmbedReceive()
|
automatic setting of default I/O functions EmbedSend() and EmbedReceive()
|
||||||
but they'll still need SetCallback xxx() at end of file
|
but they'll still need SetCallback xxx() at end of file
|
||||||
*/
|
*/
|
||||||
#ifndef WOLFSSL_USER_IO
|
#ifndef WOLFSSL_USER_IO
|
||||||
|
|
||||||
|
@ -86,8 +86,13 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#if !(defined(DEVKITPRO) || defined(HAVE_RTP_SYS) || defined(EBSNET)) \
|
|
||||||
&& !(defined(WOLFSSL_PICOTCP))
|
#if defined(HAVE_RTP_SYS)
|
||||||
|
#include <socket.h>
|
||||||
|
#elif defined(EBSNET)
|
||||||
|
#include "rtipapi.h" /* errno */
|
||||||
|
#include "socket.h"
|
||||||
|
#elif !defined(DEVKITPRO) && !defined(WOLFSSL_PICOTCP)
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
@ -98,13 +103,6 @@
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_RTP_SYS
|
|
||||||
#include <socket.h>
|
|
||||||
#endif
|
|
||||||
#ifdef EBSNET
|
|
||||||
#include "rtipapi.h" /* errno */
|
|
||||||
#include "socket.h"
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
#endif /* USE_WINDOWS_API */
|
#endif /* USE_WINDOWS_API */
|
||||||
|
|
||||||
|
@ -112,7 +110,7 @@
|
||||||
#include <sys/filio.h>
|
#include <sys/filio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_WINDOWS_API
|
#ifdef USE_WINDOWS_API
|
||||||
/* no epipe yet */
|
/* no epipe yet */
|
||||||
#ifndef WSAEPIPE
|
#ifndef WSAEPIPE
|
||||||
#define WSAEPIPE -12345
|
#define WSAEPIPE -12345
|
||||||
|
@ -218,8 +216,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Translates return codes returned from
|
/* Translates return codes returned from
|
||||||
* send() and recv() if need be.
|
* send() and recv() if need be.
|
||||||
*/
|
*/
|
||||||
static INLINE int TranslateReturnCode(int old, int sd)
|
static INLINE int TranslateReturnCode(int old, int sd)
|
||||||
{
|
{
|
||||||
|
@ -247,7 +245,7 @@ static INLINE int TranslateReturnCode(int old, int sd)
|
||||||
|
|
||||||
static INLINE int LastError(void)
|
static INLINE int LastError(void)
|
||||||
{
|
{
|
||||||
#ifdef USE_WINDOWS_API
|
#ifdef USE_WINDOWS_API
|
||||||
return WSAGetLastError();
|
return WSAGetLastError();
|
||||||
#elif defined(EBSNET)
|
#elif defined(EBSNET)
|
||||||
return xn_getlasterror();
|
return xn_getlasterror();
|
||||||
|
@ -372,7 +370,7 @@ int EmbedSend(WOLFSSL* ssl, char *buf, int sz, void *ctx)
|
||||||
return WOLFSSL_CBIO_ERR_GENERAL;
|
return WOLFSSL_CBIO_ERR_GENERAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sent;
|
return sent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,7 +511,7 @@ int EmbedSendTo(WOLFSSL* ssl, char *buf, int sz, void *ctx)
|
||||||
return WOLFSSL_CBIO_ERR_GENERAL;
|
return WOLFSSL_CBIO_ERR_GENERAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sent;
|
return sent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -709,14 +707,14 @@ static int decode_url(const char* url, int urlSz,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int i, cur;
|
int i, cur;
|
||||||
|
|
||||||
/* need to break the url down into scheme, address, and port */
|
/* need to break the url down into scheme, address, and port */
|
||||||
/* "http://example.com:8080/" */
|
/* "http://example.com:8080/" */
|
||||||
/* "http://[::1]:443/" */
|
/* "http://[::1]:443/" */
|
||||||
if (XSTRNCMP(url, "http://", 7) == 0) {
|
if (XSTRNCMP(url, "http://", 7) == 0) {
|
||||||
cur = 7;
|
cur = 7;
|
||||||
} else cur = 0;
|
} else cur = 0;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
if (url[cur] == '[') {
|
if (url[cur] == '[') {
|
||||||
cur++;
|
cur++;
|
||||||
|
@ -734,7 +732,7 @@ static int decode_url(const char* url, int urlSz,
|
||||||
}
|
}
|
||||||
outName[i] = 0;
|
outName[i] = 0;
|
||||||
/* Need to pick out the path after the domain name */
|
/* Need to pick out the path after the domain name */
|
||||||
|
|
||||||
if (cur < urlSz && url[cur] == ':') {
|
if (cur < urlSz && url[cur] == ':') {
|
||||||
char port[6];
|
char port[6];
|
||||||
int j;
|
int j;
|
||||||
|
@ -745,7 +743,7 @@ static int decode_url(const char* url, int urlSz,
|
||||||
i < 6) {
|
i < 6) {
|
||||||
port[i++] = url[cur++];
|
port[i++] = url[cur++];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < i; j++) {
|
for (j = 0; j < i; j++) {
|
||||||
if (port[j] < '0' || port[j] > '9') return -1;
|
if (port[j] < '0' || port[j] > '9') return -1;
|
||||||
bigPort = (bigPort * 10) + (port[j] - '0');
|
bigPort = (bigPort * 10) + (port[j] - '0');
|
||||||
|
@ -754,7 +752,7 @@ static int decode_url(const char* url, int urlSz,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*outPort = 80;
|
*outPort = 80;
|
||||||
|
|
||||||
if (cur < urlSz && url[cur] == '/') {
|
if (cur < urlSz && url[cur] == '/') {
|
||||||
i = 0;
|
i = 0;
|
||||||
while (cur < urlSz && url[cur] != 0 && i < 80) {
|
while (cur < urlSz && url[cur] != 0 && i < 80) {
|
||||||
|
@ -841,7 +839,7 @@ static int process_http_response(int sfd, byte** respBuf,
|
||||||
WOLFSSL_MSG("process_http_response not ocsp-response");
|
WOLFSSL_MSG("process_http_response not ocsp-response");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state == phr_http_start) state = phr_have_type;
|
if (state == phr_http_start) state = phr_have_type;
|
||||||
else if (state == phr_have_length) state = phr_wait_end;
|
else if (state == phr_have_length) state = phr_wait_end;
|
||||||
else {
|
else {
|
||||||
|
@ -861,7 +859,7 @@ static int process_http_response(int sfd, byte** respBuf,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
start = end + 2;
|
start = end + 2;
|
||||||
}
|
}
|
||||||
} while (state != phr_http_end);
|
} while (state != phr_http_end);
|
||||||
|
@ -912,7 +910,7 @@ int EmbedOcspLookup(void* ctx, const char* url, int urlSz,
|
||||||
path = (char*)XMALLOC(80, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
path = (char*)XMALLOC(80, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
domainName = (char*)XMALLOC(80, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
domainName = (char*)XMALLOC(80, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
if (domainName == NULL) {
|
if (domainName == NULL) {
|
||||||
XFREE(path, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
XFREE(path, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
|
@ -935,7 +933,7 @@ int EmbedOcspLookup(void* ctx, const char* url, int urlSz,
|
||||||
/* Note, the library uses the EmbedOcspRespFree() callback to
|
/* Note, the library uses the EmbedOcspRespFree() callback to
|
||||||
* free this buffer. */
|
* free this buffer. */
|
||||||
int httpBufSz = SCRATCH_BUFFER_SIZE;
|
int httpBufSz = SCRATCH_BUFFER_SIZE;
|
||||||
byte* httpBuf = (byte*)XMALLOC(httpBufSz, NULL,
|
byte* httpBuf = (byte*)XMALLOC(httpBufSz, NULL,
|
||||||
DYNAMIC_TYPE_OCSP);
|
DYNAMIC_TYPE_OCSP);
|
||||||
|
|
||||||
if (httpBuf == NULL) {
|
if (httpBuf == NULL) {
|
||||||
|
@ -1002,13 +1000,13 @@ WOLFSSL_API void wolfSSL_SetIOSend(WOLFSSL_CTX *ctx, CallbackIOSend CBIOSend)
|
||||||
|
|
||||||
WOLFSSL_API void wolfSSL_SetIOReadCtx(WOLFSSL* ssl, void *rctx)
|
WOLFSSL_API void wolfSSL_SetIOReadCtx(WOLFSSL* ssl, void *rctx)
|
||||||
{
|
{
|
||||||
ssl->IOCB_ReadCtx = rctx;
|
ssl->IOCB_ReadCtx = rctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WOLFSSL_API void wolfSSL_SetIOWriteCtx(WOLFSSL* ssl, void *wctx)
|
WOLFSSL_API void wolfSSL_SetIOWriteCtx(WOLFSSL* ssl, void *wctx)
|
||||||
{
|
{
|
||||||
ssl->IOCB_WriteCtx = wctx;
|
ssl->IOCB_WriteCtx = wctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1032,7 +1030,7 @@ WOLFSSL_API void* wolfSSL_GetIOWriteCtx(WOLFSSL* ssl)
|
||||||
|
|
||||||
WOLFSSL_API void wolfSSL_SetIOReadFlags(WOLFSSL* ssl, int flags)
|
WOLFSSL_API void wolfSSL_SetIOReadFlags(WOLFSSL* ssl, int flags)
|
||||||
{
|
{
|
||||||
ssl->rflags = flags;
|
ssl->rflags = flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1052,14 +1050,14 @@ WOLFSSL_API void wolfSSL_CTX_SetGenCookie(WOLFSSL_CTX* ctx, CallbackGenCookie cb
|
||||||
|
|
||||||
WOLFSSL_API void wolfSSL_SetCookieCtx(WOLFSSL* ssl, void *ctx)
|
WOLFSSL_API void wolfSSL_SetCookieCtx(WOLFSSL* ssl, void *ctx)
|
||||||
{
|
{
|
||||||
ssl->IOCB_CookieCtx = ctx;
|
ssl->IOCB_CookieCtx = ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WOLFSSL_API void* wolfSSL_GetCookieCtx(WOLFSSL* ssl)
|
WOLFSSL_API void* wolfSSL_GetCookieCtx(WOLFSSL* ssl)
|
||||||
{
|
{
|
||||||
if (ssl)
|
if (ssl)
|
||||||
return ssl->IOCB_CookieCtx;
|
return ssl->IOCB_CookieCtx;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,62 +95,114 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_RTP_SYS
|
#if defined(HAVE_RTP_SYS)
|
||||||
/* uses parital <time.h> structures */
|
/* uses parital <time.h> structures */
|
||||||
#define XTIME(tl) (0)
|
#define XTIME(tl) (0)
|
||||||
#define XGMTIME(c, t) my_gmtime((c))
|
#define XGMTIME(c, t) rtpsys_gmtime((c))
|
||||||
#define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
|
|
||||||
#elif defined(MICRIUM)
|
#elif defined(MICRIUM)
|
||||||
#if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
|
#if (NET_SECURE_MGR_CFG_EN == DEF_ENABLED)
|
||||||
#define XVALIDATE_DATE(d,f,t) NetSecure_ValidateDateHandler((d),(f),(t))
|
#define XVALIDATE_DATE(d, f, t) NetSecure_ValidateDateHandler((d), (f), (t))
|
||||||
#else
|
#else
|
||||||
#define XVALIDATE_DATE(d, f, t) (0)
|
#define XVALIDATE_DATE(d, f, t) (0)
|
||||||
#endif
|
#endif
|
||||||
#define NO_TIME_H
|
#define NO_TIME_H
|
||||||
/* since Micrium not defining XTIME or XGMTIME, CERT_GEN not available */
|
/* since Micrium not defining XTIME or XGMTIME, CERT_GEN not available */
|
||||||
|
|
||||||
#elif defined(MICROCHIP_TCPIP_V5) || defined(MICROCHIP_TCPIP)
|
#elif defined(MICROCHIP_TCPIP_V5) || defined(MICROCHIP_TCPIP)
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#define XTIME(t1) pic32_time((t1))
|
#define XTIME(t1) pic32_time((t1))
|
||||||
#define XGMTIME(c, t) gmtime((c))
|
#define XGMTIME(c, t) gmtime((c))
|
||||||
#define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
|
|
||||||
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
#elif defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
||||||
#define XTIME(t1) mqx_time((t1))
|
#define XTIME(t1) mqx_time((t1))
|
||||||
#define XGMTIME(c, t) mqx_gmtime((c), (t))
|
#define HAVE_GMTIME_R
|
||||||
#define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
|
|
||||||
#elif defined(FREESCALE_KSDK_BM) || defined(FREESCALE_FREE_RTOS)
|
#elif defined(FREESCALE_KSDK_BM) || defined(FREESCALE_FREE_RTOS)
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#define XTIME(t1) ksdk_time((t1))
|
#define XTIME(t1) ksdk_time((t1))
|
||||||
#define XGMTIME(c, t) gmtime((c))
|
#define XGMTIME(c, t) gmtime((c))
|
||||||
#define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
|
|
||||||
|
|
||||||
#elif defined(USER_TIME)
|
#elif defined(USER_TIME)
|
||||||
/* user time, and gmtime compatible functions, there is a gmtime
|
/* user time, and gmtime compatible functions, there is a gmtime
|
||||||
implementation here that WINCE uses, so really just need some ticks
|
implementation here that WINCE uses, so really just need some ticks
|
||||||
since the EPOCH
|
since the EPOCH
|
||||||
*/
|
*/
|
||||||
|
#define WOLFSSL_GMTIME
|
||||||
|
#define USE_WOLF_TM
|
||||||
|
#define USE_WOLF_TIME_T
|
||||||
|
|
||||||
|
#elif defined(TIME_OVERRIDES)
|
||||||
|
/* user would like to override time() and gmtime() functionality */
|
||||||
|
#ifndef HAVE_TIME_T_TYPE
|
||||||
|
#define USE_WOLF_TIME_T
|
||||||
|
#endif
|
||||||
|
#ifndef HAVE_TM_TYPE
|
||||||
|
#define USE_WOLF_TM
|
||||||
|
#endif
|
||||||
|
#define NEED_TMP_TIME
|
||||||
|
|
||||||
|
#elif defined(IDIRECT_DEV_TIME)
|
||||||
|
/*Gets the timestamp from cloak software owned by VT iDirect
|
||||||
|
in place of time() from <time.h> */
|
||||||
|
#include <time.h>
|
||||||
|
#define XTIME(t1) idirect_time((t1))
|
||||||
|
#define XGMTIME(c, t) gmtime((c))
|
||||||
|
|
||||||
|
#elif defined(_WIN32_WCE)
|
||||||
|
#include <windows.h>
|
||||||
|
#define XTIME(t1) windows_time((t1))
|
||||||
|
#define WOLFSSL_GMTIME
|
||||||
|
|
||||||
|
#else
|
||||||
|
/* default */
|
||||||
|
/* uses complete <time.h> facility */
|
||||||
|
#include <time.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/* Map default time functions */
|
||||||
|
#if !defined(XTIME) && !defined(TIME_OVERRIDES) && !defined(USER_TIME)
|
||||||
|
#define XTIME(tl) time((tl))
|
||||||
|
#endif
|
||||||
|
#if !defined(XGMTIME) && !defined(TIME_OVERRIDES)
|
||||||
|
#if defined(WOLFSSL_GMTIME) || !defined(HAVE_GMTIME_R)
|
||||||
|
#define XGMTIME(c, t) gmtime((c))
|
||||||
|
#else
|
||||||
|
#define XGMTIME(c, t) gmtime_r((c), (t))
|
||||||
|
#define NEED_TMP_TIME
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if !defined(XVALIDATE_DATE) && !defined(HAVE_VALIDATE_DATE)
|
||||||
|
#define USE_WOLF_VALIDDATE
|
||||||
|
#define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* wolf struct tm and time_t */
|
||||||
|
#if defined(USE_WOLF_TM)
|
||||||
struct tm {
|
struct tm {
|
||||||
int tm_sec; /* seconds after the minute [0-60] */
|
int tm_sec; /* seconds after the minute [0-60] */
|
||||||
int tm_min; /* minutes after the hour [0-59] */
|
int tm_min; /* minutes after the hour [0-59] */
|
||||||
int tm_hour; /* hours since midnight [0-23] */
|
int tm_hour; /* hours since midnight [0-23] */
|
||||||
int tm_mday; /* day of the month [1-31] */
|
int tm_mday; /* day of the month [1-31] */
|
||||||
int tm_mon; /* months since January [0-11] */
|
int tm_mon; /* months since January [0-11] */
|
||||||
int tm_year; /* years since 1900 */
|
int tm_year; /* years since 1900 */
|
||||||
int tm_wday; /* days since Sunday [0-6] */
|
int tm_wday; /* days since Sunday [0-6] */
|
||||||
int tm_yday; /* days since January 1 [0-365] */
|
int tm_yday; /* days since January 1 [0-365] */
|
||||||
int tm_isdst; /* Daylight Savings Time flag */
|
int tm_isdst; /* Daylight Savings Time flag */
|
||||||
long tm_gmtoff; /* offset from CUT in seconds */
|
long tm_gmtoff; /* offset from CUT in seconds */
|
||||||
char *tm_zone; /* timezone abbreviation */
|
char *tm_zone; /* timezone abbreviation */
|
||||||
};
|
};
|
||||||
|
#endif /* USE_WOLF_TM */
|
||||||
|
#if defined(USE_WOLF_TIME_T)
|
||||||
typedef long time_t;
|
typedef long time_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* forward declaration */
|
/* forward declarations */
|
||||||
|
#if defined(USER_TIME)
|
||||||
struct tm* gmtime(const time_t* timer);
|
struct tm* gmtime(const time_t* timer);
|
||||||
extern time_t XTIME(time_t * timer);
|
extern time_t XTIME(time_t * timer);
|
||||||
|
|
||||||
#define XGMTIME(c, t) gmtime((c))
|
|
||||||
#define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
|
|
||||||
|
|
||||||
#ifdef STACK_TRAP
|
#ifdef STACK_TRAP
|
||||||
/* for stack trap tracking, don't call os gmtime on OS X/linux,
|
/* for stack trap tracking, don't call os gmtime on OS X/linux,
|
||||||
uses a lot of stack spce */
|
uses a lot of stack spce */
|
||||||
|
@ -159,64 +211,13 @@
|
||||||
#endif /* STACK_TRAP */
|
#endif /* STACK_TRAP */
|
||||||
|
|
||||||
#elif defined(TIME_OVERRIDES)
|
#elif defined(TIME_OVERRIDES)
|
||||||
/* user would like to override time() and gmtime() functionality */
|
|
||||||
|
|
||||||
#ifndef HAVE_TIME_T_TYPE
|
|
||||||
typedef long time_t;
|
|
||||||
#endif
|
|
||||||
extern time_t XTIME(time_t * timer);
|
extern time_t XTIME(time_t * timer);
|
||||||
|
|
||||||
#ifndef HAVE_TM_TYPE
|
|
||||||
struct tm {
|
|
||||||
int tm_sec; /* seconds after the minute [0-60] */
|
|
||||||
int tm_min; /* minutes after the hour [0-59] */
|
|
||||||
int tm_hour; /* hours since midnight [0-23] */
|
|
||||||
int tm_mday; /* day of the month [1-31] */
|
|
||||||
int tm_mon; /* months since January [0-11] */
|
|
||||||
int tm_year; /* years since 1900 */
|
|
||||||
int tm_wday; /* days since Sunday [0-6] */
|
|
||||||
int tm_yday; /* days since January 1 [0-365] */
|
|
||||||
int tm_isdst; /* Daylight Savings Time flag */
|
|
||||||
long tm_gmtoff; /* offset from CUT in seconds */
|
|
||||||
char *tm_zone; /* timezone abbreviation */
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
extern struct tm* XGMTIME(const time_t* timer, struct tm* tmp);
|
extern struct tm* XGMTIME(const time_t* timer, struct tm* tmp);
|
||||||
|
|
||||||
#ifndef HAVE_VALIDATE_DATE
|
|
||||||
#define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#elif defined(IDIRECT_DEV_TIME)
|
|
||||||
/*Gets the timestamp from cloak software owned by VT iDirect
|
|
||||||
in place of time() from <time.h> */
|
|
||||||
#include <time.h>
|
|
||||||
#define XTIME(t1) idirect_time((t1))
|
|
||||||
#define XGMTIME(c) gmtime((c))
|
|
||||||
#define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
|
|
||||||
|
|
||||||
#else
|
|
||||||
/* default */
|
|
||||||
/* uses complete <time.h> facility */
|
|
||||||
#include <time.h>
|
|
||||||
#define XTIME(tl) time((tl))
|
|
||||||
#ifdef HAVE_GMTIME_R
|
|
||||||
#define XGMTIME(c, t) gmtime_r((c), (t))
|
|
||||||
#define NEED_TMP_TIME
|
|
||||||
#else
|
|
||||||
#define XGMTIME(c, t) gmtime((c))
|
|
||||||
#endif
|
|
||||||
#define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t))
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32_WCE
|
#if defined(_WIN32_WCE)
|
||||||
/* no time() or gmtime() even though in time.h header?? */
|
time_t windows_time(time_t* timer)
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
|
|
||||||
time_t time(time_t* timer)
|
|
||||||
{
|
{
|
||||||
SYSTEMTIME sysTime;
|
SYSTEMTIME sysTime;
|
||||||
FILETIME fTime;
|
FILETIME fTime;
|
||||||
|
@ -238,10 +239,9 @@ time_t time(time_t* timer)
|
||||||
|
|
||||||
return *timer;
|
return *timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _WIN32_WCE */
|
#endif /* _WIN32_WCE */
|
||||||
#if defined( _WIN32_WCE ) || defined( USER_TIME )
|
|
||||||
|
|
||||||
|
#if defined(WOLFSSL_GMTIME)
|
||||||
struct tm* gmtime(const time_t* timer)
|
struct tm* gmtime(const time_t* timer)
|
||||||
{
|
{
|
||||||
#define YEAR0 1900
|
#define YEAR0 1900
|
||||||
|
@ -289,15 +289,13 @@ struct tm* gmtime(const time_t* timer)
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif /* WOLFSSL_GMTIME */
|
||||||
#endif /* _WIN32_WCE || USER_TIME */
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_RTP_SYS
|
#if defined(HAVE_RTP_SYS)
|
||||||
|
|
||||||
#define YEAR0 1900
|
#define YEAR0 1900
|
||||||
|
|
||||||
struct tm* my_gmtime(const time_t* timer) /* has a gmtime() but hangs */
|
struct tm* rtpsys_gmtime(const time_t* timer) /* has a gmtime() but hangs */
|
||||||
{
|
{
|
||||||
static struct tm st_time;
|
static struct tm st_time;
|
||||||
struct tm* ret = &st_time;
|
struct tm* ret = &st_time;
|
||||||
|
@ -365,12 +363,6 @@ time_t mqx_time(time_t* timer)
|
||||||
return *timer;
|
return *timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CodeWarrior GCC toolchain only has gmtime_r(), no gmtime() */
|
|
||||||
struct tm* mqx_gmtime(const time_t* clock, struct tm* tmpTime)
|
|
||||||
{
|
|
||||||
return gmtime_r(clock, tmpTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* FREESCALE_MQX */
|
#endif /* FREESCALE_MQX */
|
||||||
|
|
||||||
#if defined(FREESCALE_KSDK_BM) || defined(FREESCALE_FREE_RTOS)
|
#if defined(FREESCALE_KSDK_BM) || defined(FREESCALE_FREE_RTOS)
|
||||||
|
@ -390,7 +382,7 @@ time_t ksdk_time(time_t* timer)
|
||||||
|
|
||||||
#endif /* FREESCALE_KSDK_BM */
|
#endif /* FREESCALE_KSDK_BM */
|
||||||
|
|
||||||
#ifdef WOLFSSL_TIRTOS
|
#if defined(WOLFSSL_TIRTOS)
|
||||||
|
|
||||||
time_t XTIME(time_t * timer)
|
time_t XTIME(time_t * timer)
|
||||||
{
|
{
|
||||||
|
@ -406,6 +398,7 @@ time_t XTIME(time_t * timer)
|
||||||
|
|
||||||
#endif /* WOLFSSL_TIRTOS */
|
#endif /* WOLFSSL_TIRTOS */
|
||||||
|
|
||||||
|
|
||||||
static INLINE word32 btoi(byte b)
|
static INLINE word32 btoi(byte b)
|
||||||
{
|
{
|
||||||
return b - 0x30;
|
return b - 0x30;
|
||||||
|
@ -496,7 +489,7 @@ time_t idirect_time(time_t * timer)
|
||||||
return sec;
|
return sec;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /* IDIRECT_DEV_TIME */
|
||||||
|
|
||||||
|
|
||||||
WOLFSSL_LOCAL int GetLength(const byte* input, word32* inOutIdx, int* len,
|
WOLFSSL_LOCAL int GetLength(const byte* input, word32* inOutIdx, int* len,
|
||||||
|
@ -2954,7 +2947,7 @@ static int GetName(DecodedCert* cert, int nameType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef NO_TIME_H
|
#if !defined(NO_TIME_H) && defined(USE_WOLF_VALIDDATE)
|
||||||
|
|
||||||
/* to the second */
|
/* to the second */
|
||||||
static int DateGreaterThan(const struct tm* a, const struct tm* b)
|
static int DateGreaterThan(const struct tm* a, const struct tm* b)
|
||||||
|
@ -2992,7 +2985,6 @@ static INLINE int DateLessThan(const struct tm* a, const struct tm* b)
|
||||||
return DateGreaterThan(b,a);
|
return DateGreaterThan(b,a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* like atoi but only use first byte */
|
/* like atoi but only use first byte */
|
||||||
/* Make sure before and after dates are valid */
|
/* Make sure before and after dates are valid */
|
||||||
int ValidateDate(const byte* date, byte format, int dateType)
|
int ValidateDate(const byte* date, byte format, int dateType)
|
||||||
|
@ -3006,8 +2998,7 @@ int ValidateDate(const byte* date, byte format, int dateType)
|
||||||
int diffHH = 0 ; int diffMM = 0 ;
|
int diffHH = 0 ; int diffMM = 0 ;
|
||||||
int diffSign = 0 ;
|
int diffSign = 0 ;
|
||||||
|
|
||||||
#if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) || \
|
#if defined(NEED_TMP_TIME)
|
||||||
defined(TIME_OVERRIDES) || defined(NEED_TMP_TIME)
|
|
||||||
struct tm tmpTimeStorage;
|
struct tm tmpTimeStorage;
|
||||||
tmpTime = &tmpTimeStorage;
|
tmpTime = &tmpTimeStorage;
|
||||||
#else
|
#else
|
||||||
|
@ -3065,8 +3056,7 @@ int ValidateDate(const byte* date, byte format, int dateType)
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif /* !NO_TIME_H && USE_WOLF_VALIDDATE */
|
||||||
#endif /* NO_TIME_H */
|
|
||||||
|
|
||||||
|
|
||||||
static int GetDate(DecodedCert* cert, int dateType)
|
static int GetDate(DecodedCert* cert, int dateType)
|
||||||
|
@ -6022,8 +6012,7 @@ static int SetValidity(byte* output, int daysValid)
|
||||||
struct tm* tmpTime = NULL;
|
struct tm* tmpTime = NULL;
|
||||||
struct tm local;
|
struct tm local;
|
||||||
|
|
||||||
#if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX) || \
|
#if defined(NEED_TMP_TIME)
|
||||||
defined(TIME_OVERRIDES) || defined(NEED_TMP_TIME)
|
|
||||||
/* for use with gmtime_r */
|
/* for use with gmtime_r */
|
||||||
struct tm tmpTimeStorage;
|
struct tm tmpTimeStorage;
|
||||||
tmpTime = &tmpTimeStorage;
|
tmpTime = &tmpTimeStorage;
|
||||||
|
|
Loading…
Reference in New Issue