diff options
author | lloyd <[email protected]> | 2015-03-04 04:30:20 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2015-03-04 04:30:20 +0000 |
commit | 2591a2cd863696b91128ff4a8461bb96d497e7b4 (patch) | |
tree | acb7a179a0790ec63c0c21ecb2ea9d7939e05248 /src/lib/kdf | |
parent | c794f78bd9b7eebc58c39fd00de90b26fb4cfb67 (diff) |
Hide Algorithm_Factory and use the functions in lookup.h internally.
Fix two memory leaks (in TLS and modes) caused by calling get_foo and
then cloning the result before saving it (leaking the original object),
a holdover from the conversion between construction techniques in 1.11.14
Diffstat (limited to 'src/lib/kdf')
-rw-r--r-- | src/lib/kdf/hkdf/hkdf.cpp | 4 | ||||
-rw-r--r-- | src/lib/kdf/prf_tls/prf_tls.cpp | 10 | ||||
-rw-r--r-- | src/lib/kdf/prf_x942/prf_x942.cpp | 2 |
3 files changed, 8 insertions, 8 deletions
diff --git a/src/lib/kdf/hkdf/hkdf.cpp b/src/lib/kdf/hkdf/hkdf.cpp index 8c92c779b..e725c3a4a 100644 --- a/src/lib/kdf/hkdf/hkdf.cpp +++ b/src/lib/kdf/hkdf/hkdf.cpp @@ -14,10 +14,10 @@ BOTAN_REGISTER_NAMED_T(KDF, "HKDF", HKDF, HKDF::make); HKDF* HKDF::make(const Spec& spec) { - if(auto mac = make_a<MessageAuthenticationCode>(spec.arg(0))) + if(auto mac = get_mac(spec.arg(0))) return new HKDF(mac); - if(auto mac = make_a<MessageAuthenticationCode>("HMAC(" + spec.arg(0) + ")")) + if(auto mac = get_mac("HMAC(" + spec.arg(0) + ")")) return new HKDF(mac); return nullptr; diff --git a/src/lib/kdf/prf_tls/prf_tls.cpp b/src/lib/kdf/prf_tls/prf_tls.cpp index 9161dc71e..2deb133e9 100644 --- a/src/lib/kdf/prf_tls/prf_tls.cpp +++ b/src/lib/kdf/prf_tls/prf_tls.cpp @@ -13,9 +13,9 @@ namespace Botan { TLS_12_PRF* TLS_12_PRF::make(const Spec& spec) { - if(auto mac = make_a<MessageAuthenticationCode>(spec.arg(0))) + if(auto mac = get_mac(spec.arg(0))) return new TLS_12_PRF(mac); - if(auto hash = make_a<HashFunction>(spec.arg(0))) + if(auto hash = get_hash_function(spec.arg(0))) return new TLS_12_PRF(new HMAC(hash)); return nullptr; } @@ -23,10 +23,10 @@ TLS_12_PRF* TLS_12_PRF::make(const Spec& spec) BOTAN_REGISTER_NAMED_T(KDF, "TLS-12-PRF", TLS_12_PRF, TLS_12_PRF::make); BOTAN_REGISTER_KDF_NOARGS(TLS_PRF, "TLS-PRF"); -TLS_PRF::TLS_PRF() +TLS_PRF::TLS_PRF() : + m_hmac_md5(make_message_auth("HMAC(MD5)")), + m_hmac_sha1(make_message_auth("HMAC(SHA-1)")) { - m_hmac_md5.reset(make_a<MessageAuthenticationCode>("HMAC(MD5)")); - m_hmac_sha1.reset(make_a<MessageAuthenticationCode>("HMAC(SHA-1)")); } namespace { diff --git a/src/lib/kdf/prf_x942/prf_x942.cpp b/src/lib/kdf/prf_x942/prf_x942.cpp index 5ca0f01ff..47e869bd5 100644 --- a/src/lib/kdf/prf_x942/prf_x942.cpp +++ b/src/lib/kdf/prf_x942/prf_x942.cpp @@ -35,7 +35,7 @@ size_t X942_PRF::kdf(byte key[], size_t key_len, const byte secret[], size_t secret_len, const byte salt[], size_t salt_len) const { - std::unique_ptr<HashFunction> hash(make_a<HashFunction>("SHA-160")); + std::unique_ptr<HashFunction> hash(make_hash_function("SHA-160")); const OID kek_algo(m_key_wrap_oid); secure_vector<byte> h; |