mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-25 07:52:59 +03:00
libent: use BCryptGenRandom on Windows
This commit is contained in:
parent
6ed4b7077b
commit
ad81a017c5
1
pkg/ent/configure
vendored
1
pkg/ent/configure
vendored
@ -7,6 +7,7 @@ log () {
|
||||
for impl in ENT_GETENTROPY_UNISTD \
|
||||
ENT_GETENTROPY_SYSRANDOM \
|
||||
ENT_GETRANDOM_SYSCALL \
|
||||
ENT_GETENTROPY_BCRYPTGENRANDOM \
|
||||
ENT_DEV_URANDOM
|
||||
do
|
||||
export IMPL=$impl
|
||||
|
@ -57,6 +57,16 @@ int ent_getentropy(void* buf, size_t len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Use `BCryptGenRandom` on Windows ////////////////////////////////////////////
|
||||
|
||||
#elif defined(ENT_GETENTROPY_BCRYPTGENRANDOM)
|
||||
#include <windows.h>
|
||||
#include <bcrypt.h>
|
||||
int ent_getentropy(void* buf, size_t len) {
|
||||
return BCryptGenRandom(NULL, (PUCHAR)buf, len, BCRYPT_USE_SYSTEM_PREFERRED_RNG);
|
||||
}
|
||||
|
||||
#else
|
||||
#error "One of these must be set: ENT_DEV_URANDOM, ENT_GETENTROPY_UNISTD, ENT_GETENTROPY_SYSRANDOM, ENT_GETRANDOM_SYSCALL"
|
||||
#error "One of these must be set: ENT_GETENTROPY_BCRYPTGENRANDOM, ENT_DEV_URANDOM, ENT_GETENTROPY_UNISTD, ENT_GETENTROPY_SYSRANDOM, ENT_GETRANDOM_SYSCALL"
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user