summaryrefslogtreecommitdiff
path: root/mdc.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2018-01-20 19:39:49 -0500
committerJeffrey Walton <noloader@gmail.com>2018-01-20 19:39:49 -0500
commit565bd844fcc0dec4712f8c4c3e74e056f4a9ed78 (patch)
tree9ab43180511b53005490cea580954d9630830f40 /mdc.h
parent2816efe188d5f335c4713ab68145d1b9df59452e (diff)
downloadcryptopp-git-565bd844fcc0dec4712f8c4c3e74e056f4a9ed78.tar.gz
Clear GCC -Wcast-align warnings on ARM
The buffers and workspaces are aligned
Diffstat (limited to 'mdc.h')
-rw-r--r--mdc.h22
1 files changed, 13 insertions, 9 deletions
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<H>
{
CRYPTOPP_UNUSED(params);
this->AssertValidKeyLength(length);
- ConditionalByteReverse(BIG_ENDIAN_ORDER, Key(), reinterpret_cast<const HashWordType*>(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<const HashWordType*>(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<H>
}
else
{
- ConditionalByteReverse(BIG_ENDIAN_ORDER, reinterpret_cast<HashWordType*>(outBlock), Buffer(), this->BLOCKSIZE);
+ ConditionalByteReverse(BIG_ENDIAN_ORDER, HashWordPtr(outBlock), Buffer(), this->BLOCKSIZE);
}
}
@@ -61,9 +65,9 @@ class MDC : public MDC_Info<H>
unsigned int OptimalDataAlignment() const {return sizeof(HashWordType);}
private:
- HashWordType *Key() {return reinterpret_cast<HashWordType*>(m_key.data());}
- const HashWordType *Key() const {return reinterpret_cast<const HashWordType*>(m_key.data());}
- HashWordType *Buffer() const {return reinterpret_cast<HashWordType*>(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<byte, MDC_Info<H>::KEYLENGTH, AllocatorWithCleanup<byte> > m_key;