Manual practice using an RSA key pair
Here you and the instructor will apply the RSA algorithm in the way it is normally used, except in a direct way in order to fully understand what RSA does.
1. You generate a key pair
2. You make your public key known ("publish it") so people can obtain
it
3. The instructor will thus obtain it
4. The instructor will encrypt a random string using it
5. The instructor will make this ciphertext result known ("transmit
it"), so people can obtain it
6. You will thus obtain it
7. You will decrypt it
8. You will reveal back to the instructor the random string he had produced for
you, fulfilling the assignment
Use mechanisms per the instructor for how to "publish" your public key, how to obtain his encrypted data, and how to return the decrypted version back to him.
Note that you will only be able to do this assignment by reason of your possession of the private key matching the public one you gave the instructor to encrypt with. So when you produce keys and give him one, don't forget to retain the other so you'll be able to do the assignment later, when he has time to deliver you his random string encrypted for you! Also, when generating your keys, choose primes 13 and above. Otherwise they might be too small to do their job. (Rhetorical questions: How so? What has to meet a minimum size threshold? What must it be bigger than? Hint-- the plaintext being encrypted are all ascii codes.)
You will use a shell script named "decr" with which to decrypt the random string. Obtain it, per your instructor. The random string consists of several letters. The instructor's encryption method was to get the ascii code for each, as a number, and use RSA to encrypt that number. As written, the input expected by the decr script is a file holding the encrypted version of each letter, one letter per line, named "ciphermessage". The instructor will deliver you his ciphertext in a file of the proper format, but with your name appended. So if your name is John Smith you'll get a file named "ciphermessage-smith". Change the name to "ciphermessage," put it plus decr in the current working directory, then run decr providing the 2 elements of the private key ( d and n, in that order), as command line parameters.
<obtain script file decr>
<obtain data file ciphermessage-yourname>
mv ciphermessage-yourname ciphermessage
./decr <d element of your private key> <n element of your
private key>
The result is the random string the instructor has encrypted, printed on the screen.
Tell the instructor what string he sent you to get credit for this assignment.