From: Bodo Möller Date: Wed, 29 Nov 2000 09:57:13 +0000 (+0000) Subject: Make BN_mod_inverse a little faster X-Git-Tag: OpenSSL_0_9_6a-beta1~107^2~124 X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff_plain;h=b6cafbd7d840f4e315c3a066ab742c893bc4d41a Make BN_mod_inverse a little faster --- diff --git a/crypto/bn/bn_gcd.c b/crypto/bn/bn_gcd.c index d53f32656b..d361ada8b2 100644 --- a/crypto/bn/bn_gcd.c +++ b/crypto/bn/bn_gcd.c @@ -338,15 +338,15 @@ BIGNUM *BN_mod_inverse(BIGNUM *in, { if (!BN_lshift1(tmp,X)) goto err; } - else if (BN_is_word(D,3)) - { - if (!BN_lshift1(tmp,X)) goto err; - if (!BN_add(tmp,tmp,X)) goto err; - } else if (BN_is_word(D,4)) { if (!BN_lshift(tmp,X,2)) goto err; } + else if (D->top == 1) + { + if (!BN_copy(tmp,X)) goto err; + if (!BN_mul_word(tmp,D->d[0])) goto err; + } else { if (!BN_mul(tmp,D,X,ctx)) goto err;