I am currently doing the Matasano Crypto Challenge to learn a bit about cryptography. In that specific challenge one had to implement AES in CBC mode. I did that and verified that encryption and decryption are working using these test vectors. I can't manage to decrypt the message given in the challenge though. I am not asking you to decrypt it, but when I thought about it a bit more I got a bit confused due to the used IV (which is 0x00 for each byte). Doesn't this IV have no effect at all since the decrypted message just get's XORed against the IV? Shouldn't decryption also be possible using simple AES-ECB?

EDIT: Sourcecode in Java: http://pastebin.com/cX8YZjD0

  • 1
    $\begingroup$ IV equals to constant zero means that the IV has no impact only on the first block. but for all the others something changes, try to give a look to this picture (from here: di.ens.fr/~jean/latex_crypto). For the first block you xor it with zero, but for the second you xor it with $c_0$ ... $\endgroup$
    – ddddavidee
    Dec 1, 2015 at 12:51
  • $\begingroup$ True, I forgot about that since I only dealt with 16 byte texts.. But the first 16 byte are encrypted just like with ECB, aren't they? Does this also mean something is wrong when my algorithm produces random gibberish in the first 16 bytes? $\endgroup$
    – Joba
    Dec 1, 2015 at 13:06
  • $\begingroup$ You might have the wrong key. Or maybe the first 16 bytes of plaintext are gibberish. With an all 0 IV and 16 byte plaintext, yes, it is equivalent to ECB. $\endgroup$
    – mikeazo
    Dec 1, 2015 at 13:38
  • $\begingroup$ @Joba, sorry, I did not check the plaintext length, so my comment was more general. $\endgroup$
    – ddddavidee
    Dec 1, 2015 at 13:43

1 Answer 1


I suppose you have removed the base64 decoding, so you are working on the raw data.

Then indeed the first block is decrypted as if we were in ECB-mode, because after decrypting the first block, we xor with the IV, which is all 0 and indeed has no effect.

However, the IV for the next block will be the original previous ciphertext block. So after decrypting that block we have to xor with this new IV, so there we cannot suffice with just ECB mode. See also this picture from the comments:

enter image description here

  • $\begingroup$ I in fact implemented that in my algorithm. However the same algorithm that decrypted the code in the ECB challenge doesn't even work on the first block of this one. I suppose this is not the right place to post my code? $\endgroup$
    – Joba
    Dec 1, 2015 at 21:10
  • $\begingroup$ @Joba Posting of code has been known to happen here... $\endgroup$ Dec 1, 2015 at 21:12
  • $\begingroup$ Does that mean I should, or should I rather do that on StackOverflow? $\endgroup$
    – Joba
    Dec 1, 2015 at 21:24
  • $\begingroup$ I say, post it. $\endgroup$ Dec 2, 2015 at 4:47
  • $\begingroup$ Editied in a link to the sourcecode. $\endgroup$
    – Joba
    Dec 2, 2015 at 9:55

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.