summaryrefslogtreecommitdiff
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
parent2816efe188d5f335c4713ab68145d1b9df59452e (diff)
downloadcryptopp-git-565bd844fcc0dec4712f8c4c3e74e056f4a9ed78.tar.gz
Clear GCC -Wcast-align warnings on ARM
The buffers and workspaces are aligned
-rw-r--r--aria-simd.cpp20
-rw-r--r--aria.cpp16
-rw-r--r--gcm-simd.cpp6
-rw-r--r--iterhash.h4
-rw-r--r--mdc.h22
5 files changed, 44 insertions, 24 deletions
diff --git a/aria-simd.cpp b/aria-simd.cpp
index f855be90..f7748b7e 100644
--- a/aria-simd.cpp
+++ b/aria-simd.cpp
@@ -29,6 +29,10 @@
#define M128_CAST(x) ((__m128i *)(void *)(x))
#define CONST_M128_CAST(x) ((const __m128i *)(const void *)(x))
+// GCC cast warning
+#define UINT32_CAST(x) ((uint32_t *)(void *)(x))
+#define CONST_UINT32_CAST(x) ((const uint32_t *)(const void *)(x))
+
NAMESPACE_BEGIN(CryptoPP)
NAMESPACE_BEGIN(ARIATab)
@@ -58,7 +62,7 @@ inline void ARIA_GSRK_NEON(const uint32x4_t X, const uint32x4_t Y, byte RK[16])
static const unsigned int Q2 = (3-(N/32)) % 4;
static const unsigned int R = N % 32;
- vst1q_u32(reinterpret_cast<uint32_t*>(RK),
+ vst1q_u32(UINT32_CAST(RK),
veorq_u32(X, veorq_u32(
vshrq_n_u32(vextq_u32(Y, Y, Q1), R),
vshlq_n_u32(vextq_u32(Y, Y, Q2), 32-R))));
@@ -66,10 +70,10 @@ inline void ARIA_GSRK_NEON(const uint32x4_t X, const uint32x4_t Y, byte RK[16])
void ARIA_UncheckedSetKey_Schedule_NEON(byte* rk, word32* ws, unsigned int keylen)
{
- const uint32x4_t w0 = vld1q_u32((const uint32_t*)(ws+ 0));
- const uint32x4_t w1 = vld1q_u32((const uint32_t*)(ws+ 8));
- const uint32x4_t w2 = vld1q_u32((const uint32_t*)(ws+12));
- const uint32x4_t w3 = vld1q_u32((const uint32_t*)(ws+16));
+ const uint32x4_t w0 = vld1q_u32(CONST_UINT32_CAST(ws+ 0));
+ const uint32x4_t w1 = vld1q_u32(CONST_UINT32_CAST(ws+ 8));
+ const uint32x4_t w2 = vld1q_u32(CONST_UINT32_CAST(ws+12));
+ const uint32x4_t w3 = vld1q_u32(CONST_UINT32_CAST(ws+16));
ARIA_GSRK_NEON<19>(w0, w1, rk + 0);
ARIA_GSRK_NEON<19>(w1, w2, rk + 16);
@@ -100,9 +104,9 @@ void ARIA_UncheckedSetKey_Schedule_NEON(byte* rk, word32* ws, unsigned int keyle
void ARIA_ProcessAndXorBlock_Xor_NEON(const byte* xorBlock, byte* outBlock)
{
- vst1q_u32(reinterpret_cast<uint32_t*>(outBlock), veorq_u32(
- vld1q_u32(reinterpret_cast<const uint32_t*>(outBlock)),
- vld1q_u32(reinterpret_cast<const uint32_t*>(xorBlock))));
+ vst1q_u32(UINT32_CAST(outBlock), veorq_u32(
+ vld1q_u32(CONST_UINT32_CAST(outBlock)),
+ vld1q_u32(CONST_UINT32_CAST(xorBlock))));
}
#endif // CRYPTOPP_ARM_NEON_AVAILABLE
diff --git a/aria.cpp b/aria.cpp
index a08f7850..a53a00c6 100644
--- a/aria.cpp
+++ b/aria.cpp
@@ -15,6 +15,10 @@
# define CRYPTOPP_ENABLE_ARIA_SSSE3_INTRINSICS 1
#endif
+// GCC cast warning
+#define UINT32_CAST(x) ((uint32_t *)(void *)(x))
+#define CONST_UINT32_CAST(x) ((const uint32_t *)(const void *)(x))
+
NAMESPACE_BEGIN(CryptoPP)
NAMESPACE_BEGIN(ARIATab)
@@ -97,10 +101,10 @@ inline void ARIA_GSRK(const word32 X[4], const word32 Y[4], byte RK[16])
// MSVC is not generating a "rotate immediate". Constify to help it along.
static const unsigned int Q = 4-(N/32);
static const unsigned int R = N % 32;
- reinterpret_cast<word32*>(RK)[0] = (X[0]) ^ ((Y[(Q )%4])>>R) ^ ((Y[(Q+3)%4])<<(32-R));
- reinterpret_cast<word32*>(RK)[1] = (X[1]) ^ ((Y[(Q+1)%4])>>R) ^ ((Y[(Q )%4])<<(32-R));
- reinterpret_cast<word32*>(RK)[2] = (X[2]) ^ ((Y[(Q+2)%4])>>R) ^ ((Y[(Q+1)%4])<<(32-R));
- reinterpret_cast<word32*>(RK)[3] = (X[3]) ^ ((Y[(Q+3)%4])>>R) ^ ((Y[(Q+2)%4])<<(32-R));
+ UINT32_CAST(RK)[0] = (X[0]) ^ ((Y[(Q )%4])>>R) ^ ((Y[(Q+3)%4])<<(32-R));
+ UINT32_CAST(RK)[1] = (X[1]) ^ ((Y[(Q+1)%4])>>R) ^ ((Y[(Q )%4])<<(32-R));
+ UINT32_CAST(RK)[2] = (X[2]) ^ ((Y[(Q+2)%4])>>R) ^ ((Y[(Q+1)%4])<<(32-R));
+ UINT32_CAST(RK)[3] = (X[3]) ^ ((Y[(Q+3)%4])>>R) ^ ((Y[(Q+2)%4])<<(32-R));
}
void ARIA::Base::UncheckedSetKey(const byte *key, unsigned int keylen, const NameValuePairs &params)
@@ -213,7 +217,7 @@ void ARIA::Base::UncheckedSetKey(const byte *key, unsigned int keylen, const Nam
rk = m_rk.data();
r = R; q = Q;
- a=reinterpret_cast<word32*>(rk); s=m_w.data()+24; z=a+r*4;
+ a=UINT32_CAST(rk); s=m_w.data()+24; z=a+r*4;
::memcpy(t, a, 16); ::memcpy(a, z, 16); ::memcpy(z, t, 16);
a+=4; z-=4;
@@ -314,7 +318,7 @@ void ARIA::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, b
outBlock[14] = (byte)(S1[ARIA_BRF(t[3],1)] );
outBlock[15] = (byte)(S2[ARIA_BRF(t[3],0)] );
- t = reinterpret_cast<word32*>(outBlock);
+ t = UINT32_CAST(outBlock);
BigEndianBlock::Put(rk, t)(t[0])(t[1])(t[2])(t[3]);
#endif
diff --git a/gcm-simd.cpp b/gcm-simd.cpp
index 32f04e40..ab8c4f39 100644
--- a/gcm-simd.cpp
+++ b/gcm-simd.cpp
@@ -63,6 +63,10 @@
#define M128_CAST(x) ((__m128i *)(void *)(x))
#define CONST_M128_CAST(x) ((const __m128i *)(const void *)(x))
+// GCC cast warning
+#define UINT64X2_CAST(x) ((uint64x2_t *)(void *)(x))
+#define CONST_UINT64X2_CAST(x) ((const uint64x2_t *)(const void *)(x))
+
ANONYMOUS_NAMESPACE_BEGIN
// GCC 4.8 is missing PMULL gear
@@ -285,7 +289,7 @@ void GCM_Xor16_NEON(byte *a, const byte *b, const byte *c)
CRYPTOPP_ASSERT(IsAlignedOn(a,GetAlignmentOf<uint64x2_t>()));
CRYPTOPP_ASSERT(IsAlignedOn(b,GetAlignmentOf<uint64x2_t>()));
CRYPTOPP_ASSERT(IsAlignedOn(c,GetAlignmentOf<uint64x2_t>()));
- *(uint64x2_t*)a = veorq_u64(*(uint64x2_t*)b, *(uint64x2_t*)c);
+ *UINT64X2_CAST(a) = veorq_u64(*CONST_UINT64X2_CAST(b), *CONST_UINT64X2_CAST(c));
}
#endif
diff --git a/iterhash.h b/iterhash.h
index d66998b2..dae50d43 100644
--- a/iterhash.h
+++ b/iterhash.h
@@ -16,6 +16,10 @@
# endif
#endif
+// GCC cast warning
+#define HashWordPtr(x) ((HashWordType*)(void*)(x))
+#define ConstHashWordPtr(x) ((const HashWordType*)(const void*)(x))
+
NAMESPACE_BEGIN(CryptoPP)
/// \brief Exception thrown when trying to hash more data than is allowed by a hash function
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;