RSA public key cryptosystem

RSA is a public key cryptosystem named after its three inventors, Rivest, Shamir and Adleman. The system, which can be used for both encryption and digital signatures, relies on the difficulty of factoring for its security.

Let p and q be two large random prime numbers, and compute

      N = pq.

The number N is the modulus. Next, select a value e such that e has no factor in common with (p - 1)(q - 1). Then it is easy to find d such that

      ed = 1 mod (p - 1)(q - 1)

Another way to say this is that ed - 1 is evenly divisible by (p - 1)(q - 1).

The public key is (N,e)

The private key is d

The primes p and q are discarded

To encrypt a message M, compute

      C = Me mod N

To decrypt the ciphertext C, compute

      Cd mod N.

Thanks to Fermat's Little Theorem, the result is the plaintext M.

Recall that the modulus N and the encryption exponent e are public. If someone can factor N to obtain p and q, then it is trivial for them to find d from e and the factors p and q.

Note that the crucial step in creating the public key is multiplication, while the crucial step in breaking the system is (so far as is known) factoring. Multiplication is "one-way", meaning that it is is easy to multiply, while the inverse operation, namely, factoring, is thought to be very difficult. The RSA problem has a "trap door" since the prime factors p and q disappear from the problem. Consequently, it is thought to be necessary to factor the modulus in order to recover the factors and break the system (though this has not been proven).

Go here to see the tricks used to speed up public key operations.

Click here for more details on the mathematics behind the RSA algorithm.