patched CryptoPP Crypto++ to add support for AES-256-CBC with W3C padding scheme (based on https://github.com/readium/readium-lcp-client/pull/26 )

pull/368/head
danielweck 2017-01-24 16:40:26 +00:00
parent a6105c5417
commit 46a9323d19
2 changed files with 10 additions and 0 deletions

View File

@ -701,6 +701,7 @@ void StreamTransformationFilter::LastPut(const byte *inString, size_t length)
case PKCS_PADDING:
case ONE_AND_ZEROS_PADDING:
case W3C_PADDING:
unsigned int s;
s = m_cipher.MandatoryBlockSize();
CRYPTOPP_ASSERT(s > 1);
@ -735,6 +736,13 @@ void StreamTransformationFilter::LastPut(const byte *inString, size_t length)
throw InvalidCiphertext("StreamTransformationFilter: invalid PKCS #7 block padding found");
length = s-pad;
}
else if (m_padding == W3C_PADDING)
{
byte pad = space[s - 1];
if (pad < 1 || pad > s)
throw InvalidCiphertext("StreamTransformationFilter: invalid W3C block padding found");
length = s - pad;
}
else
{
while (length > 1 && space[length-1] == 0)

View File

@ -480,6 +480,8 @@ struct BlockPaddingSchemeDef
PKCS_PADDING,
//! \brief 1 and 0's padding added to a block
ONE_AND_ZEROS_PADDING,
//! \brief [Random bytes (0 ~ N-2) and padding's length (N-1)]'s padding to a block
W3C_PADDING,
//! \brief Default padding scheme
DEFAULT_PADDING
};