# Cryptool - DES (ECB and CBC ) - double encyption

So, I uploaded a text file in Cryptool and encrypted it with DES-ECB with the key FF FF FF FF FF FF FF FF. I encrypted the cipher text again, with DES-CBC using the same key. Then, I encrypted the obtained text with DES-CBC again.

The first 8 characters match the encrypted text of ECB. The rest of it is different. I would like to know why those 8 characters are similar and why the rest of it are not? It would be very helpful if anyone could explain this to me.

• Experts can someone please assist me in understanding this,unable to get into chat due to low reputation. Thanks in advance Commented Jul 4, 2014 at 6:39
• What IV did you use in CBC mode? Commented Jul 4, 2014 at 7:09
• @HennoBrandsma, Sorry I am a newbie to cryptool.How do we look for initialization vector in cryptool? Commented Jul 4, 2014 at 13:47

There are a couple of things going on:

• First of all, the DES key FF FF FF FF FF FF FF FF happens to be a "DES weak key"; by that, we mean that if you send a block through the cipher twice, it'll end up with the original value; that is:

$$X = DES_{weak}( DES_{weak} ( X ))$$

• You are obviously encrypting in CBC mode with a zero IV.

So, let us look at what happens to the first block during your encryption. He's call the initial value of that plaintext block $A$ (which is 44 6F 75 62 6C 65 20 65 in your example)

• First you encrypt the text in ECB mode. For the first block, this just sends it through DES, resulting in a ciphertext block we're call $B$ (which is A3 77 A8 0A AD 2B EA 6E in your example:

$$B = DES_{weak}(A)$$

• Then, you encrypt that in CBC mode (with a zero IV). For the first block, this exclusive or's the block with the IV, and sends it through DES. Because we are using a weak key, this results in the original $A$ block, as:

$$DES_{weak}(IV \oplus B) = DES_{weak}(B) = DES_{weak}(DES_{weak}(A)) = A$$

• Lastly, you encrypt the text again in ECB mode. For the first block, this just redoes what we did in the first pass (because the first block is the exact same value it was):

$$B = DES_{weak}(A)$$

Now, this doesn't happen with the second block; that's because of the CBC mode in the second pass. CBC mode exclusive or's in the value of the first block, and since that is not zero, the second equation does not hold.

• Thank you for your valuable feedback. It was really helpful. Commented Jul 4, 2014 at 16:29