The bitcoin-core RNG uses the x86 RDSeed and RDRand instructions as an additional source of entropy. However RDSeed and RDRand are not used as an additional source of entropy even if the CPU supports them if the bitcoind binary was built using the the Microsoft C++ compiler, MSVC. This results from the fact that:
- The bitcoin-core code base uses the GCC macros such as
__x86_64__to detect the CPU architecture. Thus on platforms that do not support the GCC macros the compiler will make the incorrect assumption that the underlying system does not support RDRand and RDSeed. - The bitcoin-core code base uses the GCC keyword
__asm__for inline assembly. This keyword is not supported for MSVC.
This PR adds support for RDRand/RDSeed to bitcoind when built with MSVC by adding MSVC supported macros to correctly determine the target architecture and by adding MSVC supported keywords for the HDSeed and HDRand x86 instructions. This PR includes hwrand_tests to validate this behavior.