You are on page 1of 24

El_Gamal Cryptography

Data Security 1
Introduction
El_Gamal is a public-key cryptosystem
technique
was designed by Dr. Taher Elgamal .

El_Gamal depends on the one way


function, means that the encryption and
decryption are done in separate functions.

Data Security 2
Introduction
The encryption process requires two
modular exponentiations (extra
time).

A disadvantage of El_Gamal encryption is


that there is message expansion by a
factor of 2. That is, the ciphertext is twice
as long as the corresponding plaintext.

Data Security 3
Key generation

Receiver A must do the following:

1- Generate a large random prime number (p)

2- Choose a generator number (a) {show in slide 7 }

3- Choose an integer (x) less than (p-2) ,as


secret
number.

Data Security 4
Key generation

4- Compute (d) where


d= ax mod p

5- Determine the public key (p, a, d)


and the private key (x)

Data Security 5
Key generation

Example :
let p = 11 and a = 2 and x = 5

calculate d = 25 mod 11 = 10

public key = (11 ,2 ,10)


private key = (5)

Data Security 6
Generator number

How to test (a) generator or not :

1- (a) must be between 1 and p-1

2- Find = p-1

3- Find the all factors of {f1,f2,.,fn}


{1}
Data Security 7
Generator number

4- Find {q1,q2,..,qn} where


qi = f
for the redundant factors
qi = ffreq

5- (a) generator number if and only if

wi= a /qi mode p <> 1 , for all qi


Data Security 8
Generator number

Example 1 :
let p= 11 , a=2 ,test a is generator number
or not ?
sol:
= p-1 = 10 , factors of 10 = {2 , 5}
q1 = 2 ,q2 = 5
w1 = 210/2 mod 11 = 10 <> 1
w2 = 210/5 mod 11 = 4 <> 1
i.e a generator number .

Data Security 9
Generator number

Example 2 :
let p= 11 , a=3 ,test a is generator number
or not ?
sol:
= p-1 = 10 , factors of 10 = {2 , 5}
q1 = 2 ,q2 = 5
w1 = 310/2 mod 11 = 1== 1
w2 = 310/5 mod 11 = 9 <> 1
i.e a not generator number .

Data Security 10
Generator number

Example 3 :
let p= 41 , a=2 ,test a is generator number
or not ?
sol:
= p-1 = 40 , factors of 40 = {2 , 2 , 2, 5}
q1 = 21 = 2 ,q2 = 22 = 4,q3 = 23 = 8
q4 = 5
w1 = 240/2 mod 41 = 0.98 <> 1
w2 = 240/4 mod 41 = 40 <> 1

Data Security 11
Generator number

w2 = 240/8 mod 41 = 32 <> 1

w2 = 240/5 mod 41 = 10 <> 1

i.e a generator number

Data Security 12
Encryption

Sender B must do the following :

1- Obtain the public key (p , a , d ) from


the receiver A.

2- Choose an integer k such that :


1 < k < p-2

Data Security 13
Encryption

3- Represent the plaintext as an integer m


where 0 < m < p-1

4- compute (y) as follows :


y = ak mod p

5- compute (z) as follows :


z = (dk * m ) mod p

Data Security 14
Encryption

6- Find the ciphertext (C) as follows :


C= ( y , z )

7- The sender B send C to The receiver A .

Data Security 15
Decryption

Receiver A must do the following :

1- Obtain the ciphertext (C) from B .

2- compute (r) as follows :


r = yp-1-x mod p

3- Recover the plaintext as follows:


m = ( r * z ) mod p
Data Security 16
Example

Let p = 11 and a generator number = 2


and select integer number x = 5

calculate d = 25 mod 11 = 10

Then
public key = ( 11 , 2 , 10)
private key = (5)
Data Security 17
Example

Plaintext = Age

Represent the plaintext as integer value as


follows:

The new plaintext = ( 1 7 5 )

Data Security 18
Example

Encryption (sender):

y = ak mod p , z = (dk * m ) mod p

Choose an random integer value k = 6


yA = 26 mod 11 = 9
zA = (106*1) mod 11 = 1

Data Security 19
Example

Choose an random integer value k = 4


yg = 24 mod 11 = 5
zg = (104*7) mod 11 = 7

Choose an random integer value k = 7


ye = 27 mod 11 = 7
ze = (107*5) mod 11 = 6

Ciphertext = (9,1) (5,7) (7,6)

The sender B send the ciphertext to the receiver A.

Data Security 20
Example

The receiver decrypt the ciphertext as follows :

Compute (r) and (m) where


r = yp-1-x mod p , m = ( r * z ) mod p

r1= 911-1-5 mod 11 = 1


m1= (1*1) mod 11= 1

Data Security 21
Example

r1= 511-1-5 mod 11 = 1


m2 = ( 1 * 7 ) mod 11 = 7

r1= 711-1-5 mod 11 = 10


m3 = ( 10 * 6 ) mod 11 = 5

Data Security 22
Example

The receiver fnd the plaintext ( 1 7 5 )

Convert the plaintext to letters = Age

Data Security 23
End
For more information about
EL_Gamal cryptosystem please visit :

http://en.wikipedia.org/wiki/Taher_ElGamal

Data Security 24

You might also like