Adjust BN_mod_inverse algorithm selection according to experiments on
[openssl.git] / crypto / bn / bn_gcd.c
index 7496dbc3bd83b753dd12f4e52854c5bf6c27668b..7649f63fd22ab2562d7cfe384fc39b5e379eeb2b 100644 (file)
@@ -244,11 +244,12 @@ BIGNUM *BN_mod_inverse(BIGNUM *in,
         *      sign*Y*a  ==  A   (mod |n|).
         */
 
-       if (BN_is_odd(n) && (BN_num_bits(n) <= 400))
+       if (BN_is_odd(n) && (BN_num_bits(n) <= (BN_BITS <= 32 ? 450 : 2048)))
                {
                /* Binary inversion algorithm; requires odd modulus.
                 * This is faster than the general algorithm if the modulus
-                * is sufficiently small. */
+                * is sufficiently small (about 400 .. 500 bits on 32-bit
+                * sytems, but much more on 64-bit systems) */
                int shift;
                
                while (!BN_is_zero(B))