summaryrefslogtreecommitdiffstats
path: root/crypto/bn/bn_sqrt.c
diff options
context:
space:
mode:
authorBodo Möller <bodo@openssl.org>2000-11-30 09:45:26 +0000
committerBodo Möller <bodo@openssl.org>2000-11-30 09:45:26 +0000
commit25439b76adb66fe0ce6e012a9af1e1ce969a1479 (patch)
treeb7e18886eaeb9d96b00b6037fe61ad21e1a9f692 /crypto/bn/bn_sqrt.c
parent3465dd3853f000e042dc3fd26f4ce03cd92374ad (diff)
Move reduction step from BN_mod_exp to BN_mod_exp_mont_word.
Fix BN_mod_exp_simple for a==0 (mod m). Skip useless round in BN_mod_sqrt (1 is always a square, no need to test BN_kronecker for it).
Diffstat (limited to 'crypto/bn/bn_sqrt.c')
-rw-r--r--crypto/bn/bn_sqrt.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/crypto/bn/bn_sqrt.c b/crypto/bn/bn_sqrt.c
index 5176772e4e..2a72c189cb 100644
--- a/crypto/bn/bn_sqrt.c
+++ b/crypto/bn/bn_sqrt.c
@@ -140,13 +140,13 @@ BIGNUM *BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
/* e > 1, so we really have to use the Tonelli/Shanks algorithm.
* First, find some y that is not a square. */
- i = 1;
+ i = 2;
do
{
/* For efficiency, try small numbers first;
* if this fails, try random numbers.
*/
- if (i < 20)
+ if (i < 22)
{
if (!BN_set_word(y, i)) goto end;
}
@@ -171,7 +171,7 @@ BIGNUM *BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
goto end;
}
}
- while (r == 1 && i++ < 80);
+ while (r == 1 && ++i < 82);
if (r != -1)
{