RSA Interactive Simulator : Key Generation

RSA Interactive Simulator / Work Bench : Key Generation

This RSA key generator, will lead you though making a key set. You may at anytime enter your own values into the forms, or use the ones calculated for you.

Use the BACK button on your browser at your peril !

The first stage of RSA key generation is to choose two large prime numbers, p and q. A php utility to find prime numbers up to 2 Billion (i.e. 2 000 000 000 ) is provided below. This is adequate for 56 bit RSA encryption simulations. This script has a 30 second processing time limitation which will interrupt the program if a very large range is given. Best to play with this a little...

Pick some two of the prime numbers offered and cut and paste them into the form for further use.

For full RSA simulations a bc based prime number finder is provided as source code and on-line here .




FIND SUITABLE PRIMES




Prime Number Finder Taken (and modified slightly) from Prime Number finder 2 > > > > >
Min
max



FIND THE MODULUS OF THE PRIMES


These when multiplied together, should be as large as the encryption key being used (for instance a 128 bit key has approx ln(2^128)/ln(10) == 39 decimal digits), note that this has already exceeded the 52 bits of precision of double precision maths as defined by the
IEEE

Test your values of P and Q here

Multiply P and Q > > > >
Min
max




FIND PHI


When you have chosen your two prime numbers.....we need to find phi == (p-1)(q-1)

RSA p and q > > >
p
q



GREATEST COMMON DENOMINATOR


We now need to find a small number 'e' which is co-prime to phi. This number may therefore be any number you choose, (except 1, which would be unsafe cryptographically) as long as it is co-prime to phi . This number forms the second part of your public key. Hints to choosing e .

Note that this calls the gcd (greatest common denominator) function which returns 1 when co-prime values are entered.

RSA e and phi > > >
e
phi



FIND D


We now need to find a number 'd' so that d.e % phi == 1 This number will be your private key.

Enter a seed value for D or calculate it yourself. If the number typed obeys d.e % phi == 1 it will be used, otherwise it will be used as a start seed value. Leave blank to iterate to find lowest d value. Note on the algorithm used are here
RSA find 'd' > > > >
d
phi



RSA KEYSET


PUBLIC KEY
MODULUS (n)
Public Key (e)
PRIVATE KEY
MODULUS (n)
Private Key (d)

Now we have an RSA key set, we can use these to send encrypted data both ways. A user seeing the public key can encrypt using it, and the receiving party de-crypts with the private key. Note that no other user can de-crypt the message without knowing (or finding by brute force) the private key.

> > > > > >