mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
Merge pull request #2312 from gmaxwell/random_random
ApproximateBestSubset internal RNG to prevent degenerate behavior.
This commit is contained in:
26
src/util.cpp
26
src/util.cpp
@@ -1281,12 +1281,26 @@ void AddTimeData(const CNetAddr& ip, int64 nTime)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
uint32_t insecure_rand_Rz = 11;
|
||||
uint32_t insecure_rand_Rw = 11;
|
||||
void seed_insecure_rand(bool fDeterministic)
|
||||
{
|
||||
//The seed values have some unlikely fixed points which we avoid.
|
||||
if(fDeterministic)
|
||||
{
|
||||
insecure_rand_Rz = insecure_rand_Rw = 11;
|
||||
} else {
|
||||
uint32_t tmp;
|
||||
do{
|
||||
RAND_bytes((unsigned char*)&tmp,4);
|
||||
}while(tmp==0 || tmp==0x9068ffffU);
|
||||
insecure_rand_Rz=tmp;
|
||||
do{
|
||||
RAND_bytes((unsigned char*)&tmp,4);
|
||||
}while(tmp==0 || tmp==0x464fffffU);
|
||||
insecure_rand_Rw=tmp;
|
||||
}
|
||||
}
|
||||
|
||||
string FormatVersion(int nVersion)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user