match the prototype
[openssl.git] / crypto / bn / bn_div.c
index 830da87f58e047f7156a0b2aacd2195bb3495480..d8c31e1db00ce1d3daa7145ac031eb1f2ddc15c2 100644 (file)
@@ -63,7 +63,8 @@
 
 /* The old slow way */
 #if 0
-int BN_div(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx)
+int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d,
+          BN_CTX *ctx)
        {
        int i,nm,nd;
        BIGNUM *D;
@@ -226,7 +227,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
                : "cc");                        \
            q;                                  \
        })
-#  define REMINDER_IS_ALREADY_CALCULATED
+#  define REMAINDER_IS_ALREADY_CALCULATED
 #  endif /* __<cpu> */
 # endif /* __GNUC__ */
 #endif /* NO_ASM */
@@ -235,8 +236,13 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
                n0=wnump[0];
                n1=wnump[-1];
                if (n0 == d0)
+                       {
                        q=BN_MASK2;
-               else
+#ifdef REMAINDER_IS_ALREADY_CALCULATED /* in this case it isn't */
+                       rem=(n1-q*d0)&BN_MASK2;
+#endif
+                       }
+               else /* n0 < d0 */
 #if defined(BN_LLONG) && defined(BN_DIV2W) && !defined(bn_div_words)
                        q=(BN_ULONG)(((((BN_ULLONG)n0)<<BN_BITS2)|n1)/d0);
 #else
@@ -246,7 +252,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
 #ifdef BN_LLONG
                BN_ULLONG t2;
 
-#ifndef REMINDER_IS_ALREADY_CALCULATED
+#ifndef REMAINDER_IS_ALREADY_CALCULATED
                /*
                 * rem doesn't have to be BN_ULLONG. The least we
                 * know it's less that d0, isn't it?
@@ -267,7 +273,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
 #else
                BN_ULONG t2l,t2h,ql,qh;
 
-#ifndef REMINDER_IS_ALREADY_CALCULATED
+#ifndef REMAINDER_IS_ALREADY_CALCULATED
                /*
                 * It's more than enough with the only multiplication.
                 * See the comment above in BN_LLONG section...