Make BN_GF2m_mod_arr more constant time
authorMatt Caswell <matt@openssl.org>
Wed, 16 May 2018 08:58:27 +0000 (09:58 +0100)
committerMatt Caswell <matt@openssl.org>
Thu, 17 May 2018 16:11:41 +0000 (17:11 +0100)
commit7e5292ba04deb0fb01e5628bf2e3b32c7d19977d
tree7a0c23884e3734409cc30f1abbfa074facf80fd7
parentfe4fe67139bc1e1abb62035d9eb0992f614bf645
Make BN_GF2m_mod_arr more constant time

Experiments have shown that the lookup table used by BN_GF2m_mod_arr
introduces sufficient timing signal to recover the private key for an
attacker with access to cache timing information on the victim's host.
This only affects binary curves (which are less frequently used).

No CVE is considered necessary for this issue.

The fix is to replace the lookup table with an on-the-fly calculation of
the value from the table instead, which can be performed in constant time.

Thanks to Youngjoo Shin for reporting this issue.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/6270)

(cherry picked from commit b336ce57f2d5cca803a920d2a9e622b588cead3c)
crypto/bn/bn_gf2m.c