0

As far as I know there are two padding mechanisms, which are PKCS 5 and 7. Which one should be used for CBC?

AleksanderCH
  • 6,435
  • 10
  • 29
  • 62
Aymn Alaney
  • 461
  • 7
  • 18

1 Answers1

1

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”.

bartonjs
  • 564
  • 6
  • 12