mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-01 19:54:40 +02:00
global rng added to RAND_bytes
This commit is contained in:
33
src/ssl.c
33
src/ssl.c
@@ -4448,19 +4448,6 @@ int CyaSSL_set_compression(CYASSL* ssl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int CyaSSL_RAND_bytes(unsigned char* buf, int num)
|
|
||||||
{
|
|
||||||
RNG rng;
|
|
||||||
|
|
||||||
CYASSL_ENTER("RAND_bytes");
|
|
||||||
if (InitRng(&rng))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
RNG_GenerateBlock(&rng, buf, num);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CyaSSL_RAND_add(const void* add, int len, double entropy)
|
void CyaSSL_RAND_add(const void* add, int len, double entropy)
|
||||||
{
|
{
|
||||||
@@ -5684,6 +5671,26 @@ static int initGlobalRNG = 0;
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int CyaSSL_RAND_bytes(unsigned char* buf, int num)
|
||||||
|
{
|
||||||
|
RNG tmpRNG;
|
||||||
|
RNG* rng = &tmpRNG;
|
||||||
|
|
||||||
|
CYASSL_ENTER("RAND_bytes");
|
||||||
|
if (InitRng(&tmpRNG) != 0) {
|
||||||
|
CYASSL_MSG("Bad RNG Init, trying global");
|
||||||
|
if (initGlobalRNG == 0) {
|
||||||
|
CYASSL_MSG("Global RNG no Init");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
rng = &globalRNG;
|
||||||
|
}
|
||||||
|
|
||||||
|
RNG_GenerateBlock(rng, buf, num);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
CYASSL_BN_CTX* CyaSSL_BN_CTX_new(void)
|
CYASSL_BN_CTX* CyaSSL_BN_CTX_new(void)
|
||||||
{
|
{
|
||||||
static int ctx; /* ctaocrypt doesn't now need ctx */
|
static int ctx; /* ctaocrypt doesn't now need ctx */
|
||||||
|
Reference in New Issue
Block a user