summaryrefslogtreecommitdiff
path: root/sha.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2017-09-22 08:58:50 -0400
committerJeffrey Walton <noloader@gmail.com>2017-09-22 08:58:50 -0400
commit3bd01f73bae3ded9bc5b01681151bcfaf252d7cf (patch)
tree2bbd5b708af9eb10f1727dd8f9a03d4846226a6f /sha.cpp
parent375d5e18b30cb4f53b3315ea95f092e001ed50b4 (diff)
downloadcryptopp-git-3bd01f73bae3ded9bc5b01681151bcfaf252d7cf.tar.gz
Add Power8 SHA256 and SHA512 support (GH #513)
Diffstat (limited to 'sha.cpp')
-rw-r--r--sha.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/sha.cpp b/sha.cpp
index 713a1914..04dfb4d9 100644
--- a/sha.cpp
+++ b/sha.cpp
@@ -70,6 +70,11 @@ extern void SHA1_HashMultipleBlocks_ARMV8(word32 *state, const word32 *data, siz
extern void SHA256_HashMultipleBlocks_ARMV8(word32 *state, const word32 *data, size_t length, ByteOrder order);
#endif
+#if CRYPTOPP_POWER8_SHA_AVAILABLE
+extern void SHA256_HashMultipleBlocks_POWER8(word32 *state, const word32 *data, size_t length, ByteOrder order);
+extern void SHA512_HashMultipleBlocks_POWER8(word64 *state, const word64 *data, size_t length, ByteOrder order);
+#endif
+
////////////////////////////////
// start of Steve Reid's code //
////////////////////////////////
@@ -684,6 +689,13 @@ void SHA256::Transform(word32 *state, const word32 *data)
return;
}
#endif
+#if CRYPTOPP_POWER8_SHA_AVAILABLE
+ if (HasSHA256())
+ {
+ SHA256_HashMultipleBlocks_POWER8(state, data, SHA256::BLOCKSIZE, LITTLE_ENDIAN_ORDER);
+ return;
+ }
+#endif
SHA256_HashBlock_CXX(state, data);
}
@@ -715,6 +727,13 @@ size_t SHA256::HashMultipleBlocks(const word32 *input, size_t length)
return length & (SHA256::BLOCKSIZE - 1);
}
#endif
+#if CRYPTOPP_POWER8_SHA_AVAILABLE
+ if (HasSHA256())
+ {
+ SHA256_HashMultipleBlocks_POWER8(m_state, input, length, BIG_ENDIAN_ORDER);
+ return length & (SHA256::BLOCKSIZE - 1);
+ }
+#endif
const bool noReverse = NativeByteOrderIs(this->GetByteOrder());
word32 *dataBuf = this->DataBuf();