diff options
author | Jack Lloyd <[email protected]> | 2018-02-23 12:31:03 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-02-23 12:31:03 -0500 |
commit | 8d9f83f87e146be428ad7d0684496f12cf34d4c8 (patch) | |
tree | 49873a798b00cf8f4714483df047553cca560d4a /src/lib/pubkey/dl_algo/dl_algo.cpp | |
parent | edf30c4474a161dba6abd16f86fa01917294839f (diff) |
Add DL_Group functions to verify elements
Diffstat (limited to 'src/lib/pubkey/dl_algo/dl_algo.cpp')
-rw-r--r-- | src/lib/pubkey/dl_algo/dl_algo.cpp | 32 |
1 files changed, 2 insertions, 30 deletions
diff --git a/src/lib/pubkey/dl_algo/dl_algo.cpp b/src/lib/pubkey/dl_algo/dl_algo.cpp index c5fc1e082..d31f927d7 100644 --- a/src/lib/pubkey/dl_algo/dl_algo.cpp +++ b/src/lib/pubkey/dl_algo/dl_algo.cpp @@ -68,22 +68,7 @@ DL_Scheme_PrivateKey::DL_Scheme_PrivateKey(const AlgorithmIdentifier& alg_id, bool DL_Scheme_PublicKey::check_key(RandomNumberGenerator& rng, bool strong) const { - const BigInt& p = group_p(); - - if(m_y < 2 || m_y >= p) - return false; - if(!m_group.verify_group(rng, strong)) - return false; - - const BigInt& q = group_q(); - - if(q.is_zero() == false) - { - if(power_mod(m_y, q, p) != 1) - return false; - } - - return true; + return m_group.verify_group(rng, strong) && m_group.verify_public_element(m_y); } /* @@ -92,20 +77,7 @@ bool DL_Scheme_PublicKey::check_key(RandomNumberGenerator& rng, bool DL_Scheme_PrivateKey::check_key(RandomNumberGenerator& rng, bool strong) const { - const BigInt& p = group_p(); - - if(m_y < 2 || m_y >= p || m_x < 2 || m_x >= p) - return false; - if(!m_group.verify_group(rng, strong)) - return false; - - if(!strong) - return true; - - if(m_y != m_group.power_g_p(m_x)) - return false; - - return true; + return m_group.verify_group(rng, strong) && m_group.verify_element_pair(m_y, m_x); } } |