This is preliminary patch just to illustrate idea how bad (31bit) initial 
seeding of kernel's arc4random() can be fixed. Do you like it?

--- yarrow.c.bak        2011-11-26 09:40:49.000000000 +0400
+++ yarrow.c    2011-11-26 09:44:05.000000000 +0400
@@ -59,6 +59,8 @@ static void reseed(u_int);
 /* The reseed thread mutex */
 struct mtx random_reseed_mtx;
 
+static arc4rand_reseed = 1;
+
 /* Process a single stochastic event off the harvest queue */
 void
 random_process_event(struct harvest *event)
@@ -261,6 +263,11 @@ reseed(u_int fastslow)
 
        /* Release the reseed mutex */
        mtx_unlock(&random_reseed_mtx);
+
+       if (arc4rand_reseed) {
+               arc4rand_reseed = 0;
+               arc4rand(NULL, 0, 1);
+       }
 }
 
 /* Internal function to return processed entropy from the PRNG */

-- 
http://ache.vniz.net/
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"

Reply via email to