mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
RAND_seed in init, GlobalRNG before tmp.
This commit is contained in:
18
src/ssl.c
18
src/ssl.c
@ -4463,6 +4463,14 @@ int wolfSSL_Init(void)
|
|||||||
WOLFSSL_MSG("Bad wolfCrypt Init");
|
WOLFSSL_MSG("Bad wolfCrypt Init");
|
||||||
return WC_INIT_E;
|
return WC_INIT_E;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef OPENSSL_EXTRA
|
||||||
|
if (wolfSSL_RAND_seed("", 0) != WOLFSSL_SUCCESS) {
|
||||||
|
WOLFSSL_MSG("wolfSSL_RAND_Seed failed");
|
||||||
|
return WC_INIT_E;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef NO_SESSION_CACHE
|
#ifndef NO_SESSION_CACHE
|
||||||
if (wc_InitMutex(&session_mutex) != 0) {
|
if (wc_InitMutex(&session_mutex) != 0) {
|
||||||
WOLFSSL_MSG("Bad Init Mutex session");
|
WOLFSSL_MSG("Bad Init Mutex session");
|
||||||
@ -22841,6 +22849,8 @@ int wolfSSL_RAND_pseudo_bytes(unsigned char* buf, int num)
|
|||||||
/* SSL_SUCCESS on ok */
|
/* SSL_SUCCESS on ok */
|
||||||
int wolfSSL_RAND_bytes(unsigned char* buf, int num)
|
int wolfSSL_RAND_bytes(unsigned char* buf, int num)
|
||||||
{
|
{
|
||||||
|
WOLFSSL_ENTER("wolfSSL_RAND_bytes");
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int initTmpRng = 0;
|
int initTmpRng = 0;
|
||||||
WC_RNG* rng = NULL;
|
WC_RNG* rng = NULL;
|
||||||
@ -22858,13 +22868,13 @@ int wolfSSL_RAND_bytes(unsigned char* buf, int num)
|
|||||||
return ret;
|
return ret;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (wc_InitRng(tmpRNG) == 0) {
|
if (initGlobalRNG)
|
||||||
|
rng = &globalRNG;
|
||||||
|
else if(wc_InitRng(tmpRNG) == 0) {
|
||||||
rng = tmpRNG;
|
rng = tmpRNG;
|
||||||
initTmpRng = 1;
|
initTmpRng = 1;
|
||||||
}
|
}
|
||||||
else if (initGlobalRNG)
|
|
||||||
rng = &globalRNG;
|
|
||||||
|
|
||||||
if (rng) {
|
if (rng) {
|
||||||
if (wc_RNG_GenerateBlock(rng, buf, num) != 0)
|
if (wc_RNG_GenerateBlock(rng, buf, num) != 0)
|
||||||
WOLFSSL_MSG("Bad wc_RNG_GenerateBlock");
|
WOLFSSL_MSG("Bad wc_RNG_GenerateBlock");
|
||||||
|
Reference in New Issue
Block a user