Update padding check logic

pull/416/head
Jeffrey Walton 2017-05-09 15:48:52 -04:00
parent f817fc7c2e
commit 3b4a9e2ccf
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
1 changed files with 9 additions and 8 deletions

View File

@ -611,14 +611,15 @@ void StreamTransformationFilter::InitializeDerivedAndReturnNewSizes(const NameVa
else
m_padding = padding;
if (!isBlockCipher && (m_padding == PKCS_PADDING))
if (!isBlockCipher)
{
if (m_padding == PKCS_PADDING)
throw InvalidArgument("StreamTransformationFilter: PKCS_PADDING cannot be used with " + m_cipher.AlgorithmName());
if (!isBlockCipher && (m_padding == W3C_PADDING))
else if (m_padding == W3C_PADDING)
throw InvalidArgument("StreamTransformationFilter: W3C_PADDING cannot be used with " + m_cipher.AlgorithmName());
if (!isBlockCipher && (m_padding == ONE_AND_ZEROS_PADDING))
else if (m_padding == ONE_AND_ZEROS_PADDING)
throw InvalidArgument("StreamTransformationFilter: ONE_AND_ZEROS_PADDING cannot be used with " + m_cipher.AlgorithmName());
}
firstSize = 0;
blockSize = m_cipher.MandatoryBlockSize();