fix bug #185
parent
fb206e53d7
commit
aaed9ae803
21
modes.cpp
21
modes.cpp
|
|
@ -207,10 +207,19 @@ void CBC_CTS_Encryption::ProcessLastBlock(byte *outString, const byte *inString,
|
|||
// steal from next to last block
|
||||
xorbuf(m_register, inString, BlockSize());
|
||||
m_cipher->ProcessBlock(m_register);
|
||||
if (inString == outString)
|
||||
{
|
||||
length -= BlockSize();
|
||||
memcpy(outString, inString+BlockSize(), length);
|
||||
memcpy(outString+BlockSize(), m_register, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
inString += BlockSize();
|
||||
length -= BlockSize();
|
||||
memcpy(outString+BlockSize(), m_register, length);
|
||||
}
|
||||
}
|
||||
|
||||
// output last full ciphertext block
|
||||
xorbuf(m_register, inString, length);
|
||||
|
|
@ -266,6 +275,17 @@ void CBC_CTS_Decryption::ProcessLastBlock(byte *outString, const byte *inString,
|
|||
if (stealIV)
|
||||
memcpy(outString, m_temp, length);
|
||||
else
|
||||
{
|
||||
if (inString == outString)
|
||||
{
|
||||
memcpy(outString, inString+BlockSize(), length);
|
||||
memcpy(outString+BlockSize(), m_temp, length);
|
||||
// decrypt next to last plaintext block
|
||||
memcpy(m_temp, pn1, length);
|
||||
m_cipher->ProcessBlock(m_temp);
|
||||
xorbuf(outString, m_temp, m_register, BlockSize());
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(outString+BlockSize(), m_temp, length);
|
||||
// decrypt next to last plaintext block
|
||||
|
|
@ -274,6 +294,7 @@ void CBC_CTS_Decryption::ProcessLastBlock(byte *outString, const byte *inString,
|
|||
xorbuf(outString, m_temp, m_register, BlockSize());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NAMESPACE_END
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue