From 55985ad1b49b8d4e1cbc34f95ee7d603961ca786 Mon Sep 17 00:00:00 2001 From: kaleb-himes Date: Tue, 30 Jun 2020 12:01:57 -0600 Subject: [PATCH 1/3] Change Hash union to wc_Hmac_Hash --- wolfssl/wolfcrypt/hmac.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wolfssl/wolfcrypt/hmac.h b/wolfssl/wolfcrypt/hmac.h index f6744db64..06b9132ec 100644 --- a/wolfssl/wolfcrypt/hmac.h +++ b/wolfssl/wolfcrypt/hmac.h @@ -131,11 +131,11 @@ typedef union { #ifdef WOLFSSL_SHA3 wc_Sha3 sha3; #endif -} Hash; +} wc_Hmac_Hash; /* Hmac digest */ struct Hmac { - Hash hash; + wc_Hmac_Hash hash; word32 ipad[WC_HMAC_BLOCK_SIZE / sizeof(word32)]; /* same block size all*/ word32 opad[WC_HMAC_BLOCK_SIZE / sizeof(word32)]; word32 innerHash[WC_MAX_DIGEST_SIZE / sizeof(word32)]; From 8d37f579900a6f88f1b68a78db5cda2dbe08daf5 Mon Sep 17 00:00:00 2001 From: kaleb-himes Date: Tue, 30 Jun 2020 12:50:26 -0600 Subject: [PATCH 2/3] Change variable name from Hash to hashAlg --- wolfssl/ssl.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wolfssl/ssl.h b/wolfssl/ssl.h index 551b68aa1..5e0b96469 100644 --- a/wolfssl/ssl.h +++ b/wolfssl/ssl.h @@ -918,9 +918,11 @@ WOLFSSL_API int wolfSSL_SetServerID(WOLFSSL*, const unsigned char*, int, int); WOLFSSL_API int wolfSSL_BIO_new_bio_pair(WOLFSSL_BIO**, size_t, WOLFSSL_BIO**, size_t); -WOLFSSL_API int wolfSSL_RSA_padding_add_PKCS1_PSS(WOLFSSL_RSA *rsa, unsigned char *EM, +WOLFSSL_API int wolfSSL_RSA_padding_add_PKCS1_PSS(WOLFSSL_RSA *rsa, + unsigned char *EM, const unsigned char *mHash, - const WOLFSSL_EVP_MD *Hash, int saltLen); + const WOLFSSL_EVP_MD *hashAlg, + int saltLen); WOLFSSL_API int wolfSSL_RSA_verify_PKCS1_PSS(WOLFSSL_RSA *rsa, const unsigned char *mHash, const WOLFSSL_EVP_MD *hashAlg, const unsigned char *EM, int saltLen); From 64c0d53a2d0f62547e9e28198f6f137ee321eadb Mon Sep 17 00:00:00 2001 From: kaleb-himes Date: Fri, 10 Jul 2020 09:43:24 -0600 Subject: [PATCH 3/3] Use portable friendly XVALIDATE_DATE in ssl.c and add wc_ to default --- src/ssl.c | 4 ++-- wolfcrypt/src/asn.c | 2 +- wolfssl/wolfcrypt/asn.h | 2 +- wolfssl/wolfcrypt/wc_port.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ssl.c b/src/ssl.c index f95ec4f1b..c1db4512b 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -22994,11 +22994,11 @@ int wolfSSL_X509_verify_cert(WOLFSSL_X509_STORE_CTX* ctx) afterDate = ctx->current_cert->notAfter.data; beforeDate = ctx->current_cert->notBefore.data; - if (ValidateDate(afterDate, (byte)ctx->current_cert->notAfter.type, + if (XVALIDATE_DATE(afterDate, (byte)ctx->current_cert->notAfter.type, AFTER) < 1) { error = X509_V_ERR_CERT_HAS_EXPIRED; } - else if (ValidateDate(beforeDate, + else if (XVALIDATE_DATE(beforeDate, (byte)ctx->current_cert->notBefore.type, BEFORE) < 1) { error = X509_V_ERR_CERT_NOT_YET_VALID; } diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 9f04abb88..ad390e35b 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -6344,7 +6344,7 @@ static WC_INLINE int DateLessThan(const struct tm* a, const struct tm* b) /* like atoi but only use first byte */ /* Make sure before and after dates are valid */ -int ValidateDate(const byte* date, byte format, int dateType) +int wc_ValidateDate(const byte* date, byte format, int dateType) { time_t ltime; struct tm certTime; diff --git a/wolfssl/wolfcrypt/asn.h b/wolfssl/wolfcrypt/asn.h index 686d09c29..0e4845d34 100644 --- a/wolfssl/wolfcrypt/asn.h +++ b/wolfssl/wolfcrypt/asn.h @@ -1118,7 +1118,7 @@ WOLFSSL_LOCAL int GetAsnTimeString(void* currTime, byte* buf, word32 len); WOLFSSL_LOCAL int ExtractDate(const unsigned char* date, unsigned char format, wolfssl_tm* certTime, int* idx); WOLFSSL_LOCAL int DateGreaterThan(const struct tm* a, const struct tm* b); -WOLFSSL_LOCAL int ValidateDate(const byte* date, byte format, int dateType); +WOLFSSL_LOCAL int wc_ValidateDate(const byte* date, byte format, int dateType); WOLFSSL_LOCAL int wc_OBJ_sn2nid(const char *sn); /* ASN.1 helper functions */ diff --git a/wolfssl/wolfcrypt/wc_port.h b/wolfssl/wolfcrypt/wc_port.h index da451d799..41e8bfe6d 100644 --- a/wolfssl/wolfcrypt/wc_port.h +++ b/wolfssl/wolfcrypt/wc_port.h @@ -688,7 +688,7 @@ WOLFSSL_API int wolfCrypt_Cleanup(void); #endif #if !defined(XVALIDATE_DATE) && !defined(HAVE_VALIDATE_DATE) #define USE_WOLF_VALIDDATE - #define XVALIDATE_DATE(d, f, t) ValidateDate((d), (f), (t)) + #define XVALIDATE_DATE(d, f, t) wc_ValidateDate((d), (f), (t)) #endif /* wolf struct tm and time_t */