aboutsummaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-09-29 17:43:36 +0000
committerlloyd <[email protected]>2008-09-29 17:43:36 +0000
commit26abd45c61294aacdd59fa4763ff1cd78aefbc7c (patch)
tree3ef4a44cd659d0b5442d2c6d8b3e9539fc23bb05 /src/core
parentba722ad52627163f945fd9fa97ff98f0df8452d1 (diff)
Make asm implementations distinctly named objects, for instance MD5_IA32,
rather than silently replacing the C++ versions. Instead they are silently replaced (currently, at least) at the lookup level: we switch off the set of feature macros set to choose the best implementation in the current build configuration. So you can have (and benchmark) MD5 and MD5_IA32 directly against each other in the same program with no hassles, but if you ask for "MD5", you'll get maybe an MD5 or maybe MD5_IA32. Also make the canonical asm names (which aren't guarded by C++ namespaces) of the form botan_<algo>_<arch>_<func> as in botan_sha160_ia32_compress, to avoid namespace collisions. This change has another bonus that it should in many cases be possible to derive the asm specializations directly from the original implementation, saving some code (and of course logically SHA_160_IA32 is a SHA_160, just one with a faster implementation of the compression function, so this seems reasonable anyway).
Diffstat (limited to 'src/core')
-rw-r--r--src/core/def_alg.cpp44
1 files changed, 40 insertions, 4 deletions
diff --git a/src/core/def_alg.cpp b/src/core/def_alg.cpp
index b13439fe2..cad5dca5a 100644
--- a/src/core/def_alg.cpp
+++ b/src/core/def_alg.cpp
@@ -80,6 +80,10 @@
#include <botan/serpent.h>
#endif
+#if defined(BOTAN_HAS_SERPENT_IA32)
+ #include <botan/serp_ia32.h>
+#endif
+
#if defined(BOTAN_HAS_SKIPJACK)
#include <botan/skipjack.h>
#endif
@@ -148,10 +152,18 @@
#include <botan/md4.h>
#endif
+#if defined(BOTAN_HAS_MD4_IA32)
+ #include <botan/md4_ia32.h>
+#endif
+
#if defined(BOTAN_HAS_MD5)
#include <botan/md5.h>
#endif
+#if defined(BOTAN_HAS_MD5_IA32)
+ #include <botan/md5_ia32.h>
+#endif
+
#if defined(BOTAN_HAS_RIPEMD_128)
#include <botan/rmd128.h>
#endif
@@ -164,6 +176,18 @@
#include <botan/sha160.h>
#endif
+#if defined(BOTAN_HAS_SHA1_IA32)
+ #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
+
#if defined(BOTAN_HAS_SHA2)
#include <botan/sha256.h>
#include <botan/sha_64.h>
@@ -333,7 +357,9 @@ Default_Engine::find_block_cipher(const std::string& algo_spec) const
HANDLE_TYPE_NO_ARGS("SEED", SEED);
#endif
-#if defined(BOTAN_HAS_SERPENT)
+#if defined(BOTAN_HAS_SERPENT_IA32)
+ HANDLE_TYPE_NO_ARGS("Serpent", Serpent_IA32);
+#elif defined(BOTAN_HAS_SERPENT)
HANDLE_TYPE_NO_ARGS("Serpent", Serpent);
#endif
@@ -444,11 +470,15 @@ Default_Engine::find_hash(const std::string& algo_spec) const
HANDLE_TYPE_NO_ARGS("MD2", MD2);
#endif
-#if defined(BOTAN_HAS_MD4)
+#if defined(BOTAN_HAS_MD4_IA32)
+ HANDLE_TYPE_NO_ARGS("MD4", MD4_IA32);
+#elif defined(BOTAN_HAS_MD4)
HANDLE_TYPE_NO_ARGS("MD4", MD4);
#endif
-#if defined(BOTAN_HAS_MD5)
+#if defined(BOTAN_HAS_MD5_IA32)
+ HANDLE_TYPE_NO_ARGS("MD5", MD5_IA32);
+#elif defined(BOTAN_HAS_MD5)
HANDLE_TYPE_NO_ARGS("MD5", MD5);
#endif
@@ -460,7 +490,13 @@ Default_Engine::find_hash(const std::string& algo_spec) const
HANDLE_TYPE_NO_ARGS("RIPEMD-160", RIPEMD_160);
#endif
-#if defined(BOTAN_HAS_SHA1)
+#if defined(BOTAN_HAS_SHA1_SSE2)
+ HANDLE_TYPE_NO_ARGS("SHA-160", SHA_160_SSE2);
+#elif defined(BOTAN_HAS_SHA1_AMD64)
+ HANDLE_TYPE_NO_ARGS("SHA-160", SHA_160_AMD64);
+#elif defined(BOTAN_HAS_SHA1_IA32)
+ HANDLE_TYPE_NO_ARGS("SHA-160", SHA_160_IA32);
+#elif defined(BOTAN_HAS_SHA1)
HANDLE_TYPE_NO_ARGS("SHA-160", SHA_160);
#endif