summaryrefslogtreecommitdiffstats
path: root/crypto/bn/expspeed.c
diff options
context:
space:
mode:
authorBodo Möller <bodo@openssl.org>2000-11-29 12:32:10 +0000
committerBodo Möller <bodo@openssl.org>2000-11-29 12:32:10 +0000
commita08bcccc674def5ced0f921a7d0612de503b98e0 (patch)
treed7970b8392a034e81380855595fef54e419bb25f /crypto/bn/expspeed.c
parentbdec3c5323c7a726814257ec9b43fcd259f4e206 (diff)
Expand expspeed.c to make BN_kronecker timings.
This caused a segmentation fault in calls to malloc, so I cleaned up bn_lib.c a little so that it is easier to see what is going on. The bug turned out to be an off-by-one error in BN_bin2bn.
Diffstat (limited to 'crypto/bn/expspeed.c')
-rw-r--r--crypto/bn/expspeed.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/crypto/bn/expspeed.c b/crypto/bn/expspeed.c
index 5f76aa4126..7706f49da0 100644
--- a/crypto/bn/expspeed.c
+++ b/crypto/bn/expspeed.c
@@ -67,6 +67,7 @@
/* determine timings for modexp, gcd, or modular inverse */
#define TEST_EXP
#undef TEST_GCD
+#undef TEST_KRON
#undef TEST_INV
@@ -220,7 +221,7 @@ 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_INV) != 1
+#if defined(TEST_EXP) + defined(TEST_GCD) + defined(TEST_KRON) + defined(TEST_INV) != 1
# error "choose one test"
#endif
@@ -253,7 +254,11 @@ void do_mul_exp(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *c, BN_CTX *ctx)
#elif defined(TEST_GCD)
if (!BN_gcd(r,a,b,ctx)) goto err;
if (!BN_gcd(r,b,c,ctx)) goto err;
- if (!BN_gcd(r,b,c,ctx)) goto err;
+ if (!BN_gcd(r,c,a,ctx)) goto err;
+#elif defined(TEST_KRON)
+ if (-2 == BN_kronecker(a,b,ctx)) goto err;
+ if (-2 == BN_kronecker(b,c,ctx)) goto err;
+ if (-2 == BN_kronecker(c,a,ctx)) goto err;
#else /* TEST_INV */
if (!BN_mod_inverse(r,a,c,ctx)) goto err;
if (!BN_mod_inverse(r,b,c,ctx)) goto err;
@@ -265,6 +270,8 @@ void do_mul_exp(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *c, BN_CTX *ctx)
"modexp %4d ^ %4d %% %4d"
#elif defined(TEST_GCD)
"3*gcd %4d %4d %4d"
+#elif defined(TEST_KRON)
+ "3*kronecker %4d %4d %4d"
#else /* TEST_INV */
"2*inv %4d %4d mod %4d"
#endif