diff options
author | lloyd <[email protected]> | 2009-10-29 01:40:43 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-10-29 01:40:43 +0000 |
commit | 1bc4d2fb37c8f1e6e94a65ec67062826393dda7f (patch) | |
tree | a6d686a796d255d0e1b55ac341d79236a41b018f | |
parent | 16adc6a5424aad033a18bae872586a52e54d7d8e (diff) |
Rename SSE2 stuff to be generally SIMD since it supports at least SSE2
and Altivec (though Altivec is seemingly slower ATM...)
16 files changed, 126 insertions, 135 deletions
diff --git a/src/block/serpent_simd/info.txt b/src/block/serpent_simd/info.txt new file mode 100644 index 000000000..4ec5d0dfe --- /dev/null +++ b/src/block/serpent_simd/info.txt @@ -0,0 +1,9 @@ +realname "Serpent (SIMD)" + +define SERPENT_SIMD + +<requires> +serpent +simd_32 +simd_engine +</requires> diff --git a/src/block/serpent_sse2/serp_sse2.cpp b/src/block/serpent_simd/serp_simd.cpp index be79e870d..b394b0c26 100644 --- a/src/block/serpent_sse2/serp_sse2.cpp +++ b/src/block/serpent_simd/serp_simd.cpp @@ -5,8 +5,8 @@ * Distributed under the terms of the Botan license */ -#include <botan/serp_sse2.h> -#include <botan/serp_sse2_sbox.h> +#include <botan/serp_simd.h> +#include <botan/serp_simd_sbox.h> #include <botan/simd_32.h> #include <botan/loadstor.h> @@ -54,7 +54,7 @@ namespace { } while(0); /* -* SSE2 Serpent Encryption of 4 blocks in parallel +* SIMD Serpent Encryption of 4 blocks in parallel */ void serpent_encrypt_4(const byte in[64], byte out[64], @@ -112,7 +112,7 @@ void serpent_encrypt_4(const byte in[64], } /* -* SSE2 Serpent Decryption of 4 blocks in parallel +* SIMD Serpent Decryption of 4 blocks in parallel */ void serpent_decrypt_4(const byte in[64], byte out[64], @@ -174,7 +174,7 @@ void serpent_decrypt_4(const byte in[64], /* * Serpent Encryption */ -void Serpent_SSE2::encrypt_n(const byte in[], byte out[], u32bit blocks) const +void Serpent_SIMD::encrypt_n(const byte in[], byte out[], u32bit blocks) const { while(blocks >= 4) { @@ -190,7 +190,7 @@ void Serpent_SSE2::encrypt_n(const byte in[], byte out[], u32bit blocks) const /* * Serpent Decryption */ -void Serpent_SSE2::decrypt_n(const byte in[], byte out[], u32bit blocks) const +void Serpent_SIMD::decrypt_n(const byte in[], byte out[], u32bit blocks) const { while(blocks >= 4) { diff --git a/src/block/serpent_sse2/serp_sse2.h b/src/block/serpent_simd/serp_simd.h index f1e5c2028..1ecb70159 100644 --- a/src/block/serpent_sse2/serp_sse2.h +++ b/src/block/serpent_simd/serp_simd.h @@ -1,12 +1,12 @@ /* -* Serpent (SSE2) +* Serpent (SIMD) * (C) 2009 Jack Lloyd * * Distributed under the terms of the Botan license */ -#ifndef BOTAN_SERPENT_SSE2_H__ -#define BOTAN_SERPENT_SSE2_H__ +#ifndef BOTAN_SERPENT_SIMD_H__ +#define BOTAN_SERPENT_SIMD_H__ #include <botan/serpent.h> @@ -15,13 +15,13 @@ namespace Botan { /* * Serpent */ -class BOTAN_DLL Serpent_SSE2 : public Serpent +class BOTAN_DLL Serpent_SIMD : public Serpent { public: void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; - BlockCipher* clone() const { return new Serpent_SSE2; } + BlockCipher* clone() const { return new Serpent_SIMD; } }; } diff --git a/src/block/serpent_sse2/serp_sse2_sbox.h b/src/block/serpent_simd/serp_simd_sbox.h index 6e3da7359..6e3da7359 100644 --- a/src/block/serpent_sse2/serp_sse2_sbox.h +++ b/src/block/serpent_simd/serp_simd_sbox.h diff --git a/src/block/serpent_sse2/info.txt b/src/block/serpent_sse2/info.txt deleted file mode 100644 index da7eef6bc..000000000 --- a/src/block/serpent_sse2/info.txt +++ /dev/null @@ -1,8 +0,0 @@ -realname "Serpent (SSE2)" - -define SERPENT_SSE2 - -<requires> -serpent -sse2_eng -</requires> diff --git a/src/block/xtea_simd/info.txt b/src/block/xtea_simd/info.txt new file mode 100644 index 000000000..0cdce14ef --- /dev/null +++ b/src/block/xtea_simd/info.txt @@ -0,0 +1,16 @@ +realname "XTEA (SIMD)" + +define XTEA_SIMD + +load_on auto + +<add> +xtea_simd.cpp +xtea_simd.h +</add> + +<requires> +xtea +simd_32 +simd_engine +</requires> diff --git a/src/block/xtea_sse2/xtea_sse2.cpp b/src/block/xtea_simd/xtea_simd.cpp index 5d9c7dd05..6151c355c 100644 --- a/src/block/xtea_sse2/xtea_sse2.cpp +++ b/src/block/xtea_simd/xtea_simd.cpp @@ -5,7 +5,7 @@ * Distributed under the terms of the Botan license */ -#include <botan/xtea_sse2.h> +#include <botan/xtea_simd.h> #include <botan/loadstor.h> #include <botan/simd_32.h> @@ -92,7 +92,7 @@ void xtea_decrypt_8(const byte in[64], byte out[64], const u32bit EK[64]) /* * XTEA Encryption */ -void XTEA_SSE2::encrypt_n(const byte in[], byte out[], u32bit blocks) const +void XTEA_SIMD::encrypt_n(const byte in[], byte out[], u32bit blocks) const { while(blocks >= 8) { @@ -108,7 +108,7 @@ void XTEA_SSE2::encrypt_n(const byte in[], byte out[], u32bit blocks) const /* * XTEA Decryption */ -void XTEA_SSE2::decrypt_n(const byte in[], byte out[], u32bit blocks) const +void XTEA_SIMD::decrypt_n(const byte in[], byte out[], u32bit blocks) const { while(blocks >= 8) { diff --git a/src/block/xtea_sse2/xtea_sse2.h b/src/block/xtea_simd/xtea_simd.h index e691e5c40..e4ce734ed 100644 --- a/src/block/xtea_sse2/xtea_sse2.h +++ b/src/block/xtea_simd/xtea_simd.h @@ -1,26 +1,26 @@ /* -* XTEA in SSE2 +* XTEA in SIMD * (C) 2009 Jack Lloyd * * Distributed under the terms of the Botan license */ -#ifndef BOTAN_XTEA_SSE2_H__ -#define BOTAN_XTEA_SSE2_H__ +#ifndef BOTAN_XTEA_SIMD_H__ +#define BOTAN_XTEA_SIMD_H__ #include <botan/xtea.h> namespace Botan { /* -* XTEA (SSE2 variant) +* XTEA (SIMD variant) */ -class BOTAN_DLL XTEA_SSE2 : public XTEA +class BOTAN_DLL XTEA_SIMD : public XTEA { public: void encrypt_n(const byte in[], byte out[], u32bit blocks) const; void decrypt_n(const byte in[], byte out[], u32bit blocks) const; - BlockCipher* clone() const { return new XTEA_SSE2; } + BlockCipher* clone() const { return new XTEA_SIMD; } }; } diff --git a/src/block/xtea_sse2/info.txt b/src/block/xtea_sse2/info.txt deleted file mode 100644 index edcdd114d..000000000 --- a/src/block/xtea_sse2/info.txt +++ /dev/null @@ -1,15 +0,0 @@ -realname "XTEA (SSE2)" - -define XTEA_SSE2 - -load_on auto - -<add> -xtea_sse2.cpp -xtea_sse2.h -</add> - -<requires> -xtea -sse2_eng -</requires> diff --git a/src/engine/simd_engine/info.txt b/src/engine/simd_engine/info.txt new file mode 100644 index 000000000..b19664491 --- /dev/null +++ b/src/engine/simd_engine/info.txt @@ -0,0 +1,5 @@ +realname "SIMD Engine" + +define ENGINE_SIMD + +load_on dep diff --git a/src/engine/simd_engine/simd_engine.cpp b/src/engine/simd_engine/simd_engine.cpp new file mode 100644 index 000000000..7e15f9ec1 --- /dev/null +++ b/src/engine/simd_engine/simd_engine.cpp @@ -0,0 +1,54 @@ +/** +* SIMD Engine +* (C) 1999-2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#include <botan/simd_engine.h> +#include <botan/cpuid.h> + +#if defined(BOTAN_HAS_SERPENT_SIMD) + #include <botan/serp_simd.h> +#endif + +#if defined(BOTAN_HAS_XTEA_SIMD) + #include <botan/xtea_simd.h> +#endif + +#if defined(BOTAN_HAS_SHA1_SSE2) + #include <botan/sha1_sse2.h> +#endif + +namespace Botan { + +BlockCipher* +SIMD_Engine::find_block_cipher(const SCAN_Name& request, + Algorithm_Factory&) const + { +#if defined(BOTAN_HAS_SERPENT_SIMD) + if(request.algo_name() == "Serpent") + return new Serpent_SIMD; +#endif + +#if defined(BOTAN_HAS_XTEA_SIMD) + if(request.algo_name() == "XTEA") + return new XTEA_SIMD; +#endif + + return 0; + } + +HashFunction* +SIMD_Engine::find_hash(const SCAN_Name& request, + Algorithm_Factory&) const + { +#if defined(BOTAN_HAS_SHA1_SSE2) + if(request.algo_name() == "SHA-160" && CPUID::has_sse2()) + return new SHA_160_SSE2; +#endif + + return 0; + } + +} diff --git a/src/engine/sse2_eng/eng_sse2.h b/src/engine/simd_engine/simd_engine.h index c6b0ce889..f7df6ff77 100644 --- a/src/engine/sse2_eng/eng_sse2.h +++ b/src/engine/simd_engine/simd_engine.h @@ -1,18 +1,18 @@ /** -* SSE2 Assembly Engine +* SIMD Assembly Engine * (C) 1999-2009 Jack Lloyd * * Distributed under the terms of the Botan license */ -#ifndef BOTAN_SSE2_ASM_ENGINE_H__ -#define BOTAN_SSE2_ASM_ENGINE_H__ +#ifndef BOTAN_SIMD_ENGINE_H__ +#define BOTAN_SIMD_ENGINE_H__ #include <botan/engine.h> namespace Botan { -class BOTAN_DLL SSE2_Assembler_Engine : public Engine +class BOTAN_DLL SIMD_Engine : public Engine { public: std::string provider_name() const { return "sse2"; } diff --git a/src/engine/sse2_eng/eng_sse2.cpp b/src/engine/sse2_eng/eng_sse2.cpp deleted file mode 100644 index 51b7d04e3..000000000 --- a/src/engine/sse2_eng/eng_sse2.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/** -* SSE2 Assembly Engine -* (C) 1999-2009 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#include <botan/eng_sse2.h> -#include <botan/cpuid.h> - -#if defined(BOTAN_HAS_SHA1_SSE2) - #include <botan/sha1_sse2.h> -#endif - -#if defined(BOTAN_HAS_SERPENT_SSE2) - #include <botan/serp_sse2.h> -#endif - -#if defined(BOTAN_HAS_XTEA_SSE2) - #include <botan/xtea_sse2.h> -#endif - -namespace Botan { - -BlockCipher* -SSE2_Assembler_Engine::find_block_cipher(const SCAN_Name& request, - Algorithm_Factory&) const - { - if(!CPUID::has_sse2()) - return 0; - -#if defined(BOTAN_HAS_SERPENT_SSE2) - if(request.algo_name() == "Serpent") - return new Serpent_SSE2; -#endif - -#if defined(BOTAN_HAS_XTEA_SSE2) - if(request.algo_name() == "XTEA") - return new XTEA_SSE2; -#endif - - return 0; - } - -HashFunction* -SSE2_Assembler_Engine::find_hash(const SCAN_Name& request, - Algorithm_Factory&) const - { - if(!CPUID::has_sse2()) - return 0; - -#if defined(BOTAN_HAS_SHA1_SSE2) - if(request.algo_name() == "SHA-160") - return new SHA_160_SSE2; -#endif - - return 0; - } - -} diff --git a/src/engine/sse2_eng/info.txt b/src/engine/sse2_eng/info.txt deleted file mode 100644 index 7508b9874..000000000 --- a/src/engine/sse2_eng/info.txt +++ /dev/null @@ -1,23 +0,0 @@ -realname "SSE2 Assembler Engine" - -define ENGINE_SSE2_ASSEMBLER - -load_on dep - -<add> -eng_sse2.cpp -eng_sse2.h -</add> - -<arch> -pentium-m -pentium4 -prescott -amd64 -</arch> - -<cc> -gcc -icc -msvc -</cc> diff --git a/src/hash/sha1_sse2/info.txt b/src/hash/sha1_sse2/info.txt index 4a7a1b5e9..a5a5200cf 100644 --- a/src/hash/sha1_sse2/info.txt +++ b/src/hash/sha1_sse2/info.txt @@ -4,5 +4,18 @@ define SHA1_SSE2 <requires> sha1 -sse2_eng +simd_engine </requires> + +<arch> +pentium-m +pentium4 +prescott +amd64 +</arch> + +<cc> +gcc +icc +msvc +</cc> diff --git a/src/libstate/libstate.cpp b/src/libstate/libstate.cpp index ca454458b..c78bce62d 100644 --- a/src/libstate/libstate.cpp +++ b/src/libstate/libstate.cpp @@ -37,8 +37,8 @@ #include <botan/eng_amd64.h> #endif -#if defined(BOTAN_HAS_ENGINE_SSE2_ASSEMBLER) - #include <botan/eng_sse2.h> +#if defined(BOTAN_HAS_ENGINE_SIMD) + #include <botan/simd_engine.h> #endif #if defined(BOTAN_HAS_ENGINE_GNU_MP) @@ -288,8 +288,8 @@ void Library_State::initialize(bool thread_safe) engines.push_back(new OpenSSL_Engine); #endif -#if defined(BOTAN_HAS_ENGINE_SSE2_ASSEMBLER) - engines.push_back(new SSE2_Assembler_Engine); +#if defined(BOTAN_HAS_ENGINE_SIMD) + engines.push_back(new SIMD_Engine); #endif #if defined(BOTAN_HAS_ENGINE_AMD64_ASSEMBLER) |