From 25439b76adb66fe0ce6e012a9af1e1ce969a1479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bodo=20M=C3=B6ller?= Date: Thu, 30 Nov 2000 09:45:26 +0000 Subject: 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). --- crypto/bn/bn_sqrt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'crypto/bn/bn_sqrt.c') 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) { -- cgit v1.2.3