RSA Cipher Demonstration

Roger Morrison
ECE 575 - Prof. Koc - Winter 2002 - Oregon State University

What is this?

Below is a Java applet that allows a user to create RSA keys and encrypt and decrypt text or numbers.   It is for educational purposesonly and is not industrial strength for several reasons.  For starters,is it designed by a first time Java programmer, it also uses basic psuedo-random number generation.  So don't trust it with anything important.

How is it used?

The interface is not very explanatory, so you'll probably need to follow these directions the first time through.  The applet can be used for three tasks - key generation, encryption, and decryption.  If you want the details about how it works take a look at the source code - RSAdemo.java.
Key generation
To use the RSA cipher for public key cryptography, two sets of keys arerequired.  There is a public key which consists of an encryption value'e' and a modulus 'n'.  There is also a private key made up of 'd',your decryption value and the same 'n' modulus.  To start, first entertwo prime numbers into the 'p' and 'q' text fields.  Or, you can clickon the "Generate p and q" button and the applet will create two prime numbersthat are any size you select greater than 3 bits long.  Bigger numbersare, in general, more secure (512 will create an 'n' of size 1024, whichis standard) but numbers too large will take a while to generate. So remember this: generating large primes p and q(greater than about 1024 bits) may take a long time - do so at your own riskof freezing your browser!  Okay, now you've been warned.  Next, click on the "Generate n" button. It multiplies 'p*q' and will give you 'n.'  Now click on "Generatee" to come up with a 'e' value that is whatever size you want (32 bits usually okay).  And finally click on "Calculate d" to get your 'd' value.

Now, to use these values to do public key cryptography make your 'e' and 'n' values available to anyone that wants to send youan encrypted message.  Keep a copy of the 'n' value and keep the 'd'value secret (so only you can decrypt the messages).

Encryption
With the 'n' and 'e' values entered, you can nowtype a text message in the "Plain text message" area.  Since RSA onlyencrypts numbers, we convert the message to number with the "Convert tonumber" button.  You'll notice encryption is done with buttons on theleft side and flows downward, decryption is done with buttons on the rightand flows upward.  The last step is encrypting the message by clickingon the "Encrypt" button.  The encrypted message is left in numericalform because if it was converted back to text (ascii), some characters wouldnot show up and you could not copy them properly.
Decryption
After making sure the proper 'd' and 'n' valuesare entered, place the encrypted numeric message into the bottom text boxlabeled "Encoded numerical message."  Use the "Decrypt" button todecode the message, then click on the "Convert to text" button.