From 489345f0d4556c68753a0261150cd0d972abc4f1 Mon Sep 17 00:00:00 2001 From: toddouska Date: Wed, 21 Sep 2016 09:02:38 -0700 Subject: [PATCH] move CTX new_rng out of with certs block --- src/ssl.c | 66 +++++++++++++++++++++++++++---------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/src/ssl.c b/src/ssl.c index eb0e906a6..7d6a960e4 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -354,6 +354,39 @@ void wolfSSL_CTX_free(WOLFSSL_CTX* ctx) } +#ifdef SINGLE_THREADED +/* no locking in single threaded mode, allow a CTX level rng to be shared with + * WOLFSSL objects, SSL_SUCCESS on ok */ +int wolfSSL_CTX_new_rng(WOLFSSL_CTX* ctx) +{ + WC_RNG* rng; + int ret; + + if (ctx == NULL) { + return BAD_FUNC_ARG; + } + + rng = XMALLOC(sizeof(WC_RNG), ctx->heap, DYNAMIC_TYPE_RNG); + if (rng == NULL) { + return MEMORY_E; + } + +#ifndef HAVE_FIPS + ret = wc_InitRng_ex(rng, ctx->heap); +#else + ret = wc_InitRng(rng); +#endif + if (ret != 0) { + XFREE(rng, ctx->heap, DYNAMIC_TYPE_RNG); + return ret; + } + + ctx->rng = rng; + return SSL_SUCCESS; +} +#endif + + WOLFSSL* wolfSSL_new(WOLFSSL_CTX* ctx) { WOLFSSL* ssl = NULL; @@ -2323,39 +2356,6 @@ int wolfSSL_CertManagerUnloadCAs(WOLFSSL_CERT_MANAGER* cm) } -#ifdef SINGLE_THREADED -/* no locking in single threaded mode, allow a CTX level rng to be shared with - * WOLFSSL objects, SSL_SUCCESS on ok */ -int wolfSSL_CTX_new_rng(WOLFSSL_CTX* ctx) -{ - WC_RNG* rng; - int ret; - - if (ctx == NULL) { - return BAD_FUNC_ARG; - } - - rng = XMALLOC(sizeof(WC_RNG), ctx->heap, DYNAMIC_TYPE_RNG); - if (rng == NULL) { - return MEMORY_E; - } - -#ifndef HAVE_FIPS - ret = wc_InitRng_ex(rng, ctx->heap); -#else - ret = wc_InitRng(rng); -#endif - if (ret != 0) { - XFREE(rng, ctx->heap, DYNAMIC_TYPE_RNG); - return ret; - } - - ctx->rng = rng; - return SSL_SUCCESS; -} -#endif - - #ifdef WOLFSSL_TRUST_PEER_CERT int wolfSSL_CertManagerUnload_trust_peers(WOLFSSL_CERT_MANAGER* cm) {