merge bitcoin#26814: remove windows-only compat.h usage in random

This commit is contained in:
Kittywhiskers Van Gogh 2024-12-09 15:20:50 +00:00
parent 94e6637c33
commit db676a7e5f
No known key found for this signature in database
GPG Key ID: 30CD0C065E5C4AAD

View File

@ -9,24 +9,23 @@
#include <crypto/chacha20.h> #include <crypto/chacha20.h>
#include <crypto/sha256.h> #include <crypto/sha256.h>
#include <crypto/sha512.h> #include <crypto/sha512.h>
#include <support/cleanse.h>
#ifdef WIN32
#include <compat/compat.h>
#include <wincrypt.h>
#endif
#include <logging.h> #include <logging.h>
#include <randomenv.h> #include <randomenv.h>
#include <support/allocators/secure.h>
#include <span.h> #include <span.h>
#include <sync.h> // for Mutex #include <support/allocators/secure.h>
#include <util/time.h> // for GetTimeMicros() #include <support/cleanse.h>
#include <sync.h>
#include <util/time.h>
#include <array> #include <array>
#include <cmath> #include <cmath>
#include <stdlib.h> #include <stdlib.h>
#include <thread> #include <thread>
#ifndef WIN32 #ifdef WIN32
#include <windows.h>
#include <wincrypt.h>
#else
#include <fcntl.h> #include <fcntl.h>
#endif #endif
@ -729,7 +728,7 @@ bool Random_SanityCheck()
* GetOSRand() overwrites all 32 bytes of the output given a maximum * GetOSRand() overwrites all 32 bytes of the output given a maximum
* number of tries. * number of tries.
*/ */
static const ssize_t MAX_TRIES = 1024; static constexpr int MAX_TRIES{1024};
uint8_t data[NUM_OS_RANDOM_BYTES]; uint8_t data[NUM_OS_RANDOM_BYTES];
bool overwritten[NUM_OS_RANDOM_BYTES] = {}; /* Tracks which bytes have been overwritten at least once */ bool overwritten[NUM_OS_RANDOM_BYTES] = {}; /* Tracks which bytes have been overwritten at least once */
int num_overwritten; int num_overwritten;