Programming Assignment 3


Overview

In this programming assignment, you will implement decryption with the RSA public key system. You will be modifying two java class files, starting from skeletons that can be accessed from my public directories. After the modifications, you will be able to decrypt a message that I have encrypted.

Setting Up

To set up for this programming assignment, you should download the zipped netbeans project CS4411-PA3.zip and unzip it.

After you have done this, you will have a new netbeans project named "CS4411-PA3". The project source directory contains a package named "cs4411pa3". If you list the contents of this package you should see the following files:

To complete this assignment, you will need to add code to both of the .java files and rebuild the project. These files contain "FIXME" comments that indicate where you need to add code and what the added code should do.

When your code is working correctly, you can see the plaintext message by giving the following command:

    java Decrypt key.pub < ciphertext
    

If you want to save the plaintext message you can do so with the following command:

    java Decrypt key.pub < ciphertext > plaintext
    

File Formats

The "ciphertext" and "key.pub" files contain sequences of big integers encoded in a textual format. The textual format for each big integer is the hexadecimal representation of the number, chopped into lines with no more than 72 digits per line. Each big integer is followed by a blank line.

Code Organization

The BigIntegerReader class provides a read() method for reading big integers from files, one at a time. The Decrypt class just has a main() method that reads key modulus and exponent big integers from a key file specified on the command line, then reads ciphertext big integers from System.in. All of the big integer reads are done by setting up BigIntegerReader objects and invoking their read() methods. The RSA decryption algorithm is applied to each ciphertext big integer to get a plaintext big integer. A plaintext big integers named "plainNumber" can be converted to a string with the following code:

    String plainString = new String(plainNumber.toByteArray());
    

Each of these string is printed to System.out.

The modpow() method of the java.math.BigInteger class makes easy work of the RSA decryption algorithm. You should check the Java documentation for this method to get its parametrization correct.

What to Turn in

You should turn in copies of your modified .java files for the BigIntegerReader and Decrypt classes along with a printout of the output of your program using the provided key and ciphertext. These should be turned in to your TA on or before May 4. This is the last day of lecture for the course.