aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/ec
diff options
context:
space:
mode:
authorGeoff Thorpe <geoff@openssl.org>2004-03-13 23:57:20 +0000
committerGeoff Thorpe <geoff@openssl.org>2004-03-13 23:57:20 +0000
commitb6358c89a10128692875fb92921b663c4d079a1e (patch)
treed36362a84ee41209484b4b088c2b9d1728bfc613 /crypto/ec
parent5d735465d1b5b7853506979946ad5730cc3615bb (diff)
downloadopenssl-b6358c89a10128692875fb92921b663c4d079a1e.tar.gz
Convert openssl code not to assume the deprecated form of BN_zero().
Remove certain redundant BN_zero() initialisations, because BN_CTX_get(), BN_init(), [etc] already initialise to zero. Correct error checking in bn_sqr.c, and be less wishy-wash about how/why the result's 'top' value is set (note also, 'max' is always > 0 at this point).
Diffstat (limited to 'crypto/ec')
-rw-r--r--crypto/ec/ec2_mult.c4
-rw-r--r--crypto/ec/ec2_smpl.c3
-rw-r--r--crypto/ec/ec_lib.c4
-rw-r--r--crypto/ec/ecp_smpl.c7
4 files changed, 10 insertions, 8 deletions
diff --git a/crypto/ec/ec2_mult.c b/crypto/ec/ec2_mult.c
index a0ee7c152f..a8ead01d61 100644
--- a/crypto/ec/ec2_mult.c
+++ b/crypto/ec/ec2_mult.c
@@ -155,8 +155,8 @@ static int gf2m_Mxy(const EC_GROUP *group, const BIGNUM *x, const BIGNUM *y, BIG
if (BN_is_zero(z1))
{
- if (!BN_zero(x2)) return 0;
- if (!BN_zero(z2)) return 0;
+ BN_zero(x2);
+ BN_zero(z2);
return 1;
}
diff --git a/crypto/ec/ec2_smpl.c b/crypto/ec/ec2_smpl.c
index 89e8152015..1132c8e5af 100644
--- a/crypto/ec/ec2_smpl.c
+++ b/crypto/ec/ec2_smpl.c
@@ -335,7 +335,8 @@ int ec_GF2m_simple_point_copy(EC_POINT *dest, const EC_POINT *src)
int ec_GF2m_simple_point_set_to_infinity(const EC_GROUP *group, EC_POINT *point)
{
point->Z_is_one = 0;
- return (BN_zero(&point->Z));
+ BN_zero(&point->Z);
+ return 1;
}
diff --git a/crypto/ec/ec_lib.c b/crypto/ec/ec_lib.c
index b3ef05659a..ba5b821c9c 100644
--- a/crypto/ec/ec_lib.c
+++ b/crypto/ec/ec_lib.c
@@ -299,12 +299,12 @@ int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, const BIG
if (order != NULL)
{ if (!BN_copy(&group->order, order)) return 0; }
else
- { if (!BN_zero(&group->order)) return 0; }
+ BN_zero(&group->order);
if (cofactor != NULL)
{ if (!BN_copy(&group->cofactor, cofactor)) return 0; }
else
- { if (!BN_zero(&group->cofactor)) return 0; }
+ BN_zero(&group->cofactor);
return 1;
}
diff --git a/crypto/ec/ecp_smpl.c b/crypto/ec/ecp_smpl.c
index 1abe831a37..de90f90aa1 100644
--- a/crypto/ec/ecp_smpl.c
+++ b/crypto/ec/ecp_smpl.c
@@ -385,7 +385,8 @@ int ec_GFp_simple_point_copy(EC_POINT *dest, const EC_POINT *src)
int ec_GFp_simple_point_set_to_infinity(const EC_GROUP *group, EC_POINT *point)
{
point->Z_is_one = 0;
- return (BN_zero(&point->Z));
+ BN_zero(&point->Z);
+ return 1;
}
@@ -1093,7 +1094,7 @@ int ec_GFp_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, con
else
{
/* a is the inverse of b */
- if (!BN_zero(&r->Z)) goto end;
+ BN_zero(&r->Z);
r->Z_is_one = 0;
ret = 1;
goto end;
@@ -1169,7 +1170,7 @@ int ec_GFp_simple_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_
if (EC_POINT_is_at_infinity(group, a))
{
- if (!BN_zero(&r->Z)) return 0;
+ BN_zero(&r->Z);
r->Z_is_one = 0;
return 1;
}