summaryrefslogtreecommitdiff
path: root/vmac.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2016-01-24 22:01:24 -0500
committerJeffrey Walton <noloader@gmail.com>2016-01-24 22:01:24 -0500
commit917b7467b71d123b52e9cdf97b20f326e2ec7e9e (patch)
tree95a58dde241b1852c10d8a19da261cea8a951958 /vmac.cpp
parentbce92ed5e5a97cfa8ccaef54391c365834aeef08 (diff)
downloadcryptopp-git-917b7467b71d123b52e9cdf97b20f326e2ec7e9e.tar.gz
Cleared -Wcast-align (Issue 122)
Diffstat (limited to 'vmac.cpp')
-rw-r--r--vmac.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/vmac.cpp b/vmac.cpp
index d4338712..b508834c 100644
--- a/vmac.cpp
+++ b/vmac.cpp
@@ -47,6 +47,8 @@ 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");
@@ -168,13 +170,15 @@ __attribute__ ((noinline)) // Intel Compiler 9.1 workaround
#endif
VMAC_Base::VHASH_Update_SSE2(const word64 *data, size_t blocksRemainingInWord64, int tagPart)
{
- const word64 *nhK = m_nhKey();
- word64 *polyS = m_polyState();
- word32 L1KeyLength = m_L1KeyLength;
-
+ assert(IsAlignedOn(m_polyState(),GetAlignmentOf<word64>()));
+ assert(IsAlignedOn(m_nhKey(),GetAlignmentOf<word64>()));
CRYPTOPP_UNUSED(data); CRYPTOPP_UNUSED(tagPart); CRYPTOPP_UNUSED(L1KeyLength);
CRYPTOPP_UNUSED(blocksRemainingInWord64);
+ const word64 *nhK = m_nhKey();
+ word64 *polyS = (word64*)(void*)m_polyState();
+ word32 L1KeyLength = m_L1KeyLength;
+
#ifdef __GNUC__
word32 temp;
__asm__ __volatile__
@@ -532,6 +536,9 @@ template <bool T_128BitTag>
#endif
void VMAC_Base::VHASH_Update_Template(const word64 *data, size_t blocksRemainingInWord64)
{
+ assert(IsAlignedOn(m_polyState(),GetAlignmentOf<word64>()));
+ assert(IsAlignedOn(m_nhKey(),GetAlignmentOf<word64>()));
+
#define INNER_LOOP_ITERATION(j) {\
word64 d0 = ConditionalByteReverse(LITTLE_ENDIAN_ORDER, data[i+2*j+0]);\
word64 d1 = ConditionalByteReverse(LITTLE_ENDIAN_ORDER, data[i+2*j+1]);\
@@ -546,7 +553,7 @@ void VMAC_Base::VHASH_Update_Template(const word64 *data, size_t blocksRemaining
size_t L1KeyLengthInWord64 = m_L1KeyLength / 8;
size_t innerLoopEnd = L1KeyLengthInWord64;
const word64 *nhK = m_nhKey();
- word64 *polyS = m_polyState();
+ word64 *polyS = (word64*)(void*)m_polyState();
bool isFirstBlock = true;
size_t i;
@@ -861,6 +868,8 @@ static word64 L3Hash(const word64 *input, const word64 *l3Key, size_t len)
void VMAC_Base::TruncatedFinal(byte *mac, size_t size)
{
+ assert(IsAlignedOn(DataBuf(),GetAlignmentOf<word64>()));
+ assert(IsAlignedOn(m_polyState(),GetAlignmentOf<word64>()));
size_t len = ModPowerOf2(GetBitCountLo()/8, m_L1KeyLength);
if (len)