Fall 2019 CSE30264 Programming Assignment 1 - Simple Secure UDP Program


Total Points: 100 points
Goal: Refresh how to compile code, gain experience with network syscalls
Write a simple UDP network client and server
Assigned: September 9, 2019
Due: September 18, 2019 by the beginning of class.
Grouping: To be developed individually.


Background

You will be writing a simple and secure communication protocol using UDP client and server. The program will build a UDP connection between the two hosts and exchange encryption keys. The client will then send an encrypted message to the server. The server will decrypt the message and reply with a checksum of the received message. You also need to compute the round-trip-time (RTT) of your messages. More background information about public key encryption and socket programming is provided in the "Helpful Links" section at the end of this document.

Problem:

Write a simple UDP client that takes in:
Also write a simple UDP server that takes in:
The library pg1lib.h (provided) contains the following methods:

/* Generate and return an encryption key
* (won't generate a new one if one exists already)
* return: this host's encryption key
*/
char* getPubKey();

/* Encrypt a message with peer's encryption key
* char *message: plaintext message to encrypt
* char *pubkey: peer's encryption key (formatted as output to getPubKey())
* return: base64 encoded ciphertext
*/
char* encrypt(char *message, char *pubkey);

/* Decrypt a message with this host's private key
* char *cipher: base64 encoded ciphertext
* return: decrypted plaintext message
*/
char* decrypt(char *cipher);

/* Calculate the checksum for the input data
* char *data: the null terminated data to process
* return: the checksum as an unsigned long
*/
unsigned long checksum(char *data);

Note: You do not need to implement the encryption/decryption and checksum functions listed above, as they are provided in the file Your_home/esc-courses/fa19-cse-30264.01/files/program1/pg1lib.h. You can also download it from here. Feel free to copy pg1lib.h to your own directory. Two libraries must be linked: -lcrypto and -lz when you compile the pg1lib.h. If you are not familiar with public key cryptography, please refer to the links provided in the "Helpful Links" section.

The following protocol is to be implemented in your assignment:
  1. The client generates a public key using char* getPubKey(), connects to the server, and sends it its public key.
  2. The server generates its own public key (also using char* getPubKey()), encrypts it using the client's public key and the method char* encrypt(char *message, char *pubkey), and sends the encrypted key as a response back to the client.
  3. The client decrypts the server's public key (char* decrypt(char *cipher)). It then reads a file (or string) into a temporary buffer (a suggested buffer size is 4096 characters in this assignment), calculates a checksum for the message (using unsigned long checksum(char *data)), and prints the checksum to the screen. It then encrypts the message using the server's public key ( char* encrypt(char *message, char *pubkey)). The client then send both the encrypted message and the checksum to the server. (The checksum does not need to be encrypted as it cannot be used to reconstruct the original message.) Hint: The checksum is an unsigned long, and you will need to take into account endianness to transmit it correctly.
  4. The server receives the encrypted message as well as the checksum. It first decrypts the message (using char* decrypt(char *cipher)), and prints both the message and the received checksum to the screen. Then it calculates the checksum with unsigned long checksum(char *data) from the decrypted message, prints it, and compares it with the received checksum. If the checksum does not match, the server reports an error message. The server then sends the calculated checksum back to the client.
  5. The client receives the checksum, and calculates the round-trip-time (RTT), in microseconds, from the time it sent the message to when it received a response. It also verifies that the server has received the message without errors by comparing the reported checksum with what it had calculated in step c. It prints both the checksum and the RTT to the screen. If the checksum does not match, report an error message.
DO NOT output any debugging information, or other informational messages to the screen. Doing so will cost you points!

There are three test files (File1.txt, File2.txt, File3.txt) in: Your_home/esc-courses/fa19-cse-30264.01/files/program1/. You can also download them from here.
You need to run your program using these test files and a random command line string. For example:

Server
[netid@student02 ~] $ ./udpserver 41100

Client
[netid@student00 ~] $ ./udpclient student02.cse.nd.edu 41100 File1.txt
[netid@student00 ~] $ ./udpclient student02.cse.nd.edu 41100 "This is a test"

Note: The client and server should be executed on different student machines (e.g., if the server is running on student 02, then the client should be tested on student 00/01/06).

Demo

Submission

Create a README file that contains a complete listing / explanation of what files are present in the directory and the instructions to compile and run your code (e.g., give a command line example to test your code with a sample file or random string).

Create a program1 directory in your dropbox (i.e., /escnfs/courses/fa19-cse-30264.01/dropbox/yournetid), and copy your .c or .cpp file, pg1lib.h, and your README file to this dropbox. Your source code file must contain your name and netid or it will not be graded.

Note that you are encouraged to submit a Makefile for your code. If you do not submit one, please make sure to include the instructions on how to compile your code in your README file.

Your code will be evaluated on one of the student 00/01/02/06 machines based on the following evaluation rubric.

Evaluation Rubric (100 pts)

The points for the assignment are as follows:

Helpful Links

*Socket Programming in Linux : Beej's Guide to Network Programming and UDP Socket Example
*Public-key Cryptography : Public Key and Private Keys and Wikipedia Link



Appendix

Use the port number corresponding to your name in the appendix below.

Table 1. Port Assignments
UDP Port to UseName
41001 Samuel Battalio
41002 Bailey Blum
41003 Paul Brunts
41004 Kathleen Capella
41005 Jacques Charboneau
41006 Thomas Clare
41007 Jack Conway
41008 Matthew DaDamio
41009 Megha Devaraj
41010 Michael Eisemann
41011 Michael Erdenberger
41012 Nicholas Fahrney
41013 Clare Fallon
41014 Patrick Fischer
41015 Chris Foley
41016 John Fox
41017 Luke Fraser
41018 Owen Gallahue
41019 Jorge Garcia
41020 Elizabeth Genovese
41021 Gabrielle Good
41022 Joseph Gripenstraw
41023 Katherine Hecht
41024 Jack Hill
41025 Julia Hughes
41026 Carson Lance
41027 Connor Laracey
41028 Bailey Logan
41029 Horacio Lopez
41030 Catherine Markley
41031 Imari McKinney
41032 Sean Michalec
41033 Ralph Moran
41034 David Odun-Ayo
41035 Jewon Oh
41036 Cole Pickford
41037 Brendan Raimann
41038 Christopher Ray
41039 Daniel Riehm
41040 Conor Rinehart
41041 Francis Schickel
41042 Matthew Siciliano
41043 Richard Stefanik
41044 Emily Strout
41045 Blake Trossen
41046 Justin Virgadamo
41047 Trenton Wray
41048 Jillian Ybanez
41049 Logan Yokum
41050 Christina Youn