]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
getrandom: Simplify the determination of the random number devices.
authorBruno Haible <bruno@clisp.org>
Sun, 31 May 2020 11:44:04 +0000 (13:44 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 31 May 2020 11:44:04 +0000 (13:44 +0200)
Suggested by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00383.html>.

* lib/getrandom.c (NAME_OF_RANDOM_DEVICE, NAME_OF_NONCE_DEVICE): New
macros.
* modules/getrandom (Depends-on): Remove crypto/gc-random.

ChangeLog
lib/getrandom.c
modules/getrandom

index cacd4c0f5cf808e7e5105018913e39e782b9cf51..f7c9b4dfb0c7d49501b7588afe2200e3dc3d86a6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2020-05-31  Bruno Haible  <bruno@clisp.org>
+
+       getrandom: Simplify the determination of the random number devices.
+       Suggested by Paul Eggert in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00383.html>.
+       * lib/getrandom.c (NAME_OF_RANDOM_DEVICE, NAME_OF_NONCE_DEVICE): New
+       macros.
+       * modules/getrandom (Depends-on): Remove crypto/gc-random.
+
 2020-05-31  Bruno Haible  <bruno@clisp.org>
 
        crypto/gc-random: Fix list of crypto devices for Solaris.
index f20ffe01127c512c1e0ce7bc13d6ee7ef29c923a..0cc3dc3d8507f582e9c42f30630361e0c65a855e 100644 (file)
 
 #include "minmax.h"
 
+/* These devices exist on all platforms except native Windows.  */
+#if !(defined _WIN32 && ! defined __CYGWIN__)
+
+/* Name of a device through which the kernel returns high quality random
+   numbers, from an entropy pool.  When the pool is empty, the call blocks
+   until entropy sources have added enough bits of entropy.  */
+# ifndef NAME_OF_RANDOM_DEVICE
+#  define NAME_OF_RANDOM_DEVICE "/dev/random"
+# endif
+
+/* Name of a device through which the kernel returns random or pseudo-random
+   numbers.  It uses an entropy pool, but, in order to avoid blocking, adds
+   bits generated by a pseudo-random number generator, as needed.  */
+# ifndef NAME_OF_NONCE_DEVICE
+#  define NAME_OF_NONCE_DEVICE "/dev/urandom"
+# endif
+
+#endif
+
 /* Set BUFFER (of size LENGTH) to random bytes under the control of FLAGS.
    Return the number of bytes written, or -1 on error.  */
 ssize_t
index e94686d6ff9bdc800dfeed73a7b33c314970a49e..8aa4be2b781005b23b4535e1a08b595c425ae331 100644 (file)
@@ -7,7 +7,6 @@ m4/getrandom.m4
 
 Depends-on:
 sys_random
-crypto/gc-random    [test $HAVE_GETRANDOM = 0]
 fcntl-h             [test $HAVE_GETRANDOM = 0 || test $REPLACE_GETRANDOM = 1]
 minmax              [test $HAVE_GETRANDOM = 0 || test $REPLACE_GETRANDOM = 1]
 open                [test $HAVE_GETRANDOM = 0 || test $REPLACE_GETRANDOM = 1]