MCPcopy Create free account
hub / github.com/ElementsProject/elements / RandAddStaticEnv

Function RandAddStaticEnv

src/randomenv.cpp:307–500  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305}
306
307void RandAddStaticEnv(CSHA512& hasher)
308{
309 // Some compile-time static properties
310 hasher << (CHAR_MIN < 0) << sizeof(void*) << sizeof(long) << sizeof(int);
311#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
312 hasher << __GNUC__ << __GNUC_MINOR__ << __GNUC_PATCHLEVEL__;
313#endif
314#ifdef _MSC_VER
315 hasher << _MSC_VER;
316#endif
317 hasher << __cplusplus;
318#ifdef _XOPEN_VERSION
319 hasher << _XOPEN_VERSION;
320#endif
321#ifdef __VERSION__
322 const char* COMPILER_VERSION = __VERSION__;
323 hasher.Write((const unsigned char*)COMPILER_VERSION, strlen(COMPILER_VERSION) + 1);
324#endif
325
326 // Bitcoin client version
327 hasher << CLIENT_VERSION;
328
329#if defined(HAVE_STRONG_GETAUXVAL)
330 // Information available through getauxval()
331# ifdef AT_HWCAP
332 hasher << getauxval(AT_HWCAP);
333# endif
334# ifdef AT_HWCAP2
335 hasher << getauxval(AT_HWCAP2);
336# endif
337# ifdef AT_RANDOM
338 const unsigned char* random_aux = (const unsigned char*)getauxval(AT_RANDOM);
339 if (random_aux) hasher.Write(random_aux, 16);
340# endif
341# ifdef AT_PLATFORM
342 const char* platform_str = (const char*)getauxval(AT_PLATFORM);
343 if (platform_str) hasher.Write((const unsigned char*)platform_str, strlen(platform_str) + 1);
344# endif
345# ifdef AT_EXECFN
346 const char* exec_str = (const char*)getauxval(AT_EXECFN);
347 if (exec_str) hasher.Write((const unsigned char*)exec_str, strlen(exec_str) + 1);
348# endif
349#endif // HAVE_STRONG_GETAUXVAL
350
351#ifdef HAVE_GETCPUID
352 AddAllCPUID(hasher);
353#endif
354
355 // Memory locations
356 hasher << &hasher << &RandAddStaticEnv << &malloc << &errno << &environ;
357
358 // Hostname
359 char hname[256];
360 if (gethostname(hname, 256) == 0) {
361 hasher.Write((const unsigned char*)hname, strnlen(hname, 256));
362 }
363
364#if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS

Callers 1

SeedStartupFunction · 0.85

Calls 6

AddAllCPUIDFunction · 0.85
strnlenFunction · 0.85
AddSockaddrFunction · 0.85
AddPathFunction · 0.85
AddFileFunction · 0.85
WriteMethod · 0.45

Tested by

no test coverage detected