Move reduction step from BN_mod_exp to BN_mod_exp_mont_word.
[openssl.git] / crypto / bn / bn_sqrt.c
index 5176772e4e415408c2c4a389f15b39aefe4139a2..2a72c189cbad97b99694f99635dd1b175212b4de 100644 (file)
@@ -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)
                {