aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-11-24 00:39:06 +0000
committerlloyd <[email protected]>2009-11-24 00:39:06 +0000
commit404462c4dda58af79a7cf53da790a86bdae4633e (patch)
tree441fe91b4da4a97e875b090ad9673a7b6499dba5 /src
parent798230f8e6893e0a8e4eed3cd3215cb5fef13154 (diff)
Make sure the SIMD_32 implementation we're using actually works on the
system before returning a new instance.
Diffstat (limited to 'src')
-rw-r--r--src/engine/simd_engine/simd_engine.cpp4
-rw-r--r--src/utils/simd_32/simd_altivec.h2
-rw-r--r--src/utils/simd_32/simd_scalar.h2
-rw-r--r--src/utils/simd_32/simd_sse.h2
4 files changed, 7 insertions, 3 deletions
diff --git a/src/engine/simd_engine/simd_engine.cpp b/src/engine/simd_engine/simd_engine.cpp
index 7e15f9ec1..fdb1644d0 100644
--- a/src/engine/simd_engine/simd_engine.cpp
+++ b/src/engine/simd_engine/simd_engine.cpp
@@ -6,6 +6,7 @@
*/
#include <botan/simd_engine.h>
+#include <botan/simd_32.h>
#include <botan/cpuid.h>
#if defined(BOTAN_HAS_SERPENT_SIMD)
@@ -26,6 +27,9 @@ BlockCipher*
SIMD_Engine::find_block_cipher(const SCAN_Name& request,
Algorithm_Factory&) const
{
+ if(!SIMD_32::enabled())
+ return 0;
+
#if defined(BOTAN_HAS_SERPENT_SIMD)
if(request.algo_name() == "Serpent")
return new Serpent_SIMD;
diff --git a/src/utils/simd_32/simd_altivec.h b/src/utils/simd_32/simd_altivec.h
index 3e784a8c4..e1704e76c 100644
--- a/src/utils/simd_32/simd_altivec.h
+++ b/src/utils/simd_32/simd_altivec.h
@@ -20,7 +20,7 @@ namespace Botan {
class SIMD_Altivec
{
public:
- bool enabled() const { return CPUID::has_altivec(); }
+ static bool enabled() { return CPUID::has_altivec(); }
SIMD_Altivec(const u32bit B[4])
{
diff --git a/src/utils/simd_32/simd_scalar.h b/src/utils/simd_32/simd_scalar.h
index 398503d33..148b76c35 100644
--- a/src/utils/simd_32/simd_scalar.h
+++ b/src/utils/simd_32/simd_scalar.h
@@ -16,7 +16,7 @@ namespace Botan {
class SIMD_Scalar
{
public:
- bool enabled() const { return true; }
+ static bool enabled() { return true; }
SIMD_Scalar(const u32bit B[4])
{
diff --git a/src/utils/simd_32/simd_sse.h b/src/utils/simd_32/simd_sse.h
index 81d8afe75..9f03b3733 100644
--- a/src/utils/simd_32/simd_sse.h
+++ b/src/utils/simd_32/simd_sse.h
@@ -17,7 +17,7 @@ namespace Botan {
class SIMD_SSE2
{
public:
- bool enabled() const { return CPUID::has_sse2(); }
+ static bool enabled() { return CPUID::has_sse2(); }
SIMD_SSE2(const u32bit B[4])
{