From 966464c71c43e7c389540a795bb45ea3c3e73262 Mon Sep 17 00:00:00 2001 From: lloyd Date: Tue, 11 Nov 2008 19:53:07 +0000 Subject: Make a change in how providers are requiested in Algorithm_Factory to the engines. Unfortunately right now Botan doesn't understand that a construction like HMAC, while the basic HMAC class lives only in core, can use any of a variety of implementations as the underlying algorithm. The previous version got this completely wrong (basically the first time a particular HMAC was requested, one hash provider would be chosen at random). Now instead we always use the same subprovider. This means HMAC(SHA-1) won't see a speedup even if there is an asm version available (similarly, CMAC(AES) wouldn't see a speedup with OpenSSL's AES or an engine that provided AES using VIA's or Intel's extensions). Certainly a major deficiency, but I haven't worked out how to fix it yet. --- src/algo_factory/algo_factory.cpp | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'src/algo_factory/algo_factory.cpp') diff --git a/src/algo_factory/algo_factory.cpp b/src/algo_factory/algo_factory.cpp index e30d6d98b..cc2601496 100644 --- a/src/algo_factory/algo_factory.cpp +++ b/src/algo_factory/algo_factory.cpp @@ -85,8 +85,12 @@ Algorithm_Factory::prototype_block_cipher(const SCAN_Name& request) for(u32bit i = 0; i != engines.size(); ++i) { - if(BlockCipher* impl = engines[i]->find_block_cipher(request, *this)) - block_cipher_cache.add(impl, request.as_string(), engines[i]->provider_name()); + const std::string provider = engines[i]->provider_name(); + + SCAN_Name request_i(request.as_string(), provider); + + if(BlockCipher* impl = engines[i]->find_block_cipher(request_i, *this)) + block_cipher_cache.add(impl, request.as_string(), provider); } return block_cipher_cache.get(request); @@ -122,8 +126,12 @@ Algorithm_Factory::prototype_stream_cipher(const SCAN_Name& request) for(u32bit i = 0; i != engines.size(); ++i) { - if(StreamCipher* impl = engines[i]->find_stream_cipher(request, *this)) - stream_cipher_cache.add(impl, request.as_string(), engines[i]->provider_name()); + const std::string provider = engines[i]->provider_name(); + + SCAN_Name request_i(request.as_string(), provider); + + if(StreamCipher* impl = engines[i]->find_stream_cipher(request_i, *this)) + stream_cipher_cache.add(impl, request.as_string(), provider); } return stream_cipher_cache.get(request); @@ -159,8 +167,12 @@ Algorithm_Factory::prototype_hash_function(const SCAN_Name& request) for(u32bit i = 0; i != engines.size(); ++i) { - if(HashFunction* impl = engines[i]->find_hash(request, *this)) - hash_cache.add(impl, request.as_string(), engines[i]->provider_name()); + const std::string provider = engines[i]->provider_name(); + + SCAN_Name request_i(request.as_string(), provider); + + if(HashFunction* impl = engines[i]->find_hash(request_i, *this)) + hash_cache.add(impl, request.as_string(), provider); } return hash_cache.get(request); @@ -196,8 +208,12 @@ Algorithm_Factory::prototype_mac(const SCAN_Name& request) for(u32bit i = 0; i != engines.size(); ++i) { - if(MessageAuthenticationCode* impl = engines[i]->find_mac(request, *this)) - mac_cache.add(impl, request.as_string(), engines[i]->provider_name()); + const std::string provider = engines[i]->provider_name(); + + SCAN_Name request_i(request.as_string(), provider); + + if(MessageAuthenticationCode* impl = engines[i]->find_mac(request_i, *this)) + mac_cache.add(impl, request.as_string(), provider); } return mac_cache.get(request); -- cgit v1.2.3