This shows you the differences between two versions of the page.
|
ic:laboratoare:02 [2020/10/07 20:21] acosmin.maria |
ic:laboratoare:02 [2020/10/19 14:38] (current) acosmin.maria |
||
|---|---|---|---|
| Line 10: | Line 10: | ||
| * **ex1.py**: implementation of exercise 1; | * **ex1.py**: implementation of exercise 1; | ||
| * **ex2.py**: implementation of exercise 2; | * **ex2.py**: implementation of exercise 2; | ||
| - | * **ex3.py**: implementation of exercise 3; | + | * **ex3.py**: implementation of exercise 3. |
| - | * **ex4.py**: implementation of exercise 4. | + | |
| You need to fill in the TODOs from **ex1.py**, **ex2.py**, and **ex3.py**. | You need to fill in the TODOs from **ex1.py**, **ex2.py**, and **ex3.py**. | ||
| Line 45: | Line 45: | ||
| Alice sends Bob another ciphertext, but much longer this time... | Alice sends Bob another ciphertext, but much longer this time... | ||
| + | |||
| + | {{:ic:res:msg_ex2.txt|Download message file}} | ||
| Charlie needs to decrypt this as well. Some colleagues tell him this is encrypted | Charlie needs to decrypt this as well. Some colleagues tell him this is encrypted | ||
| using the substitution cipher, and that again the plaintext consists only of the English letters **A** to **Z** (all capitals, no punctuation). Try to help Charlie to decrypt this. | using the substitution cipher, and that again the plaintext consists only of the English letters **A** to **Z** (all capitals, no punctuation). Try to help Charlie to decrypt this. | ||
| - | Hint: use the frequency analysis mechanisms we discussed in class. Note that the frequency of each letter does not map precisely. In particular, the most frequent two letters do match well with the given table, but the others are sometimes mixed. However, Charlie knows that the most frequent bi-grams are the following (from most frequent to less frequent): | + | **Hint:** use the frequency analysis mechanisms we discussed in class. Note that the frequency of each letter does not map precisely. In particular, the most frequent two letters do match well with the given table, but the others are sometimes mixed. However, Charlie knows that the most frequent bi-grams are the following (from most frequent to less frequent): |
| **TH**, **HE**, **IN**, **OR**, **HA**, **ET**, **AN**, **EA**, **IS**, **OU**, **HI**, **ER**, **ST**, **RE**, **ND** | **TH**, **HE**, **IN**, **OR**, **HA**, **ET**, **AN**, **EA**, **IS**, **OU**, **HI**, **ER**, **ST**, **RE**, **ND** | ||
| Line 57: | Line 59: | ||
| ==== Exercise 3 (4p) ==== | ==== Exercise 3 (4p) ==== | ||
| - | Charlie manages to capture the last communication which turns out to be the most important, so it is crucial he decrypts it. However, this time Alice used the Vigenere cipher, with a key that Charlie knows has **7** characters. | + | Charlie manages to capture {{:ic:res:msg_ex3.txt|a last communication}} which turns out to be the most important, so it is crucial he decrypts it. However, this time Alice used the Vigenere cipher, with a key that Charlie knows has **7** characters. |
| The ciphertext is in the file attached. Try the method of multiplying probabilities as explained in class and see if you can decrypt the ciphertext. You can find details about this method [[http://www.cs.mtu.edu/~shene/NSF-4/Tutorial/VIG/Vig-Recover.html|here]]. | The ciphertext is in the file attached. Try the method of multiplying probabilities as explained in class and see if you can decrypt the ciphertext. You can find details about this method [[http://www.cs.mtu.edu/~shene/NSF-4/Tutorial/VIG/Vig-Recover.html|here]]. | ||
| Line 94: | Line 96: | ||
| ==== Bonus: Exercise 4 (2p) ==== | ==== Bonus: Exercise 4 (2p) ==== | ||
| - | In class, we explained that the one-time pad is malleable (i.e. we can easily change the encrypted plaintext by simply modifying the ciphertext). We have also discussed how the CRC was a very bad idea in the design of WEP due to its linearity. | + | In class, we explained that the One Time Pad is malleable (i.e. we can easily change the encrypted plaintext by simply modifying the ciphertext). We have also discussed how the CRC was a very bad idea in the design of WEP due to its linearity. |
| You are given the following ciphertext in hexadecimal: | You are given the following ciphertext in hexadecimal: | ||
| Line 114: | Line 116: | ||
| def main(): | def main(): | ||
| - | |||
| - | cipher = '021e0e061d1694c9' | ||
| - | crc_s1 = '8e31' | ||
| # Plaintexts | # Plaintexts | ||
| s1 = 'floare' | s1 = 'floare' | ||
| s2 = 'albina' | s2 = 'albina' | ||
| - | |||
| - | s1_xor_s2 = strxor(s1, s2) | ||
| - | crc_s2 = '54ba' # hex_xor(crc_s1, crc_s1_xor_s2) | ||
| - | |||
| G = '' # To find | G = '' # To find | ||
| - | C1 = cipher[:-4] | ||
| - | C2 = cipher[-4:] | ||
| # Obtain crc of s1 | # Obtain crc of s1 | ||