425 Recitation2 DES
425 Recitation2 DES
Note: ECB mode is highly insecure and should not be used for any cryptographic application.
© Michael J. May 1
Recitation 2 Communication and Information Security Semester 2 5784
Figure 1: Screen shot of DES under ECB with ciphertext problem highlighted
The tool encrypts the text on the left side of the tool with the key shown in the top part (“columbia”). The
cipher text is shown in decimal format (bytes) on the right side.
To understand some of the problems with ECB, let’s examine the ciphertext shown in the figure above. It
was produced using the following steps:
1. Secret key “columbia”.
2. Repeating plaintext: “The quick brown dog jumped over the lazy dogs. The quick brown dog jumped
over the lazy dogs.”
© Michael J. May 2
Recitation 2 Communication and Information Security Semester 2 5784
The ciphertext output is shown in the lower half of Figure 1 with the problem highlighted.
The issue of repeating patterns holds for AES as well - it’s an ECB problem, not a cipher problem. For
example, Figure 2 shows a similar example with AES under ECB.
© Michael J. May 3
Recitation 2 Communication and Information Security Semester 2 5784
© Michael J. May 4
Recitation 2 Communication and Information Security Semester 2 5784
5 What to do
1. Start with the “empty” tool provided and make it work with DES and CBC. You can use the code
from the DESJava project to get things going quickly.
2. Perform the experiments below in Section 6.
3. Ensure the tool supports AES (use the Cipher class and “AES/CBC/PKCS5Padding”. The change is
not that large provided that you wrote the code correctly for DES. You’ll just need to make sure that
you change the cipher init and the key object definitions.
4. Perform the experiments below in Section 6. Since the key size and IV size are different in AES, you’ll
need to choose your own keys and IVs (the ones below are only 8 bytes long).
© Michael J. May 5
Recitation 2 Communication and Information Security Semester 2 5784
6 CBC Experiments
To help understand how DES and CBC work, let’s perform the following experiments. For these experiments,
use the DES/CBC/PKCS5Padding cipher suite.
6.1 Experiment 1: IV
1. Set the key to be: “746F7261626F7261”. Set the IV to be: “756E74696C6F6E65”.
2. Encrypt a file with the contents: “This is the song that doesn’t end, yes it goes on and on my friend.”
3. What do you get for cipher text?
4. Change the IV to be: “756E74696C74776F”. Decrypt the cipher text. What happened? What part of
the message got corrupted?
5. Change the IV to be: “71776565726B6965”. Decrypt the cipher text. What happened? What part of
the message got corrupted?
6. Return the IV to “756E74696C6F6E64”. Note that the last number is 4 instead of 5 as it was originally.
Decrypt the cipher text. What happened? What part of the message got corrupted?
Based on the above experiment, can you tell how many characters in the string are included in a single
block?
© Michael J. May 6
Recitation 2 Communication and Information Security Semester 2 5784
6. Change the first letter back to “R”. Change the first “T” to be “U” (i.e., the fifth word should be
“Uhere”). Encrypt the file. How many bytes changed in the cipher text?
Why does this happen? How does this relate to how CBC works?
© Michael J. May 7