diff options
author | Daniel Neus <[email protected]> | 2016-01-11 11:55:42 +0100 |
---|---|---|
committer | Daniel Neus <[email protected]> | 2016-03-05 19:50:29 +0100 |
commit | f95cd9245d2e889a756b187452dafaf68e795179 (patch) | |
tree | d0d8afe2159821f3c89545ea7711fba05c97e720 /src/lib/pubkey | |
parent | a3ce0bd1e9e018ea69741c4380bf065cccedec93 (diff) |
Remaining cppcheck fixes that are not covered by GH #444
Diffstat (limited to 'src/lib/pubkey')
-rw-r--r-- | src/lib/pubkey/blinding.cpp | 5 | ||||
-rw-r--r-- | src/lib/pubkey/dsa/dsa.cpp | 11 | ||||
-rw-r--r-- | src/lib/pubkey/ecc_key/ecc_key.cpp | 9 | ||||
-rw-r--r-- | src/lib/pubkey/ecc_key/ecc_key.h | 3 | ||||
-rw-r--r-- | src/lib/pubkey/if_algo/if_algo.cpp | 9 | ||||
-rw-r--r-- | src/lib/pubkey/nr/nr.cpp | 11 |
6 files changed, 16 insertions, 32 deletions
diff --git a/src/lib/pubkey/blinding.cpp b/src/lib/pubkey/blinding.cpp index 4a5c5acff..b20a30fa1 100644 --- a/src/lib/pubkey/blinding.cpp +++ b/src/lib/pubkey/blinding.cpp @@ -19,11 +19,8 @@ namespace Botan { Blinder::Blinder(const BigInt& modulus, std::function<BigInt (const BigInt&)> fwd, std::function<BigInt (const BigInt&)> inv) : - m_fwd_fn(fwd), m_inv_fn(inv) + m_reducer{Modular_Reducer(modulus)}, m_rng{}, m_fwd_fn(fwd), m_inv_fn(inv), m_modulus_bits{modulus.bits()}, m_e{}, m_d{}, m_counter{} { - m_reducer = Modular_Reducer(modulus); - m_modulus_bits = modulus.bits(); - #if defined(BOTAN_HAS_SYSTEM_RNG) m_rng.reset(new System_RNG); #else diff --git a/src/lib/pubkey/dsa/dsa.cpp b/src/lib/pubkey/dsa/dsa.cpp index 63b7bd07e..471189cd8 100644 --- a/src/lib/pubkey/dsa/dsa.cpp +++ b/src/lib/pubkey/dsa/dsa.cpp @@ -140,13 +140,10 @@ class DSA_Verification_Operation : public PK_Ops::Verification_with_EMSA DSA_Verification_Operation(const DSA_PublicKey& dsa, const std::string& emsa) : PK_Ops::Verification_with_EMSA(emsa), - m_q(dsa.group_q()), m_y(dsa.get_y()) - { - m_powermod_g_p = Fixed_Base_Power_Mod(dsa.group_g(), dsa.group_p()); - m_powermod_y_p = Fixed_Base_Power_Mod(m_y, dsa.group_p()); - m_mod_p = Modular_Reducer(dsa.group_p()); - m_mod_q = Modular_Reducer(dsa.group_q()); - } + m_q(dsa.group_q()), m_y(dsa.get_y()), m_powermod_g_p{Fixed_Base_Power_Mod(dsa.group_g(), dsa.group_p())}, + m_powermod_y_p{Fixed_Base_Power_Mod(m_y, dsa.group_p())}, m_mod_p{Modular_Reducer(dsa.group_p())}, + m_mod_q{Modular_Reducer(dsa.group_q())} + {} size_t message_parts() const override { return 2; } size_t message_part_size() const override { return m_q.bytes(); } diff --git a/src/lib/pubkey/ecc_key/ecc_key.cpp b/src/lib/pubkey/ecc_key/ecc_key.cpp index a3f0ea93d..2dca20725 100644 --- a/src/lib/pubkey/ecc_key/ecc_key.cpp +++ b/src/lib/pubkey/ecc_key/ecc_key.cpp @@ -33,13 +33,8 @@ EC_PublicKey::EC_PublicKey(const EC_Group& dom_par, } EC_PublicKey::EC_PublicKey(const AlgorithmIdentifier& alg_id, - const secure_vector<byte>& key_bits) - { - m_domain_params = EC_Group(alg_id.parameters); - m_domain_encoding = EC_DOMPAR_ENC_EXPLICIT; - - m_public_key = OS2ECP(key_bits, domain().get_curve()); - } + const secure_vector<byte>& key_bits) : m_domain_params{EC_Group(alg_id.parameters)}, m_public_key{OS2ECP(key_bits, domain().get_curve())}, m_domain_encoding{EC_DOMPAR_ENC_EXPLICIT} + {} bool EC_PublicKey::check_key(RandomNumberGenerator&, bool) const diff --git a/src/lib/pubkey/ecc_key/ecc_key.h b/src/lib/pubkey/ecc_key/ecc_key.h index 3557d0266..3f93a908c 100644 --- a/src/lib/pubkey/ecc_key/ecc_key.h +++ b/src/lib/pubkey/ecc_key/ecc_key.h @@ -81,7 +81,8 @@ class BOTAN_DLL EC_PublicKey : public virtual Public_Key size_t estimated_strength() const override; protected: - EC_PublicKey() : m_domain_encoding(EC_DOMPAR_ENC_EXPLICIT) {} + EC_PublicKey() : m_domain_params{}, m_public_key{}, m_domain_encoding(EC_DOMPAR_ENC_EXPLICIT) + {} EC_Group m_domain_params; PointGFp m_public_key; diff --git a/src/lib/pubkey/if_algo/if_algo.cpp b/src/lib/pubkey/if_algo/if_algo.cpp index a79cad116..e5f3ae20f 100644 --- a/src/lib/pubkey/if_algo/if_algo.cpp +++ b/src/lib/pubkey/if_algo/if_algo.cpp @@ -97,13 +97,11 @@ IF_Scheme_PrivateKey::IF_Scheme_PrivateKey(RandomNumberGenerator& rng, const BigInt& prime2, const BigInt& exp, const BigInt& d_exp, - const BigInt& mod) + const BigInt& mod) : + m_d{ d_exp }, m_p{ prime1 }, m_q{ prime2 }, m_d1{}, m_d2{}, m_c{ inverse_mod( m_q, m_p ) } { - m_p = prime1; - m_q = prime2; - m_e = exp; - m_d = d_exp; m_n = mod.is_nonzero() ? mod : m_p * m_q; + m_e = exp; if(m_d == 0) { @@ -116,7 +114,6 @@ IF_Scheme_PrivateKey::IF_Scheme_PrivateKey(RandomNumberGenerator& rng, m_d1 = m_d % (m_p - 1); m_d2 = m_d % (m_q - 1); - m_c = inverse_mod(m_q, m_p); load_check(rng); } diff --git a/src/lib/pubkey/nr/nr.cpp b/src/lib/pubkey/nr/nr.cpp index 64e08a111..5e2cb1be5 100644 --- a/src/lib/pubkey/nr/nr.cpp +++ b/src/lib/pubkey/nr/nr.cpp @@ -144,13 +144,10 @@ class NR_Verification_Operation : public PK_Ops::Verification_with_EMSA typedef NR_PublicKey Key_Type; NR_Verification_Operation(const NR_PublicKey& nr, const std::string& emsa) : PK_Ops::Verification_with_EMSA(emsa), - m_q(nr.group_q()), m_y(nr.get_y()) - { - m_powermod_g_p = Fixed_Base_Power_Mod(nr.group_g(), nr.group_p()); - m_powermod_y_p = Fixed_Base_Power_Mod(m_y, nr.group_p()); - m_mod_p = Modular_Reducer(nr.group_p()); - m_mod_q = Modular_Reducer(nr.group_q()); - } + m_q(nr.group_q()), m_y(nr.get_y()), m_powermod_g_p{Fixed_Base_Power_Mod(nr.group_g(), nr.group_p())}, + m_powermod_y_p{Fixed_Base_Power_Mod(m_y, nr.group_p())}, m_mod_p{Modular_Reducer(nr.group_p())}, + m_mod_q{Modular_Reducer(nr.group_q())} + {} size_t message_parts() const override { return 2; } size_t message_part_size() const override { return m_q.bytes(); } |