Merge pull request #2312 from kojo1/RAND_bytes_2

RAND_bytes
This commit is contained in:
Chris Conlon
2019-07-08 15:30:06 -06:00
committed by GitHub

View File

@@ -4498,6 +4498,14 @@ int wolfSSL_Init(void)
WOLFSSL_MSG("Bad wolfCrypt Init");
return WC_INIT_E;
}
#ifdef OPENSSL_EXTRA
if (wolfSSL_RAND_seed(NULL, 0) != WOLFSSL_SUCCESS) {
WOLFSSL_MSG("wolfSSL_RAND_Seed failed");
return WC_INIT_E;
}
#endif
#ifndef NO_SESSION_CACHE
if (wc_InitMutex(&session_mutex) != 0) {
WOLFSSL_MSG("Bad Init Mutex session");
@@ -22922,12 +22930,12 @@ int wolfSSL_RAND_bytes(unsigned char* buf, int num)
return ret;
#endif
if (wc_InitRng(tmpRNG) == 0) {
if (initGlobalRNG)
rng = &globalRNG;
else if(wc_InitRng(tmpRNG) == 0) {
rng = tmpRNG;
initTmpRng = 1;
}
else if (initGlobalRNG)
rng = &globalRNG;
if (rng) {
if (wc_RNG_GenerateBlock(rng, buf, num) != 0)