santuario-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Milan Tomic" <mi...@setcce.org>
Subject [c++] WinCAPICryptoSymmetricKey::encrypt()
Date Mon, 29 Aug 2005 08:28:48 GMT
Berin,

I have found very interesting bug inside
WinCAPICryptoSymmetricKey::encrypt(). I've been encrypting an XML file
and used encrypt content (not whole element) option (
cipher->encryptElementContent() func ). The bug occur when there are
i.e. less then 12 (in my case only 4) characters inside XML element to
encrypt. In the case of 4 characters values are:

//unsigned int rounding = (m_bytesInLastBlock + inLength) % m_blockSize;
unsigned int rounding = (0 + 4) % 8; // rounding == 8 now

//rounding += m_blockSize;
rounding += 8; // rounding == 12 now

//memcpy(m_lastBlock, &inBuf[inLength - rounding], rounding);
memcpy(m_lastBlock, &inBuf[4 - 12], 12); // 4 - 12 ??? buffer
"underflow"

//memcpy(bufPtr, inBuf, inLength - rounding);
memcpy(bufPtr, inBuf, 4 - 12); // again 4 - 12 :(

Best regards,
Milan

Mime
View raw message