3
$\begingroup$

I'm going through the Matasano crypto challenges (also known as cryptopals) and I recently got stuck in the following challenge: http://cryptopals.com/sets/2/challenges/11

The goal of the challenge is detecting the block cipher mode in AES encryption: ECB or CBC.

I saw the following post that discusses this matter, but it doesn't truly solves the problem: https://stackoverflow.com/questions/17382438/how-to-detect-block-cipher-mode

The only flaw that I know of that can help detecting the mode of operation is that ECB is stateless, i.e. similar plaintext blocks convert to similar ciphertext blocks. But in the challenge it is specified that we need to add a random number of bytes (between 5 and 10) before and after the plaintext, which causes similar blocks to slide a bit so the ciphertext result doesn't necessarily contain similar blocks. Does anyone have any hint or solution to this problem?

$\endgroup$

1 Answer 1

3
$\begingroup$

Hint: Use the plaintext XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX, where the (arbitrarily chosen) byte X is repeated at least 48 = 3 × 16 times (so that, no matter how many random bytes are prepended to this plaintext, it will always cover at least two successive AES blocks).

$\endgroup$
2
  • $\begingroup$ So the only way to detect the mode of operation in these settings are for plaintexts of this type? $\endgroup$
    – Lior Moshe
    Nov 19, 2017 at 12:46
  • $\begingroup$ I think that the challenge instructions could be clearer. But if I get it correctly, the idea is that given an encryption "black box" that takes data, adds 5-10 bytes before and after the data, then encrypts the result with ECB or CBC chosen at random, with a key chosen at random, and delivers the result, assuming you can give it some data of your choosing, you should always be able to detect if your data was encrypted with ECB or CBC. Kind of harder to specify the problem than to actually solve it... $\endgroup$
    – nilo
    May 10, 2023 at 23:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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