summaryrefslogtreecommitdiffstats
path: root/crypto/bn/bntest.c
diff options
context:
space:
mode:
authorBodo Möller <bodo@openssl.org>2000-12-07 22:06:09 +0000
committerBodo Möller <bodo@openssl.org>2000-12-07 22:06:09 +0000
commit8dea52fa4270a71535b2677953662499946f02e3 (patch)
tree6c419fda8d18eac4d092e595ed5a087d6a89f1d0 /crypto/bn/bntest.c
parentf7356b677b35ad58ea2db85cfd22af83b0267978 (diff)
Fix some things that look like bugs.
One problem that looked like a problem in bn_recp.c at first turned out to be a BN_mul bug. An example is given in bn_recp.c; finding the bug responsible for this is left as an exercise.
Diffstat (limited to 'crypto/bn/bntest.c')
-rw-r--r--crypto/bn/bntest.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/crypto/bn/bntest.c b/crypto/bn/bntest.c
index 9f308b75a9..b83d0ba30d 100644
--- a/crypto/bn/bntest.c
+++ b/crypto/bn/bntest.c
@@ -921,11 +921,10 @@ int test_kron(BIO *bp, BN_CTX *ctx)
if (!BN_sub_word(t, 1)) goto err;
if (!BN_rshift1(t, t)) goto err;
/* r := a^t mod b */
- /* FIXME: Using BN_mod_exp (Montgomery variant) leads to
- * incorrect results if b is negative ("Legendre symbol
- * computation failed").
- * We want computations to be carried out modulo |b|. */
- if (!BN_mod_exp_simple(r, a, t, b, ctx)) goto err;
+ b->neg=0;
+
+ if (!BN_mod_exp_recp(r, a, t, b, ctx)) goto err; /* XXX should be BN_mod_exp_recp, but ..._recp triggers a bug that must be fixed */
+ b->neg=1;
if (BN_is_word(r, 1))
legendre = 1;
@@ -934,7 +933,7 @@ int test_kron(BIO *bp, BN_CTX *ctx)
else
{
if (!BN_add_word(r, 1)) goto err;
- if (0 != BN_cmp(r, b))
+ if (0 != BN_ucmp(r, b))
{
fprintf(stderr, "Legendre symbol computation failed\n");
goto err;
@@ -1220,7 +1219,7 @@ int test_rshift1(BIO *bp)
}
BN_sub(c,a,b);
BN_sub(c,c,b);
- if(!BN_is_zero(c) && !BN_is_one(c))
+ if(!BN_is_zero(c) && !BN_abs_is_word(c, 1))
{
fprintf(stderr,"Right shift one test failed!\n");
return 0;