aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/hash/sha1/sha160.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-09-03 14:17:33 -0400
committerJack Lloyd <[email protected]>2016-09-15 09:23:22 -0400
commitbe4655148cfc8cb048fd53de0965cc5e939c4cbc (patch)
treed441a6a5941d968fce80dd50a5f6010855714a77 /src/lib/hash/sha1/sha160.cpp
parent272fcf00572432f64085b10132e364740d7eb093 (diff)
Merge optimized implementations into base class
Various algorithms had an optimized implementation (for SSE2, AVX2, etc) which was offered alongside the 'base' implementation. This is admittedly very useful for testing, but it breaks user expectations in bad ways. See GH #477 for background. Now encrypting with `AES_128` (say) just runs whatever implementation is best on the current processor/build.
Diffstat (limited to 'src/lib/hash/sha1/sha160.cpp')
-rw-r--r--src/lib/hash/sha1/sha160.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lib/hash/sha1/sha160.cpp b/src/lib/hash/sha1/sha160.cpp
index 21e87465a..87738fb00 100644
--- a/src/lib/hash/sha1/sha160.cpp
+++ b/src/lib/hash/sha1/sha160.cpp
@@ -6,6 +6,7 @@
*/
#include <botan/sha160.h>
+#include <botan/cpuid.h>
namespace Botan {
@@ -60,9 +61,19 @@ void SHA_160::compress_n(const byte input[], size_t blocks)
{
using namespace SHA1_F;
+#if defined(BOTAN_HAS_SHA1_SSE2)
+ if(CPUID::has_sse2())
+ {
+ return sse2_compress_n(m_digest, input, blocks);
+ }
+
+#endif
+
u32bit A = m_digest[0], B = m_digest[1], C = m_digest[2],
D = m_digest[3], E = m_digest[4];
+ m_W.resize(80);
+
for(size_t i = 0; i != blocks; ++i)
{
load_be(m_W.data(), input, 16);