From 023f44bacf18d837cf651360c2514c8aa88b8b8d Mon Sep 17 00:00:00 2001 From: toddouska Date: Fri, 13 Mar 2015 12:44:25 -0700 Subject: [PATCH] fix github issue #31, allow time overrides for all time uses --- wolfcrypt/src/asn.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 1d549ed24..aa418347d 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -156,6 +156,34 @@ #define XTIME(tl) time((tl)) #endif /* STACK_TRAP */ +#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); + + #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); + + #ifndef HAVE_VALIDATE_DATE + #define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t)) + #endif #else /* default */ /* uses complete facility */