diff options
author | Jack Lloyd <[email protected]> | 2018-04-20 10:30:04 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-04-20 10:30:04 -0400 |
commit | c90d868a533c13501e8d6e3b71919501b9d70f9e (patch) | |
tree | b9a28e5edb1c172d334d79d91be2588eed1a1d59 /src/lib | |
parent | 1177467fbae03f2370f7f20d692a95b484616923 (diff) |
Use EC_Group::inverse_mod_order where appropriate
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/pubkey/ecc_key/ecc_key.cpp | 7 | ||||
-rw-r--r-- | src/lib/pubkey/gost_3410/gost_3410.cpp | 2 |
2 files changed, 3 insertions, 6 deletions
diff --git a/src/lib/pubkey/ecc_key/ecc_key.cpp b/src/lib/pubkey/ecc_key/ecc_key.cpp index 7c46a2fa0..2c23c1b47 100644 --- a/src/lib/pubkey/ecc_key/ecc_key.cpp +++ b/src/lib/pubkey/ecc_key/ecc_key.cpp @@ -118,8 +118,6 @@ EC_PrivateKey::EC_PrivateKey(RandomNumberGenerator& rng, else m_domain_encoding = EC_DOMPAR_ENC_EXPLICIT; - const BigInt& order = m_domain_params.get_order(); - if(x == 0) { m_private_key = ec_group.random_scalar(rng); @@ -133,7 +131,7 @@ EC_PrivateKey::EC_PrivateKey(RandomNumberGenerator& rng, if(with_modular_inverse) { // ECKCDSA - m_public_key = domain().get_base_point() * inverse_mod(m_private_key, order); + m_public_key = domain().get_base_point() * m_domain_params.inverse_mod_order(m_private_key); } else { @@ -183,8 +181,7 @@ EC_PrivateKey::EC_PrivateKey(const AlgorithmIdentifier& alg_id, if(with_modular_inverse) { // ECKCDSA - const BigInt& order = m_domain_params.get_order(); - m_public_key = domain().get_base_point() * inverse_mod(m_private_key, order); + m_public_key = domain().get_base_point() * m_domain_params.inverse_mod_order(m_private_key); } else { diff --git a/src/lib/pubkey/gost_3410/gost_3410.cpp b/src/lib/pubkey/gost_3410/gost_3410.cpp index b0c94fb7e..1d1b0d75e 100644 --- a/src/lib/pubkey/gost_3410/gost_3410.cpp +++ b/src/lib/pubkey/gost_3410/gost_3410.cpp @@ -185,7 +185,7 @@ bool GOST_3410_Verification_Operation::verify(const uint8_t msg[], size_t msg_le if(e == 0) e = 1; - const BigInt v = inverse_mod(e, order); + const BigInt v = m_group.inverse_mod_order(e); const BigInt z1 = m_group.multiply_mod_order(s, v); const BigInt z2 = m_group.multiply_mod_order(-r, v); |