summaryrefslogtreecommitdiffstats
path: root/crypto/ec
diff options
context:
space:
mode:
authorBodo Möller <bodo@openssl.org>2002-11-04 13:17:22 +0000
committerBodo Möller <bodo@openssl.org>2002-11-04 13:17:22 +0000
commitb53e44e57259b2b015c54de8ecbcf4e06be23298 (patch)
tree4d06528db2e5e7d8ad1680fc59159a4c689c7b3c /crypto/ec
parente5f4d8279dccad0f6dde324f52333291739dcca3 (diff)
implement and use new macros BN_get_sign(), BN_set_sign()
Submitted by: Nils Larsch
Diffstat (limited to 'crypto/ec')
-rw-r--r--crypto/ec/ec2_mult.c10
-rw-r--r--crypto/ec/ec2_smpl.c10
-rw-r--r--crypto/ec/ec_mult.c2
-rw-r--r--crypto/ec/ecp_nist.c2
-rw-r--r--crypto/ec/ecp_smpl.c2
-rw-r--r--crypto/ec/ectest.c8
6 files changed, 18 insertions, 16 deletions
diff --git a/crypto/ec/ec2_mult.c b/crypto/ec/ec2_mult.c
index 09cf08a46c..3aef959354 100644
--- a/crypto/ec/ec2_mult.c
+++ b/crypto/ec/ec2_mult.c
@@ -297,8 +297,8 @@ static int point_multiply(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scal
}
/* GF(2^m) field elements should always have BIGNUM::neg = 0 */
- r->X.neg = 0;
- r->Y.neg = 0;
+ BN_set_sign(&r->X, 0);
+ BN_set_sign(&r->Y, 0);
ret = 1;
@@ -342,14 +342,16 @@ int ec_GF2m_mont_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
if (scalar)
{
if (!point_multiply(group, p, scalar, group->generator, ctx)) goto err;
- if (scalar->neg) if (!group->meth->invert(group, p, ctx)) goto err;
+ if (BN_get_sign(scalar))
+ if (!group->meth->invert(group, p, ctx)) goto err;
if (!group->meth->add(group, r, r, p, ctx)) goto err;
}
for (i = 0; i < num; i++)
{
if (!point_multiply(group, p, scalars[i], points[i], ctx)) goto err;
- if (scalars[i]->neg) if (!group->meth->invert(group, p, ctx)) goto err;
+ if (BN_get_sign(scalars[i]))
+ if (!group->meth->invert(group, p, ctx)) goto err;
if (!group->meth->add(group, r, r, p, ctx)) goto err;
}
diff --git a/crypto/ec/ec2_smpl.c b/crypto/ec/ec2_smpl.c
index acf205597b..5e37bfaca7 100644
--- a/crypto/ec/ec2_smpl.c
+++ b/crypto/ec/ec2_smpl.c
@@ -349,11 +349,11 @@ int ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *group, EC_POINT
}
if (!BN_copy(&point->X, x)) goto err;
- point->X.neg = 0;
+ BN_set_sign(&point->X, 0);
if (!BN_copy(&point->Y, y)) goto err;
- point->Y.neg = 0;
+ BN_set_sign(&point->Y, 0);
if (!BN_copy(&point->Z, BN_value_one())) goto err;
- point->Z.neg = 0;
+ BN_set_sign(&point->Z, 0);
point->Z_is_one = 1;
ret = 1;
@@ -384,12 +384,12 @@ int ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *group, const EC_
if (x != NULL)
{
if (!BN_copy(x, &point->X)) goto err;
- x->neg = 0;
+ BN_set_sign(x, 0);
}
if (y != NULL)
{
if (!BN_copy(y, &point->Y)) goto err;
- y->neg = 0;
+ BN_set_sign(y, 0);
}
ret = 1;
diff --git a/crypto/ec/ec_mult.c b/crypto/ec/ec_mult.c
index 4978a54352..f5312aa23a 100644
--- a/crypto/ec/ec_mult.c
+++ b/crypto/ec/ec_mult.c
@@ -102,7 +102,7 @@ static signed char *compute_wNAF(const BIGNUM *scalar, int w, size_t *ret_len)
next_bit = bit << 1; /* at most 256 */
mask = next_bit - 1; /* at most 255 */
- if (scalar->neg)
+ if (BN_get_sign(scalar))
{
sign = -1;
}
diff --git a/crypto/ec/ecp_nist.c b/crypto/ec/ecp_nist.c
index 98401fe4bc..156bc54a07 100644
--- a/crypto/ec/ecp_nist.c
+++ b/crypto/ec/ecp_nist.c
@@ -191,7 +191,7 @@ int ec_GFp_nist_group_set_curve(EC_GROUP *group, const BIGNUM *p,
/* group->field */
if (!BN_copy(&group->field, p)) goto err;
- group->field.neg = 0;
+ BN_set_sign(&group->field, 0);
/* group->a */
if (!group->field_mod_func(&group->a, a, p, ctx)) goto err;
diff --git a/crypto/ec/ecp_smpl.c b/crypto/ec/ecp_smpl.c
index 97ff8eb61a..ad95b03ba6 100644
--- a/crypto/ec/ecp_smpl.c
+++ b/crypto/ec/ecp_smpl.c
@@ -177,7 +177,7 @@ int ec_GFp_simple_group_set_curve(EC_GROUP *group,
/* group->field */
if (!BN_copy(&group->field, p)) goto err;
- group->field.neg = 0;
+ BN_set_sign(&group->field, 0);
/* group->a */
if (!BN_nnmod(tmp_a, a, p, ctx)) goto err;
diff --git a/crypto/ec/ectest.c b/crypto/ec/ectest.c
index e32b231e8d..2553982644 100644
--- a/crypto/ec/ectest.c
+++ b/crypto/ec/ectest.c
@@ -603,7 +603,7 @@ void prime_field_tests()
if (!BN_pseudo_rand(y, BN_num_bits(y), 0, 0)) ABORT;
if (!BN_add(z, z, y)) ABORT;
- z->neg = 1;
+ BN_set_sign(z, 1);
scalars[0] = y;
scalars[1] = z; /* z = -(order + y) */
@@ -615,7 +615,7 @@ void prime_field_tests()
if (!BN_pseudo_rand(x, BN_num_bits(y) - 1, 0, 0)) ABORT;
if (!BN_add(z, x, y)) ABORT;
- z->neg = 1;
+ BN_set_sign(z, 1);
scalars[0] = x;
scalars[1] = y;
scalars[2] = z; /* z = -(x+y) */
@@ -1069,7 +1069,7 @@ void char2_field_tests()
if (!BN_pseudo_rand(y, BN_num_bits(y), 0, 0)) ABORT;
if (!BN_add(z, z, y)) ABORT;
- z->neg = 1;
+ BN_set_sign(z, 1);
scalars[0] = y;
scalars[1] = z; /* z = -(order + y) */
@@ -1081,7 +1081,7 @@ void char2_field_tests()
if (!BN_pseudo_rand(x, BN_num_bits(y) - 1, 0, 0)) ABORT;
if (!BN_add(z, x, y)) ABORT;
- z->neg = 1;
+ BN_set_sign(z, 1);
scalars[0] = x;
scalars[1] = y;
scalars[2] = z; /* z = -(x+y) */