summaryrefslogtreecommitdiff
path: root/camellia.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2016-01-24 19:52:39 -0500
committerJeffrey Walton <noloader@gmail.com>2016-01-24 19:52:39 -0500
commit7cff3c8d051529f5186685c7cf883e2992f446ff (patch)
tree60cc1f5ac243c35bcab1c24dec73f4d3ab359590 /camellia.cpp
parent9d6e3ae6efad4dbd3c95d279440ed25152c2b300 (diff)
downloadcryptopp-git-7cff3c8d051529f5186685c7cf883e2992f446ff.tar.gz
Cleared -Wcast-align (Issue 122)
Diffstat (limited to 'camellia.cpp')
-rw-r--r--camellia.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/camellia.cpp b/camellia.cpp
index 1c37d4e8..8d0b4d4e 100644
--- a/camellia.cpp
+++ b/camellia.cpp
@@ -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))