Professional Documents
Culture Documents
Lecture#07
Key Exchange- Diffie Helman
Course: Cryptography & Network Security (CE-408)
Course Teacher: Ms. Rukaiya
Contact Info:
Email: rukaiya@ssuet.edu.pk
1
Diffie Helman Key Exchange
• First published public-key algorithm
• A number of commercial products employ this key
exchange technique
• Purpose is to enable two users to securely
exchange a key that can then be used for
subsequent symmetric encryption of messages
• The algorithm itself is limited to the exchange of
secret values
• Its effectiveness depends on the difficulty of
computing discrete logarithms
2
Discrete Logarithms
4
Primitive Root
b = 𝒂𝒊 𝒎𝒐𝒅 𝒑
The exponent i is referred to as the discrete logarithm or
index, of b for the base a.
5
• Finding Primitive Root
• Example: Find primitive root of q =11 (prime number)
= 1,……….., q-1
= 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Suppose a= =2
𝑎1 = 2 mod 11 = 2
𝑎2 = 4 mod 11 = 4
𝑎3 = 8 mod 11 = 8
𝑎4 = 16 mod 11 = 5
𝑎5 = 32 mod 11 = 10
𝑎6 = 64 mod 11 = 9
𝑎7 = 128 mod 11 = 7
𝑎8 = 256 mod 11 = 3
𝑎9 = 512 mod 11 = 6
𝑎10 = 1024 mod 11 = 1
6
• Finding Primitive Root
• Example: Find primitive root of q =11 (prime number)
= 1,……….., q-1
= 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Suppose a= =3
𝑎1 = 3 mod 11 = 3
𝑎2 = 9 mod 11 = 9
𝑎3 = 27 mod 11 = 5
𝑎4 = 81 mod 11 = 4
𝑎5 = 243 mod 11 = 1
𝑎6 = 729 mod 11 = 3
𝑎7 =
𝑎8 =
𝑎9 =
𝑎10 =
9
Figure 10.1 Diffie-Hellman Key Exchange
Diffie Helman Algorithm
• Example
q= 97
=5
X A = 36
X B = 58
For 𝐗 𝐀
𝑌𝐴 = 𝑋𝐴 mod q
9 = 5 𝑋𝐴 mod 11
𝐗𝐀 = 6
For 𝐊 𝐒
𝐾𝑆 = (Y𝐵 )𝑋𝐴 mod q
= (3)6 mod 11
= 729 mod 11
𝐊𝐒 = 3
11
• Practice Example
q= 13
=7
Y𝐴 = 5, Y𝐵 = 12
X A = ? K𝑆 =?
For 𝐗 𝐀
𝑌𝐴 = 𝑋𝐴 mod q
𝐗𝐀 =
For 𝐊 𝐒
𝐾𝑆 = (Y𝐵 )𝑋𝐴 mod q
=
=
𝐊𝐒 =
12
• Practice Example
q= 83
= 5, X A = 6, X B = 10
Y𝐴 = ?, Y𝐵 = ?, K𝑆 =?
For 𝐘𝐀
𝑌𝐴 = 𝑋𝐴 mod q
𝐘𝐀 =
For 𝐘𝑩
𝑌𝐵 = 𝑋𝐵 mod q
𝐘𝑩 =
For 𝐊 𝐒
K S = (YB )XA mod q
=
𝐊𝐒 =
14
Alice Darth Bob
Private key XA
public key
YA = aXA mod q
YA
YB