From d741d4cddc14b54e4e7883915723d6a351c04574 Mon Sep 17 00:00:00 2001 From: Takashi Kojo Date: Fri, 30 Oct 2015 11:26:54 +0900 Subject: [PATCH 1/2] Adding UTC Time Differential in ValidateDate --- wolfcrypt/src/asn.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 03353d45a..76a565399 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -2550,6 +2550,9 @@ int ValidateDate(const byte* date, byte format, int dateType) struct tm* localTime; struct tm* tmpTime = NULL; int i = 0; + int timeDiff = 0 ; + int diffHH = 0 ; int diffMM = 0 ; + int diffSign = 0 ; #if defined(FREESCALE_MQX) || defined(TIME_OVERRIDES) struct tm tmpTimeStorage; @@ -2580,11 +2583,17 @@ int ValidateDate(const byte* date, byte format, int dateType) GetTime((int*)&certTime.tm_min, date, &i); GetTime((int*)&certTime.tm_sec, date, &i); - if (date[i] != 'Z') { /* only Zulu supported for this profile */ - WOLFSSL_MSG("Only Zulu time supported for this profile"); - return 0; + if ((date[i] == '+') || (date[i] == '-')) { + diffSign = date[i++]=='+' ? 1 : -1 ; + GetTime((int*)&diffHH, date, &i); + GetTime((int*)&diffMM, date, &i); + timeDiff = diffSign * (diffHH*60 + diffMM) * 60 ; + } else if (date[i] != 'Z') { + WOLFSSL_MSG("UTCtime, niether Zulu or time differential") ; + return 0; } + ltime -= timeDiff ; localTime = XGMTIME(<ime, tmpTime); if (localTime == NULL) { @@ -9316,4 +9325,3 @@ int ParseCRL(DecodedCRL* dcrl, const byte* buff, word32 sz, void* cm) #endif /* WOLFSSL_SEP */ - From 44165371bcb5c10622bf6ef6aaac8430eb76625a Mon Sep 17 00:00:00 2001 From: toddouska Date: Tue, 3 Nov 2015 14:15:15 -0800 Subject: [PATCH 2/2] timediff fixup --- wolfcrypt/src/asn.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 661bec19e..a29ce1527 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -2588,16 +2588,17 @@ int ValidateDate(const byte* date, byte format, int dateType) GetTime((int*)&certTime.tm_sec, date, &i); if ((date[i] == '+') || (date[i] == '-')) { - diffSign = date[i++]=='+' ? 1 : -1 ; - GetTime((int*)&diffHH, date, &i); - GetTime((int*)&diffMM, date, &i); + WOLFSSL_MSG("Using time differential, not Zulu") ; + diffSign = date[i++] == '+' ? 1 : -1 ; + GetTime(&diffHH, date, &i); + GetTime(&diffMM, date, &i); timeDiff = diffSign * (diffHH*60 + diffMM) * 60 ; } else if (date[i] != 'Z') { - WOLFSSL_MSG("UTCtime, niether Zulu or time differential") ; - return 0; + WOLFSSL_MSG("UTCtime, niether Zulu or time differential") ; + return 0; } - ltime -= timeDiff ; + ltime -= (time_t)timeDiff ; localTime = XGMTIME(<ime, tmpTime); if (localTime == NULL) {