In 1978, Rivest, Shamir and Adleman of MIT proposed a number-theoretic way of implementing a Public Key Cryptosystem. Their method has been widely adopted. The basic technique is:
p
and q
. n
= p * q
and
x
= (p-1)*(q-1)
x
and call it d
.
This means that d
is not a prime factor of x
or a multiple of it. e
such that e
* d = 1 mod x
.
To use this technique, divide the plaintext (regarded as a bit string) into
blocks so that each plaintext message P
falls into the interval 0 <= P < n
.
This can be done by dividing it into blocks of k
bits where k
is the
largest integer for which 2k < n
is true.
To encrypt: C
= Pe (mod n)
To decrypt: P
= Cd (mod n)
The public key, used to encrypt, is thus: (e, n)
and
the private key, used to decrypt, is (d, n)
)
To create the public key, select two large positive prime
numbers |
|
Compute |
|
Choose an integer |
|
Compute |
|
|
|
To create the secret key, compute |
|
To compute the ciphertext |
|
|
|
To compute the plaintext |
|
|
|
RSA works because knowledge of the public key does not
reveal the private key. Note that both the public and private keys contain the
important number n = p * q
.
The security of the system relies on the fact that n
is hard to factor
-- that is, given a large number (even one which is known to have only two
prime factors) there is no easy way to discover what they are. This is a well
known mathematical fact. If a fast method of factorisation is ever
discovered then RSA will cease to be useful.
It is obviously possible to break RSA with a brute
force attack -- simply factorise n
. To make this difficult, it's
usually recommended that p
and q
be chosen so that n
is (in
2002 numbers) at least 1024 bits.
One excellent feature of RSA is that it is symmetrical. We already know that if you encrypt a message with my public key then only I can decrypt that ciphertext, using my secret key. However, it also turns out that a message encrypted with my secret key can only be decrypted with my public key. This has important implications, see later.
The RSA algorithm operates with huge numbers, and involves lots of
exponentiation (ie, repeated multiplication) and modulus arithmetic. Such
operations are computationally expensive (ie, they take a long
time!) and so RSA encryption and decryption are incredibly slow,
even on fast computers. Compare this to the
operations involved in DES (and other single-key systems)
which consist of repeated simple XOR
s
and transpositions. Typical numbers are that DES is 100 times faster than RSA
on equivalent hardware. Furthermore, DES can be easily implemented in dedicated
hardware (RSA is, generally speaking, a software-only technology) giving a
speed improvement of up to 10,000 times.