summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/bn_prime.pl
diff options
context:
space:
mode:
authormiod <>2014-04-24 21:31:02 +0000
committermiod <>2014-04-24 21:31:02 +0000
commit7e3ee009cb00e65ea487ba61ae3b5271c73c19d6 (patch)
treee53472b5e8d9eec9f62ca322e053d1c8f66dc1cc /src/lib/libcrypto/bn/bn_prime.pl
parent04cb67d517205b357d70ac65a314fea6e6a1a479 (diff)
downloadopenbsd-7e3ee009cb00e65ea487ba61ae3b5271c73c19d6.tar.gz
openbsd-7e3ee009cb00e65ea487ba61ae3b5271c73c19d6.tar.bz2
openbsd-7e3ee009cb00e65ea487ba61ae3b5271c73c19d6.zip
Try to clean the maze of <openssl/bn.h> defines regarding the BN internals.
The intent of this change is to only keep support for two kind of architectures: - those with 32-bit int and long, and 64-bit long long, where ``long * long -> long long'' multiplication routines are available. - those with 64-bit int and long, and no 128-bit long long type. This gets rid of the SIXTY_FOUR_BIT_LONG, SIXTY_FOUR_BIT (not the same!), THIRTY_TWO_BIT, SIXTEEN_BIT and EIGHT_BIT defines. After this change, the types and defines are as follows: arch: 64bit 32bit rationale BN_LLONG undefined defined defined if l * l -> ll BN_ULLONG undefined u long long result of BN_LONG * BN_LONG BN_ULONG u long u int native register size BN_LONG long int the same, signed BN_BITS 128 64 size of 2*BN_ULONG in bits BN_BYTES 8 4 size of 2*BN_ULONG in bytes BN_BITS2 64 32 BN_BITS / 2 Tested on various 32-bit and 64-bit OpenBSD systems of various endianness.
Diffstat (limited to 'src/lib/libcrypto/bn/bn_prime.pl')
-rw-r--r--src/lib/libcrypto/bn/bn_prime.pl20
1 files changed, 2 insertions, 18 deletions
diff --git a/src/lib/libcrypto/bn/bn_prime.pl b/src/lib/libcrypto/bn/bn_prime.pl
index 3fafb6f3e9..eb73f0bfa6 100644
--- a/src/lib/libcrypto/bn/bn_prime.pl
+++ b/src/lib/libcrypto/bn/bn_prime.pl
@@ -90,30 +90,14 @@ print <<\EOF;
90 90
91EOF 91EOF
92 92
93for ($i=0; $i <= $#primes; $i++)
94 {
95 if ($primes[$i] > 256)
96 {
97 $eight=$i;
98 last;
99 }
100 }
101
102printf "#ifndef EIGHT_BIT\n";
103printf "#define NUMPRIMES %d\n",$num; 93printf "#define NUMPRIMES %d\n",$num;
104printf "typedef unsigned short prime_t;\n"; 94printf "typedef unsigned short prime_t;\n";
105printf "#else\n"; 95print "static const prime_t primes[NUMPRIMES]=\n{\n\t";
106printf "#define NUMPRIMES %d\n",$eight;
107printf "typedef unsigned char prime_t;\n";
108printf "#endif\n";
109print "static const prime_t primes[NUMPRIMES]=\n\t{\n\t";
110$init=0;
111for ($i=0; $i <= $#primes; $i++) 96for ($i=0; $i <= $#primes; $i++)
112 { 97 {
113 printf "\n#ifndef EIGHT_BIT\n\t" if ($primes[$i] > 256) && !($init++);
114 printf("\n\t") if (($i%8) == 0) && ($i != 0); 98 printf("\n\t") if (($i%8) == 0) && ($i != 0);
115 printf("%4d,",$primes[$i]); 99 printf("%4d,",$primes[$i]);
116 } 100 }
117print "\n#endif\n\t};\n"; 101print "\n};\n";
118 102
119 103