Programming Assignment #2RSA1. IntroductionCryptography 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 first learn how to generate large prime numbers followed by implementing the RSA algorithm. 2. DetailsSince you will have to compute large exponents as part of the RSA algorithm, the standard integer types (int - 16 or 32 bits, long int - 32 bits and and even long long int - 64 bits) of most computer languages will not suffice. Here are your choices:
3. What You Have to DoThe assignment is broken down into two main parts. Each part will be graded separately, but each part will also be reused for other parts of the assignment. This will allow you to test each part conclusively before moving on. 3.1 Prime Numbers (40%)RSA requires finding large prime numbers very quickly. You will need to research and implement a method for primality testing of large numbers. There are a number of such methods such as Fermat's, Miller-Rabin, AKS, etc. Your task is to develop two programs (make sure you use your two programs to check each other), both running from the command line.
The first program is called primecheck and will take a single argument, an arbitrarily long positive integer and return either True or False depending on whether the number provided as an argument is a prime number or not. You may not use the library functions that come with the language (such as in Java or Ruby) or provided by 3rd party libraries. Example (the $ sign is the command line prompt):
$ primecheck 32401
$ primecheck 3244568
Your second program will be named primegen and will take a single argument, a positive integer which represents a number of bits, and produces a prime number of that number of bits (bits not digits). You may NOT use the library functions that come with the language (such as in Java or Ruby) or provided by 3rd party libraries.
$ primegen 1024
$ primecheck 14240517506486144844266928484342048960359393061731397
66740959140734929039769848483733150143405835896743344225815617841
46805278310143147937016874549483037286357105260324082207009125626
85899698902780560484177634435915805367324801920433840628093200027
5573354237039522117150476778214733739382939035838341675795443
3.2 RSA Implementation (40%)You will implement three programs: keygen, encrypt and decrypt. keygen will generate a (public,private) key pair given two prime numbers. Example (the $ sign is the command line prompt):
$ keygen 127 131
In the table below you'll find some test cases for testing your keygen function. For those cases where you have to select your own numbers, make sure you select numbers that are at least 10 digits long; you'll have to edit this html document and drop your numbers and your name in the proper table cells.
encrypt will take a public key (n,e) and a single character c to encode, and returns the cyphertext corresponding to the plaintext, m. Example:
$ encrypt 16637 11 20
In the table below you'll find some test cases for testing your encrypt function. For those cases where you have to select your own numbers, make sure you select n such that it is at least 20 digits long and that e is two digits long. The character c is a positive integer smaller than 256.
decrypt will take a private key (n,d) and the encrypted character and return the corresponding plaintext. Example:
$ decrypt 16637 14891 12046
In the table below you'll find some test cases for testing your decrypt function.
3.3 Required Document (10%)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.4 Assignment Submission (10%)You are required to submit your work online, using the Blackboard. Here are the requirements for submission:
$Id: programmingAssignment-2.html,v 1.1 2013/08/20 17:17:13 virgil Exp $ |