Fix crash in SHA-512 when using different compile options (GH #661)

This also helps clear a crash on Sparc due to unaligned access to an uint64_t (GH #689)
This commit is contained in:
Jeffrey Walton 2018-07-20 13:15:29 -04:00
parent 8d6b1af4cf
commit 45ffb7e827
No known key found for this signature in database
GPG Key ID: B36AB348921B1838

10
sha.h
View File

@ -11,12 +11,6 @@
#include "config.h"
#include "iterhash.h"
#if (CRYPTOPP_BOOL_X86)
# define SHA_X86_ALIGN16 true
#else
# define SHA_X86_ALIGN16 false
#endif
NAMESPACE_BEGIN(CryptoPP)
/// \brief SHA-1 message digest
@ -138,7 +132,7 @@ protected:
/// \brief SHA-512 message digest
/// \sa <a href="http://www.weidai.com/scan-mirror/md.html#SHA-512">SHA-512</a>
/// \since SHA2 since Crypto++ 4.0, Power8 SHA since Crypto++ 6.1
class CRYPTOPP_DLL SHA512 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA512, 64, SHA_X86_ALIGN16>
class CRYPTOPP_DLL SHA512 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA512, 64, true>
{
public:
/// \brief Initialize state array
@ -173,7 +167,7 @@ public:
/// \brief SHA-384 message digest
/// \sa <a href="http://www.weidai.com/scan-mirror/md.html#SHA-384">SHA-384</a>
/// \since SHA2 since Crypto++ 4.0, Power8 SHA since Crypto++ 6.1
class CRYPTOPP_DLL SHA384 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA384, 48, SHA_X86_ALIGN16>
class CRYPTOPP_DLL SHA384 : public IteratedHashWithStaticTransform<word64, BigEndian, 128, 64, SHA384, 48, true>
{
public:
/// \brief Initialize state array