From: Wouter Wijngaards Date: Wed, 9 Jan 2008 10:55:37 +0000 (+0000) Subject: rng fixup (trunk). X-Git-Tag: release-0.9~110 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a0e442eb32f27ab0d35a3a9b72cd99a4924f12f8;p=thirdparty%2Funbound.git rng fixup (trunk). git-svn-id: file:///svn/unbound/trunk@827 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/doc/Changelog b/doc/Changelog index 6987af408..89ea668ea 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,7 @@ +9 January 2008: Wouter + - fixup openssl RAND problem, when the system is not configured to + give entropy, and the rng needs to be seeded. + 4 January 2008: Wouter - document misconfiguration in private network. diff --git a/util/random.c b/util/random.c index 19a72834b..3f3611d9c 100644 --- a/util/random.c +++ b/util/random.c @@ -92,7 +92,7 @@ ub_arc4random_stir(struct ub_hiddenstate* s) } int -ub_initstate(unsigned int ATTR_UNUSED(seed), struct ub_randstate* state, +ub_initstate(unsigned int seed, struct ub_randstate* state, unsigned long ATTR_UNUSED(n)) { state->s = calloc(1, sizeof(*state->s)); @@ -103,9 +103,13 @@ ub_initstate(unsigned int ATTR_UNUSED(seed), struct ub_randstate* state, /* RAND_ is threadsafe, by the way */ if(!RAND_status()) { - log_err("Random generator has no entropy (error %ld)", - ERR_get_error()); - return 0; + /* try to seed it */ + RAND_seed(&seed, (int)sizeof(seed)); + if(!RAND_status()) { + log_err("Random generator has no entropy (error %ld)", + ERR_get_error()); + return 0; + } } ub_arc4random_stir(state->s); return 1;