From 565bd844fcc0dec4712f8c4c3e74e056f4a9ed78 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sat, 20 Jan 2018 19:39:49 -0500 Subject: Clear GCC -Wcast-align warnings on ARM The buffers and workspaces are aligned --- mdc.h | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'mdc.h') diff --git a/mdc.h b/mdc.h index a49a1ad0..e6926fcc 100644 --- a/mdc.h +++ b/mdc.h @@ -1,15 +1,19 @@ // mdc.h - originally written and placed in the public domain by Wei Dai -#ifndef CRYPTOPP_MDC_H -#define CRYPTOPP_MDC_H - /// \file mdc.h /// \brief Classes for the MDC message digest +#ifndef CRYPTOPP_MDC_H +#define CRYPTOPP_MDC_H + #include "seckey.h" #include "secblock.h" #include "misc.h" +// GCC cast warning +#define HashWordPtr(x) ((HashWordType*)(void*)(x)) +#define ConstHashWordPtr(x) ((const HashWordType*)(const void*)(x)) + NAMESPACE_BEGIN(CryptoPP) /// \tparam B BlockCipher derived class @@ -37,12 +41,12 @@ class MDC : public MDC_Info { CRYPTOPP_UNUSED(params); this->AssertValidKeyLength(length); - ConditionalByteReverse(BIG_ENDIAN_ORDER, Key(), reinterpret_cast(userKey), this->KEYLENGTH); + ConditionalByteReverse(BIG_ENDIAN_ORDER, Key(), ConstHashWordPtr(userKey), this->KEYLENGTH); } void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const { - ConditionalByteReverse(BIG_ENDIAN_ORDER, Buffer(), reinterpret_cast(inBlock), this->BLOCKSIZE); + ConditionalByteReverse(BIG_ENDIAN_ORDER, Buffer(), ConstHashWordPtr(inBlock), this->BLOCKSIZE); H::Transform(Buffer(), Key()); if (xorBlock) @@ -52,7 +56,7 @@ class MDC : public MDC_Info } else { - ConditionalByteReverse(BIG_ENDIAN_ORDER, reinterpret_cast(outBlock), Buffer(), this->BLOCKSIZE); + ConditionalByteReverse(BIG_ENDIAN_ORDER, HashWordPtr(outBlock), Buffer(), this->BLOCKSIZE); } } @@ -61,9 +65,9 @@ class MDC : public MDC_Info unsigned int OptimalDataAlignment() const {return sizeof(HashWordType);} private: - HashWordType *Key() {return reinterpret_cast(m_key.data());} - const HashWordType *Key() const {return reinterpret_cast(m_key.data());} - HashWordType *Buffer() const {return reinterpret_cast(m_buffer.data());} + HashWordType *Key() {return HashWordPtr(m_key.data());} + const HashWordType *Key() const {return ConstHashWordPtr(m_key.data());} + HashWordType *Buffer() const {return HashWordPtr(m_buffer.data());} // VC60 workaround: bug triggered if using FixedSizeAllocatorWithCleanup FixedSizeSecBlock::KEYLENGTH, AllocatorWithCleanup > m_key; -- cgit v1.2.1