What are the length of ciphertexts when 16 bytes and 18 bytes of plaintext are encrypted with AES using ECB mode?
1 Answer
The ECB mode operates on full blocks, and AES has a 128 bit block size.
Which means that if the input is not a multiple of 128 bit, we have to fill the remaining bits with something. Something that, in addition, can be used by the decryption function to figure out how many bits in the last block are actual data.
In practice, this requires at least one extra byte: if the last block has 16 bytes of data, we still need to encode the fact that there is no padding.
So, a 15 bytes message + 1 byte to encode the fact that there is no padding would fit in a single AES block.
A 16 bytes message needs an extra block. The extra block makes enough room for a 18 bytes message.