gensv.pl 622 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/perl
  2. #
  3. # Generate a list of rotation vectors so we always use the same set.
  4. # This needs to be run on a platform with /dev/urandom.
  5. #
  6. ($n) = @ARGV;
  7. sysopen(UR, '/dev/urandom', O_RDONLY) or die;
  8. $maxlen = 78;
  9. print "\@random_sv_vectors = (\n";
  10. $outl = ' ';
  11. for ($i = 0; $i < $n; $i++) {
  12. die if (sysread(UR, $x8, 8) != 8);
  13. @n = unpack("V*", $x8);
  14. $xl = sprintf(" [0x%08x, 0x%08x]%s",
  15. $n[0], $n[1],
  16. ($i == $n-1) ? '' : ',');
  17. if (length($outl.$xl) > $maxlen) {
  18. print $outl, "\n";
  19. $outl = ' ';
  20. }
  21. $outl .= $xl;
  22. }
  23. close(UR);
  24. print $outl, "\n";
  25. print ");\n";
  26. print "1;\n";