Skip to content

Commit 46a9323

Browse files
committed
patched CryptoPP Crypto++ to add support for AES-256-CBC with W3C padding scheme (based on readium/readium-lcp-client#26 )
1 parent a6105c5 commit 46a9323

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

filters.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@ void StreamTransformationFilter::LastPut(const byte *inString, size_t length)
701701

702702
case PKCS_PADDING:
703703
case ONE_AND_ZEROS_PADDING:
704+
case W3C_PADDING:
704705
unsigned int s;
705706
s = m_cipher.MandatoryBlockSize();
706707
CRYPTOPP_ASSERT(s > 1);
@@ -735,6 +736,13 @@ void StreamTransformationFilter::LastPut(const byte *inString, size_t length)
735736
throw InvalidCiphertext("StreamTransformationFilter: invalid PKCS #7 block padding found");
736737
length = s-pad;
737738
}
739+
else if (m_padding == W3C_PADDING)
740+
{
741+
byte pad = space[s - 1];
742+
if (pad < 1 || pad > s)
743+
throw InvalidCiphertext("StreamTransformationFilter: invalid W3C block padding found");
744+
length = s - pad;
745+
}
738746
else
739747
{
740748
while (length > 1 && space[length-1] == 0)

filters.h

+2
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,8 @@ struct BlockPaddingSchemeDef
480480
PKCS_PADDING,
481481
//! \brief 1 and 0's padding added to a block
482482
ONE_AND_ZEROS_PADDING,
483+
//! \brief [Random bytes (0 ~ N-2) and padding's length (N-1)]'s padding to a block
484+
W3C_PADDING,
483485
//! \brief Default padding scheme
484486
DEFAULT_PADDING
485487
};

0 commit comments

Comments
 (0)