]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
rng fixup (trunk).
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 9 Jan 2008 10:55:37 +0000 (10:55 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Wed, 9 Jan 2008 10:55:37 +0000 (10:55 +0000)
git-svn-id: file:///svn/unbound/trunk@827 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
util/random.c

index 6987af408f8c41bb2f11da19249f761c2b122e27..89ea668ea90910138fd73579ed68a4bd8e2082de 100644 (file)
@@ -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.
 
index 19a72834bc3ac13173a2337dfa77b71dad92084f..3f3611d9c08837ed5c059e76ca5cd59a18b9314a 100644 (file)
@@ -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;