diff options
author | Bodo Möller <bodo@openssl.org> | 2000-12-07 07:55:26 +0000 |
---|---|---|
committer | Bodo Möller <bodo@openssl.org> | 2000-12-07 07:55:26 +0000 |
commit | bc5f2740d2a427d5e16bfb12aa8b70d5a5adcfc8 (patch) | |
tree | feb35875a8c8a1bcefaa2d9ce2f9cda355139dac /crypto/bn | |
parent | aa66eba7c8c7496db92b80da19688d6f96a40b96 (diff) |
Move 'q->neg = 0' to those places where it is needed
(just in cases someone uses a negative modulus)
Diffstat (limited to 'crypto/bn')
-rw-r--r-- | crypto/bn/bn_sqrt.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/crypto/bn/bn_sqrt.c b/crypto/bn/bn_sqrt.c index 6d50b5d895..6959cc5f6f 100644 --- a/crypto/bn/bn_sqrt.c +++ b/crypto/bn/bn_sqrt.c @@ -134,9 +134,11 @@ BIGNUM *BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) while (!BN_is_bit_set(p, e)) e++; if (e > 2) + { /* we don't need this q if e = 1 or 2 */ if (!BN_rshift(q, p, e)) goto end; - q->neg = 0; + q->neg = 0; + } if (e == 1) { @@ -148,6 +150,7 @@ BIGNUM *BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) * so we can use exponent (p+1)/4, i.e. (p-3)/4 + 1. */ if (!BN_rshift(q, p, 2)) goto end; + q->neg = 0; if (!BN_add_word(q, 1)) goto end; if (!BN_mod_exp(ret, a, q, p, ctx)) goto end; err = 0; @@ -194,6 +197,7 @@ BIGNUM *BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) /* b := (2*a)^((p-5)/8) */ if (!BN_rshift(q, p, 3)) goto end; + q->neg = 0; if (!BN_mod_exp(b, t, q, p, ctx)) goto end; /* y := b^2 */ |