Add a debugging option to PKCS#5 v2.0 key generation function.
[openssl.git] / crypto / bn / bn_div.c
index c7bc04d0b4e100d3ec52ff15e0182753c8a9ccad..defcf90c8223d282b36306aa3737dc3b22ca7460 100644 (file)
  */
 
 #include <stdio.h>
+#include <openssl/bn.h>
 #include "cryptlib.h"
 #include "bn_lcl.h"
 
 /* The old slow way */
 #if 0
-int BN_div(dv, rem, m, d,ctx)
-BIGNUM *dv;
-BIGNUM *rem;
-BIGNUM *m;
-BIGNUM *d;
-BN_CTX *ctx;
+int BN_div(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx)
        {
        int i,nm,nd;
        BIGNUM *D;
@@ -122,12 +118,8 @@ BN_CTX *ctx;
 
 #else
 
-int BN_div(dv, rm, num, divisor,ctx)
-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;
@@ -224,10 +216,10 @@ BN_CTX *ctx;
                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--;
                        }
@@ -292,11 +284,7 @@ err:
 #endif
 
 /* rem != m */
-int BN_mod(rem, m, d,ctx)
-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;