SlideShare a Scribd company logo
4
Most read
7
Most read
10
Most read
CRYPTOGRAPHY AND
NETWORK SECURITY
Submitted by :Sunita Kharayat
DIFFIE-HELLMAN KEY
EXCHANGE
Table of Content
• Diffie hellmen key exchange
▫ Introduction
▫ Founder
▫ Primitive root
▫ Discrete Logarithm
▫ Diffie Hellman Key Exchange
▫ Cryptographic Explanation
▫ The discrete Logarithmic problem
• Attacks on diffie hellmen
▫ Man in the middle attack
▫ Solution
 Key distribution center
DIFFIE-HELLMAN KEY
EXCHANGE
Introduction
• Diffie–Hellman key exchange is a method of securely
exchanging cryptographic keys over a public channel
• was one of the first public-key protocols as conceived
by Ralph Merkle and named after Whitfield
Diffie and Martin Hellman in 1976.
• DH is one of the earliest practical examples of
public key exchange implemented within the field
of cryptography.
• The Diffie–Hellman key exchange method allows two
parties to jointly establish a shared secret key over
an insecure channel. This key can then be used to
encrypt subsequent communications using a symmetric
key cipher.
Founder
Figure 1: Founder : Ralph Markle , Martin Hellman , Whitfied Diffie
The main idea behind the algorithm is to agree on a key that two
parties can use for a symmetric encryption, in such a way that an
eavesdropper cannot obtain the key.
It also depend on the difficulty to compute discrete logarithms
Primitive root
• Primitive root of a prime number ‘n’ is a number ‘a’ where a <n and follows the
below criteria:
ai mod n gives a unique result for every a= 1 to (n-1) and i =1,2,3……
• Eg: for n=7 and a=1,2,3,4,5,6
Discrete Logarithm
• If a is a primitive root of the prime number p,then the numbers
▫ a mod p , a2 mod p …….. ap-1mod p
Are distinct and consist of the integer from 1 to (p-1) in some
permutation .
Eg : for any integer b and primitive root a of prime number p , we
can find unique exponent i such that
b=ai (mod p) where 0<= i <=(p-1)
Exponent “i” is referred to as the discrete logarithm of b
12=329 (mod 17)
Here for integer 12 where 1<12<17……29 is the discrete
logarithm.
Diffie - Hellman Key Exchange
Basic idea :
• A and B are two persons wishing to communicate. Both of them
generate a random number each, say a and b respectively.
• Now
▫ A sends f(a) to B
▫ B sends f(b) to A.
• So now have
▫ A knows a and f(b)
▫ B knows b and f(a)
• There is another function g such that
g(a, f(b)) = g(b, f(a)).
• The key used by
▫ A is g(a, f(b))
▫ B is g(b, f(a)). Both are actually same
1. A and B agrees on two large prime numbers p and g.
2. such that g is the primitive root of p.
3. A selects a random integer a where a<p and
computes f(a)= ga mod p (public key)
4. B selects a random integer b where b<p and
computes f(b)=gb mod p (public key)
5. A sends ga mod p to B.
6. B sends gb mod p to A
7. B evaluates (ga mod p)b to be used as the key.
8. A evaluates (gb mod p)a to be used as the key.
9. So now both parties have the
common number gab mod p.
This is the symmetric (secret communication) key used by
both A and B now.
This works because though the other people know p, g, ga mod
p, gb mod p but still they cannot evaluate the key because they
do not know either a or b
Figure 2 : Block diagram
Cryptographic explanation
The simplest and the original implementation of the protocol
uses the multiplicative group of integers modulo p,
where p is prime, and g is a primitive root modulo p. These
two values are chosen in this way to ensure that the resulting
shared secret can take on any value from 1 to p–1.
• Here is an example of the protocol, and secret values in red.
• Alice and Bob publicly agree to use a modulus p = 23 and base g = 5 (which is a
primitive root modulo 23).
• Alice chooses a secret integer a = 6, then sends Bob public key ,A = ga mod p
▫ A = 56 mod 23 = 8
• Bob chooses a secret integer b = 15, then sends Alicepublic key, B = gb mod p
▫ B = 515 mod 23 = 19
• Alice computes s = Ba mod p
▫ s = 106 mod 23 = 2
• Bob computes s = Ab mod p
▫ s = 415 mod 23 = 2
• Alice and Bob now share a secret (the number 18).
• that is :
Ab mod p= gab mod p= gba mod p=Ba mod p
106 mod 23 = 2 = 415 mod 23
or
(ga mod p)b mod p = (gb mod p)a mod p
• Both Alice and Bob have arrived at the same values because under mod p,
Only a, b, and (gab mod p = gbamod p) are kept secret. All the other values –
p, g, ga mod p, and gb mod p – are sent in the clear.
It is difficult for eve to calculate (a,b) using only p,g,A,B
The discrete logarithm problem
Clearly, much larger values of a, b, and p are required. An eavesdropper cannot
discover this value even if she knows p and g and can obtain each of the
messages.
329 mod 17 =12
ga mod p =B
Given 12 find the value of a for prime number 17 and primitive root 3
Suppose p is a prime of around 300 digits, and a and b at least 100 digits
each. Discovering the shared secret given g, p, ga mod p and gb mod p would
take longer than the lifetime of the universe, using the best known algorithm.
This is called the discrete logarithm problem.
ATTACKS
ON
DEFFIE-HELLEMAN
Man In The Middle Attack
We assume that there is a guy Z in between A and B. Z has the
ability to capture packets and create new packets.
• When A sends p, g and ga mod p, Z captures them and sends p,
g and gz mod p to B.
• On receiving this, B sends p, g and gb mod p but again Z
captures these and sends p, g and gz mod p to A.
• So A will use the key (gz mod p)a and
B will use the key (gz mod p)b .
Both these keys are known to Z and so when a packet comes from
A, Z decrypts it using A's key and encrypts it in it's own key and
then sends it to B. Again when a packet comes from B, it does a
similar thing before sending the packet to A. So effectively there
are two keys - one operating between A and Z and the other
between Z and B.
Block diagram
Solution :
• We use a policy that A only sends half a packet at a time. M cannot decrypt
half a packet and so it is stuck. A sends the other half only when it receives a
half-packet from B. M has two options when it receives half a packet :
▫ It does not send the packet to B at all and dumps it. In this case B will anyway
come to know that there is some problem and so it will not send it's half-packet.
▫ It forwards the half-packet as it is to B. Now when B sends it's half-packet, A sends
the remaining half. When B decrypts this entire packet it sees that the data is junk
and so it comes to know that there is some problem in communication.
• Here we have assumed that there is some application level understanding
between A and B like the port number. If A sends a packet at port number 25
and receives a packet at port number 35, then it will come to know that there
is some problem. At the very least we have ensured that M cannot read the
packets though it can block the communication.
Continued….
There is another much simpler method of exchanging keys
which we now discuss :
Key Distribution Center
• There is a central trusted node called the Key Distribution
Center ( KDC ). Every node has a key which is shared
between it and the KDC. Since no one else knows A's secret
key (KA) KDC is sure that the message it received has come
from A. We show the implementation through this diagram :
Figure 4: Block diagram
• When A wants to communicate with B,
▫ it sends a message encrypted in it's key to the KDC.
▫ The KDC then sends a common key to both A and B encrypted
in their respective keys.
▫ A and B can communicate safely using this key.
There is a problem with this implementation also. It is prone
to replay attack. The messages are in encrypted form and hence
would not make sense to an intruder but they may be replayed to
the listener again and again with the listener believing that the
messages are from the correct source. To prevent this, we can use:
Timestamps: which however don't generally work because of the
offset in time between machines. Synchronization over the network
becomes a problem.
Nonce numbers: which are like ticket numbers. B accepts a
message only if it has not seen this nonce number before.
THANKYOU

More Related Content

PPT
Diffie-hellman algorithm
PPT
Diffiehellman
PPTX
RSA Algorithm
PPTX
Artificial intelligence powerpoint presentation
PPTX
Firewall Design and Implementation
PPTX
Diffie Hellman Key Exchange
PPTX
ElGamal Encryption Algoritham.pptx
PPTX
5 Protect-Application-or-System-Software (2).pptx
Diffie-hellman algorithm
Diffiehellman
RSA Algorithm
Artificial intelligence powerpoint presentation
Firewall Design and Implementation
Diffie Hellman Key Exchange
ElGamal Encryption Algoritham.pptx
5 Protect-Application-or-System-Software (2).pptx

What's hot (20)

PPTX
Cryptography.ppt
PPTX
Hash Function
PDF
2. Stream Ciphers
PPTX
Public Key Cryptography
PPTX
Cryptography
PDF
Asymmetric Cryptography
PPT
Cryptography and Network Security William Stallings Lawrie Brown
PPT
6. cryptography
PDF
symmetric key encryption algorithms
PPTX
Key Management and Distribution
PPTX
Cryptography
PPTX
Elgamal &amp; schnorr digital signature scheme copy
PPTX
Cryptography
PDF
Introduction to Cryptography
PPTX
Transposition cipher techniques
PPTX
Advanced encryption standard (aes)
PPTX
cryptography
PPTX
Public Key Cryptosystem
PPTX
Security services and mechanisms
PPTX
Diffie Hellman.pptx
Cryptography.ppt
Hash Function
2. Stream Ciphers
Public Key Cryptography
Cryptography
Asymmetric Cryptography
Cryptography and Network Security William Stallings Lawrie Brown
6. cryptography
symmetric key encryption algorithms
Key Management and Distribution
Cryptography
Elgamal &amp; schnorr digital signature scheme copy
Cryptography
Introduction to Cryptography
Transposition cipher techniques
Advanced encryption standard (aes)
cryptography
Public Key Cryptosystem
Security services and mechanisms
Diffie Hellman.pptx
Ad

Similar to Diffie hellman key exchange algorithm (20)

PDF
Elliptic curve Cryptography and Diffie- Hellman Key exchange
PPT
Other public key systems
PPTX
4_Diffie Hellman algorithm for graduates.pptx
PPT
P10co982 (2)
PDF
CRYPTOGRAPHY AND NETWORK SECURITY
PPT
CS283-PublicKey.ppt
PPT
CS283-PublicKey.ppt
PPTX
PPTX
6-PKCpartII-Encryptionandsignatures.pptx
PPT
Rsa diffi-network security-itt
PPT
crypto Digital Signature Diffie Hell man.ppt
PPT
Crypto2
PDF
PPTX
Cryptography Key Management.pptx
PPT
Information and Network Security
ODP
Diffie_Hellman-Merkle Key Exchange
PPT
public-key cryptography Shamir
PDF
Active Attacks on DH Key Exchange
DOCX
Assignment 2 (1) (1).docx
Elliptic curve Cryptography and Diffie- Hellman Key exchange
Other public key systems
4_Diffie Hellman algorithm for graduates.pptx
P10co982 (2)
CRYPTOGRAPHY AND NETWORK SECURITY
CS283-PublicKey.ppt
CS283-PublicKey.ppt
6-PKCpartII-Encryptionandsignatures.pptx
Rsa diffi-network security-itt
crypto Digital Signature Diffie Hell man.ppt
Crypto2
Cryptography Key Management.pptx
Information and Network Security
Diffie_Hellman-Merkle Key Exchange
public-key cryptography Shamir
Active Attacks on DH Key Exchange
Assignment 2 (1) (1).docx
Ad

Recently uploaded (20)

PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
Well-logging-methods_new................
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
additive manufacturing of ss316l using mig welding
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
Welding lecture in detail for understanding
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
Geodesy 1.pptx...............................................
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
Construction Project Organization Group 2.pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
web development for engineering and engineering
PPTX
Sustainable Sites - Green Building Construction
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Well-logging-methods_new................
Arduino robotics embedded978-1-4302-3184-4.pdf
Foundation to blockchain - A guide to Blockchain Tech
additive manufacturing of ss316l using mig welding
UNIT 4 Total Quality Management .pptx
Welding lecture in detail for understanding
CYBER-CRIMES AND SECURITY A guide to understanding
Geodesy 1.pptx...............................................
Lecture Notes Electrical Wiring System Components
Internet of Things (IOT) - A guide to understanding
Construction Project Organization Group 2.pptx
bas. eng. economics group 4 presentation 1.pptx
CH1 Production IntroductoryConcepts.pptx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
UNIT-1 - COAL BASED THERMAL POWER PLANTS
web development for engineering and engineering
Sustainable Sites - Green Building Construction
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx

Diffie hellman key exchange algorithm

  • 1. CRYPTOGRAPHY AND NETWORK SECURITY Submitted by :Sunita Kharayat DIFFIE-HELLMAN KEY EXCHANGE
  • 2. Table of Content • Diffie hellmen key exchange ▫ Introduction ▫ Founder ▫ Primitive root ▫ Discrete Logarithm ▫ Diffie Hellman Key Exchange ▫ Cryptographic Explanation ▫ The discrete Logarithmic problem • Attacks on diffie hellmen ▫ Man in the middle attack ▫ Solution  Key distribution center
  • 4. Introduction • Diffie–Hellman key exchange is a method of securely exchanging cryptographic keys over a public channel • was one of the first public-key protocols as conceived by Ralph Merkle and named after Whitfield Diffie and Martin Hellman in 1976. • DH is one of the earliest practical examples of public key exchange implemented within the field of cryptography. • The Diffie–Hellman key exchange method allows two parties to jointly establish a shared secret key over an insecure channel. This key can then be used to encrypt subsequent communications using a symmetric key cipher.
  • 5. Founder Figure 1: Founder : Ralph Markle , Martin Hellman , Whitfied Diffie
  • 6. The main idea behind the algorithm is to agree on a key that two parties can use for a symmetric encryption, in such a way that an eavesdropper cannot obtain the key. It also depend on the difficulty to compute discrete logarithms
  • 7. Primitive root • Primitive root of a prime number ‘n’ is a number ‘a’ where a <n and follows the below criteria: ai mod n gives a unique result for every a= 1 to (n-1) and i =1,2,3…… • Eg: for n=7 and a=1,2,3,4,5,6
  • 8. Discrete Logarithm • If a is a primitive root of the prime number p,then the numbers ▫ a mod p , a2 mod p …….. ap-1mod p Are distinct and consist of the integer from 1 to (p-1) in some permutation . Eg : for any integer b and primitive root a of prime number p , we can find unique exponent i such that b=ai (mod p) where 0<= i <=(p-1) Exponent “i” is referred to as the discrete logarithm of b 12=329 (mod 17) Here for integer 12 where 1<12<17……29 is the discrete logarithm.
  • 9. Diffie - Hellman Key Exchange Basic idea : • A and B are two persons wishing to communicate. Both of them generate a random number each, say a and b respectively. • Now ▫ A sends f(a) to B ▫ B sends f(b) to A. • So now have ▫ A knows a and f(b) ▫ B knows b and f(a) • There is another function g such that g(a, f(b)) = g(b, f(a)). • The key used by ▫ A is g(a, f(b)) ▫ B is g(b, f(a)). Both are actually same
  • 10. 1. A and B agrees on two large prime numbers p and g. 2. such that g is the primitive root of p. 3. A selects a random integer a where a<p and computes f(a)= ga mod p (public key) 4. B selects a random integer b where b<p and computes f(b)=gb mod p (public key) 5. A sends ga mod p to B. 6. B sends gb mod p to A 7. B evaluates (ga mod p)b to be used as the key. 8. A evaluates (gb mod p)a to be used as the key. 9. So now both parties have the common number gab mod p. This is the symmetric (secret communication) key used by both A and B now. This works because though the other people know p, g, ga mod p, gb mod p but still they cannot evaluate the key because they do not know either a or b
  • 11. Figure 2 : Block diagram
  • 12. Cryptographic explanation The simplest and the original implementation of the protocol uses the multiplicative group of integers modulo p, where p is prime, and g is a primitive root modulo p. These two values are chosen in this way to ensure that the resulting shared secret can take on any value from 1 to p–1.
  • 13. • Here is an example of the protocol, and secret values in red. • Alice and Bob publicly agree to use a modulus p = 23 and base g = 5 (which is a primitive root modulo 23). • Alice chooses a secret integer a = 6, then sends Bob public key ,A = ga mod p ▫ A = 56 mod 23 = 8 • Bob chooses a secret integer b = 15, then sends Alicepublic key, B = gb mod p ▫ B = 515 mod 23 = 19 • Alice computes s = Ba mod p ▫ s = 106 mod 23 = 2 • Bob computes s = Ab mod p ▫ s = 415 mod 23 = 2 • Alice and Bob now share a secret (the number 18). • that is : Ab mod p= gab mod p= gba mod p=Ba mod p 106 mod 23 = 2 = 415 mod 23 or (ga mod p)b mod p = (gb mod p)a mod p • Both Alice and Bob have arrived at the same values because under mod p, Only a, b, and (gab mod p = gbamod p) are kept secret. All the other values – p, g, ga mod p, and gb mod p – are sent in the clear.
  • 14. It is difficult for eve to calculate (a,b) using only p,g,A,B
  • 15. The discrete logarithm problem Clearly, much larger values of a, b, and p are required. An eavesdropper cannot discover this value even if she knows p and g and can obtain each of the messages. 329 mod 17 =12 ga mod p =B Given 12 find the value of a for prime number 17 and primitive root 3 Suppose p is a prime of around 300 digits, and a and b at least 100 digits each. Discovering the shared secret given g, p, ga mod p and gb mod p would take longer than the lifetime of the universe, using the best known algorithm. This is called the discrete logarithm problem.
  • 17. Man In The Middle Attack We assume that there is a guy Z in between A and B. Z has the ability to capture packets and create new packets. • When A sends p, g and ga mod p, Z captures them and sends p, g and gz mod p to B. • On receiving this, B sends p, g and gb mod p but again Z captures these and sends p, g and gz mod p to A. • So A will use the key (gz mod p)a and B will use the key (gz mod p)b . Both these keys are known to Z and so when a packet comes from A, Z decrypts it using A's key and encrypts it in it's own key and then sends it to B. Again when a packet comes from B, it does a similar thing before sending the packet to A. So effectively there are two keys - one operating between A and Z and the other between Z and B.
  • 19. Solution : • We use a policy that A only sends half a packet at a time. M cannot decrypt half a packet and so it is stuck. A sends the other half only when it receives a half-packet from B. M has two options when it receives half a packet : ▫ It does not send the packet to B at all and dumps it. In this case B will anyway come to know that there is some problem and so it will not send it's half-packet. ▫ It forwards the half-packet as it is to B. Now when B sends it's half-packet, A sends the remaining half. When B decrypts this entire packet it sees that the data is junk and so it comes to know that there is some problem in communication. • Here we have assumed that there is some application level understanding between A and B like the port number. If A sends a packet at port number 25 and receives a packet at port number 35, then it will come to know that there is some problem. At the very least we have ensured that M cannot read the packets though it can block the communication.
  • 20. Continued…. There is another much simpler method of exchanging keys which we now discuss : Key Distribution Center • There is a central trusted node called the Key Distribution Center ( KDC ). Every node has a key which is shared between it and the KDC. Since no one else knows A's secret key (KA) KDC is sure that the message it received has come from A. We show the implementation through this diagram :
  • 21. Figure 4: Block diagram
  • 22. • When A wants to communicate with B, ▫ it sends a message encrypted in it's key to the KDC. ▫ The KDC then sends a common key to both A and B encrypted in their respective keys. ▫ A and B can communicate safely using this key. There is a problem with this implementation also. It is prone to replay attack. The messages are in encrypted form and hence would not make sense to an intruder but they may be replayed to the listener again and again with the listener believing that the messages are from the correct source. To prevent this, we can use: Timestamps: which however don't generally work because of the offset in time between machines. Synchronization over the network becomes a problem. Nonce numbers: which are like ticket numbers. B accepts a message only if it has not seen this nonce number before.