diff options
author | Jack Lloyd <[email protected]> | 2018-12-16 20:33:49 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-12-18 10:20:35 -0500 |
commit | 70aa7303acfff9eefc24598c289a84db3579ebd1 (patch) | |
tree | 56506633ac75588c95c7b9277e61e13d932aa85e /src/lib/pubkey/ecc_key | |
parent | c36f2885b896de0db5713b1bda0a294fc4060909 (diff) |
Avoid using unblinded Montgomery ladder during ECC key generation
As doing so means that information about the high bits of the scalar can leak
via timing since the loop bound depends on the length of the scalar. An attacker
who has such information can perform a more efficient brute force attack (using
Pollard's rho) than would be possible otherwise.
Found by Ján Jančár (@J08nY) using ECTester (https://github.com/crocs-muni/ECTester)
CVE-2018-20187
Diffstat (limited to 'src/lib/pubkey/ecc_key')
-rw-r--r-- | src/lib/pubkey/ecc_key/ecc_key.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/pubkey/ecc_key/ecc_key.cpp b/src/lib/pubkey/ecc_key/ecc_key.cpp index 767a799bf..5a97e7a50 100644 --- a/src/lib/pubkey/ecc_key/ecc_key.cpp +++ b/src/lib/pubkey/ecc_key/ecc_key.cpp @@ -127,15 +127,17 @@ EC_PrivateKey::EC_PrivateKey(RandomNumberGenerator& rng, m_private_key = x; } - // Can't use rng here because ffi load functions use Null_RNG + std::vector<BigInt> ws; + if(with_modular_inverse) { // ECKCDSA - m_public_key = domain().get_base_point() * m_domain_params.inverse_mod_order(m_private_key); + m_public_key = domain().blinded_base_point_multiply( + m_domain_params.inverse_mod_order(m_private_key), rng, ws); } else { - m_public_key = domain().get_base_point() * m_private_key; + m_public_key = domain().blinded_base_point_multiply(m_private_key, rng, ws); } BOTAN_ASSERT(m_public_key.on_the_curve(), |