You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by bl...@apache.org on 2006/04/16 00:42:15 UTC
svn commit: r394388 -
/xml/security/trunk/c/src/enc/WinCAPI/WinCAPICryptoSymmetricKey.cpp
Author: blautenb
Date: Sat Apr 15 15:42:13 2006
New Revision: 394388
URL: http://svn.apache.org/viewcvs?rev=394388&view=rev
Log:
Fix for bug 38365 - encryption fails for small inputs in the WinCAPI crypto provider
Modified:
xml/security/trunk/c/src/enc/WinCAPI/WinCAPICryptoSymmetricKey.cpp
Modified: xml/security/trunk/c/src/enc/WinCAPI/WinCAPICryptoSymmetricKey.cpp
URL: http://svn.apache.org/viewcvs/xml/security/trunk/c/src/enc/WinCAPI/WinCAPICryptoSymmetricKey.cpp?rev=394388&r1=394387&r2=394388&view=diff
==============================================================================
--- xml/security/trunk/c/src/enc/WinCAPI/WinCAPICryptoSymmetricKey.cpp (original)
+++ xml/security/trunk/c/src/enc/WinCAPI/WinCAPICryptoSymmetricKey.cpp Sat Apr 15 15:42:13 2006
@@ -254,6 +254,17 @@
}
}
+ /* As per bug #38365 - we need to ensure there are enough characters to decrypt.
+ Otherwise we get some nasty errors due to rounding calculations when inputs
+ are too small */
+
+ else if (m_bytesInLastBlock + inLength < m_blockSize) {
+ // Not enough input data
+ memcpy(&m_lastBlock[m_bytesInLastBlock], inBuf, inLength);
+ m_bytesInLastBlock += inLength;
+ return 0;
+ }
+
DWORD outl = inLength - offset;
// Copy in last block
@@ -487,6 +498,19 @@
outl += m_ivSize;
m_ivSize = 0;
+ }
+
+ /* As per bug #38365 - we need to ensure there are enough characters to encrypt.
+ Otherwise we get some nasty errors due to rounding calculations when inputs
+ are too small */
+
+ if (m_bytesInLastBlock + inLength < m_blockSize) {
+ // Not enough input data
+ memcpy(&m_lastBlock[m_bytesInLastBlock], inBuf, inLength);
+ m_bytesInLastBlock += inLength;
+
+ // Just in case we have returned an IV
+ return outl;
}
bufPtr = &cipherBuf[offset];