PKCS5 having no padding? I am using the javax.crypto.Cipher in Java to do AES/CBC/PKCS5Padding encryption. What I am observing is that, if you try to encrypt a Plaintext with no padding, PKCS5 adds another entire block just to padding. For example, if I got a 32bytes Plaintext, assuming that AES is using 16byte block size, the padding size should be 0. But, instead of that, PKCS5 adds another block for padding.

Is this correct or is just a matter of javax.crypto.Cipher implementation?
Is this correct or is just a matter of javax.crypto.Cipher implementation?


It is correct. You need to always add some amount of padding if you are to distinguish between different padding lengths. With PKCS5 padding the length of the padding is $b - |m| \mod b$, where $b$ is the block size. With $|m|$ a multiple of block size a whole block of padding is added.