CS2105  Assignment 3 Solved

65.00 $

Category: Tags: , ,

Description

5/5 - (1 vote)

Objectives

In this assignment, you will implement a client which would use a session key to get encrypted data from a remote server and another program to check for the integrity of a file using the “Message authentication code”. After completing this assignment, you should be able to implement a simple TCP-based client and have a good understanding of

  • RSA,
  • use of Session Keys to transfer data,
  • Cryptographic Hash functions and
  • verification of message integrity using Message Authentication Codes.

Exercise 1: Message Integrity

You will be implementing Message Authentication Code using SHA256 as the hash function. Given a file, you need to verify if the file content is tampered with. The con-

Message Authentication Code (32 Bytes) Data

Figure 1: File content

tent of the file is as in Fig 1.

Input

The program takes 2 command line inputs

  • The file containing the 32 byte “authentication key”
  • The data file

Output

If the file contents are not tampered with, print “yes”; otherwise, print “no”.

Exercise 2: Session Key

You will be implementing Session Key based file transfer using RSA and AES. You need to connect to a TCP server to get the session key followed by the file.

The client needs to perform the following

  • Load the RSA Private key from the file test/rsa_key.bin
  • Connect to the TCP server
  • Receive 256B from the server
    • decrypt using RSA (link) to get the 16 B Session Key
  • Receive data from the server
    • Receive data till connection closes
    • Data size is guaranteed to be a multiple of 16B
  • Decrypt the data using AES in ECB mode (link) and write to the file.

Figure 2: Server FSM

The finite state machine of the server is shown in Fig 2.

Input

The program takes 4 command line inputs

  • The file to which the session key is to be stored
  • The file to which the data is to be stored
  • Hostname of the TCP server
  • Port number of the TCP server

Notice

  • The stu server has the package pycryptodomex (link)
    • The package name is “Cryptodome” instead of “Crypto”
    • SHA256: link
    • RSA Key: link
    • RSA Cipher: link
    • AES: link
  • We have provided some template code.
  • The outputs are case-sensitive
  • There is a low possibility that the Server gets overloaded. So start the assignment early to avoid “congestion” during the last few days.

Grading Rubric

  • Message Integrity: 2 Marks (equally divided among test cases)
  • Session Key:

Correct Session Key: 1 Marks Correct Data: 2 Marks

Testing Your Program

To test your program, please use your SoC UNIX ID and password to log on to stu as instructed on Assignment 0 paper.

  • To use the grading script, please upload your program along with the test folder given in the package to stu. Make sure that your program and the test folder are in the same directory. Then, you can run the following commands to test your server program: bash test/Integrity.sh bash test/Session.sh
  • By default, the script runs through all test cases. You can also choose to run a certain test case by specifying the case number in the command: bash test/Integrity.sh 3

test/Session.sh has only one test case

To stop a test, press ctrl-c. If pressing the key combination once does not work, hold the keys until the script exits.

tput: un known ter mi nal “xterm -256color”
  • If you ever encounter this error: when testing your program using script provided, run the command:

export TERM=xterm once after you log in and before you run the test scripts.

“con ges  

All of you will be connecting to a single server, hence start the assignment early to avoid tion” during the last few days.

  • Assignment_3-kaumwg.zip