Date: Sat, 26 Nov 2011 09:51:07 +0400 From: Andrey Chernov <ache@freebsd.org> To: das@freebsd.org, current@freebsd.org, secteam@freebsd.org Subject: Fix for pure initial seeding of libkern/arc4random.c Message-ID: <20111126055107.GA15148@vniz.net>
next in thread | raw e-mail | index | archive | help
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/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111126055107.GA15148>
