Write a program that takes a key and message as input and performs the following operations to send messages from Alice to Bob.
Alice:
For every message Mi , i = 1, …, n, Compute
- Ciphertext: Ci = Enc(ki, Mi)
- MAC: Si = MAC(ki, Ci)
- Aggregate MAC: S1,i = H(S1, i-1 || Si)
- Update ki+1 = H(ki) and delete Ki, Si, S1, i-1 Send <C1, C2, …, Cn> , S1, n
Bob:
After receiving the data from Alice, for every ciphertext Ci , i = 1, …, n. Compute
- MAC: Si = MAC(ki, Ci)
- Aggregate MAC: S1,i = H(S1, i-1 || Si)
- Update ki+1 = H(ki) and delete Si, Ki, S1, i-1
If the aggregate MAC matches with the one that the client sent, then for every ciphertext Ci , i = 1, …, n, Compute
- Plaintext Mi = DEC(ki, Ci)
- Update ki+1 = H(ki) and delete Ki
Input:
- Take 16 byte key and initialization vector (IV) as input for both Alice and Bob. It is also alright, if you hard-code it.
- Read the messages from a file. Each message is 1024 byte and total number of messages is 100.
Output:
- For Alice, print the ciphertexts and aggregate MAC in the console.
- For Bob, write the plaintexts in a file.
Grading Criteria: | ||
• Read messages from file. | [5P] | |
• | Print output in console for Alice and write output to file for Bob. | [5P] |
• | Use ZeroMQ to send and receive messages. | [10P] |
• Generating the chain of keys. | [20P] | |
• | Compute MAC and aggregate MAC. | [30P] |
• | Use AES-CTR mode for encryption-decryption. | [30P] |
Submission:
You can do this assignment individually or form a group of two persons. Submit a zip file in Canvas. The zip file should contain the sender and receiver code. You can use C/C++/Python.
Some figures are added for your better understanding.
- Computing ciphertext and MAC.
- Computing MAC to verify the aggregate MAC
- Decrypting ciphertexts if the aggregate MAC matches.