diff options
author | Rich Salz <rsalz@akamai.com> | 2016-01-23 13:23:25 -0500 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2016-01-27 19:10:13 -0500 |
commit | b4f35e5e07afa2df7125b814b45242648b33e39e (patch) | |
tree | b34236be3ec44cd00d7ae3b2e27f9f254e91a011 /crypto/bn/bn_prime.pl | |
parent | 3e9e810f2e047effb1056211794d2d12ec2b04e7 (diff) |
Remove EIGHT_BIT and SIXTEEN_BIT
Also cleaned up bn_prime.pl to current coding style.
Reviewed-by: Andy Polyakov <appro@openssl.org>
Diffstat (limited to 'crypto/bn/bn_prime.pl')
-rw-r--r-- | crypto/bn/bn_prime.pl | 65 |
1 files changed, 22 insertions, 43 deletions
diff --git a/crypto/bn/bn_prime.pl b/crypto/bn/bn_prime.pl index 4e4426a1f4..add6ffb9d0 100644 --- a/crypto/bn/bn_prime.pl +++ b/crypto/bn/bn_prime.pl @@ -1,22 +1,4 @@ -#!/usr/local/bin/perl -# bn_prime.pl - -$num=2048; -$num=$ARGV[0] if ($#ARGV >= 0); - -push(@primes,2); -$p=1; -loop: while ($#primes < $num-1) - { - $p+=2; - $s=int(sqrt($p)); - - for ($i=0; defined($primes[$i]) && $primes[$i]<=$s; $i++) - { - next loop if (($p%$primes[$i]) == 0); - } - push(@primes,$p); - } +#! /usr/bin/env perl print <<\EOF; /* Auto generated by bn_prime.pl */ @@ -79,28 +61,25 @@ print <<\EOF; EOF -for ($i=0; $i <= $#primes; $i++) - { - if ($primes[$i] > 256) - { - $eight=$i; - last; - } - } -printf "#ifndef EIGHT_BIT\n"; -printf "# define NUMPRIMES %d\n",$num; -printf "typedef unsigned short prime_t;\n"; -printf "#else\n"; -printf "# define NUMPRIMES %d\n",$eight; -printf "typedef unsigned char prime_t;\n"; -printf "#endif\n"; -print "static const prime_t primes[NUMPRIMES]= {\n "; -$init=0; -for ($i=0; $i <= $#primes; $i++) - { - printf "\n#ifndef EIGHT_BIT\n " if ($primes[$i] > 256) && !($init++); - printf "\n " if (($i%8) == 0) && ($i != 0); - printf "%4d, ", $primes[$i]; - } -print "\n#endif\n};\n"; +my $num = shift || 2048; +my @primes = ( 2 ); +my $p = 1; +loop: while ($#primes < $num-1) { + $p += 2; + my $s = int(sqrt($p)); + + for (my $i = 0; defined($primes[$i]) && $primes[$i] <= $s; $i++) { + next loop if ($p % $primes[$i]) == 0; + } + push(@primes, $p); +} + +print "typedef unsigned short prime_t;\n"; + +print "static const prime_t primes[] = {"; +for (my $i = 0; $i <= $#primes; $i++) { + printf "\n " if ($i % 8) == 0; + printf "%4d, ", $primes[$i]; +} +print "\n};\n"; |