## We discussed the One-Time-Pad cipher and showed that Eve‚Äôs guesses for the key are futile as she can get any reasonably looking result.

### computer science

##### Description

Exercise Sheet Cryptography

Advanced Computer Networks and Security, DI8001, HT19, LP1

1. We discussed the One-Time-Pad cipher and showed that Eve‚Äôs guesses for the key are futile as she can get any reasonably looking result. Check that the second key she guessed indeed decrypts the ciphertext to ‚ÄúLATER‚Äù. If it does, what should be the key stream to give ‚ÄúNEVER‚Äù instead. If it does not, correct the key so that you do get ‚ÄúLATER‚Äù. You can (of course) write a computer program in the language of your choice to help with this.

2. Implement a simple OTP cipher (in Python or any other language) that uses XOR for encryption. That is, your program should be able to read key material from a file and combine it with the plaintext data from another file to produce ciphertext, and vice versa (ciphertext to plaintext). Otherwise, design, implementation or interface details are up to you.

3. Consider the RSA cipher. Assume that the following two prime numbers are selected, P=7 and Q=11. Compute N and W. Select a valid public exponent E. Given the selected public exponent E, compute the private exponent D. What are the public key and private key here? Show an example encryption and decryption with these keys.

4. During the lectures we have seen how the generic RSA encryption and decryption can be done in Java using the BigInteger numbers. Big integers are the default in Python, implement the same generic RSA algorithms in Python. For this you will need the modular power operation and modular inverse. For the first, you can use pow(x,y,z) which gives you x y mod z, for the second use Google to find a suitable implementation of the Euclidean algorithm in Python.

5. Following the same principles, implement the generic Diffie-Hellman scheme in Python as it was done in Java during the lectures.

6. For RSA, the generic algorithm that works on (large) integers is in essence the same as the crypto library implementation. The library implementation only differs from the generic one in that it:

‚óã pads the data automatically to provide input of a fixed bit length, and

‚óã transforms the character/byte input into a corresponding (large) integer.