From 4542eb0df10fc0cc20f0a7123e5aadc1331d9c7a Mon Sep 17 00:00:00 2001 From: Kareem Date: Fri, 27 Jan 2023 12:39:53 -0700 Subject: [PATCH] Fix NO_ASN_TIME support for ASN template, also fix expired certificate unit tests with NO_ASN_TIME defined. --- tests/api.c | 6 +++--- wolfcrypt/src/asn.c | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/api.c b/tests/api.c index 120f00b11..db0f26f2d 100644 --- a/tests/api.c +++ b/tests/api.c @@ -1950,7 +1950,7 @@ static int test_wolfSSL_CertManagerLoadCABuffer(void) AssertIntEQ(ret, ASN_UNKNOWN_OID_E); res = TEST_RES_CHECK(ret == ASN_UNKNOWN_OID_E); #elif !(WOLFSSL_LOAD_VERIFY_DEFAULT_FLAGS & WOLFSSL_LOAD_FLAG_DATE_ERR_OKAY) && \ - !defined(OPENSSL_COMPATIBLE_DEFAULTS) + !defined(OPENSSL_COMPATIBLE_DEFAULTS) && !defined(NO_ASN_TIME) AssertIntEQ(ret, ASN_AFTER_DATE_E); res = TEST_RES_CHECK(ret == ASN_AFTER_DATE_E); #else @@ -3101,7 +3101,7 @@ static int test_wolfSSL_CTX_load_verify_locations_ex(void) WOLFSSL_LOAD_FLAG_NONE)); /* test expired CA */ -#ifndef OPENSSL_COMPATIBLE_DEFAULTS +#if !defined(OPENSSL_COMPATIBLE_DEFAULTS) && !defined(NO_ASN_TIME) AssertIntNE(wolfSSL_CTX_load_verify_locations_ex(ctx, ca_expired_cert, NULL, WOLFSSL_LOAD_FLAG_NONE), WOLFSSL_SUCCESS); #else @@ -3155,7 +3155,7 @@ static int test_wolfSSL_CTX_load_verify_buffer_ex(void) /* test expired CA failure */ -#ifndef OPENSSL_COMPATIBLE_DEFAULTS +#if !defined(OPENSSL_COMPATIBLE_DEFAULTS) && !defined(NO_ASN_TIME) AssertIntNE(wolfSSL_CTX_load_verify_buffer_ex(ctx, ca_expired_cert, sizeof_ca_expired_cert, WOLFSSL_FILETYPE_ASN1, 0, WOLFSSL_LOAD_FLAG_NONE), WOLFSSL_SUCCESS); diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index ed72dfd4a..a8269f735 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -27093,6 +27093,7 @@ static int SetValidity(byte* output, int daysValid) #else static int SetValidity(byte* before, byte* after, int daysValid) { +#ifndef NO_ASN_TIME int ret = 0; time_t now; time_t then; @@ -27145,6 +27146,12 @@ static int SetValidity(byte* before, byte* after, int daysValid) } return ret; +#else + (void)before; + (void)after; + (void)daysValid; + return NOT_COMPILED_IN; +#endif } #endif /* WOLFSSL_ASN_TEMPLATE */