Clear GCC -Wcast-align warnings on ARM
The buffers and workspaces are alignedpull/546/head
parent
2816efe188
commit
565bd844fc
|
|
@ -29,6 +29,10 @@
|
||||||
#define M128_CAST(x) ((__m128i *)(void *)(x))
|
#define M128_CAST(x) ((__m128i *)(void *)(x))
|
||||||
#define CONST_M128_CAST(x) ((const __m128i *)(const 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(CryptoPP)
|
||||||
NAMESPACE_BEGIN(ARIATab)
|
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 Q2 = (3-(N/32)) % 4;
|
||||||
static const unsigned int R = N % 32;
|
static const unsigned int R = N % 32;
|
||||||
|
|
||||||
vst1q_u32(reinterpret_cast<uint32_t*>(RK),
|
vst1q_u32(UINT32_CAST(RK),
|
||||||
veorq_u32(X, veorq_u32(
|
veorq_u32(X, veorq_u32(
|
||||||
vshrq_n_u32(vextq_u32(Y, Y, Q1), R),
|
vshrq_n_u32(vextq_u32(Y, Y, Q1), R),
|
||||||
vshlq_n_u32(vextq_u32(Y, Y, Q2), 32-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)
|
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 w0 = vld1q_u32(CONST_UINT32_CAST(ws+ 0));
|
||||||
const uint32x4_t w1 = vld1q_u32((const uint32_t*)(ws+ 8));
|
const uint32x4_t w1 = vld1q_u32(CONST_UINT32_CAST(ws+ 8));
|
||||||
const uint32x4_t w2 = vld1q_u32((const uint32_t*)(ws+12));
|
const uint32x4_t w2 = vld1q_u32(CONST_UINT32_CAST(ws+12));
|
||||||
const uint32x4_t w3 = vld1q_u32((const uint32_t*)(ws+16));
|
const uint32x4_t w3 = vld1q_u32(CONST_UINT32_CAST(ws+16));
|
||||||
|
|
||||||
ARIA_GSRK_NEON<19>(w0, w1, rk + 0);
|
ARIA_GSRK_NEON<19>(w0, w1, rk + 0);
|
||||||
ARIA_GSRK_NEON<19>(w1, w2, rk + 16);
|
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)
|
void ARIA_ProcessAndXorBlock_Xor_NEON(const byte* xorBlock, byte* outBlock)
|
||||||
{
|
{
|
||||||
vst1q_u32(reinterpret_cast<uint32_t*>(outBlock), veorq_u32(
|
vst1q_u32(UINT32_CAST(outBlock), veorq_u32(
|
||||||
vld1q_u32(reinterpret_cast<const uint32_t*>(outBlock)),
|
vld1q_u32(CONST_UINT32_CAST(outBlock)),
|
||||||
vld1q_u32(reinterpret_cast<const uint32_t*>(xorBlock))));
|
vld1q_u32(CONST_UINT32_CAST(xorBlock))));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // CRYPTOPP_ARM_NEON_AVAILABLE
|
#endif // CRYPTOPP_ARM_NEON_AVAILABLE
|
||||||
|
|
|
||||||
16
aria.cpp
16
aria.cpp
|
|
@ -15,6 +15,10 @@
|
||||||
# define CRYPTOPP_ENABLE_ARIA_SSSE3_INTRINSICS 1
|
# define CRYPTOPP_ENABLE_ARIA_SSSE3_INTRINSICS 1
|
||||||
#endif
|
#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(CryptoPP)
|
||||||
NAMESPACE_BEGIN(ARIATab)
|
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.
|
// MSVC is not generating a "rotate immediate". Constify to help it along.
|
||||||
static const unsigned int Q = 4-(N/32);
|
static const unsigned int Q = 4-(N/32);
|
||||||
static const unsigned int R = 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));
|
UINT32_CAST(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));
|
UINT32_CAST(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));
|
UINT32_CAST(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)[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 ¶ms)
|
void ARIA::Base::UncheckedSetKey(const byte *key, unsigned int keylen, const NameValuePairs ¶ms)
|
||||||
|
|
@ -213,7 +217,7 @@ void ARIA::Base::UncheckedSetKey(const byte *key, unsigned int keylen, const Nam
|
||||||
rk = m_rk.data();
|
rk = m_rk.data();
|
||||||
r = R; q = Q;
|
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);
|
::memcpy(t, a, 16); ::memcpy(a, z, 16); ::memcpy(z, t, 16);
|
||||||
|
|
||||||
a+=4; z-=4;
|
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[14] = (byte)(S1[ARIA_BRF(t[3],1)] );
|
||||||
outBlock[15] = (byte)(S2[ARIA_BRF(t[3],0)] );
|
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]);
|
BigEndianBlock::Put(rk, t)(t[0])(t[1])(t[2])(t[3]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,10 @@
|
||||||
#define M128_CAST(x) ((__m128i *)(void *)(x))
|
#define M128_CAST(x) ((__m128i *)(void *)(x))
|
||||||
#define CONST_M128_CAST(x) ((const __m128i *)(const 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
|
ANONYMOUS_NAMESPACE_BEGIN
|
||||||
|
|
||||||
// GCC 4.8 is missing PMULL gear
|
// 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(a,GetAlignmentOf<uint64x2_t>()));
|
||||||
CRYPTOPP_ASSERT(IsAlignedOn(b,GetAlignmentOf<uint64x2_t>()));
|
CRYPTOPP_ASSERT(IsAlignedOn(b,GetAlignmentOf<uint64x2_t>()));
|
||||||
CRYPTOPP_ASSERT(IsAlignedOn(c,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
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,10 @@
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// GCC cast warning
|
||||||
|
#define HashWordPtr(x) ((HashWordType*)(void*)(x))
|
||||||
|
#define ConstHashWordPtr(x) ((const HashWordType*)(const void*)(x))
|
||||||
|
|
||||||
NAMESPACE_BEGIN(CryptoPP)
|
NAMESPACE_BEGIN(CryptoPP)
|
||||||
|
|
||||||
/// \brief Exception thrown when trying to hash more data than is allowed by a hash function
|
/// \brief Exception thrown when trying to hash more data than is allowed by a hash function
|
||||||
|
|
|
||||||
22
mdc.h
22
mdc.h
|
|
@ -1,15 +1,19 @@
|
||||||
// mdc.h - originally written and placed in the public domain by Wei Dai
|
// mdc.h - originally written and placed in the public domain by Wei Dai
|
||||||
|
|
||||||
#ifndef CRYPTOPP_MDC_H
|
|
||||||
#define CRYPTOPP_MDC_H
|
|
||||||
|
|
||||||
/// \file mdc.h
|
/// \file mdc.h
|
||||||
/// \brief Classes for the MDC message digest
|
/// \brief Classes for the MDC message digest
|
||||||
|
|
||||||
|
#ifndef CRYPTOPP_MDC_H
|
||||||
|
#define CRYPTOPP_MDC_H
|
||||||
|
|
||||||
#include "seckey.h"
|
#include "seckey.h"
|
||||||
#include "secblock.h"
|
#include "secblock.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
|
// GCC cast warning
|
||||||
|
#define HashWordPtr(x) ((HashWordType*)(void*)(x))
|
||||||
|
#define ConstHashWordPtr(x) ((const HashWordType*)(const void*)(x))
|
||||||
|
|
||||||
NAMESPACE_BEGIN(CryptoPP)
|
NAMESPACE_BEGIN(CryptoPP)
|
||||||
|
|
||||||
/// \tparam B BlockCipher derived class
|
/// \tparam B BlockCipher derived class
|
||||||
|
|
@ -37,12 +41,12 @@ class MDC : public MDC_Info<H>
|
||||||
{
|
{
|
||||||
CRYPTOPP_UNUSED(params);
|
CRYPTOPP_UNUSED(params);
|
||||||
this->AssertValidKeyLength(length);
|
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
|
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());
|
H::Transform(Buffer(), Key());
|
||||||
|
|
||||||
if (xorBlock)
|
if (xorBlock)
|
||||||
|
|
@ -52,7 +56,7 @@ class MDC : public MDC_Info<H>
|
||||||
}
|
}
|
||||||
else
|
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);}
|
unsigned int OptimalDataAlignment() const {return sizeof(HashWordType);}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HashWordType *Key() {return reinterpret_cast<HashWordType*>(m_key.data());}
|
HashWordType *Key() {return HashWordPtr(m_key.data());}
|
||||||
const HashWordType *Key() const {return reinterpret_cast<const HashWordType*>(m_key.data());}
|
const HashWordType *Key() const {return ConstHashWordPtr(m_key.data());}
|
||||||
HashWordType *Buffer() const {return reinterpret_cast<HashWordType*>(m_buffer.data());}
|
HashWordType *Buffer() const {return HashWordPtr(m_buffer.data());}
|
||||||
|
|
||||||
// VC60 workaround: bug triggered if using FixedSizeAllocatorWithCleanup
|
// VC60 workaround: bug triggered if using FixedSizeAllocatorWithCleanup
|
||||||
FixedSizeSecBlock<byte, MDC_Info<H>::KEYLENGTH, AllocatorWithCleanup<byte> > m_key;
|
FixedSizeSecBlock<byte, MDC_Info<H>::KEYLENGTH, AllocatorWithCleanup<byte> > m_key;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue