diff options
author | Jeffrey Walton <noloader@gmail.com> | 2019-05-26 22:10:26 -0400 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2019-05-26 22:10:26 -0400 |
commit | 81da61fe7b32ab771d121cc8c889c61dfb2e60a0 (patch) | |
tree | 49c84a70304eb8f68a11925df2f2e65fc6314f51 /sha.cpp | |
parent | d4b533a60fa82f40eb8019214bb525bb7a7b20ff (diff) | |
download | cryptopp-git-81da61fe7b32ab771d121cc8c889c61dfb2e60a0.tar.gz |
Breakout sha_block_data_order and sha_block_data_order_neon (GH #847)
Diffstat (limited to 'sha.cpp')
-rw-r--r-- | sha.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
@@ -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)
|