Hi all,
It seems there is a bug in IteratedHashBase (or in HashFilter) when
using with putMessage=true.
filters.cpp: 717
size_t HashFilter::Put2(const byte *inString, size_t length, int
messageEnd, bool blocking)
{
FILTER_BEGIN;
m_hashModule.Update(inString, length);
if (m_putMessage)
FILTER_OUTPUT(1, inString, length, 0);
// ….
}
Basically IteratedHashBase::Update() modifies inString pointer when
near the end of block (64 bytes in my case). So later FILTER_OUTPUT()
pumps a length worth of bytes starting length bytes later than it
should.
In my case, after putting in 62 bytes, I put another 4 bytes, which
comes to HashFilter::Put2() in two parts, 2 and 2 (a Pump() upstream
splits them I think). IteratedHashBase::Update() copies them into its
buffer, and increments inString by 2 inside first "if ((num+len) >=
blockSize)" block (iterhash.cpp: 29). FILTER_OUTPUT() then reads 2
bytes of whatever was in memory between inString+2 and inString+4.
Thus I loose 2 bytes and get 2 random ones instead.
Calling FILTER_OUTPUT before IteratedHashBase::Update() seems to work
around the bug. To fix that properly, IteratedHashBase::Update()
should not modify the pointer to the data (I'm not sure why it
currently does). Using a temporary instead of modifying pointer
directly should fix that I think.
(I'm using 5.5.2, HashFilter with SHA1, VS 2003.Net)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [EMAIL PROTECTED]
More information about Crypto++ and this group is available at
http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---