Prefer GnuTLS when acquiring random seed
commit05e8148a24ebe51fbe758dd16265e8fb81f85953
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 17 Jan 2016 20:12:08 +0000 (17 12:12 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 17 Jan 2016 20:13:49 +0000 (17 12:13 -0800)
tree447c9fa28f9b8b3e8380f4f1c039b6cf76ce5750
parenta0d5b7ae3bb014bb0b1c205d123c597df0e76411
Prefer GnuTLS when acquiring random seed

This attempts to improve on the fix for Bug#22202.
* configure.ac (HAVE_DEV_URANDOM): Remove.
Check /dev/urandom existence at run time, not at build time,
since the device could exist in the former but not the latter.
* src/sysdep.c [HAVE_GNUTLS]: Include gnutls/gnutls.h.
(gnutls_rnd) [GNUTLS_VERSION_NUMBER < 0x020c00]: New fallback macro.
(random_seed): New typedef.
(set_random_seed): New static function.
(seed_random): Use them.
(init_random): Use random_seed instead of uintmax_t, so as to
not consume more entropy than needed.  Prefer gnutls_rnd if it
works; this avoids a redundant open of /dev/urandom on
GNU/Linux with modern GnuTLS.
configure.ac
src/sysdep.c