RijndaelManaged Padding when data matches block size

Posted by trampster on Stack Overflow See other posts from Stack Overflow or by trampster
Published on 2010-05-03T04:52:43Z Indexed on 2010/05/03 4:58 UTC
Read the original article Hit count: 311

Filed under:
|

If I use PKCS7 padding in RijndaelManaged with 16 bytes of data then I get 32 bytes of data output. It appears that for PKCS7 when the data size matches the block size it adds a whole extra block of data.

If I use Zeros padding for 16 bytes of data I get out 16 bytes of data. So for Zeros padding if the data matches the block size then it doesn't pad.

I have searched through the documentation and it says nothing about this difference in padding behavior.

Can someone please point me to some kind of documentation which specifies what the padding behavior should be for the different padding modes when the data size matches the block size.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET