diff --git a/filters.cpp b/filters.cpp index 95654b47..dcc65f5d 100644 --- a/filters.cpp +++ b/filters.cpp @@ -700,8 +700,8 @@ void StreamTransformationFilter::LastPut(const byte *inString, size_t length) break; case PKCS_PADDING: - case ONE_AND_ZEROS_PADDING: case W3C_PADDING: + case ONE_AND_ZEROS_PADDING: unsigned int s; s = m_cipher.MandatoryBlockSize(); CRYPTOPP_ASSERT(s > 1); @@ -713,9 +713,15 @@ void StreamTransformationFilter::LastPut(const byte *inString, size_t length) if (m_padding == PKCS_PADDING) { CRYPTOPP_ASSERT(s < 256); - byte pad = byte(s-length); + byte pad = static_cast(s-length); memset(space+length, pad, s-length); } + else if (m_padding == W3C_PADDING) + { + CRYPTOPP_ASSERT(s < 256); + memset(space+length, 0, s-length-1); + space[s-1] = static_cast(s-length); + } else { space[length] = 0x80; diff --git a/filters.h b/filters.h index 8851dfdb..a079fdba 100644 --- a/filters.h +++ b/filters.h @@ -480,7 +480,7 @@ 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 + //! \brief W3C padding added to a block W3C_PADDING, //! \brief Default padding scheme DEFAULT_PADDING