From: Bodo Möller Date: Fri, 1 Dec 2000 09:41:21 +0000 (+0000) Subject: functionality for BN_mod_sqrt timings X-Git-Tag: OpenSSL_0_9_6a-beta1~107^2~73 X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff_plain;h=5a12df5c40da45603adf50481685e497fddd8a09 functionality for BN_mod_sqrt timings --- diff --git a/crypto/bn/expspeed.c b/crypto/bn/expspeed.c index dd849d5016..c55347e297 100644 --- a/crypto/bn/expspeed.c +++ b/crypto/bn/expspeed.c @@ -60,15 +60,27 @@ /* most of this code has been pilfered from my libdes speed.c program */ -#define BASENUM 10000 +#define BASENUM 5000 #define NUM_START 0 /* determine timings for modexp, gcd, or modular inverse */ -#undef TEST_EXP +#define TEST_EXP #undef TEST_GCD -#define TEST_KRON +#undef TEST_KRON #undef TEST_INV +#undef TEST_SQRT +#define P_MOD_64 9 /* least significant 6 bits for prime to be used for BN_sqrt timings */ + +#if defined(TEST_EXP) + defined(TEST_GCD) + defined(TEST_KRON) + defined(TEST_INV) +defined(TEST_SQRT) != 1 +# error "choose one test" +#endif + +#if defined(TEST_INV) || defined(TEST_SQRT) +# define C_PRIME +static void genprime_cb(int p, int n, void *arg); +#endif + #undef PROG @@ -182,20 +194,6 @@ 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}; #define RAND_SEED(string) { const char str[] = string; RAND_seed(string, sizeof str); } -static void genprime_cb(int p, int n, void *arg) - { - char c='*'; - - if (p == 0) c='.'; - if (p == 1) c='+'; - if (p == 2) c='*'; - if (p == 3) c='\n'; - putc(c, stderr); - fflush(stderr); - (void)n; - (void)arg; - } - void do_mul_exp(BIGNUM *r,BIGNUM *a,BIGNUM *b,BIGNUM *c,BN_CTX *ctx); int main(int argc, char **argv) @@ -203,6 +201,11 @@ int main(int argc, char **argv) BN_CTX *ctx; BIGNUM *a,*b,*c,*r; +#if 1 + if (!CRYPTO_set_mem_debug_functions(0,0,0,0,0)) + abort(); +#endif + ctx=BN_CTX_new(); a=BN_new(); b=BN_new(); @@ -223,34 +226,48 @@ void do_mul_exp(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *c, BN_CTX *ctx) double tm; long num; -#if defined(TEST_EXP) + defined(TEST_GCD) + defined(TEST_KRON) + defined(TEST_INV) != 1 -# error "choose one test" -#endif - -#ifdef TEST_INV -# define C_PRIME -#endif - num=BASENUM; for (i=NUM_START; i %8.3fms %5.1f (%ld)\n", +#ifdef TEST_SQRT + P_MOD_64, #endif - " -> %8.3fms %5.1f (%ld)\n",sizes[i],sizes[i],sizes[i],tm*1000.0/num,tm*mul_c[i]/num, num); + sizes[i],sizes[i],sizes[i],tm*1000.0/num,tm*mul_c[i]/num, num); num/=7; if (num <= 0) num=1; } @@ -287,3 +313,19 @@ void do_mul_exp(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *c, BN_CTX *ctx) ERR_print_errors_fp(stderr); } + +#ifdef C_PRIME +static void genprime_cb(int p, int n, void *arg) + { + char c='*'; + + if (p == 0) c='.'; + if (p == 1) c='+'; + if (p == 2) c='*'; + if (p == 3) c='\n'; + putc(c, stderr); + fflush(stderr); + (void)n; + (void)arg; + } +#endif