diff options
-rw-r--r-- | src/algo_factory/algo_factory.cpp | 2 | ||||
-rw-r--r-- | src/hash/sha1_amd64/info.txt | 2 | ||||
-rw-r--r-- | src/libstate/engine/amd64_eng/eng_amd64.cpp | 25 | ||||
-rw-r--r-- | src/libstate/engine/amd64_eng/eng_amd64.h | 24 | ||||
-rw-r--r-- | src/libstate/engine/amd64_eng/info.txt | 14 | ||||
-rw-r--r-- | src/libstate/engine/asm_engine/asm_engine.h | 27 | ||||
-rw-r--r-- | src/libstate/engine/asm_engine/info.txt | 10 | ||||
-rw-r--r-- | src/libstate/engine/ia32_eng/eng_ia32.cpp (renamed from src/libstate/engine/asm_engine/asm_engine.cpp) | 33 | ||||
-rw-r--r-- | src/libstate/engine/ia32_eng/eng_ia32.h | 27 | ||||
-rw-r--r-- | src/libstate/engine/ia32_eng/info.txt | 14 | ||||
-rw-r--r-- | src/libstate/engine/sse2_eng/eng_sse2.cpp | 25 | ||||
-rw-r--r-- | src/libstate/engine/sse2_eng/eng_sse2.h | 24 | ||||
-rw-r--r-- | src/libstate/engine/sse2_eng/info.txt | 15 | ||||
-rw-r--r-- | src/libstate/libstate.cpp | 31 |
14 files changed, 202 insertions, 71 deletions
diff --git a/src/algo_factory/algo_factory.cpp b/src/algo_factory/algo_factory.cpp index b5d088881..b8c428432 100644 --- a/src/algo_factory/algo_factory.cpp +++ b/src/algo_factory/algo_factory.cpp @@ -32,7 +32,7 @@ Algorithm_Factory::~Algorithm_Factory() void Algorithm_Factory::add_engine(Engine* engine) { engine->initialize(mutex_factory); - engines.push_back(engine); + engines.insert(engines.begin(), engine); } /************************************************* diff --git a/src/hash/sha1_amd64/info.txt b/src/hash/sha1_amd64/info.txt index be3b51ca2..ad473369a 100644 --- a/src/hash/sha1_amd64/info.txt +++ b/src/hash/sha1_amd64/info.txt @@ -1,5 +1,7 @@ realname "SHA-1 (x86-64 assembler)" +define SHA1_AMD64 + load_on auto <add> diff --git a/src/libstate/engine/amd64_eng/eng_amd64.cpp b/src/libstate/engine/amd64_eng/eng_amd64.cpp new file mode 100644 index 000000000..bdc73fdd6 --- /dev/null +++ b/src/libstate/engine/amd64_eng/eng_amd64.cpp @@ -0,0 +1,25 @@ +/** +* AMD64 Assembly Implementation Engine +* (C) 1999-2008 Jack Lloyd +*/ + +#include <botan/eng_amd64.h> + +#if defined(BOTAN_HAS_SHA1_AMD64) + #include <botan/sha1_amd64.h> +#endif + +namespace Botan { + +HashFunction* AMD64_Assembler_Engine::find_hash(const SCAN_Name& request, + Algorithm_Factory&) const + { +#if defined(BOTAN_HAS_SHA1_AMD64) + if(request.algo_name() == "SHA-160") + return new SHA_160_AMD64; +#endif + + return 0; + } + +} diff --git a/src/libstate/engine/amd64_eng/eng_amd64.h b/src/libstate/engine/amd64_eng/eng_amd64.h new file mode 100644 index 000000000..efd8c2b76 --- /dev/null +++ b/src/libstate/engine/amd64_eng/eng_amd64.h @@ -0,0 +1,24 @@ +/** +* x86-64 Assembly Implementation Engines +* (C) 1999-2008 Jack Lloyd +*/ + +#ifndef BOTAN_AMD64_ASM_ENGINE_H__ +#define BOTAN_AMD64_ASM_ENGINE_H__ + +#include <botan/engine.h> + +namespace Botan { + +class BOTAN_DLL AMD64_Assembler_Engine : public Engine + { + public: + std::string provider_name() const { return "amd64"; } + private: + HashFunction* find_hash(const SCAN_Name& reqeust, + Algorithm_Factory&) const; + }; + +} + +#endif diff --git a/src/libstate/engine/amd64_eng/info.txt b/src/libstate/engine/amd64_eng/info.txt new file mode 100644 index 000000000..1d0283ad6 --- /dev/null +++ b/src/libstate/engine/amd64_eng/info.txt @@ -0,0 +1,14 @@ +realname "AMD64 Assembler Engine" + +define ENGINE_AMD64_ASSEMBLER + +load_on auto + +<add> +eng_amd64.cpp +eng_amd64.h +</add> + +<arch> +amd64 +</arch> diff --git a/src/libstate/engine/asm_engine/asm_engine.h b/src/libstate/engine/asm_engine/asm_engine.h deleted file mode 100644 index 6a4188617..000000000 --- a/src/libstate/engine/asm_engine/asm_engine.h +++ /dev/null @@ -1,27 +0,0 @@ -/************************************************* -* Assembly Implementation Engine Header File * -* (C) 1999-2007 Jack Lloyd * -*************************************************/ - -#ifndef BOTAN_ASM_ENGINE_H__ -#define BOTAN_ASM_ENGINE_H__ - -#include <botan/engine.h> - -namespace Botan { - -class BOTAN_DLL Assembler_Engine : public Engine - { - public: - std::string provider_name() const { return "asm"; } - private: - BlockCipher* find_block_cipher(const SCAN_Name&, - Algorithm_Factory&) const; - - HashFunction* find_hash(const SCAN_Name& reqeust, - Algorithm_Factory&) const; - }; - -} - -#endif diff --git a/src/libstate/engine/asm_engine/info.txt b/src/libstate/engine/asm_engine/info.txt deleted file mode 100644 index 406b07412..000000000 --- a/src/libstate/engine/asm_engine/info.txt +++ /dev/null @@ -1,10 +0,0 @@ -realname "Assembler Engine" - -define ENGINE_ASSEMBLER - -load_on auto - -<add> -asm_engine.cpp -asm_engine.h -</add> diff --git a/src/libstate/engine/asm_engine/asm_engine.cpp b/src/libstate/engine/ia32_eng/eng_ia32.cpp index 9f113b1ce..0378c094e 100644 --- a/src/libstate/engine/asm_engine/asm_engine.cpp +++ b/src/libstate/engine/ia32_eng/eng_ia32.cpp @@ -3,8 +3,7 @@ * (C) 1999-2007 Jack Lloyd * *************************************************/ -#include <botan/asm_engine.h> -#include <botan/hash.h> +#include <botan/eng_ia32.h> #if defined(BOTAN_HAS_SERPENT_IA32) #include <botan/serp_ia32.h> @@ -22,19 +21,11 @@ #include <botan/sha1_ia32.h> #endif -#if defined(BOTAN_HAS_SHA1_SSE2) - #include <botan/sha1_sse2.h> -#endif - -#if defined(BOTAN_HAS_SHA1_AMD64) - #include <botan/sha1_amd64.h> -#endif - namespace Botan { BlockCipher* -Assembler_Engine::find_block_cipher(const SCAN_Name& request, - Algorithm_Factory&) const +IA32_Assembler_Engine::find_block_cipher(const SCAN_Name& request, + Algorithm_Factory&) const { #if defined(BOTAN_HAS_SERPENT_IA32) if(request.algo_name() == "Serpent") @@ -44,8 +35,9 @@ Assembler_Engine::find_block_cipher(const SCAN_Name& request, return 0; } -HashFunction* Assembler_Engine::find_hash(const SCAN_Name& request, - Algorithm_Factory&) const +HashFunction* +IA32_Assembler_Engine::find_hash(const SCAN_Name& request, + Algorithm_Factory&) const { #if defined(BOTAN_HAS_MD4_IA32) if(request.algo_name() == "MD4") @@ -57,21 +49,10 @@ HashFunction* Assembler_Engine::find_hash(const SCAN_Name& request, return new MD5_IA32; #endif -#if defined(BOTAN_HAS_SHA1_SSE2) || \ - defined(BOTAN_HAS_SHA1_AMD64) || \ - defined(BOTAN_HAS_SHA1_IA32) - +#if defined(BOTAN_HAS_SHA1_IA32) if(request.algo_name() == "SHA-160") - { -#if defined(BOTAN_HAS_SHA1_SSE2) - return new SHA_160_SSE2; -#elif defined(BOTAN_HAS_SHA1_AMD64) - return new SHA_160_AMD64; -#elif defined(BOTAN_HAS_SHA1_IA32) return new SHA_160_IA32; #endif - } -#endif return 0; } diff --git a/src/libstate/engine/ia32_eng/eng_ia32.h b/src/libstate/engine/ia32_eng/eng_ia32.h new file mode 100644 index 000000000..587728f2f --- /dev/null +++ b/src/libstate/engine/ia32_eng/eng_ia32.h @@ -0,0 +1,27 @@ +/** +* IA-32 Assembly Implementation Engines +* (C) 1999-2008 Jack Lloyd +*/ + +#ifndef BOTAN_IA32_ASM_ENGINE_H__ +#define BOTAN_IA32_ASM_ENGINE_H__ + +#include <botan/engine.h> + +namespace Botan { + +class BOTAN_DLL IA32_Assembler_Engine : public Engine + { + public: + std::string provider_name() const { return "ia32"; } + private: + BlockCipher* find_block_cipher(const SCAN_Name&, + Algorithm_Factory&) const; + + HashFunction* find_hash(const SCAN_Name& reqeust, + Algorithm_Factory&) const; + }; + +} + +#endif diff --git a/src/libstate/engine/ia32_eng/info.txt b/src/libstate/engine/ia32_eng/info.txt new file mode 100644 index 000000000..b9e3bddd5 --- /dev/null +++ b/src/libstate/engine/ia32_eng/info.txt @@ -0,0 +1,14 @@ +realname "IA32 Assembler Engine" + +define ENGINE_IA32_ASSEMBLER + +load_on auto + +<add> +eng_ia32.cpp +eng_ia32.h +</add> + +<arch> +ia32 +</arch> diff --git a/src/libstate/engine/sse2_eng/eng_sse2.cpp b/src/libstate/engine/sse2_eng/eng_sse2.cpp new file mode 100644 index 000000000..cf5a65114 --- /dev/null +++ b/src/libstate/engine/sse2_eng/eng_sse2.cpp @@ -0,0 +1,25 @@ +/** +* SSE2 Assembly Engine +* (C) 1999-2008 Jack Lloyd +*/ + +#include <botan/eng_sse2.h> + +#if defined(BOTAN_HAS_SHA1_SSE2) + #include <botan/sha1_sse2.h> +#endif + +namespace Botan { + +HashFunction* SSE2_Assembler_Engine::find_hash(const SCAN_Name& request, + Algorithm_Factory&) const + { +#if defined(BOTAN_HAS_SHA1_SSE2) + if(request.algo_name() == "SHA-160") + return new SHA_160_SSE2; +#endif + + return 0; + } + +} diff --git a/src/libstate/engine/sse2_eng/eng_sse2.h b/src/libstate/engine/sse2_eng/eng_sse2.h new file mode 100644 index 000000000..affbaff2e --- /dev/null +++ b/src/libstate/engine/sse2_eng/eng_sse2.h @@ -0,0 +1,24 @@ +/** +* SSE2 Assembly Engine +* (C) 1999-2008 Jack Lloyd +*/ + +#ifndef BOTAN_SSE2_ASM_ENGINE_H__ +#define BOTAN_SSE2_ASM_ENGINE_H__ + +#include <botan/engine.h> + +namespace Botan { + +class BOTAN_DLL SSE2_Assembler_Engine : public Engine + { + public: + std::string provider_name() const { return "sse2"; } + private: + HashFunction* find_hash(const SCAN_Name& reqeust, + Algorithm_Factory&) const; + }; + +} + +#endif diff --git a/src/libstate/engine/sse2_eng/info.txt b/src/libstate/engine/sse2_eng/info.txt new file mode 100644 index 000000000..c44180ca4 --- /dev/null +++ b/src/libstate/engine/sse2_eng/info.txt @@ -0,0 +1,15 @@ +realname "SSE2 Assembler Engine" + +define ENGINE_SSE2_ASSEMBLER + +load_on auto + +<add> +eng_sse2.cpp +eng_sse2.h +</add> + +<arch> +ia32 +amd64 +</arch> diff --git a/src/libstate/libstate.cpp b/src/libstate/libstate.cpp index 531ae7735..1e5f7aa8b 100644 --- a/src/libstate/libstate.cpp +++ b/src/libstate/libstate.cpp @@ -26,8 +26,16 @@ #include <botan/mmap_mem.h> #endif -#if defined(BOTAN_HAS_ENGINE_ASSEMBLER) - #include <botan/asm_engine.h> +#if defined(BOTAN_HAS_ENGINE_IA32_ASSEMBLER) + #include <botan/eng_ia32.h> +#endif + +#if defined(BOTAN_HAS_ENGINE_AMD64_ASSEMBLER) + #include <botan/eng_amd64.h> +#endif + +#if defined(BOTAN_HAS_ENGINE_SSE2_ASSEMBLER) + #include <botan/eng_sse2.h> #endif #if defined(BOTAN_HAS_ENGINE_GNU_MP) @@ -269,19 +277,28 @@ void Library_State::initialize(bool thread_safe) m_algorithm_factory = new Algorithm_Factory(*mutex_factory); -#if defined(BOTAN_HAS_ENGINE_GNU_MP) - m_algorithm_factory->add_engine(new GMP_Engine); + m_algorithm_factory->add_engine(new Default_Engine); + +#if defined(BOTAN_HAS_ENGINE_IA32_ASSEMBLER) + m_algorithm_factory->add_engine(new IA32_Assembler_Engine); +#endif + +#if defined(BOTAN_HAS_ENGINE_AMD64_ASSEMBLER) + m_algorithm_factory->add_engine(new AMD64_Assembler_Engine); +#endif + +#if defined(BOTAN_HAS_ENGINE_SSE2_ASSEMBLER) + m_algorithm_factory->add_engine(new SSE2_Assembler_Engine); #endif #if defined(BOTAN_HAS_ENGINE_OPENSSL) m_algorithm_factory->add_engine(new OpenSSL_Engine); #endif -#if defined(BOTAN_HAS_ENGINE_ASSEMBLER) - m_algorithm_factory->add_engine(new Assembler_Engine); +#if defined(BOTAN_HAS_ENGINE_GNU_MP) + m_algorithm_factory->add_engine(new GMP_Engine); #endif - m_algorithm_factory->add_engine(new Default_Engine); } /** |