Cleared -Wcast-align (Issue 122)

pull/136/head
Jeffrey Walton 2016-01-24 19:52:39 -05:00
parent 9d6e3ae6ef
commit 7cff3c8d05
2 changed files with 13 additions and 7 deletions

View File

@ -91,11 +91,15 @@ void Camellia::Base::UncheckedSetKey(const byte *key, unsigned int keylen, const
kwl = (word64(k0) << 32) | k1; \
kwr = (word64(k2) << 32) | k3
#define KS_ROUND_0(i) \
*(word64*)CALC_ADDR(ks32, i+EFI(0)) = kwl; \
*(word64*)CALC_ADDR(ks32, i+EFI(1)) = kwr
assert(IsAlignedOn(CALC_ADDR(ks32, i+EFI(0)),GetAlignmentOf<word64>())); \
assert(IsAlignedOn(CALC_ADDR(ks32, i+EFI(1)),GetAlignmentOf<word64>())); \
*(word64*)(void*)CALC_ADDR(ks32, i+EFI(0)) = kwl; \
*(word64*)(void*)CALC_ADDR(ks32, i+EFI(1)) = kwr
#define KS_ROUND(i, r, which) \
if (which & (1<<int(r<64))) *(word64*)CALC_ADDR(ks32, i+EFI(r<64)) = (kwr << (r%64)) | (kwl >> (64 - (r%64))); \
if (which & (1<<int(r>64))) *(word64*)CALC_ADDR(ks32, i+EFI(r>64)) = (kwl << (r%64)) | (kwr >> (64 - (r%64)))
assert(IsAlignedOn(CALC_ADDR(ks32, i+EFI(r<64)),GetAlignmentOf<word64>())); \
assert(IsAlignedOn(CALC_ADDR(ks32, i+EFI(r>64)),GetAlignmentOf<word64>())); \
if (which & (1<<int(r<64))) *(word64*)(void*)CALC_ADDR(ks32, i+EFI(r<64)) = (kwr << (r%64)) | (kwl >> (64 - (r%64))); \
if (which & (1<<int(r>64))) *(word64*)(void*)CALC_ADDR(ks32, i+EFI(r>64)) = (kwl << (r%64)) | (kwr >> (64 - (r%64)))
#else
// SSE2 version is 30% faster on Intel Core 2. Doesn't seem worth the hassle of maintenance, but left here
// #if'd out in case someone needs it.
@ -216,9 +220,11 @@ void Camellia::Base::ProcessAndXorBlock(const byte *inBlock, const byte *xorBloc
const int cacheLineSize = GetCacheLineSize();
unsigned int i;
word32 u = 0;
assert(IsAlignedOn(s1,GetAlignmentOf<word32>()));
for (i=0; i<256; i+=cacheLineSize)
u &= *(const word32 *)(s1+i);
u &= *(const word32 *)(s1+252);
u &= *(const word32 *)(void*)(s1+i);
u &= *(const word32 *)(void*)(s1+252);
lh |= u; ll |= u;
SLOW_ROUND(lh, ll, rh, rl, KS(1,0), KS(1,1))

View File

@ -31,7 +31,7 @@ class Camellia : public Camellia_Info, public BlockCipherDocumentation
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
protected:
static const byte s1[256];
CRYPTOPP_ALIGN_DATA(4) static const byte s1[256];
static const word32 SP[4][256];
unsigned int m_rounds;