summaryrefslogtreecommitdiff
path: root/perllib/gensv.pl
blob: b80ccbe6c1945f5935ad9b946e64976bbd0027c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/perl
#
# Generate a list of rotation vectors so we always use the same set.
# This needs to be run on a platform with /dev/urandom.
#

($n) = @ARGV;

sysopen(UR, '/dev/urandom', O_RDONLY) or die;

$maxlen = 78;

print "\@random_sv_vectors = (\n";
$outl = '   ';

for ($i = 0; $i < $n; $i++) {

    die if (sysread(UR, $x8, 8) != 8);
    @n = unpack("V*", $x8);

    $xl = sprintf(" [0x%08x, 0x%08x]%s",
		  $n[0], $n[1],
		  ($i == $n-1) ? '' : ',');
    if (length($outl.$xl) > $maxlen) {
	print $outl, "\n";
	$outl = '   ';
    }
    $outl .= $xl;
}
close(UR);

print $outl, "\n";
print ");\n";
print "1;\n";