From 2a09376211fc22a5649c3cbc5dc9eaf0288e0d27 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Thu, 23 May 2019 03:17:17 -0400 Subject: Remove const_cast from CryptogamsArmCaps() --- sha.cpp | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) (limited to 'sha.cpp') diff --git a/sha.cpp b/sha.cpp index b752ea24..aaf4e123 100644 --- a/sha.cpp +++ b/sha.cpp @@ -179,9 +179,7 @@ inline unsigned int CryptogamsArmCaps() // CRYPTOGAMS_armcaps, and the Cryptogams modules use our symbol. // The Cryptogams code defines ARMV7_NEON as 1<<0, so we need to // set the bits accordingly in CRYPTOGAMS_armcaps. - *const_cast(&CRYPTOGAMS_armcaps) = CryptoPP::HasNEON() ? (1<<0) : 0; - - return CRYPTOGAMS_armcaps; + return CryptoPP::HasNEON() ? (1<<0) : 0; } #endif @@ -313,14 +311,12 @@ void SHA1::Transform(word32 *state, const word32 *data) #if CRYPTOGAMS_ARM_SHA1 && 0 if (HasARMv7()) { - static const unsigned int caps = CryptogamsArmCaps(); - # if defined(CRYPTOPP_LITTLE_ENDIAN) word32 dataBuf[16]; ByteReverse(dataBuf, data, SHA1::BLOCKSIZE); - sha1_block_data_order(state, data, 1, caps); + sha1_block_data_order(state, data, 1, CryptogamsArmCaps()); # else - sha1_block_data_order(state, data, 1, caps); + sha1_block_data_order(state, data, 1, CryptogamsArmCaps()); # endif return; } @@ -351,8 +347,7 @@ size_t SHA1::HashMultipleBlocks(const word32 *input, size_t length) #if CRYPTOGAMS_ARM_SHA1 if (HasARMv7()) { - const unsigned int caps = CryptogamsArmCaps(); - sha1_block_data_order(m_state, input, length / SHA1::BLOCKSIZE, caps); + sha1_block_data_order(m_state, input, length / SHA1::BLOCKSIZE, CryptogamsArmCaps()); return length & (SHA1::BLOCKSIZE - 1); } #endif @@ -861,14 +856,12 @@ void SHA256::Transform(word32 *state, const word32 *data) #if CRYPTOGAMS_ARM_SHA256 && 0 if (HasARMv7()) { - static const unsigned int caps = CryptogamsArmCaps(); - # if defined(CRYPTOPP_LITTLE_ENDIAN) word32 dataBuf[16]; ByteReverse(dataBuf, data, SHA256::BLOCKSIZE); - sha256_block_data_order(state, data, 1, caps); + sha256_block_data_order(state, data, 1, CryptogamsArmCaps()); # else - sha256_block_data_order(state, data, 1, caps); + sha256_block_data_order(state, data, 1, CryptogamsArmCaps()); # endif return; } @@ -914,8 +907,7 @@ size_t SHA256::HashMultipleBlocks(const word32 *input, size_t length) #if CRYPTOGAMS_ARM_SHA256 if (HasARMv7()) { - const unsigned int caps = CryptogamsArmCaps(); - sha256_block_data_order(m_state, input, length / SHA256::BLOCKSIZE, caps); + sha256_block_data_order(m_state, input, length / SHA256::BLOCKSIZE, CryptogamsArmCaps()); return length & (SHA256::BLOCKSIZE - 1); } #endif @@ -978,9 +970,7 @@ size_t SHA224::HashMultipleBlocks(const word32 *input, size_t length) #if CRYPTOGAMS_ARM_SHA256 if (HasARMv7()) { - static const unsigned int caps = CryptogamsArmCaps(); - - sha256_block_data_order(m_state, input, length / SHA256::BLOCKSIZE, caps);; + sha256_block_data_order(m_state, input, length / SHA256::BLOCKSIZE, CryptogamsArmCaps());; return length & (SHA256::BLOCKSIZE - 1); } #endif @@ -1343,15 +1333,7 @@ void SHA512::Transform(word64 *state, const word64 *data) #if CRYPTOGAMS_ARM_SHA512 && 0 if (HasARMv7()) { - static const unsigned int caps = CryptogamsArmCaps(); - -# if defined(CRYPTOPP_LITTLE_ENDIAN) - word64 dataBuf[16]; - ByteReverse(dataBuf, data, SHA512::BLOCKSIZE); - sha512_block_data_order(state, dataBuf, 1, caps); -# else - sha512_block_data_order(state, data, 1, caps); -# endif + sha512_block_data_order(state, data, 1, CryptogamsArmCaps()); return; } #endif -- cgit v1.2.1