RSA Applet with Error Detection Using Residue Codes

Usage: Follow this link to go to applet: APPLET

This applet demonstrates the steps of the RSA algorithm. It first creates keys, then allows the user to enter a value, encrypts this value and then decrypts it. The user can modify the encrypted text, and see if the residue codes are able to detect errors.
The steps are:


1) Entering Two Prime Numbers

User can enter two numbers and the applet automatically generates the closest prime numbers to what have been entered. It searches for a prime number between N and 2N where N is the entered number (Bertrand-Chebyshev theorem).

2) Calculation of N and e

After entering the two numbers, the user can press the button "Calculate N and e" to see N and possible e values. User either can choose one of the e`s or enter manually. The applet checks if it is a valid e.

4) Calculation of d

If a valid e is entered, applet will offer some possible d values. The user should enter a residue modulus value and a number in the "plain text" field.

5) Encryption and Decryption

After entering the input, the user can press the "encrypt" button for encryption and  the "decrypt" button for decryption.

6) Error Detection

To view error detection capabilities, the user can modify the encrypted text and see if applet can detect the error with the given Residue Modulus. Higher modulus values increases error detection capabilities. Errors are not detected when the residues of the message and decrypted text are equal. Some of these cases are demonstrated below.

Examples:

1) Enter 137 and 1453 as prime numbers. Calculate N and e. Choose 445 as e. Calculate d. Choose 151765 as d. Enter 8 as modulus, and 312 as input (plain text).  Encrypted text will be 195434. Decrypt it, it will be decrypted correctly and message residue will be 0. Now change the encrypted text value to 195435 and press decrypt. Applet will detect the error. Change it to 195436 and press decrypt. The applet will fail to detect the error. Change the modulus to 9 and press decrypt. Error will be detected.

2) Inputs: p = 149 , q = 797 ,  e = 351 , d = 207087, Plain Text = 64  

Outputs: c = 77847 (Encrypted Text)

For M = 3 (Modulus) , applet cannot detect errors for c = {77852, 77853, 77854}  for  77848   c 77857 . Thus out of 10 instance only 5 of them can be detected.

For M = 10, applet cannot detect errors for c = {77854 } only. Thus out of 10 instances 9 of the errors can be detected for M = 10.

For M = 13, all the errors in that range can be detected.