diff options
author | Jack Lloyd <[email protected]> | 2016-11-03 13:11:18 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2016-11-03 13:11:18 -0400 |
commit | 660d985e92d030f4ec0c3503bc14363825183371 (patch) | |
tree | 8daeec407eab8f5dc7c00f83b08fc687abe9a8d9 /src/lib/pubkey/ecies | |
parent | e42d1513fd6f80dcd2ae4109fddf53b61e935116 (diff) |
Simplify some code by using T::create_or_throw
Diffstat (limited to 'src/lib/pubkey/ecies')
-rw-r--r-- | src/lib/pubkey/ecies/ecies.cpp | 21 | ||||
-rw-r--r-- | src/lib/pubkey/ecies/ecies.h | 7 |
2 files changed, 7 insertions, 21 deletions
diff --git a/src/lib/pubkey/ecies/ecies.cpp b/src/lib/pubkey/ecies/ecies.cpp index ba7140bd0..fbf98cbad 100644 --- a/src/lib/pubkey/ecies/ecies.cpp +++ b/src/lib/pubkey/ecies/ecies.cpp @@ -143,8 +143,7 @@ SymmetricKey ECIES_KA_Operation::derive_secret(const std::vector<byte>& eph_publ throw Invalid_Argument("ECIES: other public key point is zero"); } - std::unique_ptr<KDF> kdf = m_params.create_kdf(); - BOTAN_ASSERT(kdf != nullptr, "KDF is found"); + std::unique_ptr<KDF> kdf = Botan::KDF::create_or_throw(m_params.kdf_spec()); PointGFp other_point = other_public_key_point; @@ -184,17 +183,6 @@ ECIES_KA_Params::ECIES_KA_Params(const EC_Group& domain, const std::string& kdf_ { } -std::unique_ptr<KDF> ECIES_KA_Params::create_kdf() const - { - std::unique_ptr<KDF> kdf = Botan::KDF::create(m_kdf_spec); - if(kdf == nullptr) - { - throw Algorithm_Not_Found(m_kdf_spec); - } - return kdf; - } - - ECIES_System_Params::ECIES_System_Params(const EC_Group& domain, const std::string& kdf_spec, const std::string& dem_algo_spec, size_t dem_key_len, const std::string& mac_spec, size_t mac_key_len, @@ -222,12 +210,7 @@ ECIES_System_Params::ECIES_System_Params(const EC_Group& domain, const std::stri std::unique_ptr<MessageAuthenticationCode> ECIES_System_Params::create_mac() const { - std::unique_ptr<MessageAuthenticationCode> mac = Botan::MessageAuthenticationCode::create(m_mac_spec); - if(mac == nullptr) - { - throw Algorithm_Not_Found(m_mac_spec); - } - return mac; + return Botan::MessageAuthenticationCode::create_or_throw(m_mac_spec); } std::unique_ptr<Cipher_Mode> ECIES_System_Params::create_cipher(Botan::Cipher_Dir direction) const diff --git a/src/lib/pubkey/ecies/ecies.h b/src/lib/pubkey/ecies/ecies.h index 94b0bd576..3f7a2e48b 100644 --- a/src/lib/pubkey/ecies/ecies.h +++ b/src/lib/pubkey/ecies/ecies.h @@ -70,8 +70,6 @@ class BOTAN_DLL ECIES_KA_Params virtual ~ECIES_KA_Params() = default; - std::unique_ptr<KDF> create_kdf() const; - inline const EC_Group& domain() const { return m_domain; @@ -107,6 +105,11 @@ class BOTAN_DLL ECIES_KA_Params return m_compression_mode; } + const std::string& kdf_spec() const + { + return m_kdf_spec; + } + private: const EC_Group m_domain; const std::string m_kdf_spec; |