-1
$\begingroup$

What are the length of ciphertexts when 16 bytes and 18 bytes of plaintext are encrypted with AES using ECB mode?

$\endgroup$
  • 1
    $\begingroup$ Welcome. Hint: Consider PKCS#7 padding $\endgroup$ – kelalaka Jul 10 at 17:48
  • $\begingroup$ also consider without padding... basically saying that padding will make a difference $\endgroup$ – Richie Frame Jul 10 at 20:27
1
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.