Given this formula for CBC encryption from 6.2 The Cipher Block Chaining Mode

C_1 = CIPH_K(P_1 ⊕ IV); C_j = CIPH_K(P_j ⊕ C_(j-1)) for j = 2 ... n

what is the output length of CBC if plaintext P is of length 0?

  • 1
    It is a block cipher - so it would involve padding - so the length of P would never be 0. So I believe the Cipher size should be exactly equal to one block size.
    – Y123
    Jul 14, 2015 at 22:38

1 Answer 1


Block ciphers like CBC require an input as multiple of the block size. In this case P would need to be padded to be one block long.

Another thing to notice is that the first block of P is being XORed with the IV which is also one block long - this will also ensure that you start with an input data of size which is at least one block long.

Being a block cipher your output will be the same size as input (excluding any communications for IV between sender and receiver).

  • By multiple of the block size you mean a non-zero multiple of the block size, right? So it is safe to declare 0 as an invalid input length of block cipher modes (like CBC) and padding needs to respect that? Jul 15, 2015 at 12:11
  • Yes that is correct @SimonWarta. The minimum being one block size due to padding (and indirectly by XORing with one block sized IV).
    – Y123
    Jul 15, 2015 at 17:26
  • 1
    Thanks a lot! You just supported the Botan C++11 crypto library by sharing that insight :) Jul 16, 2015 at 6:37
  • @SimonWarta, That is wonderful to know! How do I find out - if I could contribute more actively to the project?
    – Y123
    Jul 16, 2015 at 17:29
  • To be precise, you confirmed that my fix in round_up() towards mathematically correct rounding can be done because length must not be 0 in occurrence 7. 8. and 9.: github.com/randombit/botan/commit/… There is a lot more to do, including long term discussions about cryptography. I'd love to see you contributing with knowledge or code: github.com/randombit/botan/issues Jul 16, 2015 at 17:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .