Programming Assignment #3

Encrypting Network Traffic Using RSA

1. Introduction

Cryptography is a key element in preserving confidentiality; it is used to scramble data such that it cannot be easily read by anyone except the intended receiver.

In this programming assignment, you will use RSA to encrypt network traffic between a client and a server.

2. Details

You will use the networking API of your programming language for this assignment, such as in Java or socket in Ruby.

3. What You Have to Do

The assignment is broken down into two main parts, a client and a server.

You will develop an echo server and a client that sends commands to it and listens for the commands received from the server. The server and the client each have their own pair of keys, public and private, that will be used to encrypt communication.

3.1 Client (40%)

The client will use the server's public key to encrypt a message then send it to port 8080 of the server. The client then listens for an echo from the server; when it receives the echo it will print it to standard output, then decrypt it using its own private key and print the result to standard output. The result should be identical with the original message that was encrypted by the client.

3.2 Server (45%)

The server will listen to port 8080 for messages from the client; when a message is received, the server will do the following:

  • Print it to standard output
  • Decrypt it and print the result to standard output
  • Encrypt the output of the decryption step with client's public key and print the result to standard output
  • Send the result to the client

3.3 Keys

For this assignment you will use the following keys:

  • Client Public Key: (5, 10142789312725007)
  • Client Private Key: (8114231289041741, 10142789312725007)
  • Server Public Key: (5, 10142701089716483)
  • Server Private Key: (6085620532976717, 10142701089716483)

Example (the $ sign is the command line prompt):

$ ./server

$ ./client 34923459234099

3.4 Results

Fill out the empty cells in the table below. In those cases where you have to choose a client message, make sure you choose one that has at least 10 characters; you'll have to edit this html document and drop your numbers and your name in the proper table cells.

Client Message Client Encrypted Message Server Encrypted Message
              34923459234099        6894190800681618        3977641036641575
Student name:

3.5 Extra Credit (10%)

Find the prime numbers p and q used to calculate the client and server keys.

  p q
Student name:

3.6 Required Document (5%)

In addition to your source code and your output you are required to submit a memo to your instructor that is flawlessly written. No spelling errors. No grammatical errors, etc. If the document is deemed unprofessional, e.g. with grammatical or spelling errors, then it will be assigned a grade of zero.

If you're not sure about the format for a memo, then just search for "memo format" on Google.

Your memo should state clearly the status of the assignment. Is it done or not? Does it meet all of the requirements? If anything is missing then state clearly what is missing from your work.

Failure to give a status for the assignment will result in a grade of zero for the entire assignment. Providing a status that's false or significantly misleading will also result in a zero for the entire assignment.

The other things that you should include in the memo are: (i) the number of hours you needed to get the code working, (ii) the number of hours you spent preparing your submission, and (iii) a list of challenges you faced while working on this assignment. Not required, however very nice to have, is a list of recommendations for how to make the assignment better, to the possible benefit of future generations.

Make sure your document is well-written, succinct, and easy to read. If you encountered problems with the assignment, then provide a detailed description of those problems and the solution(s) you found.

3.7 Assignment Submission (10%)

You are required to submit your work online, using the Blackboard.

Here are the requirements for your submission:

  • Submit your electronic copy using the Blackboard (attach the assignment as a compressed archive file (.zip, .tgz, .tbz2, .rar)
  • The name of the compressed archive should be: (e.g.
  • Include the following in your submission
    • Your memo (PDF document)
    • A completed handout with your results and your name on it (HTML file)
    • The source code (plain text file)
    • A README file that explains how to build and on how to run each program (plain text file)
    • Compiled executable(s)
    • A shell script or batch file that will compile your programs when executed; a Makefile (see GNU Make for details) would be great, however any form of script or building tool will do
  • Include your e-mail address in the Comment field when submitting the assignment through the Digital Drop Box
  • If for any reason you are submitting the assignment more than once, indicate this in the Comment field by including the word COMPLEMENT

$Id: programmingAssignment-3.html,v 1.1 2010/08/23 16:22:40 virgil Exp $