diff options
Diffstat (limited to 'src/lib/engine/simd_engine/simd_engine.cpp')
-rw-r--r-- | src/lib/engine/simd_engine/simd_engine.cpp | 64 |
1 files changed, 10 insertions, 54 deletions
diff --git a/src/lib/engine/simd_engine/simd_engine.cpp b/src/lib/engine/simd_engine/simd_engine.cpp index af5f5d524..35d9cdad4 100644 --- a/src/lib/engine/simd_engine/simd_engine.cpp +++ b/src/lib/engine/simd_engine/simd_engine.cpp @@ -6,33 +6,9 @@ */ #include <botan/internal/simd_engine.h> -#include <botan/internal/simd_32.h> +#include <botan/algo_registry.h> #include <botan/cpuid.h> -#if defined(BOTAN_HAS_AES_SSSE3) - #include <botan/aes_ssse3.h> -#endif - -#if defined(BOTAN_HAS_SERPENT_SIMD) - #include <botan/serp_simd.h> -#endif - -#if defined(BOTAN_HAS_THREEFISH_512_AVX2) - #include <botan/threefish_avx2.h> -#endif - -#if defined(BOTAN_HAS_NOEKEON_SIMD) - #include <botan/noekeon_simd.h> -#endif - -#if defined(BOTAN_HAS_XTEA_SIMD) - #include <botan/xtea_simd.h> -#endif - -#if defined(BOTAN_HAS_IDEA_SSE2) - #include <botan/idea_sse2.h> -#endif - #if defined(BOTAN_HAS_SHA1_SSE2) #include <botan/sha1_sse2.h> #endif @@ -43,39 +19,19 @@ BlockCipher* SIMD_Engine::find_block_cipher(const SCAN_Name& request, Algorithm_Factory&) const { -#if defined(BOTAN_HAS_AES_SSSE3) - if(request.algo_name() == "AES-128" && CPUID::has_ssse3()) - return new AES_128_SSSE3; - if(request.algo_name() == "AES-192" && CPUID::has_ssse3()) - return new AES_192_SSSE3; - if(request.algo_name() == "AES-256" && CPUID::has_ssse3()) - return new AES_256_SSSE3; -#endif + auto& block_cipher = Algo_Registry<BlockCipher>::global_registry(); -#if defined(BOTAN_HAS_IDEA_SSE2) - if(request.algo_name() == "IDEA" && CPUID::has_sse2()) - return new IDEA_SSE2; -#endif + if(BlockCipher* c = block_cipher.make(request, "avx2")) + return c; -#if defined(BOTAN_HAS_NOEKEON_SIMD) - if(request.algo_name() == "Noekeon" && SIMD_32::enabled()) - return new Noekeon_SIMD; -#endif + if(BlockCipher* c = block_cipher.make(request, "ssse3")) + return c; -#if defined(BOTAN_HAS_THREEFISH_512_AVX2) - if(request.algo_name() == "Threefish-512" && CPUID::has_avx2()) - return new Threefish_512_AVX2; -#endif - -#if defined(BOTAN_HAS_SERPENT_SIMD) - if(request.algo_name() == "Serpent" && SIMD_32::enabled()) - return new Serpent_SIMD; -#endif + if(BlockCipher* c = block_cipher.make(request, "sse2")) + return c; -#if defined(BOTAN_HAS_XTEA_SIMD) - if(request.algo_name() == "XTEA" && SIMD_32::enabled()) - return new XTEA_SIMD; -#endif + if(BlockCipher* c = block_cipher.make(request, "simd32")) + return c; return nullptr; } |