[crypto/ec] for ECC parameters with NULL or zero cofactor, compute it
authorBilly Brumley <bbrumley@gmail.com>
Sat, 7 Sep 2019 07:50:58 +0000 (10:50 +0300)
committerMatt Caswell <matt@openssl.org>
Mon, 9 Sep 2019 07:34:44 +0000 (08:34 +0100)
commit21c856b75d81eff61aa63b4f036bb64a85bf6d46
tree58a7a798cb4b90065ebefac4cccde3b58f8ca99d
parentadaebd81a01e2926a3106feec0476db7c8d7b362
[crypto/ec] for ECC parameters with NULL or zero cofactor, compute it

The cofactor argument to EC_GROUP_set_generator is optional, and SCA
mitigations for ECC currently use it. So the library currently falls
back to very old SCA-vulnerable code if the cofactor is not present.

This PR allows EC_GROUP_set_generator to compute the cofactor for all
curves of cryptographic interest. Steering scalar multiplication to more
SCA-robust code.

This issue affects persisted private keys in explicit parameter form,
where the (optional) cofactor field is zero or absent.

It also affects curves not built-in to the library, but constructed
programatically with explicit parameters, then calling
EC_GROUP_set_generator with a nonsensical value (NULL, zero).

The very old scalar multiplication code is known to be vulnerable to
local uarch attacks, outside of the OpenSSL threat model. New results
suggest the code path is also vulnerable to traditional wall clock
timing attacks.

CVE-2019-1547

Reviewed-by: Nicola Tuveri <nic.tuv@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9799)
CHANGES
crypto/ec/ec.h
crypto/ec/ec_err.c
crypto/ec/ec_lib.c