Use CRYPTOPP_ARM_NEON_AVAILABLE in sha.cpp

This commit is contained in:
Jeffrey Walton 2022-02-10 21:29:30 -05:00
parent 3632a54e1a
commit 6215e1d2e3
No known key found for this signature in database
GPG Key ID: B36AB348921B1838

51
sha.cpp
View File

@ -258,8 +258,11 @@ std::string SHA1::AlgorithmProvider() const
return "SSE2";
#endif
#if CRYPTOGAMS_ARM_SHA1
# if CRYPTOPP_ARM_NEON_AVAILABLE
if (HasNEON())
return "NEON";
else
# endif
if (HasARMv7())
return "ARMv7";
#endif
@ -291,18 +294,22 @@ void SHA1::Transform(word32 *state, const word32 *data)
return;
}
#endif
// Disabled at the moment due to MDC and SEAL failures
#if CRYPTOGAMS_ARM_SHA1 && 0
# if CRYPTOPP_ARM_NEON_AVAILABLE
if (HasNEON())
{
# if defined(CRYPTOPP_LITTLE_ENDIAN)
# if defined(CRYPTOPP_LITTLE_ENDIAN)
word32 dataBuf[16];
ByteReverse(dataBuf, data, SHA1::BLOCKSIZE);
cryptogams_sha1_block_data_order_neon(state, dataBuf, 1);
# else
cryptogams_sha1_block_data_order_neon(state, data, 1);
# else
cryptogams_sha1_block_data_order_neon(state, data, 1);
# endif
# endif
return;
}
else
# endif
if (HasARMv7())
{
# if defined(CRYPTOPP_LITTLE_ENDIAN)
@ -339,11 +346,14 @@ size_t SHA1::HashMultipleBlocks(const word32 *input, size_t length)
}
#endif
#if CRYPTOGAMS_ARM_SHA1
# if CRYPTOPP_ARM_NEON_AVAILABLE
if (HasNEON())
{
cryptogams_sha1_block_data_order_neon(m_state, input, length / SHA1::BLOCKSIZE);
return length & (SHA1::BLOCKSIZE - 1);
}
else
# endif
if (HasARMv7())
{
cryptogams_sha1_block_data_order(m_state, input, length / SHA1::BLOCKSIZE);
@ -464,8 +474,11 @@ std::string SHA256_AlgorithmProvider()
return "SSE2";
#endif
#if CRYPTOGAMS_ARM_SHA256
# if CRYPTOPP_ARM_NEON_AVAILABLE
if (HasNEON())
return "NEON";
else
# endif
if (HasARMv7())
return "ARMv7";
#endif
@ -852,18 +865,22 @@ void SHA256::Transform(word32 *state, const word32 *data)
return;
}
#endif
// Disabled at the moment due to MDC and SEAL failures
#if CRYPTOGAMS_ARM_SHA256 && 0
# if CRYPTOPP_ARM_NEON_AVAILABLE
if (HasNEON())
{
# if defined(CRYPTOPP_LITTLE_ENDIAN)
# if defined(CRYPTOPP_LITTLE_ENDIAN)
word32 dataBuf[16];
ByteReverse(dataBuf, data, SHA256::BLOCKSIZE);
cryptogams_sha256_block_data_order_neon(state, dataBuf, 1);
# else
cryptogams_sha256_block_data_order_neon(state, data, 1);
# else
cryptogams_sha256_block_data_order_neon(state, data, 1);
# endif
# endif
return;
}
else
# endif
if (HasARMv7())
{
# if defined(CRYPTOPP_LITTLE_ENDIAN)
@ -915,11 +932,14 @@ size_t SHA256::HashMultipleBlocks(const word32 *input, size_t length)
}
#endif
#if CRYPTOGAMS_ARM_SHA256
# if CRYPTOPP_ARM_NEON_AVAILABLE
if (HasNEON())
{
cryptogams_sha256_block_data_order_neon(m_state, input, length / SHA256::BLOCKSIZE);
return length & (SHA256::BLOCKSIZE - 1);
}
else
# endif
if (HasARMv7())
{
cryptogams_sha256_block_data_order(m_state, input, length / SHA256::BLOCKSIZE);
@ -983,11 +1003,14 @@ size_t SHA224::HashMultipleBlocks(const word32 *input, size_t length)
}
#endif
#if CRYPTOGAMS_ARM_SHA256
# if CRYPTOPP_ARM_NEON_AVAILABLE
if (HasNEON())
{
cryptogams_sha256_block_data_order_neon(m_state, input, length / SHA256::BLOCKSIZE);
return length & (SHA256::BLOCKSIZE - 1);
}
else
# endif
if (HasARMv7())
{
cryptogams_sha256_block_data_order(m_state, input, length / SHA256::BLOCKSIZE);
@ -1039,8 +1062,11 @@ std::string SHA512_AlgorithmProvider()
return "SSE2";
#endif
#if CRYPTOGAMS_ARM_SHA512
# if CRYPTOPP_ARM_NEON_AVAILABLE
if (HasNEON())
return "NEON";
else
# endif
if (HasARMv7())
return "ARMv7";
#endif
@ -1351,17 +1377,20 @@ void SHA512::Transform(word64 *state, const word64 *data)
}
#endif
#if CRYPTOGAMS_ARM_SHA512
# if CRYPTOPP_ARM_NEON_AVAILABLE
if (HasNEON())
{
# if (CRYPTOPP_LITTLE_ENDIAN)
# if (CRYPTOPP_LITTLE_ENDIAN)
word64 dataBuf[16];
ByteReverse(dataBuf, data, SHA512::BLOCKSIZE);
cryptogams_sha512_block_data_order_neon(state, dataBuf, 1);
# else
# else
cryptogams_sha512_block_data_order_neon(state, data, 1);
# endif
# endif
return;
}
else
# endif
if (HasARMv7())
{
# if (CRYPTOPP_LITTLE_ENDIAN)