Asymmetric Algorithm: 13. Public Key Encryption
Asymmetric Algorithm: 13. Public Key Encryption
Asymmetric Algorithm: 13. Public Key Encryption
ASYMMETRIC ALGORITHM
Though private and public keys are related mathematically, it is not be feasible to
calculate the private key from the public key. In fact, intelligent part of any public-
key cryptosystem is in designing a relationship between two keys.
There are three types of Public Key Encryption schemes. We discuss them in following
sections:
RSA Cryptosystem
This cryptosystem is one of the initial system. It remains most employed cryptosystem even
today. The system was invented by three scholars Ron Rivest, Adi Shamir, and Len
Adleman and hence, it is termed as RSA cryptosystem.
We will see two aspects of the RSA cryptosystem, firstly generation of key pair and
secondly encryption-decryption algorithms.
There must be no common factor for e and (p 1)(q 1) except for 1. In other
words two numbers e and (p 1)(q 1) are coprime.
o The pair of numbers (n, e) form the RSA public key and is made public.
o Private Key d is calculated from p, q, and e. For given n and e, there is unique
number d.
o Number d is the inverse of e modulo (p 1)(q 1). This means that d is the
number less than (p 1)(q 1) such that when multiplied by e, it is equal to
1 modulo (p 1)(q 1).
ed = 1 mod (p 1)(q 1)
The Extended Euclidean Algorithm takes p, q, and e as input and gives d as output.
Example
An example of generating RSA Key pair is given below. (For ease of understanding, the
primes p & q taken here are small values. Practically, these values are very high).
Let two primes be p = 7 and q = 13. Thus, modulus n = pq = 7 x 13 = 91.
Select e = 5, which is a valid choice since there is no number that is common factor
of 5 and (p 1)(q 1) = 6 12 = 72, except for 1.
The pair of numbers (n, e) = (91, 5) forms the public key and can be made available
to anyone whom we wish to be able to send us encrypted messages.
de = 29 5 = 145 = 1 mod 72
RSA Encryption
Suppose the sender wish to send some text message to someone whose public key
is (n, e).
The sender then represents the plaintext as a series of numbers less than n.
To encrypt the first plaintext P, which is a number modulo n. The encryption process
is simple mathematical step as:
C = Pe mod n
Returning to our Key Generation example with plaintext P = 10, we get ciphertext
C:
C = 105 mod 91
RSA Decryption
The decryption process for RSA is also very straightforward. Suppose that the
receiver of public-key pair (n, e) has received a ciphertext C.
Receiver raises C to the power of his private key d. The result modulo n will be the
plaintext P.
Plaintext = Cd mod n
RSA Analysis
The security of RSA depends on the strengths of two separate functions. The RSA
cryptosystem is most popular public-key cryptosystem strength of which is based on the
practical difficulty of factoring the very large numbers.
Encryption Function: It is considered as a one-way function of converting
plaintext into ciphertext and it can be reversed only with the knowledge of private
key d.
Key Generation: The difficulty of determining a private key from an RSA public
key is equivalent to factoring the modulus n. An attacker thus cannot use
knowledge of an RSA public key to determine an RSA private key unless he can
factor n. It is also a one way function, going from p & q values to modulus n is easy
but reverse is not possible.
If either of these two functions are proved non one-way, then RSA will be broken. In fact,
if a technique for factoring efficiently is developed then RSA will no longer be safe.
The strength of RSA encryption drastically goes down against attacks if the number p and
q are not large primes and/ or chosen public key e is a small number.
ElGamal Cryptosystem
Along with RSA, there are other public-key cryptosystems proposed. Many of them are
based on different versions of the Discrete Logarithm Problem.
ElGamal cryptosystem, called Elliptic Curve Variant, is based on the Discrete Logarithm
n 3n mod 5 Problem.
It de N 3 rives the s
treng 1 3 3 th from th
e ass umption t
hat t 2 9 4 he discret
e lo garithms
3 27 2
cann ot
be f 4 81 1 ound in p
racti cal time f
rame for a given number, while the inverse operation of the
power can be computed efficiently.
Let us go through a simple version of ElGamal that works with numbers modulo p. In the
case of elliptic curve variants, it is based on quite different number systems.
Choosing the private key. The private key x is any number bigger than 1 and
smaller than p1.
Computing part of the public key. The value y is computed from the parameters
p, g and the private key x as follows:
y = gx mod p
Obtaining Public key. The ElGamal public key consists of the three parameters
(p, g, y).
For example, suppose that p = 17 and that g = 6 (It can be confirmed that 6 is a
generator of group Z17). The private key x can be any number bigger than 1 and
smaller than 71, so we choose x = 5. The value y is then computed as follows:
y = 65 mod 17 = 7
Thus the private key is 62 and the public key is (17, 6, 7).
ElGamal Encryption
Suppose sender wishes to send a plaintext to someone whose ElGamal public key is (p, g,
y), then:
Sender represents the plaintext as a series of numbers modulo p.
C1 = gk mod p
C2 = (P*yk) mod p
o Send the ciphertext C, consisting of the two separate values (C1, C2), sent
together.
o Referring to our ElGamal key generation example given above, the plaintext
P = 13 is encrypted as follows:
C1 = 610 mod 17
C2 = (13*710) mod 17 = 9
ElGamal Decryption
To decrypt the ciphertext (C1, C2) using private key x, the following two steps are
taken:
In our example, to decrypt the ciphertext C = (C1, C2) = (15, 9) using private key
x = 5, the decryption factor is
15-5 mod 17 = 9
ElGamal Analysis
In ElGamal system, each user has a private key x. and has three components of public
key: prime modulus p, generator g, and public Y = gx mod p. The strength of the
ElGamal is based on the difficulty of discrete logarithm problem.
The secure key size is generally > 1024 bits. Today even 2048 bits long key are used. On
the processing speed front, Elgamal is quite slow, it is used mainly for key authentication
protocols. Due to higher processing efficiency, Elliptic Curve variants of ElGamal are
becoming increasingly popular.