Switch to reinterpret_cast in MDC

pull/461/head
Jeffrey Walton 2017-08-04 19:11:53 -04:00
parent 3fe6709ae7
commit 662cccce3b
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
1 changed files with 6 additions and 7 deletions

13
mdc.h
View File

@ -39,13 +39,12 @@ class MDC : public MDC_Info<H>
{ {
CRYPTOPP_UNUSED(params); CRYPTOPP_UNUSED(params);
this->AssertValidKeyLength(length); this->AssertValidKeyLength(length);
memcpy_s(m_key, m_key.size(), userKey, this->KEYLENGTH); ConditionalByteReverse(BIG_ENDIAN_ORDER, Key(), reinterpret_cast<const HashWordType*>(userKey), this->KEYLENGTH);
ConditionalByteReverse(BIG_ENDIAN_ORDER, Key(), Key(), 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(), (HashWordType *)inBlock, this->BLOCKSIZE); ConditionalByteReverse(BIG_ENDIAN_ORDER, Buffer(), reinterpret_cast<const HashWordType*>(inBlock), this->BLOCKSIZE);
H::Transform(Buffer(), Key()); H::Transform(Buffer(), Key());
if (xorBlock) if (xorBlock)
@ -55,7 +54,7 @@ class MDC : public MDC_Info<H>
} }
else else
{ {
ConditionalByteReverse(BIG_ENDIAN_ORDER, (HashWordType *)outBlock, Buffer(), this->BLOCKSIZE); ConditionalByteReverse(BIG_ENDIAN_ORDER, reinterpret_cast<HashWordType*>(outBlock), Buffer(), this->BLOCKSIZE);
} }
} }
@ -64,9 +63,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 (HashWordType *)m_key.data();} HashWordType *Key() {return reinterpret_cast<HashWordType*>(m_key.data());}
const HashWordType *Key() const {return (const HashWordType *)m_key.data();} const HashWordType *Key() const {return reinterpret_cast<const HashWordType*>(m_key.data());}
HashWordType *Buffer() const {return (HashWordType *)m_buffer.data();} HashWordType *Buffer() const {return reinterpret_cast<HashWordType*>(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;