Changeset View
Changeset View
Standalone View
Standalone View
src/random.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <random.h> | #include <random.h> | ||||
#ifdef WIN32 | #ifdef WIN32 | ||||
#include <compat.h> // for Windows API | #include <compat.h> // for Windows API | ||||
#include <wincrypt.h> | #include <wincrypt.h> | ||||
#endif | #endif | ||||
#include <crypto/sha512.h> | #include <crypto/sha512.h> | ||||
#include <logging.h> // for LogPrint() | #include <logging.h> // for LogPrint() | ||||
#include <support/cleanse.h> | #include <support/cleanse.h> | ||||
#include <sync.h> // for WAIT_LOCK | #include <sync.h> // for WAIT_LOCK | ||||
#include <utiltime.h> // for GetTime() | #include <util/time.h> // for GetTime() | ||||
#include <openssl/err.h> | #include <openssl/err.h> | ||||
#include <openssl/rand.h> | #include <openssl/rand.h> | ||||
#include <chrono> | #include <chrono> | ||||
#include <cstdlib> | #include <cstdlib> | ||||
#include <limits> | #include <limits> | ||||
#include <mutex> | #include <mutex> | ||||
Show All 11 Lines | #if defined(HAVE_GETENTROPY) || \ | ||||
(defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)) | (defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)) | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#endif | #endif | ||||
#if defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX) | #if defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX) | ||||
#include <sys/random.h> | #include <sys/random.h> | ||||
#endif | #endif | ||||
#ifdef HAVE_SYSCTL_ARND | #ifdef HAVE_SYSCTL_ARND | ||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <utilstrencodings.h> // for ARRAYLEN | #include <util/strencodings.h> // for ARRAYLEN | ||||
#endif | #endif | ||||
#if defined(__x86_64__) || defined(__amd64__) || defined(__i386__) | #if defined(__x86_64__) || defined(__amd64__) || defined(__i386__) | ||||
#include <cpuid.h> | #include <cpuid.h> | ||||
#endif | #endif | ||||
[[noreturn]] static void RandFailure() { | [[noreturn]] static void RandFailure() { | ||||
LogPrintf("Failed to read randomness, aborting\n"); | LogPrintf("Failed to read randomness, aborting\n"); | ||||
▲ Show 20 Lines • Show All 449 Lines • Show Last 20 Lines |