Assignment 1Encryption and Decryption Algorithms
Assignment Date: 9/8/2015
Deadlines: Step1: 9/18/2015; Step 2: 9/25/2015



Narrative:
You have been hired as an intern at NSA. Your team has been charged with implementing and testing a set of encryption/decryption algorithms. Specifically, you are assigned to the DecryptTeam, who is responsible for implementing the decryption algorithms for a new cryptosystem. Fortunately, you are given all necessary specs, some test plaintext/ciphertext pairs, and the related encryption keys, which you can use to demonstrate your code works correctly and can recover the plaintext with no errors.

Assignment Goals:
In this assignment, you are required to develop a set of decryption tools. The assignment will be conducted in 2 different steps, with increasing levels of difficulty.

Description:
You will be presented with a series of encrypted messages, related encryption keys, and the specification for the cryptosystem used to generate the ciphertext.

Step 1: decrypt a fixed length data block using a one-round DES-like algorithm

block_size = 32 bits
key_size = 32 bits
half_block = 16 bits (left or right side of a block)
right_key = least significant 16 bits of the key
left_key = most significant 16 bits of the key
mangler_function = (half_block ^ right_key) | (half_block ^ left_key)

Step 2: similar to Step 1; but message can be of any byte length, is encrypted using ECB, and is padded using PKCS#5.



Hints:
1) Remember to work with "raw" bytes. Do not let the type casting/encoding features of the programming language get in the way of your algorithm.


Grading:
This Assignment is worth 10 points

Step1: 6 points
Step2: 4 points


Inputs you will be given for each step:

1) A set of files containing known plaintext P
1_step1_example.msg
2_step1_example.msg
3_step1_example.msg
4_step1_example.msg
5_step1_example.msg

1_step2_example.msg
2_step2_example.msg
3_step2_example.msg
4_step2_example.msg
5_step2_example.msg

2) A set of files containing a key K consisting of 4 ASCII characters (e.g., "ABCD")
1_step1_example.key
2_step1_example.key
3_step1_example.key
4_step1_example.key
5_step1_example.key

1_step2_example.key
2_step2_example.key
3_step2_example.key
4_step2_example.key
5_step2_example.key

3) A set of files containing the ciphertext C obtained by encrypting P using K
1_step1_example.enc
2_step1_example.enc
3_step1_example.enc
4_step1_example.enc
5_step1_example.enc

1_step2_example.enc
2_step2_example.enc
3_step2_example.enc
4_step2_example.enc
5_step2_example.enc


4) A file containing a second encrypted message E, which needs to be decrypted with a given key

LastName_step1_ciphertext.enc (e.g., Perdisci_step1_ciphertext.enc)
LastName_step1.key (e.g., Perdisci_step1.key)

LastName_step2_ciphertext.enc (e.g., Perdisci_step2_ciphertext.enc)
LastName_step2.key (e.g., Perdisci_step2.key)

Your files can be retreived under this URL: http://cobweb.cs.uga.edu/~perdisci/CSCIx250-F15/Assignments/Assignment1-files/FILENAME, where FILENAME is the name of your assignments files, formatted as explained above.



Hint: inputs 1-3 will allow you to test the correctness of your decryption algorithm

Goal: Find the plaintext that, when encrypted using K, produces E


Solution File Format:

1) A file containing the decrypted message, namely the sequence of raw bytes in the plaintext recovered by decrypting E using K

LastName_step1_solution.msg (e.g., Perdisci_step1_solution.msg)
LastName_step2_solution.msg (e.g., Perdisci_step2_solution.msg)

VERY IMPORTANT: the solution file MUST NOT contain any extra bytes: no empty lines, no spaces or "\n" characters that do not explicitly belong to the decrypted message

Solution Submission:
Once you have output the solution to a text file,  you need to do the following:

1) Name the solution file using this format, and submit it via the submission system on nike using

$ submit FILENAME csx250

LastName_stepX_solution.msg, where LastName is your UGA user name, and the X in StepX needs to be changed into the correct step number. For example, I would submit a file named  Perdisci_step2_solution.msg

2) Every time you finish a step, compute the MD5 hash of the solution file, save it to a file called LastName_stepX_solution.md5, and submit it via nike.

4) Once you have solved all steps, or the time available for the assignment expires, you will need to submit the source code you wrote to solve all the steps of the assignment. Create a .ZIP file with all necessary source code files, and submit it via nike.

5) [Optional] At every step, measure approximately how much time it took for you to write the decryption code. Submit this information along with your solution (include a TIME_INFO.txt file into your .ZIP file). Have fun!