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

Discussion related to AES Crypt, the file encryption software for Windows, Mac, Linux, and FreeBSD.
Post Reply
done8989
Posts: 1
Joined: Wed Jul 03, 2013 3:22 pm

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

Post 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 ?
User avatar
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 ...

Post 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.
Post Reply