mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
Merge a7e80449c0 into merged_master (Bitcoin PR bitcoin/bitcoin#24238)
This commit is contained in:
commit
b01ac942ee
2 changed files with 8 additions and 19 deletions
|
|
@ -1123,13 +1123,6 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>
|
|||
[ AC_MSG_RESULT([no])]
|
||||
)
|
||||
|
||||
AC_MSG_CHECKING([for getentropy])
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]],
|
||||
[[ getentropy(nullptr, 32) ]])],
|
||||
[ AC_MSG_RESULT([yes]); AC_DEFINE([HAVE_GETENTROPY], [1], [Define this symbol if the BSD getentropy system call is available]) ],
|
||||
[ AC_MSG_RESULT([no])]
|
||||
)
|
||||
|
||||
AC_MSG_CHECKING([for getentropy via random.h])
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>
|
||||
#include <sys/random.h>]],
|
||||
|
|
|
|||
|
|
@ -32,10 +32,8 @@
|
|||
#include <sys/syscall.h>
|
||||
#include <linux/random.h>
|
||||
#endif
|
||||
#if defined(HAVE_GETENTROPY) || (defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX))
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#if defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)
|
||||
#include <unistd.h>
|
||||
#include <sys/random.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYSCTL_ARND
|
||||
|
|
@ -305,16 +303,14 @@ void GetOSRand(unsigned char *ent32)
|
|||
RandFailure();
|
||||
}
|
||||
}
|
||||
#elif defined(HAVE_GETENTROPY) && defined(__OpenBSD__)
|
||||
/* On OpenBSD this can return up to 256 bytes of entropy, will return an
|
||||
* error if more are requested.
|
||||
* The call cannot return less than the requested number of bytes.
|
||||
getentropy is explicitly limited to openbsd here, as a similar (but not
|
||||
the same) function may exist on other platforms via glibc.
|
||||
#elif defined(__OpenBSD__)
|
||||
/* OpenBSD. From the arc4random(3) man page:
|
||||
"Use of these functions is encouraged for almost all random number
|
||||
consumption because the other interfaces are deficient in either
|
||||
quality, portability, standardization, or availability."
|
||||
The function call is always successful.
|
||||
*/
|
||||
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
|
||||
RandFailure();
|
||||
}
|
||||
arc4random_buf(ent32, NUM_OS_RANDOM_BYTES);
|
||||
// Silence a compiler warning about unused function.
|
||||
(void)GetDevURandom;
|
||||
#elif defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue