Switch to ConditionalByteReverse. Removed mutuable hash member

pull/461/head
Jeffrey Walton 2017-08-04 16:02:32 -04:00
parent e52be9ae84
commit 24db613a81
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
1 changed files with 7 additions and 5 deletions

12
mdc.h
View File

@ -40,20 +40,23 @@ 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); memcpy_s(m_key, m_key.size(), userKey, this->KEYLENGTH);
m_hash.CorrectEndianess(Key(), Key(), 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
{ {
m_hash.CorrectEndianess(Buffer(), (HashWordType *)inBlock, this->BLOCKSIZE); ConditionalByteReverse(BIG_ENDIAN_ORDER, Buffer(), (HashWordType *)inBlock, this->BLOCKSIZE);
H::Transform(Buffer(), Key()); H::Transform(Buffer(), Key());
if (xorBlock) if (xorBlock)
{ {
m_hash.CorrectEndianess(Buffer(), Buffer(), this->BLOCKSIZE); ConditionalByteReverse(BIG_ENDIAN_ORDER, Buffer(), Buffer(), this->BLOCKSIZE);
xorbuf(outBlock, xorBlock, m_buffer, this->BLOCKSIZE); xorbuf(outBlock, xorBlock, m_buffer, this->BLOCKSIZE);
} }
else else
m_hash.CorrectEndianess((HashWordType *)outBlock, Buffer(), this->BLOCKSIZE); {
ConditionalByteReverse(BIG_ENDIAN_ORDER, (HashWordType *)outBlock, Buffer(), this->BLOCKSIZE);
}
} }
bool IsPermutation() const {return false;} bool IsPermutation() const {return false;}
@ -68,7 +71,6 @@ class MDC : public MDC_Info<H>
// 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;
mutable FixedSizeSecBlock<byte, MDC_Info<H>::BLOCKSIZE, AllocatorWithCleanup<byte> > m_buffer; mutable FixedSizeSecBlock<byte, MDC_Info<H>::BLOCKSIZE, AllocatorWithCleanup<byte> > m_buffer;
mutable H m_hash;
}; };
public: public: