blib/lib/Digest/mkrandomtable.pl untested

filter: Statementstmt 0.0% 0 / 10 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 0.0% 0 / 14 SCAR -
1 #! /usr/bin/perl -w
2 #
3 #
4 # wget http://www.random.org/files/2007/2007-10-03.bin
5 # mkrandomtable.pl > random56x256.h
6 # This table must never change.
7 #
8 # From the FAQ:
9 # It's not just the software you'd need, but also three radios (or one, at any
10 # rate), which must be carefully adjusted to pick up atmospheric noise at the
11 # right volume. It's not completely trivial to set up.
12 # RANDOM.ORG uses radio receivers to pick up atmospheric noise, which is then
13 # used to generate random numbers. The radios are tuned between stations. A
14 # possible attack on the generator is therefore to broadcast on the frequencies
15 # that the RANDOM.ORG radios use in order to affect the generator. However,
16 # radio frequency attacks of this type would be difficult for a variety of
17 # reasons. First, the frequencies that the radios use are not published, so an
18 # attacker would have to broadcast across the entire FM band. Second, this is
19 # not an attack that can be launched from anywhere in the world, only
20 # reasonably close to the generator, meaning an attacker would have to be in
21 # Dublin. Third, if an attacker actually did succeed at broadcasting a very
22 # regular signal (e.g., a perfect sine wave) at the right frequency, then the
23 # RANDOM.ORG real-time statistics would pick up the drop in quality very
24 # rapidly.
25 # The RANDOM.ORG setup uses an array of radios that pick up atmospheric noise.
26 # Each radio generates approximately 3,000 bits per second. The random bits
27 # produced by the radios are used as the raw material for all the different
28 # generators you see on RANDOM.ORG
29 # The generator doesn't produce a constant stream of numbers (...) but works in
30 # a kind of start-and-stop mode, depending on whether the numbers are needed or
31 # not. For this reason, there are periods of time (at least on most days) where
32 # the generator is not producing numbers.
33 #
34 # See also
35 # http://www.random.org/analysis/dilbert.jpg
36 # http://imgs.xkcd.com/comics/random_number.png
37  
38 open IN, "<2007-10-03.bin";
39  
40 for my $i (0..255)
41 {
42 my $col = $i % 4;
43  
44 print "0x";
45 for (0..6)
46 {
47 printf "%02x", ord getc(IN);
48 }
49  
50 # Add suffix LL to assure the compiler grocks 64bit per int.
51 # If you still get many warnings:
52 # "integer constant is too large for ‘long’ type'" then your
53 # compiler cannot do 64bit at all. Try a recent GCC.
54 print "LL";
55 print "," unless $i == 255;
56 print $col==3 ? "\n" : ' ';
57 }
58 close IN;