Return 0 on error in |EC_POINT_is_on_curve| instead of -1.

Callers of this function are not checking for the -1 result. Change
the semantics to match their expectations and to match the common
semantics of most other parts of BoringSSL.

Change-Id: I4ec537d7619e20e8ddfee80c72125e4c02cfaac1
Reviewed-on: https://boringssl-review.googlesource.com/7125
Reviewed-by: David Benjamin <davidben@google.com>
This commit is contained in:
Brian Smith 2016-02-13 16:46:11 -10:00 committed by David Benjamin
parent 0bc2349375
commit 76c6381c21
2 changed files with 4 additions and 3 deletions

View File

@ -821,7 +821,7 @@ int ec_GFp_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point,
const BIGNUM *p;
BN_CTX *new_ctx = NULL;
BIGNUM *rh, *tmp, *Z4, *Z6;
int ret = -1;
int ret = 0;
if (EC_POINT_is_at_infinity(group, point)) {
return 1;
@ -834,7 +834,7 @@ int ec_GFp_simple_is_on_curve(const EC_GROUP *group, const EC_POINT *point,
if (ctx == NULL) {
ctx = new_ctx = BN_CTX_new();
if (ctx == NULL) {
return -1;
return 0;
}
}

View File

@ -189,7 +189,8 @@ OPENSSL_EXPORT int EC_POINT_is_at_infinity(const EC_GROUP *group,
const EC_POINT *point);
/* EC_POINT_is_on_curve returns one if |point| is an element of |group| and
* zero otheriwse. If |ctx| is non-NULL, it may be used. */
* and zero otherwise or when an error occurs. This is different from OpenSSL,
* which returns -1 on error. If |ctx| is non-NULL, it may be used. */
OPENSSL_EXPORT int EC_POINT_is_on_curve(const EC_GROUP *group,
const EC_POINT *point, BN_CTX *ctx);