Fix for pure initial seeding of libkern/arc4random.c
Andrey Chernov
ache at freebsd.org
Sat Nov 26 05:51:10 UTC 2011
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/
More information about the freebsd-current
mailing list