From 7aaa89aedcfbfefe5efc1d7175293c88708a70a1 Mon Sep 17 00:00:00 2001 From: Juliusz Sosinowicz Date: Wed, 22 Jan 2020 15:18:23 -0800 Subject: [PATCH] Cleanup bn_one in wolfSSL_Cleanup --- src/ssl.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/ssl.c b/src/ssl.c index 17afbb5ce..9e3748eaa 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -345,6 +345,10 @@ int wolfSSL_send_session(WOLFSSL* ssl) #endif /* WOLFSSL_DTLS */ #endif /* WOLFSSL_SESSION_EXPORT */ +#ifdef OPENSSL_EXTRA +/* Global pointer to constant BN on */ +static WOLFSSL_BIGNUM* bn_one = NULL; +#endif /* prevent multiple mutex initializations */ static volatile WOLFSSL_GLOBAL int initRefCount = 0; @@ -12463,6 +12467,13 @@ int wolfSSL_Cleanup(void) if (!release) return ret; +#ifdef OPENSSL_EXTRA + if (bn_one) { + wolfSSL_BN_free(bn_one); + bn_one = NULL; + } +#endif + #ifndef NO_SESSION_CACHE if (wc_FreeMutex(&session_mutex) != 0) ret = BAD_MUTEX_E; @@ -46357,10 +46368,9 @@ int wolfSSL_BN_mod_mul(WOLFSSL_BIGNUM *r, const WOLFSSL_BIGNUM *a, return SSL_FAILURE; } +#ifdef OPENSSL_EXTRA const WOLFSSL_BIGNUM* wolfSSL_BN_value_one(void) { - static WOLFSSL_BIGNUM* bn_one = NULL; - WOLFSSL_MSG("wolfSSL_BN_value_one"); if (bn_one == NULL) { @@ -46376,6 +46386,7 @@ const WOLFSSL_BIGNUM* wolfSSL_BN_value_one(void) return bn_one; } +#endif /* return compliant with OpenSSL * size of BIGNUM in bytes, 0 if error */