6#include <bitcoin-build-config.h>
33#include <netinet/in.h>
34#include <sys/resource.h>
35#include <sys/socket.h>
38#include <sys/utsname.h>
45#include <sys/sysctl.h>
46#if __has_include(<vm/vm_param.h>)
47#include <vm/vm_param.h>
49#if __has_include(<sys/resources.h>)
50#include <sys/resources.h>
52#if __has_include(<sys/vmmeter.h>)
53#include <sys/vmmeter.h>
56#if defined(HAVE_STRONG_GETAUXVAL)
60#if defined(__APPLE__) || \
61 defined(__FreeBSD__) || \
62 defined(__NetBSD__) || \
63 defined(__OpenBSD__) || \
77 static_assert(!std::is_same_v<std::decay_t<T>,
char*>,
"Calling operator<<(CSHA512, char*) is probably not what you want");
78 static_assert(!std::is_same_v<std::decay_t<T>,
unsigned char*>,
"Calling operator<<(CSHA512, unsigned char*) is probably not what you want");
79 static_assert(!std::is_same_v<std::decay_t<T>,
const char*>,
"Calling operator<<(CSHA512, const char*) is probably not what you want");
80 static_assert(!std::is_same_v<std::decay_t<T>,
const unsigned char*>,
"Calling operator<<(CSHA512, const unsigned char*) is probably not what you want");
88 if (addr ==
nullptr)
return;
89 switch (addr->sa_family) {
97 hasher.
Write((
const unsigned char*)&addr->sa_family,
sizeof(addr->sa_family));
107 unsigned char fbuf[4096];
109 hasher.Write((
const unsigned char*)&
f,
sizeof(
f));
116 }
while (n ==
sizeof(
fbuf) && total < 1048576);
124 if (
stat(path, &
sb) == 0) {
125 hasher.Write((
const unsigned char*)path,
strlen(path) + 1);
135 int CTL[
sizeof...(S)] = {
S...};
136 unsigned char buffer[65536];
142 if (
siz >
sizeof(buffer))
siz =
sizeof(buffer);
168 if ((
ax & 0x1f) == 0)
break;
169 }
else if (
leaf == 7) {
172 }
else if (
leaf == 11) {
173 if ((
cx & 0xff00) == 0)
break;
174 }
else if (
leaf == 13) {
175 if (
ax == 0 &&
bx == 0 &&
cx == 0 &&
dx == 0)
break;
201# ifdef CLOCK_MONOTONIC
205# ifdef CLOCK_REALTIME
209# ifdef CLOCK_BOOTTIME
219 hasher << std::chrono::system_clock::now().time_since_epoch().count();
220 hasher << std::chrono::steady_clock::now().time_since_epoch().count();
221 hasher << std::chrono::high_resolution_clock::now().time_since_epoch().count();
243# if defined(KERN_PROC) && defined(KERN_PROC_ALL)
266 void* addr =
malloc(4097);
275#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
293#if defined(HAVE_STRONG_GETAUXVAL)
325 char hname[max_size];
326 DWORD size = max_size;
342 while (
ifit !=
nullptr) {
345 hasher.Write((
const unsigned char*)&
ifit->ifa_flags,
sizeof(
ifit->ifa_flags));
403# ifdef HW_MACHINE_ARCH
426# ifdef KERN_CLOCKRATE
438# ifdef KERN_OSRELDATE
441# ifdef KERN_OSRELEASE
461 for (
size_t i = 0;
environ[i]; ++i) {
472 hasher << std::this_thread::get_id();
A hasher class for SHA-512.
CSHA512 & Write(const unsigned char *data, size_t len)
static const int CLIENT_VERSION
static OutputStream & operator<<(OutputStream &os, const Array &array)
#define T(expected, seed, data)
#define S(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p)
void RandAddStaticEnv(CSHA512 &hasher)
Gather non-cryptographic environment data that does not change over time.
void RandAddDynamicEnv(CSHA512 &hasher)
Gather non-cryptographic environment data that changes over time.
unsigned char * UCharCast(char *c)
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.