Fix warnings in expspeed.c (but the segmentation fault remains)
authorBodo Möller <bodo@openssl.org>
Wed, 29 Nov 2000 13:40:08 +0000 (13:40 +0000)
committerBodo Möller <bodo@openssl.org>
Wed, 29 Nov 2000 13:40:08 +0000 (13:40 +0000)
Improve readability of bn_shift.c.

Add comment in bn_lib.c (why zero data between top and max?)

Change bntest.c output for BN_kronecker test

crypto/bn/bn_lib.c
crypto/bn/bn_shift.c
crypto/bn/bntest.c
crypto/bn/expspeed.c

index d7a54d5fb580e615a4eacc6c461be3232143f55b..a63c031216947fc94ee8caff98a06204878fd1ce 100644 (file)
@@ -357,6 +357,7 @@ static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
                }
 
        /* Now need to zero any data between b->top and b->max */
                }
 
        /* Now need to zero any data between b->top and b->max */
+       /* XXX Why? */
 
        A= &(a[b->top]);
        for (i=(words - b->top)>>3; i>0; i--,A+=8)
 
        A= &(a[b->top]);
        for (i=(words - b->top)>>3; i>0; i--,A+=8)
index e4da833ea67f33aa68b22a7dde588ca182034358..37c6988da3dfdb1d358855a1a1d3802e3d554837 100644 (file)
@@ -128,8 +128,8 @@ int BN_lshift(BIGNUM *r, const BIGNUM *a, int n)
        BN_ULONG l;
 
        r->neg=a->neg;
        BN_ULONG l;
 
        r->neg=a->neg;
-       if (bn_wexpand(r,a->top+(n/BN_BITS2)+1) == NULL) return(0);
        nw=n/BN_BITS2;
        nw=n/BN_BITS2;
+       if (bn_wexpand(r,a->top+nw+1) == NULL) return(0);
        lb=n%BN_BITS2;
        rb=BN_BITS2-lb;
        f=a->d;
        lb=n%BN_BITS2;
        rb=BN_BITS2-lb;
        f=a->d;
index 84412f31f31a7f60d09fd74a3f5592508ac8b3f2..86d384428c6db4abab6e813a88a0d69d9ab60ddc 100644 (file)
@@ -981,9 +981,12 @@ int test_kron(BIO *bp, BN_CTX *ctx)
                        goto err;
                        }
 
                        goto err;
                        }
 
-               fprintf(stderr, "ok\n");
+               putc('.', stderr);
+               fflush(stderr);
                }
 
                }
 
+       putc('\n', stderr);
+       fflush(stderr);
        ret = 1;
  err:
        if (a != NULL) BN_free(a);
        ret = 1;
  err:
        if (a != NULL) BN_free(a);
index 7706f49da028e9f11e648d1532a8c04c533c1ef8..dd849d50164d87b5f035c496b520b6be322b8101 100644 (file)
@@ -65,9 +65,9 @@
 
 
 /* determine timings for modexp, gcd, or modular inverse */
 
 
 /* determine timings for modexp, gcd, or modular inverse */
-#define TEST_EXP
+#undef TEST_EXP
 #undef TEST_GCD
 #undef TEST_GCD
-#undef TEST_KRON
+#define TEST_KRON
 #undef TEST_INV
 
 
 #undef TEST_INV
 
 
@@ -80,6 +80,7 @@
 #include <string.h>
 #include <openssl/crypto.h>
 #include <openssl/err.h>
 #include <string.h>
 #include <openssl/crypto.h>
 #include <openssl/err.h>
+#include <openssl/rand.h>
 
 #if !defined(MSDOS) && (!defined(VMS) || defined(__DECC))
 #define TIMES
 
 #if !defined(MSDOS) && (!defined(VMS) || defined(__DECC))
 #define TIMES
@@ -179,7 +180,7 @@ static int sizes[NUM_SIZES]={128,256,512,1024,2048,4096,8192};
 static int mul_c[NUM_SIZES]={8*8*8*8*8*8,8*8*8*8*8,8*8*8*8,8*8*8,8*8,8,1};
 /*static int sizes[NUM_SIZES]={59,179,299,419,539}; */
 
 static int mul_c[NUM_SIZES]={8*8*8*8*8*8,8*8*8*8*8,8*8*8*8,8*8*8,8*8,8,1};
 /*static int sizes[NUM_SIZES]={59,179,299,419,539}; */
 
-#define RAND_SEED(string) { const char str[] = string; RAND_seed(string, sizeof string); }
+#define RAND_SEED(string) { const char str[] = string; RAND_seed(string, sizeof str); }
 
 static void genprime_cb(int p, int n, void *arg)
        {
 
 static void genprime_cb(int p, int n, void *arg)
        {
@@ -213,6 +214,7 @@ int main(int argc, char **argv)
                RAND_SEED("I demand a manual recount!");
 
        do_mul_exp(r,a,b,c,ctx);
                RAND_SEED("I demand a manual recount!");
 
        do_mul_exp(r,a,b,c,ctx);
+       return 0;
        }
 
 void do_mul_exp(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *c, BN_CTX *ctx)
        }
 
 void do_mul_exp(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *c, BN_CTX *ctx)
@@ -275,7 +277,7 @@ void do_mul_exp(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *c, BN_CTX *ctx)
 #else /* TEST_INV */
                        "2*inv %4d %4d mod %4d"
 #endif
 #else /* TEST_INV */
                        "2*inv %4d %4d mod %4d"
 #endif
-                       " -> %8.3fms %5.1f (%d)\n",sizes[i],sizes[i],sizes[i],tm*1000.0/num,tm*mul_c[i]/num, num);
+                       " -> %8.3fms %5.1f (%ld)\n",sizes[i],sizes[i],sizes[i],tm*1000.0/num,tm*mul_c[i]/num, num);
                num/=7;
                if (num <= 0) num=1;
                }
                num/=7;
                if (num <= 0) num=1;
                }