diff options
Diffstat (limited to 'src/lib/pubkey')
-rw-r--r-- | src/lib/pubkey/blinding.cpp | 5 | ||||
-rw-r--r-- | src/lib/pubkey/curve25519/curve25519.h | 6 | ||||
-rw-r--r-- | src/lib/pubkey/dsa/dsa.cpp | 11 | ||||
-rw-r--r-- | src/lib/pubkey/ec_group/ec_group.h | 4 | ||||
-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/mce/gf2m_small_m.h | 2 | ||||
-rw-r--r-- | src/lib/pubkey/mce/mceliece.h | 4 | ||||
-rw-r--r-- | src/lib/pubkey/mce/polyn_gf2m.h | 2 | ||||
-rw-r--r-- | src/lib/pubkey/nr/nr.cpp | 11 | ||||
-rw-r--r-- | src/lib/pubkey/pk_ops_impl.h | 14 | ||||
-rw-r--r-- | src/lib/pubkey/pkcs8.h | 2 | ||||
-rw-r--r-- | src/lib/pubkey/rsa/rsa.cpp | 4 |
14 files changed, 35 insertions, 51 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/curve25519/curve25519.h b/src/lib/pubkey/curve25519/curve25519.h index c3e3d4e60..9d2868d6d 100644 --- a/src/lib/pubkey/curve25519/curve25519.h +++ b/src/lib/pubkey/curve25519/curve25519.h @@ -32,7 +32,7 @@ class BOTAN_DLL Curve25519_PublicKey : public virtual Public_Key Curve25519_PublicKey(const AlgorithmIdentifier& alg_id, const secure_vector<byte>& key_bits); - Curve25519_PublicKey(const secure_vector<byte>& pub) : m_public(pub) {} + explicit Curve25519_PublicKey(const secure_vector<byte>& pub) : m_public(pub) {} protected: Curve25519_PublicKey() {} secure_vector<byte> m_public; @@ -47,9 +47,9 @@ class BOTAN_DLL Curve25519_PrivateKey : public Curve25519_PublicKey, const secure_vector<byte>& key_bits, RandomNumberGenerator& rng); - Curve25519_PrivateKey(RandomNumberGenerator& rng); + explicit Curve25519_PrivateKey(RandomNumberGenerator& rng); - Curve25519_PrivateKey(const secure_vector<byte>& secret_key); + explicit Curve25519_PrivateKey(const secure_vector<byte>& secret_key); std::vector<byte> public_value() const override { return Curve25519_PublicKey::public_value(); } 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/ec_group/ec_group.h b/src/lib/pubkey/ec_group/ec_group.h index c7e52b238..a03b97a68 100644 --- a/src/lib/pubkey/ec_group/ec_group.h +++ b/src/lib/pubkey/ec_group/ec_group.h @@ -54,13 +54,13 @@ class BOTAN_DLL EC_Group * Decode a BER encoded ECC domain parameter set * @param ber_encoding the bytes of the BER encoding */ - EC_Group(const std::vector<byte>& ber_encoding); + explicit EC_Group(const std::vector<byte>& ber_encoding); /** * Create an EC domain by OID (or throw if unknown) * @param oid the OID of the EC domain to create */ - EC_Group(const OID& oid); + explicit EC_Group(const OID& oid); /** * Create an EC domain from PEM encoding (as from PEM_encode), or 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/mce/gf2m_small_m.h b/src/lib/pubkey/mce/gf2m_small_m.h index 6a8de4424..0b27a82e3 100644 --- a/src/lib/pubkey/mce/gf2m_small_m.h +++ b/src/lib/pubkey/mce/gf2m_small_m.h @@ -25,7 +25,7 @@ typedef u16bit gf2m; class BOTAN_DLL GF2m_Field { public: - GF2m_Field(size_t extdeg); + explicit GF2m_Field(size_t extdeg); gf2m gf_mul(gf2m x, gf2m y) const { diff --git a/src/lib/pubkey/mce/mceliece.h b/src/lib/pubkey/mce/mceliece.h index b9e54ec0e..311f0f253 100644 --- a/src/lib/pubkey/mce/mceliece.h +++ b/src/lib/pubkey/mce/mceliece.h @@ -21,7 +21,7 @@ namespace Botan { class BOTAN_DLL McEliece_PublicKey : public virtual Public_Key { public: - McEliece_PublicKey(const std::vector<byte>& key_bits); + explicit McEliece_PublicKey(const std::vector<byte>& key_bits); McEliece_PublicKey(std::vector<byte> const& pub_matrix, u32bit the_t, u32bit the_code_length) : m_public_matrix(pub_matrix), @@ -90,7 +90,7 @@ class BOTAN_DLL McEliece_PrivateKey : public virtual McEliece_PublicKey, */ McEliece_PrivateKey(RandomNumberGenerator& rng, size_t code_length, size_t t); - McEliece_PrivateKey(const secure_vector<byte>& key_bits); + explicit McEliece_PrivateKey(const secure_vector<byte>& key_bits); McEliece_PrivateKey(polyn_gf2m const& goppa_polyn, std::vector<u32bit> const& parity_check_matrix_coeffs, diff --git a/src/lib/pubkey/mce/polyn_gf2m.h b/src/lib/pubkey/mce/polyn_gf2m.h index 938c1f553..62264e480 100644 --- a/src/lib/pubkey/mce/polyn_gf2m.h +++ b/src/lib/pubkey/mce/polyn_gf2m.h @@ -27,7 +27,7 @@ struct polyn_gf2m /** * create a zero polynomial: */ - polyn_gf2m( std::shared_ptr<GF2m_Field> sp_field ); + explicit polyn_gf2m( std::shared_ptr<GF2m_Field> sp_field ); polyn_gf2m() :m_deg(-1) 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(); } diff --git a/src/lib/pubkey/pk_ops_impl.h b/src/lib/pubkey/pk_ops_impl.h index bda3434bf..9be65cf21 100644 --- a/src/lib/pubkey/pk_ops_impl.h +++ b/src/lib/pubkey/pk_ops_impl.h @@ -23,7 +23,7 @@ class Encryption_with_EME : public Encryption ~Encryption_with_EME(); protected: - Encryption_with_EME(const std::string& eme); + explicit Encryption_with_EME(const std::string& eme); private: virtual size_t max_raw_input_bits() const = 0; @@ -41,7 +41,7 @@ class Decryption_with_EME : public Decryption ~Decryption_with_EME(); protected: - Decryption_with_EME(const std::string& eme); + explicit Decryption_with_EME(const std::string& eme); private: virtual size_t max_raw_input_bits() const = 0; virtual secure_vector<byte> raw_decrypt(const byte msg[], size_t len) = 0; @@ -59,7 +59,7 @@ class Verification_with_EMSA : public Verification protected: - Verification_with_EMSA(const std::string& emsa); + explicit Verification_with_EMSA(const std::string& emsa); ~Verification_with_EMSA(); /** @@ -105,7 +105,7 @@ class Signature_with_EMSA : public Signature secure_vector<byte> sign(RandomNumberGenerator& rng) override; protected: - Signature_with_EMSA(const std::string& emsa); + explicit Signature_with_EMSA(const std::string& emsa); ~Signature_with_EMSA(); private: @@ -132,7 +132,7 @@ class Key_Agreement_with_KDF : public Key_Agreement const byte salt[], size_t salt_len) override; protected: - Key_Agreement_with_KDF(const std::string& kdf); + explicit Key_Agreement_with_KDF(const std::string& kdf); ~Key_Agreement_with_KDF(); private: virtual secure_vector<byte> raw_agree(const byte w[], size_t w_len) = 0; @@ -154,7 +154,7 @@ class KEM_Encryption_with_KDF : public KEM_Encryption secure_vector<byte>& raw_shared_key, Botan::RandomNumberGenerator& rng) = 0; - KEM_Encryption_with_KDF(const std::string& kdf); + explicit KEM_Encryption_with_KDF(const std::string& kdf); ~KEM_Encryption_with_KDF(); private: std::unique_ptr<KDF> m_kdf; @@ -173,7 +173,7 @@ class KEM_Decryption_with_KDF : public KEM_Decryption virtual secure_vector<byte> raw_kem_decrypt(const byte encap_key[], size_t len) = 0; - KEM_Decryption_with_KDF(const std::string& kdf); + explicit KEM_Decryption_with_KDF(const std::string& kdf); ~KEM_Decryption_with_KDF(); private: std::unique_ptr<KDF> m_kdf; diff --git a/src/lib/pubkey/pkcs8.h b/src/lib/pubkey/pkcs8.h index 9dc5265c7..791a612df 100644 --- a/src/lib/pubkey/pkcs8.h +++ b/src/lib/pubkey/pkcs8.h @@ -19,7 +19,7 @@ namespace Botan { */ struct BOTAN_DLL PKCS8_Exception : public Decoding_Error { - PKCS8_Exception(const std::string& error) : + explicit PKCS8_Exception(const std::string& error) : Decoding_Error("PKCS #8: " + error) {} }; diff --git a/src/lib/pubkey/rsa/rsa.cpp b/src/lib/pubkey/rsa/rsa.cpp index 18a694754..eb9fc2892 100644 --- a/src/lib/pubkey/rsa/rsa.cpp +++ b/src/lib/pubkey/rsa/rsa.cpp @@ -71,7 +71,7 @@ class RSA_Private_Operation protected: size_t get_max_input_bits() const { return (m_n.bits() - 1); } - RSA_Private_Operation(const RSA_PrivateKey& rsa) : + explicit RSA_Private_Operation(const RSA_PrivateKey& rsa) : m_n(rsa.get_n()), m_q(rsa.get_q()), m_c(rsa.get_c()), @@ -190,7 +190,7 @@ class RSA_KEM_Decryption_Operation : public PK_Ops::KEM_Decryption_with_KDF, class RSA_Public_Operation { public: - RSA_Public_Operation(const RSA_PublicKey& rsa) : + explicit RSA_Public_Operation(const RSA_PublicKey& rsa) : m_n(rsa.get_n()), m_powermod_e_n(rsa.get_e(), rsa.get_n()) {} |