As far as I know there are two padding mechanisms, which are PKCS 5 and 7. Which one should be used for CBC?
1 Answer
They are, effectively, the same thing.
PKCS#5 describes a padding that wrote down 8-n
padding bytes, but was only valid for DES and RC2.
PKCS#7 described a padding scheme which wrote down k-n
bytes for a k-byte block cipher.
Most libraries call the scheme PKCS#7 padding, since that’s the more generalized one (and is defined for AES), but some decided that “7 fixed 5, so credit really goes to 5”.