diff options
author | Jack Lloyd <[email protected]> | 2018-02-19 12:30:20 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-02-19 12:30:20 -0500 |
commit | b300eb0515b2a392793d887435b8ca44a1de7898 (patch) | |
tree | 44e6cdf1710f537a53098dad4e03d9caf6e79643 /src/lib/pubkey/dl_algo | |
parent | 4dcff1874ad430269bb7d75818b906b34331d919 (diff) |
Small fixes
Diffstat (limited to 'src/lib/pubkey/dl_algo')
-rw-r--r-- | src/lib/pubkey/dl_algo/dl_algo.cpp | 14 | ||||
-rw-r--r-- | src/lib/pubkey/dl_algo/dl_algo.h | 20 |
2 files changed, 18 insertions, 16 deletions
diff --git a/src/lib/pubkey/dl_algo/dl_algo.cpp b/src/lib/pubkey/dl_algo/dl_algo.cpp index c28ccaee0..0ac6bfce5 100644 --- a/src/lib/pubkey/dl_algo/dl_algo.cpp +++ b/src/lib/pubkey/dl_algo/dl_algo.cpp @@ -34,12 +34,17 @@ std::vector<uint8_t> DL_Scheme_PublicKey::public_key_bits() const return DER_Encoder().encode(m_y).get_contents_unlocked(); } +DL_Scheme_PublicKey::DL_Scheme_PublicKey(const DL_Group& group, const BigInt& y) : + m_y(y), + m_group(group) + { + } + DL_Scheme_PublicKey::DL_Scheme_PublicKey(const AlgorithmIdentifier& alg_id, const std::vector<uint8_t>& key_bits, - DL_Group::Format format) + DL_Group::Format format) : + m_group(alg_id.get_parameters(), format) { - m_group.BER_decode(alg_id.get_parameters(), format); - BER_Decoder(key_bits).decode(m_y); } @@ -91,7 +96,6 @@ bool DL_Scheme_PrivateKey::check_key(RandomNumberGenerator& rng, bool strong) const { const BigInt& p = group_p(); - const BigInt& g = group_g(); if(m_y < 2 || m_y >= p || m_x < 2 || m_x >= p) return false; @@ -101,7 +105,7 @@ bool DL_Scheme_PrivateKey::check_key(RandomNumberGenerator& rng, if(!strong) return true; - if(m_y != power_mod(g, m_x, p)) + if(m_y != m_group.power_g_p(m_x)) return false; return true; diff --git a/src/lib/pubkey/dl_algo/dl_algo.h b/src/lib/pubkey/dl_algo/dl_algo.h index 9364f4c5d..af01bc217 100644 --- a/src/lib/pubkey/dl_algo/dl_algo.h +++ b/src/lib/pubkey/dl_algo/dl_algo.h @@ -69,6 +69,11 @@ class BOTAN_PUBLIC_API(2,0) DL_Scheme_PublicKey : public virtual Public_Key size_t key_length() const override; size_t estimated_strength() const override; + DL_Scheme_PublicKey& operator=(const DL_Scheme_PublicKey& other) = default; + + protected: + DL_Scheme_PublicKey() = default; + /** * Create a public key. * @param alg_id the X.509 algorithm identifier @@ -79,14 +84,7 @@ class BOTAN_PUBLIC_API(2,0) DL_Scheme_PublicKey : public virtual Public_Key const std::vector<uint8_t>& key_bits, DL_Group::Format group_format); - DL_Scheme_PublicKey(const DL_Group& group, const BigInt& y) : - m_y(y), m_group(group) - {} - - DL_Scheme_PublicKey& operator=(const DL_Scheme_PublicKey& other) = default; - - protected: - DL_Scheme_PublicKey() = default; + DL_Scheme_PublicKey(const DL_Group& group, const BigInt& y); /** * The DL public key @@ -116,6 +114,9 @@ class BOTAN_PUBLIC_API(2,0) DL_Scheme_PrivateKey : public virtual DL_Scheme_Publ secure_vector<uint8_t> private_key_bits() const override; + DL_Scheme_PrivateKey& operator=(const DL_Scheme_PrivateKey& other) = default; + + protected: /** * Create a private key. * @param alg_id the X.509 algorithm identifier @@ -126,9 +127,6 @@ class BOTAN_PUBLIC_API(2,0) DL_Scheme_PrivateKey : public virtual DL_Scheme_Publ const secure_vector<uint8_t>& key_bits, DL_Group::Format group_format); - DL_Scheme_PrivateKey& operator=(const DL_Scheme_PrivateKey& other) = default; - - protected: DL_Scheme_PrivateKey() = default; /** |