From 874022d93802ad5204c699c16688e14101a19638 Mon Sep 17 00:00:00 2001 From: Takashi Kojo Date: Sat, 19 May 2018 17:57:00 +0900 Subject: [PATCH] fix #if conditions and others --- src/crl.c | 2 +- src/ssl.c | 18 +++++++++--------- tests/api.c | 2 +- wolfssl/openssl/ssl.h | 2 ++ wolfssl/ssl.h | 4 ++++ wolfssl/wolfcrypt/sha256.h | 2 +- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/crl.c b/src/crl.c index 8850e9617..5bceabbd4 100644 --- a/src/crl.c +++ b/src/crl.c @@ -490,7 +490,7 @@ int BufferLoadCRL(WOLFSSL_CRL* crl, const byte* buff, long sz, int type, return ret ? ret : WOLFSSL_SUCCESS; /* convert 0 to WOLFSSL_SUCCESS */ } -#if defined(OPENSSL_EXTRA) || defined(HAVE_CRL) +#if defined(OPENSSL_EXTRA) && defined(HAVE_CRL) int wolfSSL_X509_STORE_add_crl(WOLFSSL_X509_STORE *store, WOLFSSL_X509_CRL *newcrl) { CRL_Entry *crle; diff --git a/src/ssl.c b/src/ssl.c index bcf16c2a7..9b989e913 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -17996,7 +17996,7 @@ int wolfSSL_X509_verify_cert(WOLFSSL_X509_STORE_CTX* ctx) #ifndef NO_FILESYSTEM static void *wolfSSL_d2i_X509_fp_ex(XFILE file, void **x509, int type) { - void *new = NULL; + void *newx509 = NULL; DerBuffer* der = NULL; byte *fileBuffer = NULL; @@ -18023,13 +18023,13 @@ static void *wolfSSL_d2i_X509_fp_ex(XFILE file, void **x509, int type) goto err_exit; } if(type == CERT_TYPE) - new = (void *)wolfSSL_X509_d2i(NULL, fileBuffer, (int)sz); + newx509 = (void *)wolfSSL_X509_d2i(NULL, fileBuffer, (int)sz); #ifdef HAVE_CRL else if(type == CRL_TYPE) - new = (void *)wolfSSL_d2i_X509_CRL(NULL, fileBuffer, (int)sz); + newx509 = (void *)wolfSSL_d2i_X509_CRL(NULL, fileBuffer, (int)sz); #endif else goto err_exit; - if(new == NULL) + if(newx509 == NULL) { WOLFSSL_MSG("X509 failed"); goto err_exit; @@ -18037,18 +18037,18 @@ static void *wolfSSL_d2i_X509_fp_ex(XFILE file, void **x509, int type) } } if (x509 != NULL) - *x509 = new; + *x509 = newx509; goto _exit; err_exit: - if(new != NULL){ + if(newx509 != NULL){ if(type == CERT_TYPE) - wolfSSL_X509_free(new); + wolfSSL_X509_free((WOLFSSL_X509*)newx509); #ifdef HAVE_CRL else { if(type == CRL_TYPE) - wolfSSL_X509_CRL_free(new); + wolfSSL_X509_CRL_free((WOLFSSL_X509_CRL*)newx509); } #endif } @@ -18057,7 +18057,7 @@ _exit: FreeDer(&der); if(fileBuffer != NULL) XFREE(fileBuffer, NULL, DYNAMIC_TYPE_FILE); - return new; + return newx509; } WOLFSSL_X509 *wolfSSL_d2i_X509_fp(XFILE fp, WOLFSSL_X509 **x509) diff --git a/tests/api.c b/tests/api.c index aa58f52d4..47a5cb197 100644 --- a/tests/api.c +++ b/tests/api.c @@ -17753,7 +17753,7 @@ static void test_wolfSSL_SHA(void) } #endif - #if !defined(WOLFSSL_SHA512) + #if defined(WOLFSSL_SHA512) { const unsigned char in[] = "abc"; unsigned char expected[] = "\xdd\xaf\x35\xa1\x93\x61\x7a\xba\xcc\x41\x73\x49\xae\x20\x41" diff --git a/wolfssl/openssl/ssl.h b/wolfssl/openssl/ssl.h index a2b8a49ca..c87da9855 100644 --- a/wolfssl/openssl/ssl.h +++ b/wolfssl/openssl/ssl.h @@ -516,6 +516,8 @@ typedef WOLFSSL_X509_STORE_CTX X509_STORE_CTX; #define d2i_X509_fp wolfSSL_d2i_X509_fp #define i2d_X509 wolfSSL_i2d_X509 #define d2i_X509 wolfSSL_d2i_X509 +#define d2i_PKCS12_bio wolfSSL_d2i_PKCS12_bio +#define d2i_PKCS12_fp wolfSSL_d2i_PKCS12_fp #define d2i_RSAPublicKey wolfSSL_d2i_RSAPublicKey #define i2d_RSAPublicKey wolfSSL_i2d_RSAPublicKey #define d2i_X509_CRL wolfSSL_d2i_X509_CRL diff --git a/wolfssl/ssl.h b/wolfssl/ssl.h index 30b5fb32a..0ab534153 100644 --- a/wolfssl/ssl.h +++ b/wolfssl/ssl.h @@ -1554,6 +1554,10 @@ WOLFSSL_API int wolfSSL_connect_cert(WOLFSSL* ssl); typedef struct WC_PKCS12 WC_PKCS12; WOLFSSL_API WC_PKCS12* wolfSSL_d2i_PKCS12_bio(WOLFSSL_BIO* bio, WC_PKCS12** pkcs12); +#ifndef NO_FILESYSTEM +WOLFSSL_API WC_PKCS12* wolfSSL_d2i_PKCS12_fp(XFILE fp, + WC_PKCS12** pkcs12); +#endif WOLFSSL_API int wolfSSL_PKCS12_parse(WC_PKCS12* pkcs12, const char* psw, WOLFSSL_EVP_PKEY** pkey, WOLFSSL_X509** cert, WOLF_STACK_OF(WOLFSSL_X509)** ca); diff --git a/wolfssl/wolfcrypt/sha256.h b/wolfssl/wolfcrypt/sha256.h index d16a2afdf..3409b5151 100644 --- a/wolfssl/wolfcrypt/sha256.h +++ b/wolfssl/wolfcrypt/sha256.h @@ -81,7 +81,7 @@ #define SHA256_NOINLINE #endif -#if !defined(NO_OLD_SHA256_NAMES) || !defined(OPENSSL_EXTRA) +#if !defined(NO_OLD_SHA256_NAMES) #define SHA256 WC_SHA256 #endif