From 04319af23bf8ed467b17f9b74c814343e051ab6b Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Mon, 21 Sep 2015 14:59:01 -0400 Subject: Remove use of lookup.h in favor of new T::create API. --- src/lib/misc/benchmark/benchmark.cpp | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'src/lib/misc/benchmark/benchmark.cpp') diff --git a/src/lib/misc/benchmark/benchmark.cpp b/src/lib/misc/benchmark/benchmark.cpp index 152b45d37..d5e3694b5 100644 --- a/src/lib/misc/benchmark/benchmark.cpp +++ b/src/lib/misc/benchmark/benchmark.cpp @@ -7,7 +7,6 @@ #include #include -#include #include #include #include @@ -56,10 +55,8 @@ time_algorithm_ops(const std::string& name, const double mb_mult = buffer.size() / static_cast(Mebibyte); - if(BlockCipher* p = get_block_cipher(name, provider)) + if(auto bc = BlockCipher::create(name, provider)) { - std::unique_ptr bc(p); - const SymmetricKey key(rng, bc->maximum_keylength()); return std::map({ @@ -68,10 +65,8 @@ time_algorithm_ops(const std::string& name, { "decrypt", mb_mult * time_op(runtime / 2, [&]() { bc->decrypt(buffer); }) }, }); } - else if(StreamCipher* p = get_stream_cipher(name, provider)) + else if(auto sc = StreamCipher::create(name, provider)) { - std::unique_ptr sc(p); - const SymmetricKey key(rng, sc->maximum_keylength()); return std::map({ @@ -79,18 +74,14 @@ time_algorithm_ops(const std::string& name, { "", mb_mult * time_op(runtime, [&]() { sc->encipher(buffer); }) }, }); } - else if(HashFunction* p = get_hash_function(name, provider)) + else if(auto h = HashFunction::create(name, provider)) { - std::unique_ptr h(p); - return std::map({ { "", mb_mult * time_op(runtime, [&]() { h->update(buffer); }) }, }); } - else if(MessageAuthenticationCode* p = get_mac(name, provider)) + else if(auto mac = MessageAuthenticationCode::create(name, provider)) { - std::unique_ptr mac(p); - const SymmetricKey key(rng, mac->maximum_keylength()); return std::map({ @@ -137,10 +128,10 @@ std::set get_all_providers_of(const std::string& algo) auto add_to_set = [&provs](const std::vector& str) { for(auto&& s : str) { provs.insert(s); } }; - add_to_set(get_block_cipher_providers(algo)); - add_to_set(get_stream_cipher_providers(algo)); - add_to_set(get_hash_function_providers(algo)); - add_to_set(get_mac_providers(algo)); + add_to_set(BlockCipher::providers(algo)); + add_to_set(StreamCipher::providers(algo)); + add_to_set(HashFunction::providers(algo)); + add_to_set(MessageAuthenticationCode::providers(algo)); return provs; } -- cgit v1.2.3