Add a debugging option to PKCS#5 v2.0 key generation function.
[openssl.git] / crypto / bn / bn_div.c
index bffa9f3e6119c22acbef811d388d501c45036946..defcf90c8223d282b36306aa3737dc3b22ca7460 100644 (file)
@@ -57,6 +57,7 @@
  */
 
 #include <stdio.h>
+#include <openssl/bn.h>
 #include "cryptlib.h"
 #include "bn_lcl.h"
 
@@ -117,8 +118,8 @@ int BN_div(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx)
 
 #else
 
-int BN_div(BIGNUM *dv, BIGNUM *rm, BIGNUM *num, BIGNUM *divisor,
-            BN_CTX *ctx)
+int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
+          BN_CTX *ctx)
        {
        int norm_shift,i,j,loop;
        BIGNUM *tmp,wnum,*snum,*sdiv,*res;
@@ -215,10 +216,10 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, BIGNUM *num, BIGNUM *divisor,
                t1=((BN_ULLONG)n0<<BN_BITS2)|n1;
                for (;;)
                        {
-                       t2=(BN_ULLONG)d1*q;
                        rem=t1-(BN_ULLONG)q*d0;
-                       if ((rem>>BN_BITS2) ||
-                               (t2 <= ((BN_ULLONG)(rem<<BN_BITS2)+wnump[-2])))
+                       t2=(BN_ULLONG)d1*q;
+                        if ((rem>>BN_BITS2) ||
+                               (t2 <= ((rem<<BN_BITS2)|wnump[-2])))
                                break;
                        q--;
                        }
@@ -283,7 +284,7 @@ err:
 #endif
 
 /* rem != m */
-int BN_mod(BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx)
+int BN_mod(BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx)
        {
 #if 0 /* The old slow way */
        int i,nm,nd;