summaryrefslogtreecommitdiff
path: root/sha.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sha.cpp')
-rw-r--r--sha.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/sha.cpp b/sha.cpp
index ce742b2a..4fc80520 100644
--- a/sha.cpp
+++ b/sha.cpp
@@ -68,6 +68,7 @@ extern void SHA256_HashMultipleBlocks_SHANI(word32 *state, const word32 *data, s
#if CRYPTOGAMS_ARM_SHA1
extern "C" void sha1_block_data_order(word32* state, const word32 *data, size_t blocks);
+extern "C" void sha1_block_data_order_neon(word32* state, const word32 *data, size_t blocks);
#endif
#if CRYPTOPP_ARM_SHA1_AVAILABLE
@@ -80,6 +81,7 @@ extern void SHA256_HashMultipleBlocks_ARMV8(word32 *state, const word32 *data, s
#if CRYPTOGAMS_ARM_SHA256
extern "C" void sha256_block_data_order(word32* state, const word32 *data, size_t blocks);
+extern "C" void sha256_block_data_order_neon(word32* state, const word32 *data, size_t blocks);
#endif
#if CRYPTOPP_ARM_SHA512_AVAILABLE
@@ -93,6 +95,7 @@ extern void SHA512_HashMultipleBlocks_POWER8(word64 *state, const word64 *data,
#if CRYPTOGAMS_ARM_SHA512
extern "C" void sha512_block_data_order(word64* state, const word64 *data, size_t blocks);
+extern "C" void sha512_block_data_order_neon(word64* state, const word64 *data, size_t blocks);
#endif
// We add extern to export table to sha_simd.cpp, but it
@@ -289,6 +292,17 @@ void SHA1::Transform(word32 *state, const word32 *data)
}
#endif
#if CRYPTOGAMS_ARM_SHA1 && 0
+ if (HasNEON())
+ {
+# if defined(CRYPTOPP_LITTLE_ENDIAN)
+ word32 dataBuf[16];
+ ByteReverse(dataBuf, data, SHA1::BLOCKSIZE);
+ sha1_block_data_order_neon(state, data, 1);
+# else
+ sha1_block_data_order_neon(state, data, 1);
+# endif
+ return;
+ }
if (HasARMv7())
{
# if defined(CRYPTOPP_LITTLE_ENDIAN)
@@ -325,6 +339,11 @@ size_t SHA1::HashMultipleBlocks(const word32 *input, size_t length)
}
#endif
#if CRYPTOGAMS_ARM_SHA1
+ if (HasNEON())
+ {
+ sha1_block_data_order_neon(m_state, input, length / SHA1::BLOCKSIZE);
+ return length & (SHA1::BLOCKSIZE - 1);
+ }
if (HasARMv7())
{
sha1_block_data_order(m_state, input, length / SHA1::BLOCKSIZE);
@@ -834,6 +853,17 @@ void SHA256::Transform(word32 *state, const word32 *data)
}
#endif
#if CRYPTOGAMS_ARM_SHA256 && 0
+ if (HasNEON())
+ {
+# if defined(CRYPTOPP_LITTLE_ENDIAN)
+ word32 dataBuf[16];
+ ByteReverse(dataBuf, data, SHA256::BLOCKSIZE);
+ sha256_block_data_order_neon(state, data, 1);
+# else
+ sha256_block_data_order_neon(state, data, 1);
+# endif
+ return;
+ }
if (HasARMv7())
{
# if defined(CRYPTOPP_LITTLE_ENDIAN)
@@ -885,6 +915,11 @@ size_t SHA256::HashMultipleBlocks(const word32 *input, size_t length)
}
#endif
#if CRYPTOGAMS_ARM_SHA256
+ if (HasNEON())
+ {
+ sha256_block_data_order_neon(m_state, input, length / SHA256::BLOCKSIZE);
+ return length & (SHA256::BLOCKSIZE - 1);
+ }
if (HasARMv7())
{
sha256_block_data_order(m_state, input, length / SHA256::BLOCKSIZE);
@@ -948,6 +983,11 @@ size_t SHA224::HashMultipleBlocks(const word32 *input, size_t length)
}
#endif
#if CRYPTOGAMS_ARM_SHA256
+ if (HasNEON())
+ {
+ sha256_block_data_order_neon(m_state, input, length / SHA256::BLOCKSIZE);
+ return length & (SHA256::BLOCKSIZE - 1);
+ }
if (HasARMv7())
{
sha256_block_data_order(m_state, input, length / SHA256::BLOCKSIZE);
@@ -1311,6 +1351,17 @@ void SHA512::Transform(word64 *state, const word64 *data)
}
#endif
#if CRYPTOGAMS_ARM_SHA512
+ if (HasNEON())
+ {
+# if (CRYPTOPP_LITTLE_ENDIAN)
+ word64 dataBuf[16];
+ ByteReverse(dataBuf, data, SHA512::BLOCKSIZE);
+ sha512_block_data_order_neon(state, dataBuf, 1);
+# else
+ sha512_block_data_order_neon(state, data, 1);
+# endif
+ return;
+ }
if (HasARMv7())
{
# if (CRYPTOPP_LITTLE_ENDIAN)