[NCLUG] My attempts using /dev/random...
Jeremy Hinegardner
jeremy at hinegardner.org
Sun Apr 13 17:44:07 MDT 2008
On Sun, Apr 13, 2008 at 03:15:59PM -0600, Sean Reifschneider wrote:
> I went ahead and generated a bunch of randomness from /dev/random on
> several different hosts. My laptop, over the last 4 days or so, didn't
> even get enough randomness for 100,000 rolls of 2 dies (using the mechanism
> suggested by Stephen's research). The other systems I tried were able to
> get enough randomness for 4 iterations of 100,000 rolls.
>
> See the README for more details, but I ran this against an OpenSolaris
> (backup1) system, 2 Linux systems with plenty of activity on them (routera
> and mirrors), /dev/urandom on my laptop, and then also a pass running the
> Python random number generator.
>
> The results are:
>
> ======================== randomness-backup1 ========================
> chi squared: 13.56146 iters: 100000
> chi squared: 10.712816 iters: 100000
> chi squared: 9.986612 iters: 100000
> chi squared: 15.16541 iters: 100000
>
> ======================== randomness-mirrors ========================
> chi squared: 9.383732 iters: 100000
> chi squared: 5.289914 iters: 100000
> chi squared: 7.222466 iters: 100000
> chi squared: 10.234694 iters: 100000
>
> ======================== randomness-routera ========================
> chi squared: 6.807866 iters: 100000
> chi squared: 10.522898 iters: 100000
> chi squared: 9.53456 iters: 100000
> chi squared: 3.227186 iters: 100000
>
> ======================== urandomness-guin ========================
> chi squared: 8.0114 iters: 100000
> chi squared: 7.466174 iters: 100000
> chi squared: 9.163472 iters: 100000
> chi squared: 7.094624 iters: 100000
>
> ======================== pyrandomness-guin ========================
> chi squared: 12.198728 iters: 100000
> chi squared: 16.710518 iters: 100000
> chi squared: 14.67455 iters: 100000
> chi squared: 14.655584 iters: 100000
>
> My findings:
>
> 1,008 and 10,000 iterations were really showing huge discrepancies
> between iterations. Which isn't surprising for random data sets.
> Things seemed to settle down at 100,000, but there are still fairly
> large swings (3-10 in one set).
>
> The Python random number generator isn't great. I'll probably continue
> to use it though, as I don't think I have anything that really cares
> about things being THAT random.
>
> Linux /dev/random seems to be pretty good, if we say that random.org is
> scoring a chi^2 of 7-ish.
>
> OpenSolaris' /dev/random is not as good as Linux's, /dev/random *OR*
> /dev/urandom.
>
> Linux's /dev/urandom is probably good enough. I'd definitely use it for
> populating randomness on a hard drive before putting a crypto
> file-system on it, for example.
>
I ran the code against /dev/arandom on my OpenBSD 4.2 machine with these
results:
% dd if=/dev/arandom of=randomness-obsd-arandom.out bs=1 count=2000000
% ./dorolls randomness-obsd-arandom.out 4 1000
chi squared: 9.2672 iters: 1000
chi squared: 12.26 iters: 1000
chi squared: 17.0228 iters: 1000
chi squared: 7.7282 iters: 1000
% ./dorolls randomness-obsd-arandom.out 4 10000
chi squared: 12.48554 iters: 10000
chi squared: 18.97622 iters: 10000
chi squared: 6.26474 iters: 10000
chi squared: 7.95584 iters: 10000
% ./dorolls randomness-obsd-arandom.out 4 100000
chi squared: 9.010736 iters: 100000
chi squared: 8.099072 iters: 100000
chi squared: 4.86659 iters: 100000
chi squared: 6.07481 iters: 100000
/dev/arandom on OpenBSD is what is returned for the arc4rand() system call.
/dev/srandom (Strong Random) hasn't returned enough entropy to run anything yet.
enjoy,
-jeremy
--
========================================================================
Jeremy Hinegardner jeremy at hinegardner.org
More information about the NCLUG
mailing list