Cryptography Tutorials - Herong's Tutorial Examples - Version 5.35, by Dr. Herong Yang
Finding Large Prime Numbers
This section describes different ways to generate large prime numbers to be used to generate public key and private key. Today most RSA tools are using probable prime numbers.
Now we have an efficient algorithm for the RSA encryption and decryption operation, the next thing to look at is on how to generate public and private keys.
The first step of the public and private key generation process is to get 2 large prime numbers. This can be done in different ways:
1. Selecting existing prime numbers from prime number databases. If you need 2 prime numbers to generate a new pair public key and private key, you can select 2 prime numbers from an existing prime number database like http://www.bigprimes.net/, which currently have about 1.4 billion prime numbers.
The largest prime number currently stored in www.bigprimes.net is 32416190071, which has 11 decimal digits. If select 2 11-digit prime numbers, p and q, the product of p and q, n, will be have 22 decimal digits, which is about 50-bit long. This tells us that if we use prime numbers from http://www.bigprimes.net/, we can only generate 50-bit RSA keys.
This is not long enough to meet today's security standard. Remember, security experts recommend to use 2048-bit public and private keys if you want to keep your data safe up to year 2030.
2. Generating prime numbers using prime number generating algorithms. If you need 2 prime numbers to generate a new pair public key and private key, you can generate 2 prime numbers using a prime number generating algorithm like "Sieve of Eratosthenes" which iteratively marking composite (i.e. not prime) by calculating multiples of each known prime and keeping numbers that are not marked as prime numbers at the end.
The "Sieve of Eratosthenes" algorithm is very efficient algorithm to generate prime numbers. But it is still takes too long to generate large prime numbers.
3. Generating probable prime numbers using probable prime number generating algorithms. If you need 2 prime numbers to generate a new pair public key and private key and don't want to wait for a long time to find them, you can generate 2 probable prime numbers using a probable prime number generating algorithm like the probablePrime() method provided in java.math.BigInteger class.
Of course, public key and private key generated from probable prime numbers may fail to work in encryption and description. But the likelihood of failure is very small.
Today most RSA public key and private key tools are using probable prime numbers.
Last update: 2013.
Table of Contents