test_mont was exercising 100-bit multiplication modulus X*I-bit, where
[openssl.git] / crypto / bn / bntest.c
index fd63bd6fd5ca4788b0c04c71c0466ddc9345c1da..d64d512e9a3cbd6acb78b73cf317362cc0f4ba02 100644 (file)
@@ -72,9 +72,9 @@
 #include "../bio/bss_file.c"
 #endif
 
-const num0 = 100; /* number of tests */
-const num1 = 50;  /* additional tests for some functions */
-const num2 = 5;   /* number of tests for slow functions */
+const int num0 = 100; /* number of tests */
+const int num1 = 50;  /* additional tests for some functions */
+const int num2 = 5;   /* number of tests for slow functions */
 
 int test_add(BIO *bp);
 int test_sub(BIO *bp);
@@ -104,10 +104,10 @@ static unsigned char lst[]="\xC6\x4F\x43\x04\x2A\xEA\xCA\x6E\x58\x36\x80\x5B\xE8
 
 static const char rnd_seed[] = "string to make the random number generator think it has entropy";
 
-void message(BIO *out, char *m)
+static void message(BIO *out, char *m)
        {
        fprintf(stderr, "test %s\n", m);
-#if 1
+#if defined(linux) || defined(FreeBSD) /* can we use GNU bc features? */
        BIO_puts(out, "print \"test ");
        BIO_puts(out, m);
        BIO_puts(out, "\\n\"\n");
@@ -615,7 +615,7 @@ int test_mont(BIO *bp, BN_CTX *ctx)
        BN_rand(&b,100,0,0); /**/
        for (i=0; i<num2; i++)
                {
-               int bits = (100%BN_BITS2+1)*BN_BITS2*i*BN_BITS2;
+               int bits = (200*(i+1))/num2;
 
                if (bits == 0)
                        continue;
@@ -733,7 +733,8 @@ int test_mod_mul(BIO *bp, BN_CTX *ctx)
        BN_rand(c,1024,0,0); /**/
        for (i=0; i<num0; i++)
                {
-               BN_rand(b,425+i*10,0,0); /**/
+               BN_rand(a,475+i*10,0,0); /**/
+               BN_rand(b,425+i*11,0,0); /**/
                a->neg=rand_neg();
                b->neg=rand_neg();
        /*      if (bp == NULL)