| 270 | } |
| 271 | |
| 272 | void RandAddStaticEnv(CSHA512& hasher) |
| 273 | { |
| 274 | // Some compile-time static properties |
| 275 | hasher << (CHAR_MIN < 0) << sizeof(void*) << sizeof(long) << sizeof(int); |
| 276 | #if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) |
| 277 | hasher << __GNUC__ << __GNUC_MINOR__ << __GNUC_PATCHLEVEL__; |
| 278 | #endif |
| 279 | #ifdef _MSC_VER |
| 280 | hasher << _MSC_VER; |
| 281 | #endif |
| 282 | hasher << __cplusplus; |
| 283 | #ifdef _XOPEN_VERSION |
| 284 | hasher << _XOPEN_VERSION; |
| 285 | #endif |
| 286 | #ifdef __VERSION__ |
| 287 | const char* COMPILER_VERSION = __VERSION__; |
| 288 | hasher.Write((const unsigned char*)COMPILER_VERSION, strlen(COMPILER_VERSION) + 1); |
| 289 | #endif |
| 290 | |
| 291 | // Bitcoin client version |
| 292 | hasher << CLIENT_VERSION; |
| 293 | |
| 294 | #if defined(HAVE_STRONG_GETAUXVAL) |
| 295 | // Information available through getauxval() |
| 296 | # ifdef AT_HWCAP |
| 297 | hasher << getauxval(AT_HWCAP); |
| 298 | # endif |
| 299 | # ifdef AT_HWCAP2 |
| 300 | hasher << getauxval(AT_HWCAP2); |
| 301 | # endif |
| 302 | # ifdef AT_RANDOM |
| 303 | const unsigned char* random_aux = (const unsigned char*)getauxval(AT_RANDOM); |
| 304 | if (random_aux) hasher.Write(random_aux, 16); |
| 305 | # endif |
| 306 | # ifdef AT_PLATFORM |
| 307 | const char* platform_str = (const char*)getauxval(AT_PLATFORM); |
| 308 | if (platform_str) hasher.Write((const unsigned char*)platform_str, strlen(platform_str) + 1); |
| 309 | # endif |
| 310 | # ifdef AT_EXECFN |
| 311 | const char* exec_str = (const char*)getauxval(AT_EXECFN); |
| 312 | if (exec_str) hasher.Write((const unsigned char*)exec_str, strlen(exec_str) + 1); |
| 313 | # endif |
| 314 | #endif // HAVE_STRONG_GETAUXVAL |
| 315 | |
| 316 | #ifdef HAVE_GETCPUID |
| 317 | AddAllCPUID(hasher); |
| 318 | #endif |
| 319 | |
| 320 | // Memory locations |
| 321 | hasher << &hasher << &RandAddStaticEnv << &malloc << &errno << &environ; |
| 322 | |
| 323 | // Hostname |
| 324 | #ifdef WIN32 |
| 325 | constexpr DWORD max_size = MAX_COMPUTERNAME_LENGTH + 1; |
| 326 | char hname[max_size]; |
| 327 | DWORD size = max_size; |
| 328 | if (GetComputerNameA(hname, &size) != 0) { |
| 329 | hasher.Write(UCharCast(hname), size); |
no test coverage detected