diff options
author | Andy Polyakov <appro@openssl.org> | 2007-09-18 20:55:10 +0000 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2007-09-18 20:55:10 +0000 |
commit | ab011d51be7c468899b486c235fc6db17d51a959 (patch) | |
tree | 71524c662c88ac46d6a465dadd9bb1d0575002e7 /crypto/bn | |
parent | 898d9b1a87aa65cab480253bcf73b56436e54501 (diff) |
Minimize stack utilization in probable_prime [from HEAD].
Diffstat (limited to 'crypto/bn')
-rw-r--r-- | crypto/bn/bn_prime.c | 4 | ||||
-rw-r--r-- | crypto/bn/bn_prime.h | 4 | ||||
-rw-r--r-- | crypto/bn/bn_prime.pl | 4 |
3 files changed, 8 insertions, 4 deletions
diff --git a/crypto/bn/bn_prime.c b/crypto/bn/bn_prime.c index 5bab019553..7b25979dd1 100644 --- a/crypto/bn/bn_prime.c +++ b/crypto/bn/bn_prime.c @@ -377,14 +377,14 @@ static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1, static int probable_prime(BIGNUM *rnd, int bits) { int i; - BN_ULONG mods[NUMPRIMES]; + prime_t mods[NUMPRIMES]; BN_ULONG delta,maxdelta; again: if (!BN_rand(rnd,bits,1,1)) return(0); /* we now have a random number 'rand' to test. */ for (i=1; i<NUMPRIMES; i++) - mods[i]=BN_mod_word(rnd,(BN_ULONG)primes[i]); + mods[i]=(prime_t)BN_mod_word(rnd,(BN_ULONG)primes[i]); maxdelta=BN_MASK2 - primes[NUMPRIMES-1]; delta=0; loop: for (i=1; i<NUMPRIMES; i++) diff --git a/crypto/bn/bn_prime.h b/crypto/bn/bn_prime.h index b7cf9a9bfe..51d2194feb 100644 --- a/crypto/bn/bn_prime.h +++ b/crypto/bn/bn_prime.h @@ -58,10 +58,12 @@ #ifndef EIGHT_BIT #define NUMPRIMES 2048 +typedef unsigned short prime_t; #else #define NUMPRIMES 54 +typedef unsigned char prime_t; #endif -static const unsigned int primes[NUMPRIMES]= +static const prime_t primes[NUMPRIMES]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, diff --git a/crypto/bn/bn_prime.pl b/crypto/bn/bn_prime.pl index e583d1d53b..3fafb6f3e9 100644 --- a/crypto/bn/bn_prime.pl +++ b/crypto/bn/bn_prime.pl @@ -101,10 +101,12 @@ for ($i=0; $i <= $#primes; $i++) 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 unsigned int primes[NUMPRIMES]=\n\t{\n\t"; +print "static const prime_t primes[NUMPRIMES]=\n\t{\n\t"; $init=0; for ($i=0; $i <= $#primes; $i++) { |