summaryrefslogtreecommitdiffstats
path: root/crypto/ec/ec_mult.c
diff options
context:
space:
mode:
authorNicola Tuveri <nic.tuv@gmail.com>2018-04-20 11:13:40 +0000
committerMatt Caswell <matt@openssl.org>2018-04-23 19:20:32 +0100
commitb43ad53119c0ac2ecfa6e4356210ccda57e0d16b (patch)
tree333c586a200e504c977d8ce519cc62408bc6587b /crypto/ec/ec_mult.c
parentf916a735bcdce496cebc7653a8ad2e72b333405a (diff)
Move up check for EC_R_INCOMPATIBLE_OBJECTS and for the point at infinity case
Reviewed-by: Andy Polyakov <appro@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/6009) (cherry picked from commit 736b31e5ea33166d89d5cff5774697d0c15d96bd)
Diffstat (limited to 'crypto/ec/ec_mult.c')
-rw-r--r--crypto/ec/ec_mult.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/crypto/ec/ec_mult.c b/crypto/ec/ec_mult.c
index aa5097e5b8..f3227f7c66 100644
--- a/crypto/ec/ec_mult.c
+++ b/crypto/ec/ec_mult.c
@@ -376,6 +376,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.
@@ -402,15 +411,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);