For ECB, CBC, and CFB, padding is required when the plaintext does not fill out a complete multiple of the block size. However, I have heard that is good practice to pad all messages, even if the plaintext does fill out a complete multiple of the block size. What benefit does doing such a thing have? Does it increase security in any way?

  • 1
    $\begingroup$ Where did you hear this? In some cases there may be a minor benefit to hiding some information about a message's length, you may be misinterpreting what you've read: If you want to allow messages that aren't a multiple of the block size, then padding is required even for a message that is a multiple of the block size. Otherwise, how can you tell a padded message apart from a plaintext that happens to end in a sequence of bytes that is also valid padding? $\endgroup$ – Seth Mar 22 '16 at 5:17
  • 2
    $\begingroup$ CFB doesn't require padding. $\endgroup$ – CodesInChaos Mar 22 '16 at 10:04
  • 3
    $\begingroup$ Related question: Why can the last block contain a full block of padding in CBC Encryption? $\endgroup$ – CodesInChaos Mar 22 '16 at 10:14
  • $\begingroup$ @CodesInChaos, while theoretically CFB does not require padding, NIST requires that you use padding with it... Anyway, I think this is simply dupe of the question you linked. $\endgroup$ – otus Jun 22 '16 at 7:01

Browse other questions tagged or ask your own question.