RSA Encryption Implementation using BigInteger Class

This section describes the outline of a simple RSA public key encryption implementation using the java.math.BigInteger class.

After learning methods provided in the java.math.BigInteger class, I think I am ready to implement RSA public key encryption algorithm in Java now. Here is the outline of my implementation logic:

1. Public key generation:

• Call probablePrime() method to generate a prime number, p.
• Call probablePrime() method to generate another prime number, q.
• Compute the modulus, n, as p*q.
• Compute the Euler's totient value, m, as (p-1)*(q-1).
• Find a public key, e, until m.gcd(e)==1.
• Find a private key, d, using e.modInverse(m).

2. Message encryption with public key:

• Divide original message into a sequence of blocks.
• Encrypt each block, M, using C = M.modPow(e,n).

3. Ciphertext decryption with private key:

• Divide ciphertext into a sequence of blocks.
• Decrypt each block, C, using M = C.modPow(d,n).

See next tutorials for Java implementation programs.

Last update: 2013.