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.

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. a significant number of 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.

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. Late work will be accepted, however it is subject to late penalties as described in the syllabus.

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
    • A completed handout with your results and your name on it
    • The source code
    • A README file that explains how to build and on how to run each program
    • 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

Last update: Jan 3, 2009 Virgil Bistriceanu cs458 Computer Science

$Id: programmingAssignment-3.html,v 1.2 2009/01/04 02:19:03 virgil Exp $