aboutsummaryrefslogtreecommitdiffstats
path: root/src/hash/sha1_sse2
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/hash/sha1_sse2
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/hash/sha1_sse2')
-rw-r--r--src/hash/sha1_sse2/info.txt15
-rw-r--r--src/hash/sha1_sse2/sha1_sse2.cpp (renamed from src/hash/sha1_sse2/sha160.cpp)22
-rw-r--r--src/hash/sha1_sse2/sha1_sse2.h (renamed from src/hash/sha1_sse2/sha160.h)11
-rw-r--r--src/hash/sha1_sse2/sha1_sse2_imp.cpp (renamed from src/hash/sha1_sse2/sha1_sse.cpp)4
4 files changed, 25 insertions, 27 deletions
diff --git a/src/hash/sha1_sse2/info.txt b/src/hash/sha1_sse2/info.txt
index 4177c0ab7..cf5fb0943 100644
--- a/src/hash/sha1_sse2/info.txt
+++ b/src/hash/sha1_sse2/info.txt
@@ -1,15 +1,20 @@
realname "SHA-1 (SSE2)"
-define SHA1
+define SHA1_SSE2
-load_on request
+load_on auto
<add>
-sha160.cpp
-sha160.h
-sha1_sse.cpp
+sha1_sse2_imp.cpp
+sha1_sse2.cpp
+sha1_sse2.h
</add>
+<requires>
+mdx_hash
+utils
+</requires>
+
<arch>
pentium-m
pentium4
diff --git a/src/hash/sha1_sse2/sha160.cpp b/src/hash/sha1_sse2/sha1_sse2.cpp
index dfb5fdfe5..df7f2277c 100644
--- a/src/hash/sha1_sse2/sha160.cpp
+++ b/src/hash/sha1_sse2/sha1_sse2.cpp
@@ -1,28 +1,28 @@
/*************************************************
-* SHA-160 Source File *
+* SHA-160 (SSE2) Source File *
* (C) 1999-2007 Jack Lloyd *
*************************************************/
-#include <botan/sha160.h>
+#include <botan/sha1_sse2.h>
#include <botan/loadstor.h>
#include <botan/bit_ops.h>
namespace Botan {
-extern "C" void botan_sha1_sse(u32bit[5], const byte[64]);
+extern "C" void botan_sha1_sse2_compress(u32bit[5], const byte[64]);
/*************************************************
* SHA-160 Compression Function *
*************************************************/
-void SHA_160::hash(const byte input[])
+void SHA_160_SSE2::hash(const byte input[])
{
- botan_sha1_sse(digest, input);
+ botan_sha1_sse2_compress(digest, input);
}
/*************************************************
* Copy out the digest *
*************************************************/
-void SHA_160::copy_out(byte output[])
+void SHA_160_SSE2::copy_out(byte output[])
{
for(u32bit j = 0; j != OUTPUT_LENGTH; ++j)
output[j] = get_byte(j % 4, digest[j/4]);
@@ -31,7 +31,7 @@ void SHA_160::copy_out(byte output[])
/*************************************************
* Clear memory of sensitive data *
*************************************************/
-void SHA_160::clear() throw()
+void SHA_160_SSE2::clear() throw()
{
MDx_HashFunction::clear();
digest[0] = 0x67452301;
@@ -41,12 +41,4 @@ void SHA_160::clear() throw()
digest[4] = 0xC3D2E1F0;
}
-/*************************************************
-* SHA_160 Constructor *
-*************************************************/
-SHA_160::SHA_160() : MDx_HashFunction(20, 64, true, true)
- {
- clear();
- }
-
}
diff --git a/src/hash/sha1_sse2/sha160.h b/src/hash/sha1_sse2/sha1_sse2.h
index c6f8482cf..5683acc4f 100644
--- a/src/hash/sha1_sse2/sha160.h
+++ b/src/hash/sha1_sse2/sha1_sse2.h
@@ -3,8 +3,8 @@
* (C) 1999-2007 The Botan Project *
*************************************************/
-#ifndef BOTAN_SHA_160_H__
-#define BOTAN_SHA_160_H__
+#ifndef BOTAN_SHA_160_SSE2_H__
+#define BOTAN_SHA_160_SSE2_H__
#include <botan/mdx_hash.h>
@@ -13,13 +13,14 @@ namespace Botan {
/*************************************************
* SHA-160 *
*************************************************/
-class SHA_160 : public MDx_HashFunction
+class SHA_160_SSE2 : public MDx_HashFunction
{
public:
void clear() throw();
std::string name() const { return "SHA-160"; }
- HashFunction* clone() const { return new SHA_160; }
- SHA_160();
+ HashFunction* clone() const { return new SHA_160_SSE2; }
+
+ SHA_160_SSE2() : MDx_HashFunction(20, 64, true, true) { clear(); }
private:
void hash(const byte[]);
void copy_out(byte[]);
diff --git a/src/hash/sha1_sse2/sha1_sse.cpp b/src/hash/sha1_sse2/sha1_sse2_imp.cpp
index 23dbfc5e2..759d88afa 100644
--- a/src/hash/sha1_sse2/sha1_sse.cpp
+++ b/src/hash/sha1_sse2/sha1_sse2_imp.cpp
@@ -188,8 +188,8 @@ static inline u32bit f60_79(u32bit x, u32bit y, u32bit z)
(xt) += ((xe) + rol((xa), 5)); \
} while(0)
-extern "C" void botan_sha1_sse(u32bit* H,
- const u32bit* inputu)
+extern "C" void botan_sha1_sse2_compress(u32bit* H,
+ const u32bit* inputu)
{
const __m128i * input = (const __m128i *)inputu;
__m128i W0, W1, W2, W3;