Remove EIGHT_BIT and SIXTEEN_BIT
authorRich Salz <rsalz@akamai.com>
Sat, 23 Jan 2016 18:23:25 +0000 (13:23 -0500)
committerRich Salz <rsalz@openssl.org>
Thu, 28 Jan 2016 00:10:13 +0000 (19:10 -0500)
Also cleaned up bn_prime.pl to current coding style.

Reviewed-by: Andy Polyakov <appro@openssl.org>
Configure
crypto/bn/bn_prime.c
crypto/bn/bn_prime.h
crypto/bn/bn_prime.pl
makevms.com

index 3d2e3cd90871aaa5deda8d658c7598c19593ef47..f34444cab15008328e5ce6b1056a3a59d9f73ea6 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -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;
 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/;
 
 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 "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;
 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;
index 7d210d37cf175025e613b1a8c6ca22330f233568..8d1294fcfcc0a44468555e226f405e0ac3acdda0 100644 (file)
 #include "bn_lcl.h"
 #include <openssl/rand.h>
 
 #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
 /*
  * 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
  */
 #include "bn_prime.h"
 
  */
 #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);
 static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1,
                    const BIGNUM *a1_odd, int k, BN_CTX *ctx,
                    BN_MONT_CTX *mont);
index c2824a8b48229472680cca5748286b20d5f6c9db..d1fbcd1021b98ea6c774d40c1ec4e85e1849650e 100644 (file)
  * [including the GNU Public Licence.]
  */
 
  * [including the GNU Public Licence.]
  */
 
-#ifndef EIGHT_BIT
-# define NUMPRIMES 2048
 typedef unsigned short prime_t;
 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, 
        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, 
      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, 
     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
 };
 };
index 4e4426a1f4826f5fb27edddea64a5cbeafe821d1..add6ffb9d0d724eec2e3fe60bd90e31b02303713 100644 (file)
@@ -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 */
 
 print <<\EOF;
 /* Auto generated by bn_prime.pl */
@@ -79,28 +61,25 @@ print <<\EOF;
 
 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";
index 02e0cf2eba1c021cb354c4678c70c453cc2e9bf0..bfaf261b4e113e276211d955eb61968263d5ddf8 100755 (executable)
@@ -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 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"
 $   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 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"
 $   WRITE H_FILE "#endif"
 $!
 $   WRITE H_FILE "#undef OPENSSL_EXPORT_VAR_AS_FUNCTION"