Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] Update RNG code from upstream #2278

Merged
merged 55 commits into from
Apr 14, 2021
Merged
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
94b2ead
Make FastRandomContext support standard C++11 RNG interface
sipa Mar 21, 2018
e862564
Make addrman use its local RNG exclusively
Fuzzbawls Mar 28, 2021
1cdf124
Use a local FastRandomContext in a few more places in net
Fuzzbawls Mar 28, 2021
746d466
Introduce a Shuffle for FastRandomContext and use it in wallet
Fuzzbawls Mar 28, 2021
af52bf5
Use a FastRandomContext in LimitOrphanTxSize
Fuzzbawls Mar 28, 2021
972effa
Make unit tests use the insecure_rand_ctx exclusively
Fuzzbawls Mar 28, 2021
32e6c42
Simplify testing RNG code
Fuzzbawls Mar 28, 2021
1a5dbc5
Don't log RandAddSeedPerfmon details
sipa Dec 19, 2018
d76ee83
Automatically initialize RNG on first use.
sipa Dec 18, 2018
2326535
Rename some hardware RNG related functions
sipa Jan 16, 2019
298f97c
Add thread safety annotations to RNG state
sipa Dec 18, 2018
5f20e62
Abstract out seeding/extracting entropy into RNGState::MixExtract
sipa Dec 18, 2018
038a45a
Integrate util/system's CInit into RNGState
Fuzzbawls Mar 28, 2021
698d133
Switch all RNG code to the built-in PRNG.
sipa Dec 14, 2018
774899f
Remove hwrand_initialized.
sipa Dec 18, 2018
5bc2583
Sprinkle some sweet noexcepts over the RNG code
sipa Dec 17, 2018
787d72f
DRY: Implement GetRand using FastRandomContext::randrange
sipa Jan 4, 2019
080deb3
Encapsulate RNGState better
sipa Jan 11, 2019
2b6381e
Use secure allocator for RNG state
sipa Jan 11, 2019
4ffda1f
Document RNG design in random.h
sipa Jan 13, 2019
67e336d
Use RdSeed when available, and reduce RdRand load
sipa Jan 25, 2019
0190dec
Add hash strengthening to the RNG
sipa Dec 17, 2018
7b33223
Document strenghtening
sipa Jan 21, 2019
c82e359
test: Make bloom tests deterministic
Feb 1, 2019
28c9cdb
tests: Add script checking for deterministic line coverage
practicalswift Jan 30, 2019
6966aa9
Add ChaCha20 encryption option (XOR)
jonasschnelli Mar 1, 2019
79e7fd3
Add ChaCha20 bench
jonasschnelli Mar 5, 2019
22a7121
Fix non-deterministic coverage of test DoS_mapOrphans
Fuzzbawls Mar 29, 2021
ada9868
gui: remove OpenSSL PRNG seeding (Windows, Qt only)
fanquake Oct 13, 2019
5eed08c
random: remove call to RAND_screen() (Windows only)
fanquake Oct 18, 2019
630931f
break circular dependency: random/sync -> util -> random/sync
Fuzzbawls Mar 30, 2021
909473e
Fix FreeBSD build by including utilstrencodings.h
Fuzzbawls Mar 30, 2021
fccd2b8
doc: correct function name in ReportHardwareRand()
fanquake Oct 17, 2019
27cf995
doc: minor corrections in random.cpp
fanquake Oct 26, 2019
52b5336
[MOVEONLY] Move perfmon data gathering to new randomenv module
sipa Oct 26, 2019
7bde8b7
[MOVEONLY] Move cpuid code from random to compat/cpuid
Fuzzbawls Mar 30, 2021
6142e1f
Seed randomness with process id / thread id / various clocks
sipa Oct 27, 2019
67de246
Gather additional entropy from the environment
sipa Oct 27, 2019
8f5b9c9
Use sysctl for seeding on MacOS/BSD
sipa Oct 28, 2019
88d97d0
Feed CPUID data into RNG
sipa Oct 27, 2019
4679181
Add information gathered through getauxval()
sipa Oct 27, 2019
7d6ddcb
Run background seeding periodically instead of unpredictably
sipa Oct 29, 2019
f363ea9
Seed RNG with precision timestamps on receipt of net messages.
TheBlueMatt Nov 23, 2019
81d382f
doc: correct random.h docs after #17270
fanquake Nov 18, 2019
88c2ae5
random: mark RandAddPeriodic and SeedPeriodic as noexcept
fanquake Nov 18, 2019
8a9bbb1
Move events_hasher into RNGState()
sipa Dec 4, 2019
41ab1ff
Fix CPUID subleaf iteration
sipa Nov 19, 2019
fec460c
Put bounds on the number of CPUID leaves explored
sipa Nov 20, 2019
b70b26f
Fix typo in comment in randomenv.cpp
Fuzzbawls Apr 14, 2021
77bddd7
Use GetStrongRandBytes in gmp bignum initialization
Fuzzbawls Apr 14, 2021
3a039d6
build: avoid getifaddrs when unavailable
theuni Jul 19, 2018
414f405
rand: only try and use freeifaddrs if available
fanquake Mar 20, 2021
e906436
build: check if -lsocket is required with *ifaddrs
fanquake Mar 21, 2021
d9f67da
net: add ifaddrs.h include
fanquake Mar 26, 2021
cecbf6c
Use secure.h header for secure allocators
Fuzzbawls Apr 14, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove hwrand_initialized.
 All access to hwrand is now gated by GetRNGState, which initializes the hwrand code.
  • Loading branch information
sipa authored and Fuzzbawls committed Apr 14, 2021
commit 774899f92a30441d193a59d4ec1d7177a5cf3243
4 changes: 0 additions & 4 deletions src/random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ static inline int64_t GetPerformanceCounter()
}

#if defined(__x86_64__) || defined(__amd64__) || defined(__i386__)
static std::atomic<bool> hwrand_initialized{false};
static bool rdrand_supported = false;
static constexpr uint32_t CPUID_F1_ECX_RDRAND = 0x40000000;
static void InitHardwareRand()
Expand All @@ -85,12 +84,10 @@ static void InitHardwareRand()
if (__get_cpuid(1, &eax, &ebx, &ecx, &edx) && (ecx & CPUID_F1_ECX_RDRAND)) {
rdrand_supported = true;
}
hwrand_initialized.store(true);
}

static void ReportHardwareRand()
{
assert(hwrand_initialized.load(std::memory_order_relaxed));
if (rdrand_supported) {
// This must be done in a separate function, as HWRandInit() may be indirectly called
// from global constructors, before logging is initialized.
Expand All @@ -110,7 +107,6 @@ static void ReportHardwareRand() {}

static bool GetHardwareRand(unsigned char* ent32) {
#if defined(__x86_64__) || defined(__amd64__) || defined(__i386__)
assert(hwrand_initialized.load(std::memory_order_relaxed));
if (rdrand_supported) {
uint8_t ok;
// Not all assemblers support the rdrand instruction, write it in hex.
Expand Down