summaryrefslogtreecommitdiffstats
path: root/crypto/bn/bn_gcd.c
diff options
context:
space:
mode:
authorBodo Möller <bodo@openssl.org>2000-11-29 09:57:13 +0000
committerBodo Möller <bodo@openssl.org>2000-11-29 09:57:13 +0000
commitb6cafbd7d840f4e315c3a066ab742c893bc4d41a (patch)
tree7b14498f59c67a5c652949f84490c89c94219db8 /crypto/bn/bn_gcd.c
parent499e167fda19e01d384fb093f18447b5051d5da9 (diff)
Make BN_mod_inverse a little faster
Diffstat (limited to 'crypto/bn/bn_gcd.c')
-rw-r--r--crypto/bn/bn_gcd.c10
1 files changed, 5 insertions, 5 deletions
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;