]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Don't use coordinate blinding when scalar is group order
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Fri, 12 Apr 2019 12:28:00 +0000 (14:28 +0200)
committerBernd Edlinger <bernd.edlinger@hotmail.de>
Sun, 14 Apr 2019 09:24:08 +0000 (11:24 +0200)
This happens in ec_key_simple_check_key and EC_GROUP_check.
Since the the group order is not a secret scalar, it is
unnecessary to use coordinate blinding.

Fixes: #8731
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8734)

crypto/ec/ec_mult.c

index 755d64400a18269768c73ddb551978d82cf12c64..968125f3cdc5bd066f48f3ab50006f74b484eafc 100644 (file)
@@ -441,7 +441,7 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
          * scalar multiplication implementation based on a Montgomery ladder,
          * with various timing attack defenses.
          */
-        if ((scalar != NULL) && (num == 0)) {
+        if ((scalar != group->order) && (scalar != NULL) && (num == 0)) {
             /*-
              * In this case we want to compute scalar * GeneratorPoint: this
              * codepath is reached most prominently by (ephemeral) key
@@ -452,7 +452,7 @@ int ec_wNAF_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar,
              */
             return ec_scalar_mul_ladder(group, r, scalar, NULL, ctx);
         }
-        if ((scalar == NULL) && (num == 1)) {
+        if ((scalar == NULL) && (num == 1) && (scalars[0] != group->order)) {
             /*-
              * In this case we want to compute scalar * VariablePoint: this
              * codepath is reached most prominently by the second half of ECDH,