From: Nicola Tuveri Date: Fri, 20 Apr 2018 11:13:40 +0000 (+0000) Subject: Move up check for EC_R_INCOMPATIBLE_OBJECTS and for the point at infinity case X-Git-Tag: OpenSSL_1_1_1-pre6~45 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=736b31e5ea33166d89d5cff5774697d0c15d96bd;p=oweals%2Fopenssl.git Move up check for EC_R_INCOMPATIBLE_OBJECTS and for the point at infinity case Reviewed-by: Andy Polyakov Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/6009) --- diff --git a/crypto/ec/ec_mult.c b/crypto/ec/ec_mult.c index 801726f9f5..1ed7449228 100644 --- a/crypto/ec/ec_mult.c +++ b/crypto/ec/ec_mult.c @@ -372,6 +372,15 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, * precomputation is not available */ int ret = 0; + if (group->meth != r->meth) { + ECerr(EC_F_EC_WNAF_MUL, EC_R_INCOMPATIBLE_OBJECTS); + return 0; + } + + if ((scalar == NULL) && (num == 0)) { + return EC_POINT_set_to_infinity(group, r); + } + /*- * Handle the common cases where the scalar is secret, enforcing a constant * time scalar multiplication algorithm. @@ -398,15 +407,6 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, return ec_mul_consttime(group, r, scalars[0], points[0], ctx); } - if (group->meth != r->meth) { - ECerr(EC_F_EC_WNAF_MUL, EC_R_INCOMPATIBLE_OBJECTS); - return 0; - } - - if ((scalar == NULL) && (num == 0)) { - return EC_POINT_set_to_infinity(group, r); - } - for (i = 0; i < num; i++) { if (group->meth != points[i]->meth) { ECerr(EC_F_EC_WNAF_MUL, EC_R_INCOMPATIBLE_OBJECTS);