.. 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 ?
If I try to change the code and use PCS5Padding ...
- paulej
- Posts: 629
- Joined: Sun Aug 23, 2009 7:32 pm
- Location: Research Triangle Park, NC, USA
- Contact:
Re: If I try to change the code and use PCS5Padding ...
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.

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.