diff options
author | lloyd <[email protected]> | 2015-01-28 06:20:39 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2015-01-28 06:20:39 +0000 |
commit | 710229be83cdbc061949c61942896b5af9e134d8 (patch) | |
tree | 5a28c6d2cd456a5a686a332b7466ed9f326cc5f8 /src/lib/engine/asm_engine/asm_engine.cpp | |
parent | 7b56f1bd570dc684ffd7c945dee0d9b5480354ff (diff) |
Use Algo_Registry also for hashes.
Diffstat (limited to 'src/lib/engine/asm_engine/asm_engine.cpp')
-rw-r--r-- | src/lib/engine/asm_engine/asm_engine.cpp | 53 |
1 files changed, 10 insertions, 43 deletions
diff --git a/src/lib/engine/asm_engine/asm_engine.cpp b/src/lib/engine/asm_engine/asm_engine.cpp index 59be4a826..d30bae035 100644 --- a/src/lib/engine/asm_engine/asm_engine.cpp +++ b/src/lib/engine/asm_engine/asm_engine.cpp @@ -6,26 +6,7 @@ */ #include <botan/internal/asm_engine.h> - -#if defined(BOTAN_HAS_SERPENT_X86_32) - #include <botan/serp_x86_32.h> -#endif - -#if defined(BOTAN_HAS_MD4_X86_32) - #include <botan/md4_x86_32.h> -#endif - -#if defined(BOTAN_HAS_MD5_X86_32) - #include <botan/md5_x86_32.h> -#endif - -#if defined(BOTAN_HAS_SHA1_X86_64) - #include <botan/sha1_x86_64.h> -#endif - -#if defined(BOTAN_HAS_SHA1_X86_32) - #include <botan/sha1_x86_32.h> -#endif +#include <botan/algo_registry.h> namespace Botan { @@ -33,12 +14,10 @@ BlockCipher* Assembler_Engine::find_block_cipher(const SCAN_Name& request, Algorithm_Factory&) const { - if(request.algo_name() == "Serpent") - { -#if defined(BOTAN_HAS_SERPENT_X86_32) - return new Serpent_X86_32; -#endif - } + auto& block_cipher = Algo_Registry<BlockCipher>::global_registry(); + + if(BlockCipher* c = block_cipher.make(request, "x86-32")) + return c; return nullptr; } @@ -47,24 +26,12 @@ HashFunction* Assembler_Engine::find_hash(const SCAN_Name& request, Algorithm_Factory&) const { -#if defined(BOTAN_HAS_MD4_X86_32) - if(request.algo_name() == "MD4") - return new MD4_X86_32; -#endif - -#if defined(BOTAN_HAS_MD5_X86_32) - if(request.algo_name() == "MD5") - return new MD5_X86_32; -#endif + auto& hash_fns = Algo_Registry<HashFunction>::global_registry(); + if(HashFunction* c = hash_fns.make(request, "x86-64")) + return c; - if(request.algo_name() == "SHA-160") - { -#if defined(BOTAN_HAS_SHA1_X86_64) - return new SHA_160_X86_64; -#elif defined(BOTAN_HAS_SHA1_X86_32) - return new SHA_160_X86_32; -#endif - } + if(HashFunction* c = hash_fns.make(request, "x86-32")) + return c; return nullptr; } |