diff options
author | Nils Larsch <nils@openssl.org> | 2005-04-22 20:02:44 +0000 |
---|---|---|
committer | Nils Larsch <nils@openssl.org> | 2005-04-22 20:02:44 +0000 |
commit | ff22e913a3fbeb025e612828859102aa1a3effaa (patch) | |
tree | 9b30cca57b4f6fd9436fb222dbd2fe9647bc56a9 /crypto/ec | |
parent | 04d0d0accfbfe88cb52c92abf521c69577c8d33e (diff) |
- use BN_set_negative and BN_is_negative instead of BN_set_sign
and BN_get_sign
- implement BN_set_negative as a function
- always use "#define BN_is_zero(a) ((a)->top == 0)"
Diffstat (limited to 'crypto/ec')
-rw-r--r-- | crypto/ec/ec2_mult.c | 8 | ||||
-rw-r--r-- | crypto/ec/ec2_smpl.c | 10 | ||||
-rw-r--r-- | crypto/ec/ec_mult.c | 2 | ||||
-rw-r--r-- | crypto/ec/ecp_smpl.c | 2 | ||||
-rw-r--r-- | crypto/ec/ectest.c | 8 |
5 files changed, 15 insertions, 15 deletions
diff --git a/crypto/ec/ec2_mult.c b/crypto/ec/ec2_mult.c index a8ead01d61..3431671444 100644 --- a/crypto/ec/ec2_mult.c +++ b/crypto/ec/ec2_mult.c @@ -296,8 +296,8 @@ static int ec_GF2m_montgomery_point_multiply(const EC_GROUP *group, EC_POINT *r, } /* GF(2^m) field elements should always have BIGNUM::neg = 0 */ - BN_set_sign(&r->X, 0); - BN_set_sign(&r->Y, 0); + BN_set_negative(&r->X, 0); + BN_set_negative(&r->Y, 0); ret = 1; @@ -343,7 +343,7 @@ int ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, if (scalar) { if (!ec_GF2m_montgomery_point_multiply(group, p, scalar, group->generator, ctx)) goto err; - if (BN_get_sign(scalar)) + if (BN_is_negative(scalar)) if (!group->meth->invert(group, p, ctx)) goto err; if (!group->meth->add(group, r, r, p, ctx)) goto err; } @@ -351,7 +351,7 @@ int ec_GF2m_simple_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, for (i = 0; i < num; i++) { if (!ec_GF2m_montgomery_point_multiply(group, p, scalars[i], points[i], ctx)) goto err; - if (BN_get_sign(scalars[i])) + if (BN_is_negative(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 34c3a953a5..a9f7c9d378 100644 --- a/crypto/ec/ec2_smpl.c +++ b/crypto/ec/ec2_smpl.c @@ -354,11 +354,11 @@ int ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *group, EC_POINT } if (!BN_copy(&point->X, x)) goto err; - BN_set_sign(&point->X, 0); + BN_set_negative(&point->X, 0); if (!BN_copy(&point->Y, y)) goto err; - BN_set_sign(&point->Y, 0); + BN_set_negative(&point->Y, 0); if (!BN_copy(&point->Z, BN_value_one())) goto err; - BN_set_sign(&point->Z, 0); + BN_set_negative(&point->Z, 0); point->Z_is_one = 1; ret = 1; @@ -389,12 +389,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; - BN_set_sign(x, 0); + BN_set_negative(x, 0); } if (y != NULL) { if (!BN_copy(y, &point->Y)) goto err; - BN_set_sign(y, 0); + BN_set_negative(y, 0); } ret = 1; diff --git a/crypto/ec/ec_mult.c b/crypto/ec/ec_mult.c index 236b66c18a..101f44a2e0 100644 --- a/crypto/ec/ec_mult.c +++ b/crypto/ec/ec_mult.c @@ -203,7 +203,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 (BN_get_sign(scalar)) + if (BN_is_negative(scalar)) { sign = -1; } diff --git a/crypto/ec/ecp_smpl.c b/crypto/ec/ecp_smpl.c index 1c0052c5ca..75296a3673 100644 --- a/crypto/ec/ecp_smpl.c +++ b/crypto/ec/ecp_smpl.c @@ -192,7 +192,7 @@ int ec_GFp_simple_group_set_curve(EC_GROUP *group, /* group->field */ if (!BN_copy(&group->field, p)) goto err; - BN_set_sign(&group->field, 0); + BN_set_negative(&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 b96feae7f3..92d2f671ac 100644 --- a/crypto/ec/ectest.c +++ b/crypto/ec/ectest.c @@ -672,7 +672,7 @@ void prime_field_tests() if (!BN_pseudo_rand(y, BN_num_bits(y), 0, 0)) ABORT; if (!BN_add(z, z, y)) ABORT; - BN_set_sign(z, 1); + BN_set_negative(z, 1); scalars[0] = y; scalars[1] = z; /* z = -(order + y) */ @@ -684,7 +684,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; - BN_set_sign(z, 1); + BN_set_negative(z, 1); scalars[0] = x; scalars[1] = y; scalars[2] = z; /* z = -(x+y) */ @@ -1147,7 +1147,7 @@ void char2_field_tests() if (!BN_pseudo_rand(y, BN_num_bits(y), 0, 0)) ABORT; if (!BN_add(z, z, y)) ABORT; - BN_set_sign(z, 1); + BN_set_negative(z, 1); scalars[0] = y; scalars[1] = z; /* z = -(order + y) */ @@ -1159,7 +1159,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; - BN_set_sign(z, 1); + BN_set_negative(z, 1); scalars[0] = x; scalars[1] = y; scalars[2] = z; /* z = -(x+y) */ |