提交 b4f35e5e 编写于 作者: R Rich Salz 提交者: Rich Salz

Remove EIGHT_BIT and SIXTEEN_BIT

Also cleaned up bn_prime.pl to current coding style.
Reviewed-by: NAndy Polyakov <appro@openssl.org>
上级 3e9e810f
......@@ -1131,7 +1131,7 @@ $config{export_var_as_fn} =0;
my $def_int="unsigned int";
$config{rc4_int} =$def_int;
$config{rc2_int} =$def_int;
($config{b64l},$config{b64},$config{b32},$config{b16},$config{b8})=(0,0,1,0,0);
($config{b64l},$config{b64},$config{b32})=(0,0,1);
foreach (sort split(/\s+/,$target{bn_ops})) {
$config{bn_ll}=1 if /BN_LLONG/;
......@@ -1295,8 +1295,6 @@ print "\n";
print "SIXTY_FOUR_BIT_LONG mode\n" if $config{b64l};
print "SIXTY_FOUR_BIT mode\n" if $config{b64};
print "THIRTY_TWO_BIT mode\n" if $config{b32};
print "SIXTEEN_BIT mode\n" if $config{b16};
print "EIGHT_BIT mode\n" if $config{b8};
print "BN_LLONG mode\n" if $config{bn_ll};
print "RC4 uses $config{rc4_int}\n" if $config{rc4_int} != $def_int;
print "RC2 uses $config{rc2_int}\n" if $config{rc2_int} != $def_int;
......
......@@ -114,12 +114,6 @@
#include "bn_lcl.h"
#include <openssl/rand.h>
/*
* NB: these functions have been "upgraded", the deprecated versions (which
* are compatibility wrappers using these functions) are in bn_depr.c. -
* Geoff
*/
/*
* The quick sieve algorithm approach to weeding out primes is Philip
* Zimmermann's, as implemented in PGP. I have had a read of his comments
......@@ -127,6 +121,8 @@
*/
#include "bn_prime.h"
#define NUMPRIMES OSSL_NELEM(primes)
static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1,
const BIGNUM *a1_odd, int k, BN_CTX *ctx,
BN_MONT_CTX *mont);
......
......@@ -56,23 +56,15 @@
* [including the GNU Public Licence.]
*/
#ifndef EIGHT_BIT
# define NUMPRIMES 2048
typedef unsigned short prime_t;
#else
# define NUMPRIMES 54
typedef unsigned char prime_t;
#endif
static const prime_t primes[NUMPRIMES]= {
static const prime_t primes[] = {
2, 3, 5, 7, 11, 13, 17, 19,
23, 29, 31, 37, 41, 43, 47, 53,
59, 61, 67, 71, 73, 79, 83, 89,
97, 101, 103, 107, 109, 113, 127, 131,
137, 139, 149, 151, 157, 163, 167, 173,
179, 181, 191, 193, 197, 199, 211, 223,
227, 229, 233, 239, 241, 251,
#ifndef EIGHT_BIT
257, 263,
227, 229, 233, 239, 241, 251, 257, 263,
269, 271, 277, 281, 283, 293, 307, 311,
313, 317, 331, 337, 347, 349, 353, 359,
367, 373, 379, 383, 389, 397, 401, 409,
......@@ -322,5 +314,4 @@ static const prime_t primes[NUMPRIMES]= {
17609, 17623, 17627, 17657, 17659, 17669, 17681, 17683,
17707, 17713, 17729, 17737, 17747, 17749, 17761, 17783,
17789, 17791, 17807, 17827, 17837, 17839, 17851, 17863,
#endif
};
#!/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;
}
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);
}
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);
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#endif\n};\n";
}
print "\n};\n";
......@@ -592,8 +592,6 @@ $ WRITE H_FILE "#undef SIXTY_FOUR_BIT_LONG"
$ WRITE H_FILE "#undef SIXTY_FOUR_BIT"
$ WRITE H_FILE "#define SIXTY_FOUR_BIT"
$ WRITE H_FILE "#undef THIRTY_TWO_BIT"
$ WRITE H_FILE "#undef SIXTEEN_BIT"
$ WRITE H_FILE "#undef EIGHT_BIT"
$ WRITE H_FILE "#endif"
$
$ WRITE H_FILE "#undef OPENSSL_EXPORT_VAR_AS_FUNCTION"
......@@ -619,8 +617,6 @@ $ WRITE H_FILE "#undef SIXTY_FOUR_BIT_LONG"
$ WRITE H_FILE "#undef SIXTY_FOUR_BIT"
$ WRITE H_FILE "#undef THIRTY_TWO_BIT"
$ WRITE H_FILE "#define THIRTY_TWO_BIT"
$ WRITE H_FILE "#undef SIXTEEN_BIT"
$ WRITE H_FILE "#undef EIGHT_BIT"
$ WRITE H_FILE "#endif"
$!
$ WRITE H_FILE "#undef OPENSSL_EXPORT_VAR_AS_FUNCTION"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册