RAND cleanup and no-op functions for compatibility -- brackets added to ssl.c if statements for gcc-6

This commit is contained in:
Jacob Barthelmeh 2017-01-10 15:44:03 -07:00
parent 4f76e33bc7
commit 9290b2e464
7 changed files with 62 additions and 3 deletions

View File

@ -18560,7 +18560,18 @@ int wolfSSL_RAND_seed(const void* seed, int len)
}
/* WOLFSSL_SUCCESS on ok */
void wolfSSL_RAND_Cleanup(void)
{
WOLFSSL_ENTER("wolfSSL_RAND_Cleanup()");
if (initGlobalRNG != 0) {
wc_FreeRng(&globalRNG);
initGlobalRNG = 0;
}
}
/* SSL_SUCCESS on ok */
int wolfSSL_RAND_bytes(unsigned char* buf, int num)
{
int ret = 0;
@ -20536,6 +20547,9 @@ int wolfSSL_RSA_public_encrypt(int len, const unsigned char* fr,
if (ret <= 0) {
WOLFSSL_MSG("Bad Rsa Encrypt");
}
if (len <= 0) {
WOLFSSL_MSG("Bad Rsa Encrypt");
}
}
if (initTmpRng)

View File

@ -217,7 +217,8 @@
#include <wolfssl/openssl/dh.h>
#include <wolfssl/openssl/bn.h>
#include <wolfssl/openssl/pem.h>
#include <wolfssl/openssl/ec.h>
#include <wolfssl/openssl/engine.h>
#include <wolfssl/openssl/crypto.h>
#ifndef NO_DES3
#include <wolfssl/openssl/des.h>
#endif
@ -14642,6 +14643,37 @@ static void test_wolfSSL_X509(void)
}
static void test_wolfSSL_RAND(void)
{
#if defined(OPENSSL_EXTRA)
byte seed[16];
printf(testingFmt, "wolfSSL_RAND()");
RAND_seed(seed, sizeof(seed));
RAND_cleanup();
printf(resultFmt, passed);
#endif
}
static void test_no_op_functions(void)
{
#if defined(OPENSSL_EXTRA)
printf(testingFmt, "no_op_functions()");
/* this makes sure wolfSSL can compile and run these no-op functions */
SSL_load_error_strings();
ENGINE_load_builtin_engines();
OpenSSL_add_all_ciphers();
CRYPTO_malloc_init();
printf(resultFmt, passed);
#endif
}
/*----------------------------------------------------------------------------*
| wolfCrypt ASN
*----------------------------------------------------------------------------*/
@ -15414,6 +15446,7 @@ void ApiTest(void)
test_wolfSSL_DES_ecb_encrypt();
test_wolfSSL_ASN1_STRING();
test_wolfSSL_X509();
test_wolfSSL_RAND();
test_wolfSSL_DES_ecb_encrypt();
test_wolfSSL_set_tlsext_status_type();
test_wolfSSL_ASN1_TIME_adj();
@ -15423,6 +15456,11 @@ void ApiTest(void)
test_wolfSSL_CTX_set_srp_password();
AssertIntEQ(test_wolfSSL_Cleanup(), WOLFSSL_SUCCESS);
/* test the no op functions for compatibility */
test_no_op_functions();
AssertIntEQ(test_wolfSSL_Cleanup(), SSL_SUCCESS);
/* wolfCrypt ASN tests */
test_wc_GetPkcs8TraditionalOffset();

View File

@ -45,7 +45,10 @@ WOLFSSL_API unsigned long wolfSSLeay(void);
#define SSLEAY_VERSION 0x0090600fL
#define SSLEAY_VERSION_NUMBER SSLEAY_VERSION
#if defined(HAVE_STUNNEL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY)
/* this function was used to set the default malloc, free, and realloc */
#define CRYPTO_malloc_init() /* CRYPTO_malloc_init is not needed */
#if defined(HAVE_STUNNEL) || defined(WOLFSSL_NGINX) || defined(HAPROXY)
#define CRYPTO_set_mem_ex_functions wolfSSL_CRYPTO_set_mem_ex_functions
#define FIPS_mode wolfSSL_FIPS_mode
#define FIPS_mode_set wolfSSL_FIPS_mode_set

View File

@ -2,4 +2,5 @@
#undef HAVE_OPENSSL_ENGINE_H
#define ENGINE_load_builtin_engines() /*ENGINE_load_builtin_engines not needed*/

View File

@ -22,3 +22,4 @@
/* err.h for openssl */
#define ERR_load_crypto_strings wolfSSL_ERR_load_crypto_strings
#define ERR_peek_last_error wolfSSL_ERR_peek_last_error
#define SSL_load_error_strings() /* SSL_load_error_strings not needed */

View File

@ -282,6 +282,7 @@ typedef WOLFSSL_X509_STORE_CTX X509_STORE_CTX;
#define RAND_load_file wolfSSL_RAND_load_file
#define RAND_egd wolfSSL_RAND_egd
#define RAND_seed wolfSSL_RAND_seed
#define RAND_cleanup wolfSSL_RAND_Cleanup
#define RAND_add wolfSSL_RAND_add
#define COMP_zlib wolfSSL_COMP_zlib

View File

@ -726,6 +726,7 @@ WOLFSSL_API int wolfSSL_RAND_write_file(const char*);
WOLFSSL_API int wolfSSL_RAND_load_file(const char*, long);
WOLFSSL_API int wolfSSL_RAND_egd(const char*);
WOLFSSL_API int wolfSSL_RAND_seed(const void*, int);
WOLFSSL_API void wolfSSL_RAND_Cleanup(void);
WOLFSSL_API void wolfSSL_RAND_add(const void*, int, double);
WOLFSSL_API WOLFSSL_COMP_METHOD* wolfSSL_COMP_zlib(void);