Raven Core  3.0.0
P2P Digital Currency
Functions
random.cpp File Reference
#include "random.h"
#include "crypto/sha512.h"
#include "support/cleanse.h"
#include "util.h"
#include "utilstrencodings.h"
#include <stdlib.h>
#include <limits>
#include <chrono>
#include <thread>
#include <sys/time.h>
#include <mutex>
#include <openssl/err.h>
#include <openssl/rand.h>
Include dependency graph for random.cpp:

Go to the source code of this file.

Functions

void RandAddSeed ()
 
void GetDevURandom (unsigned char *ent32)
 Fallback: get 32 bytes of system entropy from /dev/urandom. More...
 
void GetOSRand (unsigned char *ent32)
 Get 32 bytes of system entropy. More...
 
void GetRandBytes (unsigned char *buf, int num)
 Functions to gather random data via the OpenSSL PRNG. More...
 
void RandAddSeedSleep ()
 Add a little bit of randomness to the output of GetStrongRangBytes. More...
 
void GetStrongRandBytes (unsigned char *out, int num)
 Function to gather random data from multiple sources, failing whenever any of those source fail to provide a result. More...
 
uint64_t GetRand (uint64_t nMax)
 
int GetRandInt (int nMax)
 
uint256 GetRandHash ()
 
bool Random_SanityCheck ()
 Check that OS randomness is available and returning the requested number of bytes. More...
 
void RandomInit ()
 Initialize the RNG. More...
 

Function Documentation

◆ GetDevURandom()

void GetDevURandom ( unsigned char *  ent32)

Fallback: get 32 bytes of system entropy from /dev/urandom.

The most compatible way to get cryptographic randomness on UNIX-ish platforms.

Definition at line 183 of file random.cpp.

◆ GetOSRand()

void GetOSRand ( unsigned char *  ent32)

Get 32 bytes of system entropy.

Definition at line 203 of file random.cpp.

◆ GetRand()

uint64_t GetRand ( uint64_t  nMax)

Definition at line 353 of file random.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetRandBytes()

void GetRandBytes ( unsigned char *  buf,
int  num 
)

Functions to gather random data via the OpenSSL PRNG.

Definition at line 274 of file random.cpp.

Here is the caller graph for this function:

◆ GetRandHash()

uint256 GetRandHash ( )

Definition at line 373 of file random.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetRandInt()

int GetRandInt ( int  nMax)

Definition at line 368 of file random.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetStrongRandBytes()

void GetStrongRandBytes ( unsigned char *  out,
int  num 
)

Function to gather random data from multiple sources, failing whenever any of those source fail to provide a result.

Definition at line 318 of file random.cpp.

Here is the caller graph for this function:

◆ RandAddSeed()

void RandAddSeed ( )

Definition at line 131 of file random.cpp.

◆ RandAddSeedSleep()

void RandAddSeedSleep ( )

Add a little bit of randomness to the output of GetStrongRangBytes.

This sleeps for a millisecond, so should only be called when there is no other work to be done.

Definition at line 283 of file random.cpp.

Here is the caller graph for this function:

◆ Random_SanityCheck()

bool Random_SanityCheck ( )

Check that OS randomness is available and returning the requested number of bytes.

Definition at line 412 of file random.cpp.

Here is the caller graph for this function:

◆ RandomInit()

void RandomInit ( )

Initialize the RNG.

Definition at line 465 of file random.cpp.

Here is the caller graph for this function: