From 03f41b6ceb6e9dcfbe4b134239431de43afd7e6b Mon Sep 17 00:00:00 2001 From: lloyd Date: Fri, 25 Sep 2009 11:51:55 +0000 Subject: Add runtime cpuid support. Check in the SSE2 engine that SSE2 is actually existing on the current CPU before returning an object. --- src/engine/sse2_eng/eng_sse2.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/engine') diff --git a/src/engine/sse2_eng/eng_sse2.cpp b/src/engine/sse2_eng/eng_sse2.cpp index 9f68a070e..07c625c7c 100644 --- a/src/engine/sse2_eng/eng_sse2.cpp +++ b/src/engine/sse2_eng/eng_sse2.cpp @@ -6,6 +6,7 @@ */ #include +#include #if defined(BOTAN_HAS_SHA1_SSE2) #include @@ -21,6 +22,9 @@ 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; @@ -33,6 +37,9 @@ 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; -- cgit v1.2.3