diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2015-02-08 22:25:04 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2015-02-08 22:25:04 +0000 |
commit | c460ab3c1ce775304bf920089e5f785e451fb3a7 (patch) | |
tree | 2e99dd5285409b2ca4d599f8fc1e51d3bac149c2 /lib/libcrypto | |
parent | 1414007b73111e4dd26c1fd65cb33108871be7fc (diff) |
Use `> 0' instead of `!= 0' as a successful condition for
EC_POINT_is_at_infinity() and EC_POINT_is_on_curve(), for they may return -1
should an error arise.
ok doug@ jsing@
Diffstat (limited to 'lib/libcrypto')
-rw-r--r-- | lib/libcrypto/ec/ec2_mult.c | 4 | ||||
-rw-r--r-- | lib/libcrypto/ec/ec2_oct.c | 8 | ||||
-rw-r--r-- | lib/libcrypto/ec/ec2_smpl.c | 20 | ||||
-rw-r--r-- | lib/libcrypto/ec/ec_check.c | 6 | ||||
-rw-r--r-- | lib/libcrypto/ec/ec_key.c | 8 | ||||
-rw-r--r-- | lib/libcrypto/ec/ecp_nistp224.c | 4 | ||||
-rw-r--r-- | lib/libcrypto/ec/ecp_nistp256.c | 4 | ||||
-rw-r--r-- | lib/libcrypto/ec/ecp_nistp521.c | 4 | ||||
-rw-r--r-- | lib/libcrypto/ec/ecp_oct.c | 8 | ||||
-rw-r--r-- | lib/libcrypto/ec/ecp_smpl.c | 22 |
10 files changed, 44 insertions, 44 deletions
diff --git a/lib/libcrypto/ec/ec2_mult.c b/lib/libcrypto/ec/ec2_mult.c index c74571f88c7..dd113907be1 100644 --- a/lib/libcrypto/ec/ec2_mult.c +++ b/lib/libcrypto/ec/ec2_mult.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec2_mult.c,v 1.5 2014/07/12 16:03:37 miod Exp $ */ +/* $OpenBSD: ec2_mult.c,v 1.6 2015/02/08 22:25:03 miod Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -272,7 +272,7 @@ ec_GF2m_montgomery_point_multiply(const EC_GROUP *group, EC_POINT *r, } /* if result should be point at infinity */ if ((scalar == NULL) || BN_is_zero(scalar) || (point == NULL) || - EC_POINT_is_at_infinity(group, point)) { + EC_POINT_is_at_infinity(group, point) > 0) { return EC_POINT_set_to_infinity(group, r); } /* only support affine coordinates */ diff --git a/lib/libcrypto/ec/ec2_oct.c b/lib/libcrypto/ec/ec2_oct.c index 3b8039af6ea..c45d9c22190 100644 --- a/lib/libcrypto/ec/ec2_oct.c +++ b/lib/libcrypto/ec/ec2_oct.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec2_oct.c,v 1.5 2014/07/12 16:03:37 miod Exp $ */ +/* $OpenBSD: ec2_oct.c,v 1.6 2015/02/08 22:25:03 miod Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -183,7 +183,7 @@ ec_GF2m_simple_point2oct(const EC_GROUP *group, const EC_POINT *point, ECerr(EC_F_EC_GF2M_SIMPLE_POINT2OCT, EC_R_INVALID_FORM); goto err; } - if (EC_POINT_is_at_infinity(group, point)) { + if (EC_POINT_is_at_infinity(group, point) > 0) { /* encodes to a single 0 octet */ if (buf != NULL) { if (len < 1) { @@ -363,8 +363,8 @@ ec_GF2m_simple_oct2point(const EC_GROUP *group, EC_POINT *point, goto err; } - if (!EC_POINT_is_on_curve(group, point, ctx)) { - /* test required by X9.62 */ + /* test required by X9.62 */ + if (EC_POINT_is_on_curve(group, point, ctx) <= 0) { ECerr(EC_F_EC_GF2M_SIMPLE_OCT2POINT, EC_R_POINT_IS_NOT_ON_CURVE); goto err; } diff --git a/lib/libcrypto/ec/ec2_smpl.c b/lib/libcrypto/ec/ec2_smpl.c index 0031a161c70..b9c066c5c16 100644 --- a/lib/libcrypto/ec/ec2_smpl.c +++ b/lib/libcrypto/ec/ec2_smpl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec2_smpl.c,v 1.12 2014/07/12 16:03:37 miod Exp $ */ +/* $OpenBSD: ec2_smpl.c,v 1.13 2015/02/08 22:25:03 miod Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -413,7 +413,7 @@ ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *group, { int ret = 0; - if (EC_POINT_is_at_infinity(group, point)) { + if (EC_POINT_is_at_infinity(group, point) > 0) { ECerr(EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES, EC_R_POINT_AT_INFINITY); return 0; } @@ -448,12 +448,12 @@ ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BIGNUM *x0, *y0, *x1, *y1, *x2, *y2, *s, *t; int ret = 0; - if (EC_POINT_is_at_infinity(group, a)) { + if (EC_POINT_is_at_infinity(group, a) > 0) { if (!EC_POINT_copy(r, b)) return 0; return 1; } - if (EC_POINT_is_at_infinity(group, b)) { + if (EC_POINT_is_at_infinity(group, b) > 0) { if (!EC_POINT_copy(r, a)) return 0; return 1; @@ -564,7 +564,7 @@ ec_GF2m_simple_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, int ec_GF2m_simple_invert(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx) { - if (EC_POINT_is_at_infinity(group, point) || BN_is_zero(&point->Y)) + if (EC_POINT_is_at_infinity(group, point) > 0 || BN_is_zero(&point->Y)) /* point is its own inverse */ return 1; @@ -595,7 +595,7 @@ ec_GF2m_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point, BN_CTX int (*field_mul) (const EC_GROUP *, BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *); int (*field_sqr) (const EC_GROUP *, BIGNUM *, const BIGNUM *, BN_CTX *); - if (EC_POINT_is_at_infinity(group, point)) + if (EC_POINT_is_at_infinity(group, point) > 0) return 1; field_mul = group->meth->field_mul; @@ -657,10 +657,10 @@ ec_GF2m_simple_cmp(const EC_GROUP * group, const EC_POINT * a, const EC_POINT * BN_CTX *new_ctx = NULL; int ret = -1; - if (EC_POINT_is_at_infinity(group, a)) { - return EC_POINT_is_at_infinity(group, b) ? 0 : 1; + if (EC_POINT_is_at_infinity(group, a) > 0) { + return EC_POINT_is_at_infinity(group, b) > 0 ? 0 : 1; } - if (EC_POINT_is_at_infinity(group, b)) + if (EC_POINT_is_at_infinity(group, b) > 0) return 1; if (a->Z_is_one && b->Z_is_one) { @@ -701,7 +701,7 @@ ec_GF2m_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ct BIGNUM *x, *y; int ret = 0; - if (point->Z_is_one || EC_POINT_is_at_infinity(group, point)) + if (point->Z_is_one || EC_POINT_is_at_infinity(group, point) > 0) return 1; if (ctx == NULL) { diff --git a/lib/libcrypto/ec/ec_check.c b/lib/libcrypto/ec/ec_check.c index 779e03cc2bf..21072305d5c 100644 --- a/lib/libcrypto/ec/ec_check.c +++ b/lib/libcrypto/ec/ec_check.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_check.c,v 1.4 2014/07/12 16:03:37 miod Exp $ */ +/* $OpenBSD: ec_check.c,v 1.5 2015/02/08 22:25:03 miod Exp $ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * @@ -85,7 +85,7 @@ EC_GROUP_check(const EC_GROUP * group, BN_CTX * ctx) ECerr(EC_F_EC_GROUP_CHECK, EC_R_UNDEFINED_GENERATOR); goto err; } - if (!EC_POINT_is_on_curve(group, group->generator, ctx)) { + if (EC_POINT_is_on_curve(group, group->generator, ctx) <= 0) { ECerr(EC_F_EC_GROUP_CHECK, EC_R_POINT_IS_NOT_ON_CURVE); goto err; } @@ -100,7 +100,7 @@ EC_GROUP_check(const EC_GROUP * group, BN_CTX * ctx) } if (!EC_POINT_mul(group, point, order, NULL, NULL, ctx)) goto err; - if (!EC_POINT_is_at_infinity(group, point)) { + if (EC_POINT_is_at_infinity(group, point) <= 0) { ECerr(EC_F_EC_GROUP_CHECK, EC_R_INVALID_GROUP_ORDER); goto err; } diff --git a/lib/libcrypto/ec/ec_key.c b/lib/libcrypto/ec/ec_key.c index 1154c4dbf5b..f9904b4ee9d 100644 --- a/lib/libcrypto/ec/ec_key.c +++ b/lib/libcrypto/ec/ec_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_key.c,v 1.9 2014/07/12 16:03:37 miod Exp $ */ +/* $OpenBSD: ec_key.c,v 1.10 2015/02/08 22:25:03 miod Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -277,7 +277,7 @@ EC_KEY_check_key(const EC_KEY * eckey) ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_PASSED_NULL_PARAMETER); return 0; } - if (EC_POINT_is_at_infinity(eckey->group, eckey->pub_key)) { + if (EC_POINT_is_at_infinity(eckey->group, eckey->pub_key) > 0) { ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_POINT_AT_INFINITY); goto err; } @@ -287,7 +287,7 @@ EC_KEY_check_key(const EC_KEY * eckey) goto err; /* testing whether the pub_key is on the elliptic curve */ - if (!EC_POINT_is_on_curve(eckey->group, eckey->pub_key, ctx)) { + if (EC_POINT_is_on_curve(eckey->group, eckey->pub_key, ctx) <= 0) { ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_POINT_IS_NOT_ON_CURVE); goto err; } @@ -301,7 +301,7 @@ EC_KEY_check_key(const EC_KEY * eckey) ECerr(EC_F_EC_KEY_CHECK_KEY, ERR_R_EC_LIB); goto err; } - if (!EC_POINT_is_at_infinity(eckey->group, point)) { + if (EC_POINT_is_at_infinity(eckey->group, point) <= 0) { ECerr(EC_F_EC_KEY_CHECK_KEY, EC_R_WRONG_ORDER); goto err; } diff --git a/lib/libcrypto/ec/ecp_nistp224.c b/lib/libcrypto/ec/ecp_nistp224.c index ed0bad2a722..d29113045a5 100644 --- a/lib/libcrypto/ec/ecp_nistp224.c +++ b/lib/libcrypto/ec/ecp_nistp224.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_nistp224.c,v 1.15 2014/07/12 16:03:37 miod Exp $ */ +/* $OpenBSD: ecp_nistp224.c,v 1.16 2015/02/08 22:25:03 miod Exp $ */ /* * Written by Emilia Kasper (Google) for the OpenSSL project. */ @@ -1298,7 +1298,7 @@ ec_GFp_nistp224_point_get_affine_coordinates(const EC_GROUP * group, felem z1, z2, x_in, y_in, x_out, y_out; widefelem tmp; - if (EC_POINT_is_at_infinity(group, point)) { + if (EC_POINT_is_at_infinity(group, point) > 0) { ECerr(EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES, EC_R_POINT_AT_INFINITY); return 0; diff --git a/lib/libcrypto/ec/ecp_nistp256.c b/lib/libcrypto/ec/ecp_nistp256.c index 6905b614bcd..23a2131980d 100644 --- a/lib/libcrypto/ec/ecp_nistp256.c +++ b/lib/libcrypto/ec/ecp_nistp256.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_nistp256.c,v 1.14 2014/07/12 16:03:37 miod Exp $ */ +/* $OpenBSD: ecp_nistp256.c,v 1.15 2015/02/08 22:25:03 miod Exp $ */ /* * Written by Adam Langley (Google) for the OpenSSL project */ @@ -1848,7 +1848,7 @@ ec_GFp_nistp256_point_get_affine_coordinates(const EC_GROUP * group, smallfelem x_out, y_out; longfelem tmp; - if (EC_POINT_is_at_infinity(group, point)) { + if (EC_POINT_is_at_infinity(group, point) > 0) { ECerr(EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES, EC_R_POINT_AT_INFINITY); return 0; diff --git a/lib/libcrypto/ec/ecp_nistp521.c b/lib/libcrypto/ec/ecp_nistp521.c index c9313ada8e2..6382091cf91 100644 --- a/lib/libcrypto/ec/ecp_nistp521.c +++ b/lib/libcrypto/ec/ecp_nistp521.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_nistp521.c,v 1.15 2014/07/12 16:03:37 miod Exp $ */ +/* $OpenBSD: ecp_nistp521.c,v 1.16 2015/02/08 22:25:03 miod Exp $ */ /* * Written by Adam Langley (Google) for the OpenSSL project */ @@ -1738,7 +1738,7 @@ ec_GFp_nistp521_point_get_affine_coordinates(const EC_GROUP * group, felem z1, z2, x_in, y_in, x_out, y_out; largefelem tmp; - if (EC_POINT_is_at_infinity(group, point)) { + if (EC_POINT_is_at_infinity(group, point) > 0) { ECerr(EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES, EC_R_POINT_AT_INFINITY); return 0; diff --git a/lib/libcrypto/ec/ecp_oct.c b/lib/libcrypto/ec/ecp_oct.c index d2402ee0d81..abc31e63821 100644 --- a/lib/libcrypto/ec/ecp_oct.c +++ b/lib/libcrypto/ec/ecp_oct.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_oct.c,v 1.5 2014/07/12 16:03:37 miod Exp $ */ +/* $OpenBSD: ecp_oct.c,v 1.6 2015/02/08 22:25:03 miod Exp $ */ /* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> * for the OpenSSL project. * Includes code written by Bodo Moeller for the OpenSSL project. @@ -211,7 +211,7 @@ ec_GFp_simple_point2oct(const EC_GROUP * group, const EC_POINT * point, point_co ECerr(EC_F_EC_GFP_SIMPLE_POINT2OCT, EC_R_INVALID_FORM); goto err; } - if (EC_POINT_is_at_infinity(group, point)) { + if (EC_POINT_is_at_infinity(group, point) > 0) { /* encodes to a single 0 octet */ if (buf != NULL) { if (len < 1) { @@ -379,8 +379,8 @@ ec_GFp_simple_oct2point(const EC_GROUP * group, EC_POINT * point, goto err; } - if (!EC_POINT_is_on_curve(group, point, ctx)) { /* test required by - * X9.62 */ + /* test required by X9.62 */ + if (EC_POINT_is_on_curve(group, point, ctx) <= 0) { ECerr(EC_F_EC_GFP_SIMPLE_OCT2POINT, EC_R_POINT_IS_NOT_ON_CURVE); goto err; } diff --git a/lib/libcrypto/ec/ecp_smpl.c b/lib/libcrypto/ec/ecp_smpl.c index dabc5af899b..7b3bb2364d9 100644 --- a/lib/libcrypto/ec/ecp_smpl.c +++ b/lib/libcrypto/ec/ecp_smpl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_smpl.c,v 1.13 2014/07/12 16:03:37 miod Exp $ */ +/* $OpenBSD: ecp_smpl.c,v 1.14 2015/02/08 22:25:03 miod Exp $ */ /* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> * for the OpenSSL project. * Includes code written by Bodo Moeller for the OpenSSL project. @@ -529,7 +529,7 @@ ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP * group, const EC_POIN const BIGNUM *Z_; int ret = 0; - if (EC_POINT_is_at_infinity(group, point)) { + if (EC_POINT_is_at_infinity(group, point) > 0) { ECerr(EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES, EC_R_POINT_AT_INFINITY); return 0; } @@ -637,9 +637,9 @@ ec_GFp_simple_add(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, cons if (a == b) return EC_POINT_dbl(group, r, a, ctx); - if (EC_POINT_is_at_infinity(group, a)) + if (EC_POINT_is_at_infinity(group, a) > 0) return EC_POINT_copy(r, b); - if (EC_POINT_is_at_infinity(group, b)) + if (EC_POINT_is_at_infinity(group, b) > 0) return EC_POINT_copy(r, a); field_mul = group->meth->field_mul; @@ -819,7 +819,7 @@ ec_GFp_simple_dbl(const EC_GROUP * group, EC_POINT * r, const EC_POINT * a, BN_C BIGNUM *n0, *n1, *n2, *n3; int ret = 0; - if (EC_POINT_is_at_infinity(group, a)) { + if (EC_POINT_is_at_infinity(group, a) > 0) { BN_zero(&r->Z); r->Z_is_one = 0; return 1; @@ -952,7 +952,7 @@ err: int ec_GFp_simple_invert(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx) { - if (EC_POINT_is_at_infinity(group, point) || BN_is_zero(&point->Y)) + if (EC_POINT_is_at_infinity(group, point) > 0 || BN_is_zero(&point->Y)) /* point is its own inverse */ return 1; @@ -977,7 +977,7 @@ ec_GFp_simple_is_on_curve(const EC_GROUP * group, const EC_POINT * point, BN_CTX BIGNUM *rh, *tmp, *Z4, *Z6; int ret = -1; - if (EC_POINT_is_at_infinity(group, point)) + if (EC_POINT_is_at_infinity(group, point) > 0) return 1; field_mul = group->meth->field_mul; @@ -1083,10 +1083,10 @@ ec_GFp_simple_cmp(const EC_GROUP * group, const EC_POINT * a, const EC_POINT * b const BIGNUM *tmp1_, *tmp2_; int ret = -1; - if (EC_POINT_is_at_infinity(group, a)) { - return EC_POINT_is_at_infinity(group, b) ? 0 : 1; + if (EC_POINT_is_at_infinity(group, a) > 0) { + return EC_POINT_is_at_infinity(group, b) > 0 ? 0 : 1; } - if (EC_POINT_is_at_infinity(group, b)) + if (EC_POINT_is_at_infinity(group, b) > 0) return 1; if (a->Z_is_one && b->Z_is_one) { @@ -1175,7 +1175,7 @@ ec_GFp_simple_make_affine(const EC_GROUP * group, EC_POINT * point, BN_CTX * ctx BIGNUM *x, *y; int ret = 0; - if (point->Z_is_one || EC_POINT_is_at_infinity(group, point)) + if (point->Z_is_one || EC_POINT_is_at_infinity(group, point) > 0) return 1; if (ctx == NULL) { |