20-CS-5153 | Network Security | Spring 2017 |
---|---|---|
Lab 2 |
Adding Authentication and Encryption
Due: Feburary 13, 2017 (submit instructions: here)
Rationale: | |||
To add encryption and decryption routines to the solution of Lab 1 for
encrypted communication with the monitor.
| |||
Lab Problem: | |||
Write C++ or Java code to support encrypted communication with the
Monitor. This code should be added to the code you wrote for Lab 1. The protocol for encrypted transmissions is as follows:
The cryptosystem is set up as follows: split the bits of the shared secret into two halves: a left key half and a right key half (left is lower order bytes). To encrypt, first add a "guard" byte of value 42. Then, for each block of plaintext, divide the block into a left and right half. Find the message digest of the concatenation of the left plaintext half and the left key half. XOR the digest with the right plaintext half. This produces the right ciphertext half. Find the message digest of the ciphertext right half concatenated with the key right half. XOR the digest with the plaintext left half. This gives the ciphertext left half. Output the ciphertext left half then the ciphertext right half. To decrypt, strip the guard byte. For each ciphertext block, split the block into a left half and a right half. Find the message digest of the ciphertext right half concatenated with the key right half. XOR the result with the ciphertext left half to obtain the plaintext left half. Find the message digest of the plaintext left half and the key left half. XOR the result with the ciphertext right half to get the plaintext right half. The monitor recognizes block sizes of 40 bytes. Messages may have to be padded to get this blocksize. Sample (incomplete) code is given in Karn.java. Use of the class defined in this file is illustrated by KarnTestServer.java and KarnTestClient.java. Use as follows in Unix: java KarnTestServer & java KarnTestClient "The quick brown fox jumped over the lazy dog's back"You will need Karn.class to do this until you have built your own Karn class. You will also need DiffieHellmanExchange.java, DHKey (you may have to rename it to DHKey if you save the link - sometimes it saves as DHKey.bin), and PlantDHKey.java. Compile PlantDHKey.java first, then DiffieHellman.java, then the Karn Client and the Karn Server. |