Dash Core Source Documentation (0.16.0.1)
Find detailed information regarding the Dash Core source code.
#include <crypto/chacha20.h>
#include <crypto/common.h>
#include <uint256.h>
#include <chrono>
#include <cstdint>
Go to the source code of this file.
Classes | |
class | FastRandomContext |
Fast randomness source. More... | |
Functions | |
void | RandAddSeed () |
void | GetRandBytes (unsigned char *buf, int num) |
Functions to gather random data via the OpenSSL PRNG. More... | |
uint64_t | GetRand (uint64_t nMax) |
std::chrono::microseconds | GetRandMicros (std::chrono::microseconds duration_max) noexcept |
int | GetRandInt (int nMax) |
uint256 | GetRandHash () |
bool | GetRandBool (double rate) |
void | RandAddSeedSleep () |
Add a little bit of randomness to the output of GetStrongRangBytes. More... | |
void | GetStrongRandBytes (unsigned char *buf, int num) |
Function to gather random data from multiple sources, failing whenever any of those source fail to provide a result. More... | |
void | GetOSRand (unsigned char *ent32) |
Get 32 bytes of system entropy. More... | |
bool | Random_SanityCheck () |
Check that OS randomness is available and returning the requested number of bytes. More... | |
void | RandomInit () |
Initialize the RNG. More... | |
Variables | |
static const int | NUM_OS_RANDOM_BYTES = 32 |
Function Documentation
◆ GetOSRand()
void GetOSRand | ( | unsigned char * | ent32 | ) |
Get 32 bytes of system entropy.
Do not use this in application code: use GetStrongRandBytes instead.
Definition at line 202 of file random.cpp.
References ARRAYLEN, GetDevURandom(), name, NUM_OS_RANDOM_BYTES, and RandFailure().
Referenced by GetStrongRandBytes(), and Random_SanityCheck().
◆ GetRand()
uint64_t GetRand | ( | uint64_t | nMax | ) |
Definition at line 354 of file random.cpp.
References g_mock_deterministic_tests, GetRandBytes(), and FastRandomContext::randrange().
Referenced by AdvertiseLocal(), AppInitMain(), CTxMemPool::check(), CConnman::ConnectNode(), convertSeed6(), GetRandBool(), GetRandInt(), GetRandMicros(), PoissonNextSend(), ProcessMessage(), CWallet::ResendWalletTransactions(), CRollingBloomFilter::reset(), and CConnman::ThreadDNSAddressSeed().
◆ GetRandBool()
bool GetRandBool | ( | double | rate | ) |
Definition at line 391 of file random.cpp.
References GetRand().
Referenced by llmq::ShouldSimulateError().
◆ GetRandBytes()
void GetRandBytes | ( | unsigned char * | buf, |
int | num | ||
) |
Functions to gather random data via the OpenSSL PRNG.
Definition at line 273 of file random.cpp.
References RandFailure().
Referenced by BOOST_AUTO_TEST_CASE(), CDBWrapper::CreateObfuscateKey(), ECC_Start(), GenerateAuthCookie(), GetRand(), GetRandHash(), GetStrongRandBytes(), TorController::protocolinfo_cb(), PeerLogicValidation::SendMessages(), and CKey::VerifyPubKey().
◆ GetRandHash()
uint256 GetRandHash | ( | ) |
Definition at line 384 of file random.cpp.
References GetRandBytes().
Referenced by AddTx(), BLSSign_Normal(), BOOST_AUTO_TEST_CASE(), BuildTestVectors(), llmq::CLLMQUtils::CalcDeterministicWatchConnections(), CAddrMan::Clear(), CWallet::InitPrivateSendSalt(), LimitOrphanTxSize(), and FastRandomContext::RandomSeed().
◆ GetRandInt()
int GetRandInt | ( | int | nMax | ) |
Definition at line 379 of file random.cpp.
References GetRand().
Referenced by DKG::Bench_VerifyContributionShares(), BLSVerify_LargeAggregatedBlock1000PreVerified(), CPrivateSendServer::ChargeFees(), CPrivateSendServer::ChargeRandomFees(), CPrivateSendServer::CreateNewSession(), CWallet::CreateTransaction(), CPrivateSendClientManager::DoMaintenance(), CWallet::GetCollateralTxDSIn(), CPrivateSendClientSession::PrepareDenominate(), CAddrMan::RandomInt(), CGovernanceManager::RequestGovernanceObject(), CWallet::SelectCoinsMinConf(), CWallet::SelectPSInOutPairsByDenominations(), llmq::CDKGSession::SendCommitment(), CPrivateSendClientSession::StartNewQueue(), CConnman::ThreadOpenConnections(), and CConnman::ThreadOpenMasternodeConnections().
◆ GetRandMicros()
|
noexcept |
Definition at line 374 of file random.cpp.
References GetRand().
Referenced by GetObjectRandomDelay(), and PeerLogicValidation::SendMessages().
◆ GetStrongRandBytes()
void GetStrongRandBytes | ( | unsigned char * | buf, |
int | num | ||
) |
Function to gather random data from multiple sources, failing whenever any of those source fail to provide a result.
Definition at line 317 of file random.cpp.
References cs_rng_state, CSHA512::Finalize(), GetHWRand(), GetOSRand(), GetRandBytes(), memcpy(), memory_cleanse(), RandAddSeedPerfmon(), rng_counter, rng_state, and CSHA512::Write().
Referenced by CBLSIESEncryptedBlob::Encrypt(), CWallet::EncryptWallet(), CMnemonic::Generate(), CKeePassIntegrator::generateRandomKey(), CBLSIESMultiRecipientBlobs::InitEncrypt(), CKey::MakeNewKey(), and CBLSSecretKey::MakeNewKey().
◆ RandAddSeed()
void RandAddSeed | ( | ) |
Definition at line 130 of file random.cpp.
References GetPerformanceCounter(), and memory_cleanse().
Referenced by CInit::CInit(), and RandAddSeedPerfmon().
◆ 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 282 of file random.cpp.
References AddDataToRng(), GetPerformanceCounter(), and memory_cleanse().
Referenced by CScheduler::serviceQueue().
◆ Random_SanityCheck()
bool Random_SanityCheck | ( | ) |
Check that OS randomness is available and returning the requested number of bytes.
Definition at line 434 of file random.cpp.
References GetOSRand(), GetPerformanceCounter(), NUM_OS_RANDOM_BYTES, and stop().
Referenced by InitSanityCheck().
◆ RandomInit()
void RandomInit | ( | ) |
Initialize the RNG.
Definition at line 487 of file random.cpp.
References RDRandInit().
Referenced by AppInitSanityChecks(), and main().
Variable Documentation
◆ NUM_OS_RANDOM_BYTES
|
static |
Definition at line 143 of file random.h.
Referenced by GetDevURandom(), GetOSRand(), and Random_SanityCheck().