summaryrefslogtreecommitdiffstats
path: root/crypto/bn/bn_kron.c
diff options
context:
space:
mode:
authorBodo Möller <bodo@openssl.org>2000-11-29 19:26:33 +0000
committerBodo Möller <bodo@openssl.org>2000-11-29 19:26:33 +0000
commiteb1f1b0a341cbe2c75d8f24b2dc62f4cad05dcec (patch)
tree0283e16350c453a812e800021a182dbf98b1d3fa /crypto/bn/bn_kron.c
parenta9376dbff94c9ddd06639264389ae9777bcb2d30 (diff)
Fix BN_kronecker so that it works correctly if 'a' is negative
(we need the two's complement of BN_lsw then).
Diffstat (limited to 'crypto/bn/bn_kron.c')
-rw-r--r--crypto/bn/bn_kron.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/crypto/bn/bn_kron.c b/crypto/bn/bn_kron.c
index 20b593e679..0dd8a194cb 100644
--- a/crypto/bn/bn_kron.c
+++ b/crypto/bn/bn_kron.c
@@ -65,7 +65,7 @@
int BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
{
int i;
- int ret;
+ int ret = -2; /* avoid 'uninitialized' warning */
int err = 0;
BIGNUM *A, *B, *tmp;
/* In 'tab', only odd-indexed entries are relevant:
@@ -165,7 +165,7 @@ int BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
/* Cohen's step 4: */
/* multiply 'ret' by $(-1)^{(A-1)(B-1)/4}$ */
- if (BN_lsw(A) & BN_lsw(B) & 2)
+ if ((A->neg ? ~BN_lsw(A) : BN_lsw(A)) & BN_lsw(B) & 2)
ret = -ret;
/* (A, B) := (B mod |A|, |A|) */