Al-Gamal-W6(al gamal)-d1-d2

19
Information Security I By Fahad Layth Malallah Reference Books: 1. Introduction to Computer Security, by Matt Bishop. 2. Security in Computing, 4 th Edition, by Charls P. Pfleeger. 3. Principle of Computer Security. 2 nd edition, by Arthur. 4 th grade, Computer Science Cihan University First Semester, 2014-2015. Lecture-W6-D1-D2. 1

Transcript of Al-Gamal-W6(al gamal)-d1-d2

Information Security I

By

Fahad Layth MalallahReference Books:1. Introduction to Computer Security, by Matt Bishop.

2. Security in Computing, 4th Edition, by Charls P. Pfleeger.

3. Principle of Computer Security. 2nd edition, by Arthur.

4th grade, Computer ScienceCihan UniversityFirst Semester, 2014-2015.Lecture-W6-D1-D2.

1

4-CryptographyA- Definitions.B-Encryption and Decryption Definition(Symmetric & Asymmetric).C-Classical Cryptosystems.

1- Transposition Ciphers (Permutation):- Shuffling Scheme.

2- Substitution Ciphers :- Caesar’s Cipher.-Vigenère Cipher.-One-Time Pad.

D-Symmetric Cryptography :-Data Encryption Standard (DES) Algorithm.

E- Asymmetric Cryptography (Public-Key Systems):1-Basic on modular arithmetic, Number Theory.2-Modular arithmetic inverse computation.3- Al-Gamal Algorithm (ciphering & de-ciphering).4-RSA Algorithm (ciphering & de-ciphering).

Summary- Exercises.

2

-Aim of this lecture:Students will be familiar and able to secure information by using:

E- Asymmetric Cryptography (Public-Key Systems):1-Basic on modular arithmetic, Number Theory.2-Modular arithmetic inverse computation.3- Al-Gamal Algorithm (ciphering & de-ciphering).4-RSA Algorithm (ciphering & de-ciphering).

3

3- Al-Gamal Algorithm (ciphering & de-ciphering).

Al-Gamal-It is a public-key cryptosystem technique was designed by Dr.Taher Algamal.

-The strength of Al-Gamal depends on Discrete Logarithm Problem(DLP).

A disadvantage of Al-Gamal encryption is that there is messageexpansion by a factor of 2. That is, the ciphertext is twice as long asthe corresponding plaintext.

The following are the same terms:

-Asymmetric Cryptography

-Public Key Cryptography (PKC)

-Public Key System (PKS)

-Public Key infrastructure (PKI).4

3- Al-Gamal Algorithm (ciphering & de-ciphering).

-El-Gamal PKC

5

Public Parameter Creation

A trusted third party chooses and publishes a large prime p and a primitive root g modulo p.

Key Creation

Ali Salim

1. Choose a private key 1 ≤ a ≤ p-1.

2. Compute A = ga (mod p).

3. Publish the public key A.

Encryption

1. Choose plaintext m.

2. Choose random ephemeral key k.

3. Use Ali’s public key A to compute:

i. c1 = gk (mod p)

ii. c2 = mAk (mod p)

4. Send ciphertext (c1 , c2) to Ali.

Decryption

Compute (c1a )-1 c2 (mod p). This quantity is

equal to m.

-How do you prove that Al-Gamal can reconstruct the

original message text from a cipher text ?.

Sol: the proof of Al-Gamal:• The following computations will occur:

M= (c1a )-1 c2 (mod p) --(1)

A = ga (mod p) --(2)

c1 = gk (mod p) --(3)

c2 = mAk (mod p) --(4)

Now, by Substituting (2), (3), (4) in (1):

• M= (c1a )-1 c2 (mod p)

M= (gak)-1 (mAk) (mod p)

M= (gak)-1 (m(ga )k) (mod p)

M= M (mod p)

= M6

Example -1: by using prime number 19, and its primitive root 3,encrypt and decrypt message=17 by using Al-Gamalcryptosystem:

Solution:

• p=19, g= 3 and Ali chooses Private key: a=10

• Ali computes:– A=3

10 mod 19 = 16, then send to Bob.

• Bob Encrypt message m=17 , by using , p, g, A and select k as:– choosing random k=6

– computing C1 = gkmod p = 3

6mod 19 = 7;

C2 = M. Ak mod p = 17. 166mod 19 = 5;

• Ali Decrypt the cipher text by computing:– M = C a

1 -1 . C2 mod p= (710) -1 . 5 mod 19

– M = 7 -1 . 5 mod 19 =

Example -1: by using prime number 19, and its primitive root 3,encrypt and decrypt message=17 by using Al-Gamalcryptosystem:

Solution: Continue…• Ali Decrypt the cipher text by computing:

– M = C a 1

-1 . C2 mod p= 710 -1 . 5 mod 19

– M = 7 -1 . 5 mod 19 =

To compute the inverse of 7 -1 mod 19:

1= ax + by, a= 7, b= 19

1= 7x + 19y 1= 7*-8+19*3. ok satisfy!

x=-8. -8 mod 19 7 -1mod 19= 11.

Then, in the main equation to find M:

M = 11. 5 mod 19 = 17

Then the Decrypted message is 17.

Example-2: By using Al-Gamal, Encrypt & Decrypt message

m=331. use g=2, p=467, a= 153, k=197.

Solution:

• Ali uses the prime p= 467 and the primitive root g = 2.

• He chooses a = 153 to be his private key.

• Ali computes A = ga = 2153 = 224 (mod 467).

• Ali publishes his public key : 224.

• Salim wants to encrypt the message m = 331 to Ali.

• Salim chooses a random key k = 197.

• Salim then computes the pair

i. c1 = 2197 = 87 (mod 467)

ii. c2 = (331)(224197) = 57 (mod 467)

9

Solution: Continue…Example-2:

• The pair (87, 57) is sent to Ali.

• Ali will first compute

i. x = c1a = 87153 = 367 (mod 467).

Then,

ii. x-1 = 14 (mod 467)

• Finally, Ali will compute

M = (57) (14) = 331 (mod 467)

M= 331

10

Inverse of :

367 mod 467

1= ax + by

a= 367.

b= 467

1= 367 x + 467 y

-After Calculating q, x and y

-then:

X5= 14, Y5= -11 satisfy the inverse equation as:

1= (367)(14) + (467) (-11)

Attack on El-Gamal

• Eve has the parameters p, g, c1 and c2.

• Eve wants to decrypt the ciphertext.

• Eve also knows the value of the public key A =

ga (mod p).

• Eve needs to compute the value:

» x-1 c2 = (c1a )-1 c2 (mod p)

• Eve has to derive the value a from the public key.

• Solve the DLP!!! – infeasible!!!

11

-Summary-Encryption and Decryption of Asymmetric cryptography AlGamal have been illustrated with two examples.

12

-Exercises:1- Explain Al-Gamal algorithm by parameters. Then, show the encryption and

decryption steps.

2-Design an Al-Gamal PKC using small primes such as p=23, g=2, private key

(a)= 7 and k =10. show the diagram of encryption and decryption of m=4.

3- Prove Al-Gamal can reconstruct the original message (Plaintext).

4-Analyse Al-Gamal security , and mention why does the attacker cannot decrypt

the cipher text if he / she doesn’t have a private key?.

5- Assume that prime p = 31 and the primitive element g = 3. Bob, who has a

private key a=2 wants to decrypt the cipher text. Suha encrypts the M=5 using

k=7, Compute the cipher text (c1, c2) and show your steps, also, compute the

message.

6-Encrypt & Decrypt this message=15, by choosing p, g, a and k as you like, but

according to the condition of (a) and (k).

13

-Exercises & Solution:1- Explain Al-Gamal algorithm by parameters. Then, show the encryption and

decryption steps.

Sol:It is available in Al-Gamal Document slide-5.

2-Design an Al-Gamal PKC using small primes such as p=23, g=2, private key

(a)= 7 and k =10. show the diagram of encryption and decryption of m=4.

Sol:

-To Compute A:

-To Encrypt the message:

-To Decrypt the Cipher:

14

13

23mod2mod 7

A

ApgA a

1823mod13.42mod.2

1223mod21mod1

10

10

CpAMC

CpgC

k

k

23mod18.)12(mod2.)1( 171 MpCCM a

-Exercises:-To Decrypt the Cipher:

Now, to compute the inverse as :

As this inverse equation : 1= ax + by : a= 16, b= 23.

X= -10, y =7 1 = 16. -10 + 23 . 7

X= -10 to make it plus we have to add 23 until we get plus value.

X= -10 + 23= 13. finally, the final value of the inverse is 13.

15

23mod18.)12(mod2.)1( 171 MpCCM a

23mod)16(1

23mod)12(1

1

17

4

23mod18.13mod2.)1( 1

M

MpCCM a

3- Prove Al-Gamal can reconstruct the original message (Plaintext).

Sol:It is available in Al-Gamal Document slide-6.

4-Analyse Al-Gamal security , and mention why does the attacker cannot decrypt

the cipher text if he / she doesn’t have a private key?.

Sol:It is available in Al-Gamal Document slide-11.

16

5- Assume that prime p = 31 and the primitive element g = 3. Bob, who has a

private key a=2 wants to decrypt the cipher text. Suha encrypts the M=5 using

k=7, Compute the cipher text (c1, c2) and show your steps, also, compute the

message.

Sol:

-To Compute A:

-To Encrypt the message:

-To Decrypt the Cipher C1 & C2:

-To Compute the inverse of

17

931mod3mod 2 ApgA a

1931mod9.52mod.2

1731mod31mod1

7

7

CpAMC

CpgC

k

k

31mod19.)17(mod2.)1( 121 MpCCM a

31mod)10(1

31mod)17(1

1

12

-To Compute the inverse of:

-Finally, to compute the message:

18

31mod)10(1

31mod)17(1

1

12

28)10( 1

5

31mod19.28

mod2.)1( 1

M

M

pCCM a

6-Encrypt & Decrypt this message=15, by choosing p, g, a and k as you like, but

according to the condition of (a) and (k).

19