mirror of
https://github.com/eosswedenorg/libantelope
synced 2026-06-16 03:34:56 +02:00
src/libsecp256k1/rng.h: fix C467 warning on MSVC compilers.
This commit is contained in:
parent
e0d0bcb0cb
commit
7e9bd41a83
1 changed files with 5 additions and 0 deletions
|
|
@ -42,12 +42,17 @@
|
||||||
|
|
||||||
static int fill_random(unsigned char* data, size_t size) {
|
static int fill_random(unsigned char* data, size_t size) {
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
/* Disable C4267 Warning (dataloss when casting variable to smaller size) temporarily */
|
||||||
|
#pragma warning( push )
|
||||||
|
#pragma warning( disable: 4267 )
|
||||||
NTSTATUS res = BCryptGenRandom(NULL, data, size, BCRYPT_USE_SYSTEM_PREFERRED_RNG);
|
NTSTATUS res = BCryptGenRandom(NULL, data, size, BCRYPT_USE_SYSTEM_PREFERRED_RNG);
|
||||||
|
#pragma warning( pop )
|
||||||
if (res != STATUS_SUCCESS || size > ULONG_MAX) {
|
if (res != STATUS_SUCCESS || size > ULONG_MAX) {
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(__linux__) || defined(__FreeBSD__)
|
#elif defined(__linux__) || defined(__FreeBSD__)
|
||||||
/* If `getrandom(2)` is not available you should fallback to /dev/urandom */
|
/* If `getrandom(2)` is not available you should fallback to /dev/urandom */
|
||||||
ssize_t res = getrandom(data, size, 0);
|
ssize_t res = getrandom(data, size, 0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue