random: Use modern Windows randomness functions

The old randomness API has been deprecated and may be removed soon.[^1]

For reference on `BCryptGenRandom`, see: https://learn.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom.

`STATUS_SUCCESS`[^2] gets defined here since including `ntstatus.h` is
more trouble than it's worth. [^3]

[^1]: https://learn.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptacquirecontextw & https://learn.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptgenrandom
[^2]: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/596a1078-e883-4972-9bbc-49e60bebca55
[^3]: See 70f149b9a1/examples/examples_util.h (L19-L28)
This commit is contained in:
David Gumberg
2025-05-01 16:36:24 -07:00
parent 31d3eebfb9
commit 6b4bcc1623
4 changed files with 12 additions and 11 deletions

View File

@@ -87,6 +87,7 @@ target_link_libraries(bitcoinkernel
bitcoin_crypto
leveldb
secp256k1
$<$<PLATFORM_ID:Windows>:bcrypt>
$<TARGET_NAME_IF_EXISTS:USDT::headers>
PUBLIC
Boost::headers