Skip to content

Commit b1d6d55

Browse files
committed
Timing vulnerability in ECDSA signature generation (CVE-2018-0735)
Preallocate an extra limb for some of the big numbers to avoid a reallocation that can potentially provide a side channel. Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de> (Merged from #7486) (cherry picked from commit 99540ec)
1 parent 8abfe72 commit b1d6d55

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

crypto/ec/ec_mult.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ int ec_scalar_mul_ladder(const EC_GROUP *group, EC_POINT *r,
206206
*/
207207
cardinality_bits = BN_num_bits(cardinality);
208208
group_top = bn_get_top(cardinality);
209-
if ((bn_wexpand(k, group_top + 1) == NULL)
210-
|| (bn_wexpand(lambda, group_top + 1) == NULL)) {
209+
if ((bn_wexpand(k, group_top + 2) == NULL)
210+
|| (bn_wexpand(lambda, group_top + 2) == NULL)) {
211211
ECerr(EC_F_EC_SCALAR_MUL_LADDER, ERR_R_BN_LIB);
212212
goto err;
213213
}
@@ -244,7 +244,7 @@ int ec_scalar_mul_ladder(const EC_GROUP *group, EC_POINT *r,
244244
* k := scalar + 2*cardinality
245245
*/
246246
kbit = BN_is_bit_set(lambda, cardinality_bits);
247-
BN_consttime_swap(kbit, k, lambda, group_top + 1);
247+
BN_consttime_swap(kbit, k, lambda, group_top + 2);
248248

249249
group_top = bn_get_top(group->field);
250250
if ((bn_wexpand(s->X, group_top) == NULL)

0 commit comments

Comments
 (0)