summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2016-01-25 00:12:37 -0500
committerJeffrey Walton <noloader@gmail.com>2016-01-25 00:12:37 -0500
commitcdcff65a350895bf81bc245d71ed27866a34787c (patch)
tree47302621ce15b9072e8980d8e9674a304841a7e4
parent475c574e5fc35adf74ba57e308d86e9d25531dc9 (diff)
downloadcryptopp-git-cdcff65a350895bf81bc245d71ed27866a34787c.tar.gz
Cleared -Wcast-align (Issue 122)
-rw-r--r--gcm.cpp14
-rw-r--r--vmac.cpp4
2 files changed, 11 insertions, 7 deletions
diff --git a/gcm.cpp b/gcm.cpp
index e74c7408..18067eac 100644
--- a/gcm.cpp
+++ b/gcm.cpp
@@ -89,8 +89,11 @@ inline static void SSE2_Xor16(byte *a, const byte *b, const byte *c)
inline static void Xor16(byte *a, const byte *b, const byte *c)
{
- ((word64 *)a)[0] = ((word64 *)b)[0] ^ ((word64 *)c)[0];
- ((word64 *)a)[1] = ((word64 *)b)[1] ^ ((word64 *)c)[1];
+ assert(IsAlignedOn(a,GetAlignmentOf<word64>()));
+ assert(IsAlignedOn(b,GetAlignmentOf<word64>()));
+ assert(IsAlignedOn(c,GetAlignmentOf<word64>()));
+ ((word64 *)(void *)a)[0] = ((word64 *)(void *)b)[0] ^ ((word64 *)(void *)c)[0];
+ ((word64 *)(void *)a)[1] = ((word64 *)(void *)b)[1] ^ ((word64 *)(void *)c)[1];
}
#if CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE
@@ -436,7 +439,8 @@ size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len)
#endif
typedef BlockGetAndPut<word64, NativeByteOrder> Block;
- word64 *hashBuffer = (word64 *)HashBuffer();
+ word64 *hashBuffer = (word64 *)(void *)HashBuffer();
+ assert(IsAlignedOn(hashBuffer,GetAlignmentOf<word64>()));
switch (2*(m_buffer.size()>=64*1024)
#if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)
@@ -459,7 +463,7 @@ size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len)
data += HASH_BLOCKSIZE;
len -= HASH_BLOCKSIZE;
- #define READ_TABLE_WORD64_COMMON(a, b, c, d) *(word64 *)(table+(a*1024)+(b*256)+c+d*8)
+ #define READ_TABLE_WORD64_COMMON(a, b, c, d) *(word64 *)(void *)(table+(a*1024)+(b*256)+c+d*8)
#ifdef IS_LITTLE_ENDIAN
#if CRYPTOPP_BOOL_SLOW_WORD64
@@ -530,7 +534,7 @@ size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len)
#undef READ_TABLE_WORD64_COMMON
#undef READ_TABLE_WORD64
- #define READ_TABLE_WORD64_COMMON(a, c, d) *(word64 *)(table+(a)*256*16+(c)+(d)*8)
+ #define READ_TABLE_WORD64_COMMON(a, c, d) *(word64 *)(void *)(table+(a)*256*16+(c)+(d)*8)
#ifdef IS_LITTLE_ENDIAN
#if CRYPTOPP_BOOL_SLOW_WORD64
diff --git a/vmac.cpp b/vmac.cpp
index b508834c..c3c97cfe 100644
--- a/vmac.cpp
+++ b/vmac.cpp
@@ -47,8 +47,6 @@ static const word128 m126 = (word128(m62)<<64)|m64; /* 126-bit mask */
void VMAC_Base::UncheckedSetKey(const byte *userKey, unsigned int keylength, const NameValuePairs &params)
{
- assert(IsAlignedOn(m_l3Key(),GetAlignmentOf<word64>()));
-
int digestLength = params.GetIntValueWithDefault(Name::DigestSize(), DefaultDigestSize());
if (digestLength != 8 && digestLength != 16)
throw InvalidArgument("VMAC: DigestSize must be 8 or 16");
@@ -89,6 +87,8 @@ void VMAC_Base::UncheckedSetKey(const byte *userKey, unsigned int keylength, con
in[0] = 0xE0;
in[15] = 0;
word64 *l3Key = m_l3Key();
+ assert(IsAlignedOn(l3Key,GetAlignmentOf<word64>()));
+
for (i = 0; i <= (size_t)m_is128; i++)
do
{