global rng added to RAND_bytes
This commit is contained in:
parent
968dfc4cf7
commit
a97dbb8a14
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)
|
||||
{
|
||||
@ -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)
|
||||
{
|
||||
static int ctx; /* ctaocrypt doesn't now need ctx */
|
||||
|
Loading…
Reference in New Issue
Block a user