SlideShare a Scribd company logo
DIFFIE – HELLMAN
KEY EXCHANGE
ALGORITHM
Diffie–Hellman key exchange is a method of securely exchanging
cryptographic keys over a public channel and was one of the first public-
key protocols as originally conceptualized by Ralph Merkle and named after
Whitfield Diffie and Martin Hellman
2/4/2020Dr.RajniBhalla(LPU)
1
Diffie Hellman
• Not an encryption algorithm
• Used to share secret keys between 2 users .
• We will use assymmteric encryption (public and private key
concept) to exchange the secret key.
2/4/2020Dr.RajniBhalla(LPU)
2
Why this algo?
• When we are sending a key to a receiver, it can be attacked in
between
2/4/2020Dr.RajniBhalla(LPU)
3
Algorithm
1. Consider a prime number q.
2. Select Alpha(which is primitive root) such that it must be
primitive root of q and (alpha<q)
‘a’ is a primitive root of q
a1 mod q, a2mod q,…………………….aq-1 mod q gives result
(1,2,3…………………….q-1)
Values should not be repeated & we should have all values in the
o/p set from 1 to q—1.
2/4/2020Dr.RajniBhalla(LPU)
4
What is primitive root?
• A is primitive root of q if
• a mod q, a2 mod q, a3 mod q………………………………….a(q-1)
mod q
• Example q=7,we want to check whthr 3 is primitive root or
not.
• We will check value until q value id less than one.(7-1=6)
• If q=7, then we must get all values less than 7(like 1,2,3,4,5
and 6).
2/4/2020Dr.RajniBhalla(LPU)
5
We get all values less than 7,so we can 3 is
the primitive root of 7
31 MOD 7 = 3
32 MOD 7 = 2
33 MOD 7 = 6
34 MOD 7 = 4
35 MOD 7 = 5
36 MOD 7 = 1
2/4/2020Dr.RajniBhalla(LPU)
6
Check 5 whether is primitive root
or not q=7.
51 MOD 7 = 5
52 MOD 7 = 4
53 MOD 7 = 6
54 MOD 7 = 3
55 MOD 7 = 2
56 MOD 7 = 1
We can 5 is primitive root of q. Primitive root must always be less
than q.
2/4/2020Dr.RajniBhalla(LPU)
7
Consideraprimenumberq.
Letsq=7
Sowewillcheckfrom1to7
Checkfor1.
Values are repeated so we will cancel 1 or discard immediately.
11 MOD 7 = 1
12 MOD 7 = 1
2/4/2020Dr.RajniBhalla(LPU)
8
Check for 2
• Values repeated ,will discard this one too
21 MOD 7 = 2
22 MOD 7 = 4
23 MOD 7 = 1
24 MOD 7 = 2
2/4/2020Dr.RajniBhalla(LPU)
9
We will take Alpha =5
• Primitive root can be 2 or 3 or 4 or more.
• We have to select one that must be less than q.
• Suppose we select alpha = 5.
2/4/2020Dr.RajniBhalla(LPU)
10
Global Elements
• Alpha and q are global elements that are known to all
2/4/2020Dr.RajniBhalla(LPU)
11
3rd step of algorithm
Note: x->private key of users(will choose by user)
y-> public key of users.
3. Assume Xa (private key of a) and Xa < q.
Once we know ,private key then public will be calculated i.e(Ya)
Calculate Ya = alphaxamod q A is a public key of A
Example
Key generation of person 1
Assume private key Xa=3 (3<7 ,yes condition satisfy)
Calculating public key Ya =alphaxamod q
We already assume apha=5
So, 5pow 3 mod 7 =125 mod 7 equals to Ya=6
2/4/2020Dr.RajniBhalla(LPU)
12
4rth step of algorithm
Calculate private key of second person
• Assume Xb (private key of b) Xb < q
• Calculate Yb = alphaxbmod q (public key of b)
Key generation of person 2
Let private key Xb = 4
Caluclating public key Yb = alphaxbmod q
Yb=5 pow 4 mod 7
Yb=2
2/4/2020Dr.RajniBhalla(LPU)
13
Q=7
Q=5
Global elements
Public Keys
Ya=6
Yb=2
Xa=3
Private Key
Private Key
Xb=4
Person 1 Person 2
Now person 1 and person 2 knows their
private key.
Ya,Yb public key will be known to all.
Person A will generate secret key
2/4/2020Dr.RajniBhalla(LPU)
14
Now we will calculate secret
key
• To calculate the secret key ,both the sender and receiver will use
public key.
• Value of Yb is 2
• Value of xa=3
Ka = (2)3 mod 7 we get k=1
2/4/2020Dr.RajniBhalla(LPU)
15
Calculate kb for person 2
• Kb = (Ya )xb mod q
• Ya = 6
• Xb=4
• Kb = (6 )4 mod 7
• Kb = 1
Both values of ka and kb is 1. So keys are succesfully exhanged.
2/4/2020Dr.RajniBhalla(LPU)
16
2/4/2020Dr.RajniBhalla(LPU)
17
• Step 1: Alice and Bob get public numbers P = 23, G = 9
• Step 2: Alice selected a private key a = 4 and Bob
selected a private key b = 3
• Step 3: Alice and Bob compute public values Alice: x
=(9^4 mod 23) = (6561 mod 23) = 6 Bob: y = (9^3 mod
23) = (729 mod 23) = 16
• Step 4: Alice and Bob exchange public numbers
• Step 5: Alice receives public key y =16 and Bob
receives public key x = 6
• Step 6: Alice and Bob compute symmetric keys Alice:
ka = y^a mod p = 65536 mod 23 = 9 Bob: kb = x^b mod
p = 216 mod 23 = 9
• Step 7: 9 is the shared secret.
2/4/2020Dr.RajniBhalla(LPU)
18
2/4/2020Dr.RajniBhalla(LPU)
19
References
1. https://www.geeksforgeeks.org/implementation-diffie-
hellman-algorithm/
2. https://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_ke
y_exchange
2/4/2020Dr.RajniBhalla(LPU)
20

More Related Content

Similar to Diffie hellman key exchange algo

Rsa diffi-network security-itt
Rsa diffi-network security-ittRsa diffi-network security-itt
Rsa diffi-network security-itt
rameshvvv
 

Similar to Diffie hellman key exchange algo (15)

Public Key Cryptography
Public Key CryptographyPublic Key Cryptography
Public Key Cryptography
 
Key Management
Key ManagementKey Management
Key Management
 
Information and Network Security
Information and Network SecurityInformation and Network Security
Information and Network Security
 
CNS - Unit - 4 - Public Key Cryptosystem
CNS - Unit - 4 - Public Key Cryptosystem CNS - Unit - 4 - Public Key Cryptosystem
CNS - Unit - 4 - Public Key Cryptosystem
 
Discrete Logarithmic Problem- Basis of Elliptic Curve Cryptosystems
Discrete Logarithmic Problem- Basis of Elliptic Curve CryptosystemsDiscrete Logarithmic Problem- Basis of Elliptic Curve Cryptosystems
Discrete Logarithmic Problem- Basis of Elliptic Curve Cryptosystems
 
UNIT-IV.pptx
UNIT-IV.pptxUNIT-IV.pptx
UNIT-IV.pptx
 
Rsa diffi-network security-itt
Rsa diffi-network security-ittRsa diffi-network security-itt
Rsa diffi-network security-itt
 
Other public key systems
Other public key systemsOther public key systems
Other public key systems
 
CNIT 141 8. Public-Key Cryptosystems Based on the DLP
CNIT 141 8. Public-Key Cryptosystems Based on the DLPCNIT 141 8. Public-Key Cryptosystems Based on the DLP
CNIT 141 8. Public-Key Cryptosystems Based on the DLP
 
Class3
Class3Class3
Class3
 
2.11 Diffie -hellman exchange.pptx
2.11 Diffie -hellman exchange.pptx2.11 Diffie -hellman exchange.pptx
2.11 Diffie -hellman exchange.pptx
 
ch10.KeyManagement.Diffie-Hellman.ECC.ppt
ch10.KeyManagement.Diffie-Hellman.ECC.pptch10.KeyManagement.Diffie-Hellman.ECC.ppt
ch10.KeyManagement.Diffie-Hellman.ECC.ppt
 
ch10_Key_Management.ppt ch10_Key_Management.ppt ch10_Key_Management.ppt
ch10_Key_Management.ppt ch10_Key_Management.ppt ch10_Key_Management.pptch10_Key_Management.ppt ch10_Key_Management.ppt ch10_Key_Management.ppt
ch10_Key_Management.ppt ch10_Key_Management.ppt ch10_Key_Management.ppt
 
Diffie hellman key exchange algorithm
Diffie hellman key exchange algorithmDiffie hellman key exchange algorithm
Diffie hellman key exchange algorithm
 
Bypassing ASLR Exploiting CVE 2015-7545
Bypassing ASLR Exploiting CVE 2015-7545Bypassing ASLR Exploiting CVE 2015-7545
Bypassing ASLR Exploiting CVE 2015-7545
 

Recently uploaded

Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
Kamal Acharya
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
Hall booking system project report .pdf
Hall booking system project report  .pdfHall booking system project report  .pdf
Hall booking system project report .pdf
Kamal Acharya
 
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdfONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
Kamal Acharya
 

Recently uploaded (20)

ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge
 
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical EngineeringIntroduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
Introduction to Machine Learning Unit-4 Notes for II-II Mechanical Engineering
 
Automobile Management System Project Report.pdf
Automobile Management System Project Report.pdfAutomobile Management System Project Report.pdf
Automobile Management System Project Report.pdf
 
A case study of cinema management system project report..pdf
A case study of cinema management system project report..pdfA case study of cinema management system project report..pdf
A case study of cinema management system project report..pdf
 
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWINGBRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
 
Courier management system project report.pdf
Courier management system project report.pdfCourier management system project report.pdf
Courier management system project report.pdf
 
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and ClusteringKIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
KIT-601 Lecture Notes-UNIT-4.pdf Frequent Itemsets and Clustering
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
Hall booking system project report .pdf
Hall booking system project report  .pdfHall booking system project report  .pdf
Hall booking system project report .pdf
 
Natalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in KrakówNatalia Rutkowska - BIM School Course in Kraków
Natalia Rutkowska - BIM School Course in Kraków
 
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdfONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
 
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
Explosives Industry manufacturing process.pdf
Explosives Industry manufacturing process.pdfExplosives Industry manufacturing process.pdf
Explosives Industry manufacturing process.pdf
 
Top 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering ScientistTop 13 Famous Civil Engineering Scientist
Top 13 Famous Civil Engineering Scientist
 
Pharmacy management system project report..pdf
Pharmacy management system project report..pdfPharmacy management system project report..pdf
Pharmacy management system project report..pdf
 

Diffie hellman key exchange algo

  • 1. DIFFIE – HELLMAN KEY EXCHANGE ALGORITHM Diffie–Hellman key exchange is a method of securely exchanging cryptographic keys over a public channel and was one of the first public- key protocols as originally conceptualized by Ralph Merkle and named after Whitfield Diffie and Martin Hellman 2/4/2020Dr.RajniBhalla(LPU) 1
  • 2. Diffie Hellman • Not an encryption algorithm • Used to share secret keys between 2 users . • We will use assymmteric encryption (public and private key concept) to exchange the secret key. 2/4/2020Dr.RajniBhalla(LPU) 2
  • 3. Why this algo? • When we are sending a key to a receiver, it can be attacked in between 2/4/2020Dr.RajniBhalla(LPU) 3
  • 4. Algorithm 1. Consider a prime number q. 2. Select Alpha(which is primitive root) such that it must be primitive root of q and (alpha<q) ‘a’ is a primitive root of q a1 mod q, a2mod q,…………………….aq-1 mod q gives result (1,2,3…………………….q-1) Values should not be repeated & we should have all values in the o/p set from 1 to q—1. 2/4/2020Dr.RajniBhalla(LPU) 4
  • 5. What is primitive root? • A is primitive root of q if • a mod q, a2 mod q, a3 mod q………………………………….a(q-1) mod q • Example q=7,we want to check whthr 3 is primitive root or not. • We will check value until q value id less than one.(7-1=6) • If q=7, then we must get all values less than 7(like 1,2,3,4,5 and 6). 2/4/2020Dr.RajniBhalla(LPU) 5
  • 6. We get all values less than 7,so we can 3 is the primitive root of 7 31 MOD 7 = 3 32 MOD 7 = 2 33 MOD 7 = 6 34 MOD 7 = 4 35 MOD 7 = 5 36 MOD 7 = 1 2/4/2020Dr.RajniBhalla(LPU) 6
  • 7. Check 5 whether is primitive root or not q=7. 51 MOD 7 = 5 52 MOD 7 = 4 53 MOD 7 = 6 54 MOD 7 = 3 55 MOD 7 = 2 56 MOD 7 = 1 We can 5 is primitive root of q. Primitive root must always be less than q. 2/4/2020Dr.RajniBhalla(LPU) 7
  • 8. Consideraprimenumberq. Letsq=7 Sowewillcheckfrom1to7 Checkfor1. Values are repeated so we will cancel 1 or discard immediately. 11 MOD 7 = 1 12 MOD 7 = 1 2/4/2020Dr.RajniBhalla(LPU) 8
  • 9. Check for 2 • Values repeated ,will discard this one too 21 MOD 7 = 2 22 MOD 7 = 4 23 MOD 7 = 1 24 MOD 7 = 2 2/4/2020Dr.RajniBhalla(LPU) 9
  • 10. We will take Alpha =5 • Primitive root can be 2 or 3 or 4 or more. • We have to select one that must be less than q. • Suppose we select alpha = 5. 2/4/2020Dr.RajniBhalla(LPU) 10
  • 11. Global Elements • Alpha and q are global elements that are known to all 2/4/2020Dr.RajniBhalla(LPU) 11
  • 12. 3rd step of algorithm Note: x->private key of users(will choose by user) y-> public key of users. 3. Assume Xa (private key of a) and Xa < q. Once we know ,private key then public will be calculated i.e(Ya) Calculate Ya = alphaxamod q A is a public key of A Example Key generation of person 1 Assume private key Xa=3 (3<7 ,yes condition satisfy) Calculating public key Ya =alphaxamod q We already assume apha=5 So, 5pow 3 mod 7 =125 mod 7 equals to Ya=6 2/4/2020Dr.RajniBhalla(LPU) 12
  • 13. 4rth step of algorithm Calculate private key of second person • Assume Xb (private key of b) Xb < q • Calculate Yb = alphaxbmod q (public key of b) Key generation of person 2 Let private key Xb = 4 Caluclating public key Yb = alphaxbmod q Yb=5 pow 4 mod 7 Yb=2 2/4/2020Dr.RajniBhalla(LPU) 13
  • 14. Q=7 Q=5 Global elements Public Keys Ya=6 Yb=2 Xa=3 Private Key Private Key Xb=4 Person 1 Person 2 Now person 1 and person 2 knows their private key. Ya,Yb public key will be known to all. Person A will generate secret key 2/4/2020Dr.RajniBhalla(LPU) 14
  • 15. Now we will calculate secret key • To calculate the secret key ,both the sender and receiver will use public key. • Value of Yb is 2 • Value of xa=3 Ka = (2)3 mod 7 we get k=1 2/4/2020Dr.RajniBhalla(LPU) 15
  • 16. Calculate kb for person 2 • Kb = (Ya )xb mod q • Ya = 6 • Xb=4 • Kb = (6 )4 mod 7 • Kb = 1 Both values of ka and kb is 1. So keys are succesfully exhanged. 2/4/2020Dr.RajniBhalla(LPU) 16
  • 18. • Step 1: Alice and Bob get public numbers P = 23, G = 9 • Step 2: Alice selected a private key a = 4 and Bob selected a private key b = 3 • Step 3: Alice and Bob compute public values Alice: x =(9^4 mod 23) = (6561 mod 23) = 6 Bob: y = (9^3 mod 23) = (729 mod 23) = 16 • Step 4: Alice and Bob exchange public numbers • Step 5: Alice receives public key y =16 and Bob receives public key x = 6 • Step 6: Alice and Bob compute symmetric keys Alice: ka = y^a mod p = 65536 mod 23 = 9 Bob: kb = x^b mod p = 216 mod 23 = 9 • Step 7: 9 is the shared secret. 2/4/2020Dr.RajniBhalla(LPU) 18