summaryrefslogtreecommitdiff
path: root/iterhash.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2017-05-25 06:20:00 -0400
committerJeffrey Walton <noloader@gmail.com>2017-05-25 06:20:00 -0400
commit3b56ba118f34968b1281e14bd45d78b8f03af288 (patch)
tree425f7d727177a0b93c7d1ee2510bbe03992b0c49 /iterhash.cpp
parentb65ec291ea96edfdd16b7e9c6d7d848962e6e3f5 (diff)
downloadcryptopp-git-3b56ba118f34968b1281e14bd45d78b8f03af288.tar.gz
Avoid extra ByteReverse
This gains about 0.6 cpb. SHA-1 is down to 1.9 cpb. SHA-256 is not affected
Diffstat (limited to 'iterhash.cpp')
-rw-r--r--iterhash.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/iterhash.cpp b/iterhash.cpp
index 722d4f77..ce2e5cc3 100644
--- a/iterhash.cpp
+++ b/iterhash.cpp
@@ -82,11 +82,14 @@ template <class T, class BASE> byte * IteratedHashBase<T, BASE>::CreateUpdateSpa
template <class T, class BASE> size_t IteratedHashBase<T, BASE>::HashMultipleBlocks(const T *input, size_t length)
{
- // Hardware based SHA1 and SHA256 correct blocks themselves due to hardware requirements.
- // For Intel, SHA1 will effectively call ByteReverse(). SHA256 formats data to Intel
- // requirements, which means eight words ABCD EFGH are transformed to ABEF CDGH.
+#if CRYPTOPP_BOOL_SSE_SHA_INTRINSICS_AVAILABLE
+ // SHA-1 and SHA-256 only
+ static const bool noReverse = HasSHA() && this->BlockSize() <= 64;
+#else
+ const bool noReverse = NativeByteOrderIs(this->GetByteOrder());
+#endif
+
unsigned int blockSize = this->BlockSize();
- bool noReverse = NativeByteOrderIs(this->GetByteOrder());
T* dataBuf = this->DataBuf();
do
{