Make BN_mod_inverse a little faster
authorBodo Möller <bodo@openssl.org>
Wed, 29 Nov 2000 09:57:13 +0000 (09:57 +0000)
committerBodo Möller <bodo@openssl.org>
Wed, 29 Nov 2000 09:57:13 +0000 (09:57 +0000)
crypto/bn/bn_gcd.c

index d53f326..d361ada 100644 (file)
@@ -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;