Uploaded by kishan2sachin

project1

advertisement
3460:435/535 Algorithms
Project 1 ‐‐‐ RSA & Digital signature
Your first programming assignment is to implement RSA Encryption and apply it to digital signature
(http://en.wikipedia.org/wiki/RSA_(algorithm)). To facilitate the grading, you are REQUIRED to use c++ to complete the
project and your program must run on the lab machines under Linux environment.
Part I: RSA key generation.
 Implement Fermat test;
 Use Fermat’s test to generate two large prime numbers (p,q), each should have a size >= 512 bits;
 Save p and q in a file named p_q.txt, one integer per line and making sure no white space saved;
 Use the extended Euclidean algorithm to generate two pairs of keys: (e,n), (d,n), where n=p*q;
 Save the two pairs of keys in two separate files: e_n.txt and d_n.txt, one integer per line and no white space;
To implement RSA Part I, download the bigInt435 and complete the program rsa435.cc. No other file except rsa435.cc
needs to be modified. Use “make clean” and then “make all” to compile and link your programs. To run, execute
“rsa435”. The bigInt435 program is written by Matt McCutchen. It can be downloaded directly from his site:
https://mattmccutchen.net/bigint/ .
Submission: Zip your program rsa435.cc into a folder called Project1Part1. Once I compile the program, I should be
able to run it using: “rsa435” (it should be an executable file)
Part II: Generate and verify digital signatures using a SHA‐256 hash.
 Sign a given file
o Generate a SHA‐256 hash of the content of the file to be signed (e.g., "file.txt");
o Sign/"decrypt" this hash value using the private key stored in d_n.txt;
For undergraduate students:
o Save the signature to filename.signature (e.g. "file.txt.signature")
(In practice, the original content and the signature are saved in one document. For easy implementation of
your project, save the signature file separately.);
For graduate students:
o Save the original content and the signature into one document filename.signed (e.g. "file.txt.signed")

Verify the signed file
For undergraduate students:
o Generate a SHA‐256 hash of the content of the file you have signed (e.g., "file.txt");
o Obtain the signature from the signature file (e.g. "file.txt.signature");
For graduate students:
o Separate the signature from the content of the file in the signed document (e.g. "file.txt.signed");
o Generate a SHA‐256 hash of the content of the file you have signed
All students:
o "encrypt" signature using the public key stored in e_n.txt;
o Compare the SHA‐256 hash value and the “encrypted” signature;
o Report whether the document is authentic or modified.
To implement RSA Part II, download the messageDigest435 and modify and complete the program
messageDigest435.cc. No other file except messageDigest435.cc needs to be modified. SHA‐256 algorithm in the
package generates an almost‐unique, fixed size 256‐bit (32‐byte) hash. See https://en.wikipedia.org/wiki/SHA‐2 for
more description of SHA. The c++ implementation was written by Olivier Gay and the code can be accessed directly
from: http://www.zedwood.com/article/cpp‐sha256‐function.
Submission: Zip your messageDigest435.cc into a folder called Project1Part2. Once I compile the program, I should be
able to sign the file using:
messageDigest435 s “file.txt”
and verify the file using:
messageDigest435 v “file.txt” “file.txt.signature” (for undergraduate students);
messageDigest435 v “file.txt.signed” (for graduate students)
What to submit.
1. Submit your source code (not your .exe). Make sure to test your code on more than one set of data. DO NOT submit
programs that are not reasonably correct! To be considered reasonably correct, a program must be completely
documented and work correctly for sample data provided with the assignment.
2. A text file named readme.txt file to give the reader a high‐level explanation of your implementation and anything we
need to know to run your program.
Source code submission instructions. You must submit an electronic copy of the program using your Brightplace dropbox.
Follow these steps:
1. Create a folder named jsmith_1 (but use your first initial and last name).
2. Place the two zipped folders (Project1Part1.zip, Project2Part2.zip) inside this folder.
3. Right‐click on the folder and choose Send To... Compressed Folder (or use some other Zip utility to archive the entire
folder). The goal is to create a zip archive named jsmith_1.zip (your initial and name) that contains the folder which
contains two parts of your project.
4. Drop this single zipped file to the drop box.
Please pay attention to the naming conventions for the submission files. These must be followed exactly in order to
receive credit. Invalid submissions will need to be resubmitted with a penalty assessed.
Be sure to electronically submit your working solution before the due date! Do not submit non‐working programs. The
electronic submission time will be used to assess late penalties (if applicable).
Grading. Your code will be graded on correctness, efficiency, clarity and elegance.
Related documents
Download