RSA algorithm uses only two prime numbers to generate a public and private key. As an outcome, it remains vulnerable to prime factorization, cycling, and forward search attacks. Until today, RSA has maintained security by doubling the length of a public key whenever it gets cracked. The security of RSA can be easily compromised with the help of quantum computers. Thus, much research has been carried out and papers have been published for strengthening the RSA Algorithm. One of many is the Modified RSA Encryption Algorithm. After studying this paper, I have created two scripts namely rsa.py and modified_rsa.py for generating key-pairs using RSA and Modified RSA Algorithms respectively.
SAMPLE A: Encrypting and Decrypting message “123” using RSA.
Step 01: Selecting two large distinct random prime numbers i.e. [p=83 and q=89]
Step 02: Calculating n, n = p * q, n = 83 * 89, [n = 7387]
Step 03: Calculating ϕ(n) = (p-1) * (q-1), ϕ(n) = (83-1) * (89-1), [ϕ(n) = 7216]
Step 04: Selecting “e” in the range of 1 < e < ϕ(n) and gcd (e, ϕ(n)) = 1, [e = 97]
Step 05: Calculating “d” in the range of 1 < d <ϕ(n) and [e * d mod ϕ (n) = 1], [d = 5505]
Step 06: Selecting Plaintext “M”, [M = 123]
Step 07: Encryption, Cipher text; C = Me mod n, C = 12397 mod 7387, [C = 1369]
Step 08: Decryption, Plaintext; M = Cd mod n, P = 13695505 mod 7387, [P = 123]
TEST: Encrypting / Decrypting Message “98526” using Modified – RSA Algorithm.
Step 01: Selecting three large distinct random prime numbers i.e. [p=83 and q=89 and r = 97]
Step 02: Calculating n, n = p * q * r, n = 83 * 89 * 97, [n =716539]
Step 03: Calculating z, z = n – 10, z= 716539 – 10, [z = 716529]
Step 04: Calculating ϕ(n) = (p-1) * (q-1) * (r-1), ϕ(n) = (83-1) * (89-1) * (r-1), [ϕ(n) = 692736]
Step 05: Selecting “e” in the range of 1 < e < ϕ(n) and gcd (e, ϕ(n)) = 1, [e = 101]
Step 06: Calculating “f”, f = (e * 2) + 1, f = (101 * 2) + 1, [f = 203]
Step 07: Calculating “d” in the range of 1 < d <ϕ(n) and [e * d mod ϕ (n) = 1], [d =150893]
Step 08: Selecting Plaintext “M”, [M = 98526]
Step 09: Encryption, Cipher text; C = M(f-1)/2 mod (z+10), C = 98526(203-1)/2 mod 716539, [C = 637929]
Step 10: Decryption, Plaintext; M = Cd mod (z+10), P = 637929150893 mod 716539, [P = 98526]
Note: In the above samples, we have generated key pairs and used them to encrypt and decrypt messages that are in numeric form. These messages in the numeric form are obtained after performing ASCII to numeric conversion.