From 92114fef753bec7516bd3bfec1f31871f328f3f8 Mon Sep 17 00:00:00 2001 From: David Garske Date: Mon, 24 Feb 2020 19:24:53 -0800 Subject: [PATCH] Fixes for building NO_ASN_TIME with OPENSSL_EXTRA. Fixes #2820. * `./configure --enable-opensslextra CFLAGS="-DNO_ASN_TIME"` --- src/internal.c | 4 ++-- src/ssl.c | 11 +++++++++-- tests/api.c | 19 ++++++++++--------- wolfssl/wolfcrypt/settings.h | 6 ++++++ 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/internal.c b/src/internal.c index d73a881c7..f457c4841 100644 --- a/src/internal.c +++ b/src/internal.c @@ -7309,8 +7309,7 @@ ProtocolVersion MakeDTLSv1_2(void) #endif /* WOLFSSL_DTLS */ - - +#ifndef NO_ASN_TIME #if defined(USER_TICKS) #if 0 word32 LowResTimer(void) @@ -7525,6 +7524,7 @@ ProtocolVersion MakeDTLSv1_2(void) return (word32)XTIME(0); } #endif +#endif /* !NO_ASN_TIME */ #if !defined(WOLFSSL_NO_CLIENT_AUTH) && \ ((defined(HAVE_ED25519) && !defined(NO_ED25519_CLIENT_AUTH)) || \ (defined(HAVE_ED448) && !defined(NO_ED448_CLIENT_AUTH))) diff --git a/src/ssl.c b/src/ssl.c index 96b99596c..41bec979f 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -23539,6 +23539,7 @@ int wolfSSL_X509_cmp(const WOLFSSL_X509 *a, const WOLFSSL_X509 *b) } } + #ifndef NO_ASN_TIME /* print validity */ { char tmp[80]; @@ -23547,6 +23548,7 @@ int wolfSSL_X509_cmp(const WOLFSSL_X509 *a, const WOLFSSL_X509 *b) (int)XSTRLEN(" Validity\n")) <= 0) { return WOLFSSL_FAILURE; } + if (wolfSSL_BIO_write(bio, " Not Before: ", (int)XSTRLEN(" Not Before: ")) <= 0) { return WOLFSSL_FAILURE; @@ -23591,6 +23593,7 @@ int wolfSSL_X509_cmp(const WOLFSSL_X509 *a, const WOLFSSL_X509 *b) return WOLFSSL_FAILURE; } } + #endif /* print subject */ { @@ -26450,6 +26453,7 @@ void wolfSSL_X509_OBJECT_free_contents(WOLFSSL_X509_OBJECT* obj) } #endif +#ifndef NO_ASN_TIME int wolfSSL_X509_cmp_current_time(const WOLFSSL_ASN1_TIME* asnTime) { return wolfSSL_X509_cmp_time(asnTime, NULL); @@ -26534,6 +26538,7 @@ int wolfSSL_X509_cmp_time(const WOLFSSL_ASN1_TIME* asnTime, time_t* cmpTime) return ret; } +#endif /* !NO_ASN_TIME */ #if defined(OPENSSL_EXTRA) && !defined(NO_ASN_TIME) && !defined(USER_TIME) && \ !defined(TIME_OVERRIDES) @@ -26754,6 +26759,7 @@ WOLFSSL_ASN1_INTEGER* wolfSSL_X509_get_serialNumber(WOLFSSL_X509* x509) #if defined(WOLFSSL_MYSQL_COMPATIBLE) || defined(WOLFSSL_NGINX) || \ defined(WOLFSSL_HAPROXY) || defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL) +#ifndef NO_ASN_TIME int wolfSSL_ASN1_TIME_print(WOLFSSL_BIO* bio, const WOLFSSL_ASN1_TIME* asnTime) { char buf[MAX_TIME_STRING_SZ]; @@ -26781,7 +26787,6 @@ int wolfSSL_ASN1_TIME_print(WOLFSSL_BIO* bio, const WOLFSSL_ASN1_TIME* asnTime) return ret; } - char* wolfSSL_ASN1_TIME_to_string(WOLFSSL_ASN1_TIME* t, char* buf, int len) { WOLFSSL_ENTER("wolfSSL_ASN1_TIME_to_string"); @@ -26802,6 +26807,7 @@ char* wolfSSL_ASN1_TIME_to_string(WOLFSSL_ASN1_TIME* t, char* buf, int len) return buf; } +#endif /* !NO_ASN_TIME */ #endif /* WOLFSSL_MYSQL_COMPATIBLE || WOLFSSL_NGINX || WOLFSSL_HAPROXY || OPENSSL_EXTRA*/ @@ -29454,6 +29460,7 @@ int wolfSSL_BIO_dump(WOLFSSL_BIO *bio, const char *buf, int length) return ret; } +#ifndef NO_ASN_TIME int wolfSSL_ASN1_UTCTIME_print(WOLFSSL_BIO* bio, const WOLFSSL_ASN1_UTCTIME* a) { WOLFSSL_ENTER("ASN1_UTCTIME_print"); @@ -29468,7 +29475,6 @@ int wolfSSL_ASN1_UTCTIME_print(WOLFSSL_BIO* bio, const WOLFSSL_ASN1_UTCTIME* a) return wolfSSL_ASN1_TIME_print(bio, a); } - /* Checks the ASN1 syntax of "a" * returns WOLFSSL_SUCCESS (1) if correct otherwise WOLFSSL_FAILURE (0) */ int wolfSSL_ASN1_TIME_check(const WOLFSSL_ASN1_TIME* a) @@ -29484,6 +29490,7 @@ int wolfSSL_ASN1_TIME_check(const WOLFSSL_ASN1_TIME* a) } return WOLFSSL_SUCCESS; } +#endif /* !NO_ASN_TIME */ #ifndef NO_WOLFSSL_STUB int wolfSSL_ASN1_TIME_diff(int *pday, int *psec, diff --git a/tests/api.c b/tests/api.c index 8bbfbeb6c..23f51d060 100644 --- a/tests/api.c +++ b/tests/api.c @@ -20388,7 +20388,7 @@ static void test_wolfSSL_ASN1_TIME_print(void) static void test_wolfSSL_ASN1_UTCTIME_print(void) { - #if defined(OPENSSL_EXTRA) +#if defined(OPENSSL_EXTRA) && !defined(NO_ASN_TIME) BIO* bio; ASN1_UTCTIME* utc = NULL; unsigned char buf[25]; @@ -20429,7 +20429,7 @@ static void test_wolfSSL_ASN1_UTCTIME_print(void) BIO_free(bio); printf(resultFmt, passed); - #endif /* OPENSSL_EXTRA */ +#endif /* OPENSSL_EXTRA && !NO_ASN_TIME */ } @@ -23365,7 +23365,7 @@ static void test_wolfSSL_DES_ecb_encrypt(void) static void test_wolfSSL_ASN1_TIME_adj(void) { -#if defined(OPENSSL_EXTRA) && !defined(NO_ASN1_TIME) \ +#if defined(OPENSSL_EXTRA) && !defined(NO_ASN_TIME) \ && !defined(USER_TIME) && !defined(TIME_OVERRIDES) const int year = 365*24*60*60; @@ -23455,7 +23455,7 @@ static void test_wolfSSL_ASN1_TIME_adj(void) static void test_wolfSSL_X509_cmp_time(void) { -#if defined(OPENSSL_EXTRA) && !defined(NO_ASN1_TIME) \ +#if defined(OPENSSL_EXTRA) && !defined(NO_ASN_TIME) \ && !defined(USER_TIME) && !defined(TIME_OVERRIDES) WOLFSSL_ASN1_TIME asn_time; time_t t; @@ -23477,9 +23477,10 @@ static void test_wolfSSL_X509_cmp_time(void) static void test_wolfSSL_X509_time_adj(void) { -#if defined(OPENSSL_EXTRA) && !defined(NO_ASN1_TIME) && \ +#if defined(OPENSSL_EXTRA) && !defined(NO_ASN_TIME) && \ !defined(USER_TIME) && !defined(TIME_OVERRIDES) && \ - defined(USE_CERT_BUFFERS_2048) && !defined(NO_RSA) + defined(USE_CERT_BUFFERS_2048) && !defined(NO_RSA) && \ + !defined(NO_ASN_TIME) X509* x509; time_t t, not_before, not_after; @@ -24647,7 +24648,7 @@ static void test_wolfSSL_X509_set_name(void) static void test_wolfSSL_X509_set_notAfter(void) { #if (defined(OPENSSL_ALL) || defined(WOLFSSL_APACHE_HTTPD)) \ - && !defined(NO_ASN1_TIME) && !defined(USER_TIME) && \ + && !defined(NO_ASN_TIME) && !defined(USER_TIME) && \ !defined(TIME_OVERRIDES) && !defined(NO_CERTS) && \ defined(WOLFSSL_CERT_GEN) && defined(WOLFSSL_CERT_REQ) &&\ !defined(TIME_T_NOT_64BIT) && !defined(NO_64BIT) @@ -24702,7 +24703,7 @@ static void test_wolfSSL_X509_set_notAfter(void) static void test_wolfSSL_X509_set_notBefore(void) { #if (defined(OPENSSL_ALL) || defined(WOLFSSL_APACHE_HTTPD)) \ - && !defined(NO_ASN1_TIME) && !defined(USER_TIME) && \ + && !defined(NO_ASN_TIME) && !defined(USER_TIME) && \ !defined(TIME_OVERRIDES) && !defined(NO_CERTS) && \ defined(WOLFSSL_CERT_GEN) && defined(WOLFSSL_CERT_REQ) @@ -26462,7 +26463,7 @@ static void test_wolfSSL_ASN1_STRING_print_ex(void){ } static void test_wolfSSL_ASN1_TIME_to_generalizedtime(void){ -#if defined(OPENSSL_EXTRA) && !defined(NO_ASN1_TIME) +#if defined(OPENSSL_EXTRA) && !defined(NO_ASN_TIME) WOLFSSL_ASN1_TIME *t; WOLFSSL_ASN1_TIME *out; WOLFSSL_ASN1_TIME *gtime; diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index 594e73f91..dd047c2a4 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -2168,6 +2168,12 @@ extern void uITRON4_free(void *p) ; #undef WOLFSSL_SMALL_STACK #endif +/* The client session cache requires time for timeout */ +#if defined(NO_ASN_TIME) && !defined(NO_SESSION_CACHE) + #define NO_SESSION_CACHE +#endif + + #ifdef __cplusplus } /* extern "C" */ #endif