Adding UTC Time Differential in ValidateDate

This commit is contained in:
Takashi Kojo
2015-10-30 11:26:54 +09:00
parent 2c41a5b961
commit d741d4cddc

View File

@ -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(&ltime, tmpTime);
if (localTime == NULL) {
@ -9316,4 +9325,3 @@ int ParseCRL(DecodedCRL* dcrl, const byte* buff, word32 sz, void* cm)
#endif /* WOLFSSL_SEP */