diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/pubkey/dl_algo/dl_algo.cpp | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/lib/pubkey/dl_algo/dl_algo.cpp b/src/lib/pubkey/dl_algo/dl_algo.cpp index 472b979b1..85576e9bf 100644 --- a/src/lib/pubkey/dl_algo/dl_algo.cpp +++ b/src/lib/pubkey/dl_algo/dl_algo.cpp @@ -35,8 +35,8 @@ std::vector<byte> DL_Scheme_PublicKey::public_key_bits() const } DL_Scheme_PublicKey::DL_Scheme_PublicKey(const AlgorithmIdentifier& alg_id, - const std::vector<byte>& key_bits, - DL_Group::Format format) + const std::vector<byte>& key_bits, + DL_Group::Format format) { m_group.BER_decode(alg_id.parameters, format); @@ -49,8 +49,8 @@ secure_vector<byte> DL_Scheme_PrivateKey::private_key_bits() const } DL_Scheme_PrivateKey::DL_Scheme_PrivateKey(const AlgorithmIdentifier& alg_id, - const secure_vector<byte>& key_bits, - DL_Group::Format format) + const secure_vector<byte>& key_bits, + DL_Group::Format format) { m_group.BER_decode(alg_id.parameters, format); @@ -63,12 +63,24 @@ DL_Scheme_PrivateKey::DL_Scheme_PrivateKey(const AlgorithmIdentifier& alg_id, bool DL_Scheme_PublicKey::check_key(RandomNumberGenerator& rng, bool strong) const { - if(m_y < 2 || m_y >= group_p()) + const BigInt& p = group_p(); + + if(m_y < 2 || m_y >= p) return false; if(!m_group.verify_group(rng, strong)) return false; - if(power_mod(m_y,group_q(),group_p()) != 1) - return false; + + try + { + const BigInt& q = group_q(); + if(power_mod(m_y, q, p) != 1) + return false; + } + catch(const Invalid_State& e) + { + return true; + } + return true; } |