Page 1 of 1

If I try to change the code and use PCS5Padding ...

Posted: Wed Jul 03, 2013 3:29 pm
by done8989
.. the encryption doesn't work. I receive a ShortBufferException: Output buffer too short: 32 bytes given, 48 bytes needed

Hello,
I was trying to setup the code so I could use PCS5Padding in the encryption mode but I noticed that I can't. Do you have any idea what should I do to make it work ? And, if you think it's better with nopadding, why ?

Re: If I try to change the code and use PCS5Padding ...

Posted: Thu Jul 04, 2013 12:57 am
by paulej
PKCS#5 padding is for ciphers that work with 64-bit block sizes. AES uses 128-bit block sizes. However, regardless of what padding you use, if you are getting an exception, then you've broken something :-)

I think the Linux and Windows code for AES Crypt does not do anything special with padding. I think it either leaves plaintext or ciphertext from the previous block. That gets encrypted again as a full block. The number of octets in the last block is information left outside the final block.

Why do you want to do the padding with anything that might be predictable? What I've considered doing is padding with random values. It's not clear which is better, but I prefer to never use anything predictable.