update mysql patch

This commit is contained in:
Jacob Barthelmeh 2016-06-27 15:44:52 -06:00
parent 19da114c0c
commit f18ff8bfa4
6 changed files with 71 additions and 38 deletions

View File

@ -1955,6 +1955,16 @@ void InitSuites(Suites* suites, ProtocolVersion pv, word16 haveRSA,
}
#endif
/* Place as higher priority for MYSQL */
#if defined(WOLFSSL_MYSQL_COMPATIBLE)
#ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_CBC_SHA
if (tls && haveDH && haveRSA) {
suites->suites[idx++] = 0;
suites->suites[idx++] = TLS_DHE_RSA_WITH_AES_256_CBC_SHA;
}
#endif
#endif
#ifdef BUILD_TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
if (tls1_2 && haveRSAsig) {
suites->suites[idx++] = ECC_BYTE;
@ -2179,12 +2189,15 @@ void InitSuites(Suites* suites, ProtocolVersion pv, word16 haveRSA,
}
#endif
/* Place as higher priority for MYSQL testing */
#if !defined(WOLFSSL_MYSQL_COMPATIBLE)
#ifdef BUILD_TLS_DHE_RSA_WITH_AES_256_CBC_SHA
if (tls && haveDH && haveRSA) {
suites->suites[idx++] = 0;
suites->suites[idx++] = TLS_DHE_RSA_WITH_AES_256_CBC_SHA;
}
#endif
#endif
#ifdef BUILD_TLS_DHE_RSA_WITH_AES_128_CBC_SHA
if (tls && haveDH && haveRSA) {

View File

@ -12507,8 +12507,6 @@ int wolfSSL_ASN1_TIME_print(WOLFSSL_BIO* bio, const WOLFSSL_ASN1_TIME* asnTime)
#if defined(WOLFSSL_MYSQL_COMPATIBLE)
char* wolfSSL_ASN1_TIME_to_string(WOLFSSL_ASN1_TIME* time, char* buf, int len)
{
struct tm t;
int idx = 0;
int format;
int dateLen;
byte* date = (byte*)time;
@ -12523,43 +12521,14 @@ char* wolfSSL_ASN1_TIME_to_string(WOLFSSL_ASN1_TIME* time, char* buf, int len)
format = *date; date++;
dateLen = *date; date++;
if (dateLen > len) {
return "error";
WOLFSSL_MSG("Length of date is longer then buffer");
return NULL;
}
if (!ExtractDate(date, format, &t, &idx)) {
return "error";
if (!GetTimeString(date, format, buf, len)) {
return NULL;
}
if (date[idx] != 'Z') {
WOLFSSL_MSG("UTCtime, not Zulu") ;
return "Not Zulu";
}
/* place month in buffer */
buf[0] = '\0';
switch(t.tm_mon) {
case 0: XSTRNCAT(buf, "Jan ", 4); break;
case 1: XSTRNCAT(buf, "Feb ", 4); break;
case 2: XSTRNCAT(buf, "Mar ", 4); break;
case 3: XSTRNCAT(buf, "Apr ", 4); break;
case 4: XSTRNCAT(buf, "May ", 4); break;
case 5: XSTRNCAT(buf, "Jun ", 4); break;
case 6: XSTRNCAT(buf, "Jul ", 4); break;
case 7: XSTRNCAT(buf, "Aug ", 4); break;
case 8: XSTRNCAT(buf, "Sep ", 4); break;
case 9: XSTRNCAT(buf, "Oct ", 4); break;
case 10: XSTRNCAT(buf, "Nov ", 4); break;
case 11: XSTRNCAT(buf, "Dec ", 4); break;
default:
return "error";
}
idx = 4; /* use idx now for char buffer */
buf[idx] = ' ';
XSNPRINTF(buf + idx, len - idx, "%2d %02d:%02d:%02d %d GMT",
t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec, t.tm_year + 1900);
return buf;
}
#endif /* WOLFSSL_MYSQL_COMPATIBLE */

View File

@ -3005,6 +3005,50 @@ static INLINE int DateLessThan(const struct tm* a, const struct tm* b)
}
#if defined(WOLFSSL_MYSQL_COMPATIBLE)
int GetTimeString(byte* date, int format, char* buf, int len)
{
struct tm t;
int idx = 0;
if (!ExtractDate(date, format, &t, &idx)) {
return 0;
}
if (date[idx] != 'Z') {
WOLFSSL_MSG("UTCtime, not Zulu") ;
return 0;
}
/* place month in buffer */
buf[0] = '\0';
switch(t.tm_mon) {
case 0: XSTRNCAT(buf, "Jan ", 4); break;
case 1: XSTRNCAT(buf, "Feb ", 4); break;
case 2: XSTRNCAT(buf, "Mar ", 4); break;
case 3: XSTRNCAT(buf, "Apr ", 4); break;
case 4: XSTRNCAT(buf, "May ", 4); break;
case 5: XSTRNCAT(buf, "Jun ", 4); break;
case 6: XSTRNCAT(buf, "Jul ", 4); break;
case 7: XSTRNCAT(buf, "Aug ", 4); break;
case 8: XSTRNCAT(buf, "Sep ", 4); break;
case 9: XSTRNCAT(buf, "Oct ", 4); break;
case 10: XSTRNCAT(buf, "Nov ", 4); break;
case 11: XSTRNCAT(buf, "Dec ", 4); break;
default:
return 0;
}
idx = 4; /* use idx now for char buffer */
buf[idx] = ' ';
XSNPRINTF(buf + idx, len - idx, "%2d %02d:%02d:%02d %d GMT",
t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec, t.tm_year + 1900);
return 1;
}
#endif /* MYSQL compatibility */
int ExtractDate(const unsigned char* date, unsigned char format,
struct tm* certTime, int* idx)
{

View File

@ -610,7 +610,9 @@ WOLFSSL_LOCAL int ToTraditional(byte* buffer, word32 length);
WOLFSSL_LOCAL int ToTraditionalEnc(byte* buffer, word32 length,const char*,int);
typedef struct tm wolfssl_tm;
#if defined(WOLFSSL_MYSQL_COMPATIBLE)
WOLFSSL_LOCAL int GetTimeString(byte* date, int format, char* buf, int len);
#endif
WOLFSSL_LOCAL int ExtractDate(const unsigned char* date, unsigned char format,
wolfssl_tm* certTime, int* idx);
WOLFSSL_LOCAL int ValidateDate(const byte* date, byte format, int dateType);

View File

@ -1257,6 +1257,11 @@ static char *fgets(char *buff, int sz, FILE *fp)
#endif /* WOLFSSL_STATIC_MEMORY */
/* Place any other flags or defines here */
#if defined(WOLFSSL_MYSQL_COMPATIBLE) && defined(_WIN32) \
&& defined(HAVE_GMTIME_R)
#undef HAVE_GMTIME_R /* don't trust macro with windows */
#endif /* WOLFSSL_MYSQL_COMPATIBLE */
#ifdef __cplusplus
} /* extern "C" */

View File

@ -247,10 +247,10 @@ WOLFSSL_API int wolfCrypt_Init(void);
/* Windows API defines its own min() macro. */
#if defined(USE_WINDOWS_API)
#ifdef min
#if defined(min) || defined(WOLFSSL_MYSQL_COMPATIBLE)
#define WOLFSSL_HAVE_MIN
#endif /* min */
#ifdef max
#if defined(max) || defined(WOLFSSL_MYSQL_COMPATIBLE)
#define WOLFSSL_HAVE_MAX
#endif /* max */
#endif /* USE_WINDOWS_API */