diff options
author | Jack Lloyd <[email protected]> | 2015-09-21 14:59:01 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2015-09-21 14:59:01 -0400 |
commit | 04319af23bf8ed467b17f9b74c814343e051ab6b (patch) | |
tree | 630d1a0cc931e77e7e1f07319e5cf89d00af4458 /src/lib/kdf | |
parent | 408ea0a9b8ed0f575f8ee26891473920b42ef026 (diff) |
Remove use of lookup.h in favor of new T::create API.
Diffstat (limited to 'src/lib/kdf')
-rw-r--r-- | src/lib/kdf/hkdf/hkdf.cpp | 9 | ||||
-rw-r--r-- | src/lib/kdf/prf_tls/prf_tls.cpp | 17 | ||||
-rw-r--r-- | src/lib/kdf/prf_x942/prf_x942.cpp | 3 |
3 files changed, 15 insertions, 14 deletions
diff --git a/src/lib/kdf/hkdf/hkdf.cpp b/src/lib/kdf/hkdf/hkdf.cpp index d4c688afc..6f83853f9 100644 --- a/src/lib/kdf/hkdf/hkdf.cpp +++ b/src/lib/kdf/hkdf/hkdf.cpp @@ -6,17 +6,16 @@ */ #include <botan/hkdf.h> -#include <botan/lookup.h> namespace Botan { HKDF* HKDF::make(const Spec& spec) { - if(auto mac = get_mac(spec.arg(0))) - return new HKDF(mac); + if(auto mac = MessageAuthenticationCode::create(spec.arg(0))) + return new HKDF(mac.release()); - if(auto mac = get_mac("HMAC(" + spec.arg(0) + ")")) - return new HKDF(mac); + if(auto mac = MessageAuthenticationCode::create("HMAC(" + spec.arg(0) + ")")) + return new HKDF(mac.release()); return nullptr; } diff --git a/src/lib/kdf/prf_tls/prf_tls.cpp b/src/lib/kdf/prf_tls/prf_tls.cpp index 382f527ea..547b0c9c8 100644 --- a/src/lib/kdf/prf_tls/prf_tls.cpp +++ b/src/lib/kdf/prf_tls/prf_tls.cpp @@ -7,23 +7,26 @@ #include <botan/prf_tls.h> #include <botan/hmac.h> -#include <botan/lookup.h> namespace Botan { TLS_12_PRF* TLS_12_PRF::make(const Spec& spec) { - if(auto mac = get_mac(spec.arg(0))) - return new TLS_12_PRF(mac); - if(auto hash = get_hash_function(spec.arg(0))) - return new TLS_12_PRF(new HMAC(hash)); + if(auto mac = MessageAuthenticationCode::create(spec.arg(0))) + return new TLS_12_PRF(mac.release()); + + if(auto mac = MessageAuthenticationCode::create("HMAC(" + spec.arg(0) + ")")) + return new TLS_12_PRF(mac.release()); + return nullptr; } TLS_PRF::TLS_PRF() : - m_hmac_md5(make_message_auth("HMAC(MD5)")), - m_hmac_sha1(make_message_auth("HMAC(SHA-1)")) + m_hmac_md5(MessageAuthenticationCode::create("HMAC(MD5)")), + m_hmac_sha1(MessageAuthenticationCode::create("HMAC(SHA-1)")) { + if(!m_hmac_md5 || !m_hmac_sha1) + throw Algorithm_Not_Found("TLS_PRF HMACs not available"); } namespace { diff --git a/src/lib/kdf/prf_x942/prf_x942.cpp b/src/lib/kdf/prf_x942/prf_x942.cpp index 443e207f2..fb8de1e85 100644 --- a/src/lib/kdf/prf_x942/prf_x942.cpp +++ b/src/lib/kdf/prf_x942/prf_x942.cpp @@ -10,7 +10,6 @@ #include <botan/oids.h> #include <botan/hash.h> #include <botan/loadstor.h> -#include <botan/lookup.h> #include <algorithm> namespace Botan { @@ -33,7 +32,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_hash_function("SHA-160")); + std::unique_ptr<HashFunction> hash(HashFunction::create("SHA-160")); const OID kek_algo(m_key_wrap_oid); secure_vector<byte> h; |