SlideShare a Scribd company logo
CNIT 141
Cryptography for Computer Networks
11. Diffie-Hellman
Topics
• The Diffie-Hellman Function
• The Diffie-Hellman Problems
• Key Agreement Protocols
• Diffie-Hellman Protocols
• How Things Can Go Wrong
1976
• Whitfield Diffie and Martin Hellman
• Published "New Directions in Cryptography"
• Revolutionized cryptography
• Specified a public-key distribution scheme
• The Diffie-Hellman (DH) protocol
• The basis for public-key encryption and
signatures
Key Agreement
• After exchanging a shared secret
• Parties turn the secret into a symmetric key
• Thus establishing a secure channel
The Diffie-Hellman
Function
The Group Zp*
• The integers 1, 2, 3, ... p-1
• Where p is prime
• In DH, the two parties choose random
elements a and b to be their secrets
• From the group
• Both parties also use a number g
• Which is not a secret
Alice and Bob
• They can both calculate gab by combining
public and secret information
Keep a secret

Transmit ga
Keep b secret

Transmit gb
Diffie-Hellman
• Alice calculates A = ga mod p
• and sends it to Bob
• Bob calculates B = gb mod p
• and sends it to Alice
• Alice calculates Ba mod p = gba mod p
• Bob calculates Ab mod p = gab mod p
• They now have the same shared secret
Key Derivation Function
(KDF)
• The shared secret is not used directly as the
key
• It's passed through a KDF to create a random-
looking value of the proper size
• A kind of hash function
Safe Primes
• Not all values of p and g work
• For highest security, both p and (p - 1) / 2
should be prime
• Those are called safe primes
• They don't have small subgroups
• That would limit the shared secret to a small
number of possible values
Safe Primes
• With safe primes even a g of 2 works
• But safe primes are slow to generate
• 1000x as long as generating mere random
primes
Generating 2048-bit DH
• 154 seconds
Generating 2048-bit RSA
• 0.17 seconds
The Diffie-Hellman
Problems
Discrete Logarithm
Problem
• Public value: ga
• Secret value: a
• Recovering a from ga is the DLP
• Diffie-Hellman's security depends on the DLP's
hardness
Eavesdropper
• Evil attacker knows only ga and gb
Keep a secret

Transmit ga
Keep b secret

Transmit gb
The Computational Diffie-
Hellman Problem (CDH)
• Consider an eavesdropper
• Compute the shared secret gab
• Given only the public values ga and gb
• And not the secrets a or b
• This might be easier than the DLP
• We don't know for sure
Number Sieve
• DH protocol with 2048 bit prime p provides 90
bits of security
• Same as RSA with a 2048-bit n
• Fastest known attack on Computational Diffie-
Hellman is the number field sieve
• Similar to the fastest known attack on RSA:
the "general number field sieve"
Decisional Diffie-Hellman
Problem (DDH)
• Stronger than CDH's hardness assumption
• If DDH is hard, the attacker can't learn
anything about the shared secret from the
public information
• Not even a few bits of it
• Because it appears completely random
• Both DDH and CDH are hard if the
parameters are well-chosen
Key Agreement Protocols
A Non-DH Key Agreement
Protocol
• Authenticated Key Agreement (AKA)
• Used by 3G and 4G
• To establish secure communication between a
SIM card and a telecom operator
• Uses only symmetric-key operations
• Relies on a pre-shared secret K
CNIT 141: 11. Diffie-Hellman
Replay Attack
• Attacker captures pair (R, V1)
• Sends it to SIM card to open a new session
impersonating the telco
• To precent this, protocol checks to make sure
R isn't reused
Compromised K
• Attacker who gets K
• Can perform MiTM attack and listen to all
cleartext communications
• Can impersonate either party
• Can record communications and later
decrypt them using the captured R values
Attack Models for
Key Agreement Protocols
• Eavesdropper
• Attacker is a MiTM
• Can record, modify, drop or inject messages
• To stop: protocol must not leak any
information about the shared secret
• Data leak
• Attacker gets the session key and all
temporary secrets
• But not long-term secret K
Attack Models for
Key Agreement Protocols
• Breach
• Attacker learns long-term key K
• Impossible to protect current session from
this attack
• But a protocol can protect other sessions
Security Goals
• Authentication
• Mutual authentication: each party can
authenticate to the other party
• Authenticated Key Agreement happens
when a protocol authenticates both parties
Security Goals
• Key control
• Neither party can control the final shared
secret
• The 3G/4G protocol lacks this property
• Because the operator chooses R
• Which entirely determines the final shared
key
Security Goals
• Forward secrecy
• Even if all long-term secrets are exposed
• Shared secrets from previous sessions are
not available
• 3G/4G protocol doesn't provide this
Performance
• Number of messages exchanged
• Message length
• Computations required
• Possibility of pre-computation
• The main cause of latency is usually round-
trip time
• Computation required also counts
Performance of 3G/4G
• Exchanges two messages of a few hundred
bits each
• Pre-computation is possible
• Operator can pick many values of R in
advance
Diffie-Hellman Protocols
Anonymous Diffie-Hellman
• Not authenticated
• Vulnerable to MiTM attack (next slide)
CNIT 141: 11. Diffie-Hellman
Authenticated Diffie-Hellman
• Uses public-key signatures to sign messages
• With a system such as RSA-PSS
Security Against
Eavesdroppers
• Authenticated DH stops eavesdroppers
• Attacker can't learn the shared secret gab
• Neither party can control the shared secret
Replay
• Eve can record and replay previous values of
A and sigA
• To pretend to be Alice
• Key confirmation prevents this
• Alice and Bob send a message to prove that
they both own the shared secret
Security Against Data Leaks
• If Eve has a, she can impersonate Alice
• To prevent this, integrate long-term keys into the
shared secret computation
Memezes-Qu-Vanstone
MQV
• Designed in 1998
• NSA included it in Suite B
• Designed to protect classified information
• More secure than authenticated DH
• Better performance
MQV
• x and y are long-term private keys
• X and Y are long-term public keys
Data Leak
• Attacker who gets the ephemeral secrets a
and b
• Can't find the shared secret
• That would require knowing the long-term
private keys
Breach
• Attacker gets Alice's long-term private key x
• Previous sessions are still safe
• Because they used Alice's ephemeral private
keys
• There is an attack that could compromise a
targeted old session
• It can be mitigated by a key-confirmation
step
MQV Rarely Used
• Was encumbered by patents
• Complex and difficult to implement
• Authenticated DH is simpler and regarded as
good enough
How Things Can Go
Wrong
Not Hashing the Shared
Secret
• The shared secret gab is not a session key
• A symmetric key should look random
• Every bit should be 50% likely to be 0
• But gab is in the range 1, 2, ... p
• High-order bit more likely to be 0
• Use a KDF to convert the secret to a key
Legacy DH in TLS
• Old cipher suites uses Anonymous DH
• TLS_DH_anon_WITH_AES_128_CBC_SHA
• TLS_DH_ANON_AES_128_CBC_SHA1
• TLS_DH_anon_WITH_AES_128_CBC_SHA
• ADH-AES128-SHA
• Link Ch 11i
Unsafe Group Parameters
• OpenSSL allowed unsafe primes p
• Attacker can craft DH parameters that reveal
information about the private key
• Fixed in 2016
CNIT 141: 11. Diffie-Hellman

More Related Content

PDF
CNIT 141: 14. Quantum and Post-Quantum
PDF
CNIT 141 12. Elliptic Curves
PDF
CNIT 141: 12. Elliptic Curves
PDF
CNIT 141 11. Diffie-Hellman
PDF
CNIT 141 12. Elliptic Curves
PDF
CNIT 141 12. Elliptic Curves
PDF
CNIT 141 9. Hard Problems
PDF
CNIT 141: 14. Quantum and Post-Quantum
CNIT 141: 14. Quantum and Post-Quantum
CNIT 141 12. Elliptic Curves
CNIT 141: 12. Elliptic Curves
CNIT 141 11. Diffie-Hellman
CNIT 141 12. Elliptic Curves
CNIT 141 12. Elliptic Curves
CNIT 141 9. Hard Problems
CNIT 141: 14. Quantum and Post-Quantum

What's hot (20)

PDF
CNIT 141: 4. Block Ciphers
PDF
CNIT 141: 1. Encryption
PDF
CNIT 141 6. Hash Functions
PDF
CNIT 141: 1. Encryption
PDF
CNIT 141: 1. Encryption
PDF
CNIT 141: 4. Block Ciphers
PDF
CNIT 141: 10. RSA
PDF
CNIT 141: 13. TLS
PDF
CNIT 141 8. Authenticated Encryption
PDF
CNIT 141: 4. Block Ciphers
PDF
CNIT 141: 6. Hash Functions
PDF
CNIT 141 7. Keyed Hashing
PDF
CNIT 1417. Keyed Hashing
PDF
CNIT 126: 13: Data Encoding
PDF
CNIT 141: 3. Cryptographic Security
PDF
CNIT 141 10. RSA
PDF
CNIT 141 5. Stream Ciphers
PDF
CRYPTOGRAPHY AND NETWORK SECURITY
PPTX
CISSP Certification Security Engineering-Part2
PDF
CNIT 141: 8. Authenticated Encryption
CNIT 141: 4. Block Ciphers
CNIT 141: 1. Encryption
CNIT 141 6. Hash Functions
CNIT 141: 1. Encryption
CNIT 141: 1. Encryption
CNIT 141: 4. Block Ciphers
CNIT 141: 10. RSA
CNIT 141: 13. TLS
CNIT 141 8. Authenticated Encryption
CNIT 141: 4. Block Ciphers
CNIT 141: 6. Hash Functions
CNIT 141 7. Keyed Hashing
CNIT 1417. Keyed Hashing
CNIT 126: 13: Data Encoding
CNIT 141: 3. Cryptographic Security
CNIT 141 10. RSA
CNIT 141 5. Stream Ciphers
CRYPTOGRAPHY AND NETWORK SECURITY
CISSP Certification Security Engineering-Part2
CNIT 141: 8. Authenticated Encryption
Ad

Similar to CNIT 141: 11. Diffie-Hellman (20)

PDF
11. Diffie-Hellman
PPTX
information security(Public key encryption its characteristics and weakness, ...
PDF
CNS - Unit - 4 - Public Key Cryptosystem
PDF
SSL/TLS 101
PPTX
SSL/TLS 101
PPTX
Diffie Hellman.pptx
PPTX
man in the middle
PDF
alorithms yhuixeuy ydheujj uehq hu dguhd ued2.pdf
PPTX
UNIT-IV.pptx
PPTX
20 security
PDF
Digital Security 101
PPT
ch10_Key_Management.ppt ch10_Key_Management.ppt ch10_Key_Management.ppt
PPTX
4_Diffie Hellman algorithm for graduates.pptx
PDF
CISSP Prep: Ch 4. Security Engineering (Part 2)
PPT
cryptography.ppt by karthika kumar hirehegaalla
PPT
cryptography.pptcryptography.pptcryptography.ppt
PDF
Asymmetric Cryptography
PDF
18CS2005 Cryptography and Network Security
PDF
Fundamentals of Cryptography: Securing Data in the Digital Age
PPT
The Diffie-Hellman Algorithm
11. Diffie-Hellman
information security(Public key encryption its characteristics and weakness, ...
CNS - Unit - 4 - Public Key Cryptosystem
SSL/TLS 101
SSL/TLS 101
Diffie Hellman.pptx
man in the middle
alorithms yhuixeuy ydheujj uehq hu dguhd ued2.pdf
UNIT-IV.pptx
20 security
Digital Security 101
ch10_Key_Management.ppt ch10_Key_Management.ppt ch10_Key_Management.ppt
4_Diffie Hellman algorithm for graduates.pptx
CISSP Prep: Ch 4. Security Engineering (Part 2)
cryptography.ppt by karthika kumar hirehegaalla
cryptography.pptcryptography.pptcryptography.ppt
Asymmetric Cryptography
18CS2005 Cryptography and Network Security
Fundamentals of Cryptography: Securing Data in the Digital Age
The Diffie-Hellman Algorithm
Ad

More from Sam Bowne (20)

PDF
Introduction to the Class & CISSP Certification
PDF
Cyberwar
PDF
3: DNS vulnerabilities
PDF
8. Software Development Security
PDF
4 Mapping the Application
PDF
3. Attacking iOS Applications (Part 2)
PDF
12 Elliptic Curves
PDF
2a Analyzing iOS Apps Part 1
PDF
9 Writing Secure Android Applications
PDF
12 Investigating Windows Systems (Part 2 of 3)
PDF
10 RSA
PDF
12 Investigating Windows Systems (Part 1 of 3
PDF
9. Hard Problems
PDF
8 Android Implementation Issues (Part 1)
PDF
11 Analysis Methodology
PDF
8. Authenticated Encryption
PDF
7. Attacking Android Applications (Part 2)
PDF
7. Attacking Android Applications (Part 1)
PDF
5. Stream Ciphers
PDF
6 Scope & 7 Live Data Collection
Introduction to the Class & CISSP Certification
Cyberwar
3: DNS vulnerabilities
8. Software Development Security
4 Mapping the Application
3. Attacking iOS Applications (Part 2)
12 Elliptic Curves
2a Analyzing iOS Apps Part 1
9 Writing Secure Android Applications
12 Investigating Windows Systems (Part 2 of 3)
10 RSA
12 Investigating Windows Systems (Part 1 of 3
9. Hard Problems
8 Android Implementation Issues (Part 1)
11 Analysis Methodology
8. Authenticated Encryption
7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 1)
5. Stream Ciphers
6 Scope & 7 Live Data Collection

Recently uploaded (20)

PPTX
Pharma ospi slides which help in ospi learning
PDF
Insiders guide to clinical Medicine.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Cell Types and Its function , kingdom of life
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
Complications of Minimal Access Surgery at WLH
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
master seminar digital applications in india
PPTX
Lesson notes of climatology university.
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
Institutional Correction lecture only . . .
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
Pharma ospi slides which help in ospi learning
Insiders guide to clinical Medicine.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Cell Types and Its function , kingdom of life
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Complications of Minimal Access Surgery at WLH
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPH.pptx obstetrics and gynecology in nursing
O7-L3 Supply Chain Operations - ICLT Program
GDM (1) (1).pptx small presentation for students
master seminar digital applications in india
Lesson notes of climatology university.
Microbial diseases, their pathogenesis and prophylaxis
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Institutional Correction lecture only . . .
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
human mycosis Human fungal infections are called human mycosis..pptx

CNIT 141: 11. Diffie-Hellman

  • 1. CNIT 141 Cryptography for Computer Networks 11. Diffie-Hellman
  • 2. Topics • The Diffie-Hellman Function • The Diffie-Hellman Problems • Key Agreement Protocols • Diffie-Hellman Protocols • How Things Can Go Wrong
  • 3. 1976 • Whitfield Diffie and Martin Hellman • Published "New Directions in Cryptography" • Revolutionized cryptography • Specified a public-key distribution scheme • The Diffie-Hellman (DH) protocol • The basis for public-key encryption and signatures
  • 4. Key Agreement • After exchanging a shared secret • Parties turn the secret into a symmetric key • Thus establishing a secure channel
  • 6. The Group Zp* • The integers 1, 2, 3, ... p-1 • Where p is prime • In DH, the two parties choose random elements a and b to be their secrets • From the group • Both parties also use a number g • Which is not a secret
  • 7. Alice and Bob • They can both calculate gab by combining public and secret information Keep a secret Transmit ga Keep b secret Transmit gb
  • 8. Diffie-Hellman • Alice calculates A = ga mod p • and sends it to Bob • Bob calculates B = gb mod p • and sends it to Alice • Alice calculates Ba mod p = gba mod p • Bob calculates Ab mod p = gab mod p • They now have the same shared secret
  • 9. Key Derivation Function (KDF) • The shared secret is not used directly as the key • It's passed through a KDF to create a random- looking value of the proper size • A kind of hash function
  • 10. Safe Primes • Not all values of p and g work • For highest security, both p and (p - 1) / 2 should be prime • Those are called safe primes • They don't have small subgroups • That would limit the shared secret to a small number of possible values
  • 11. Safe Primes • With safe primes even a g of 2 works • But safe primes are slow to generate • 1000x as long as generating mere random primes
  • 15. Discrete Logarithm Problem • Public value: ga • Secret value: a • Recovering a from ga is the DLP • Diffie-Hellman's security depends on the DLP's hardness
  • 16. Eavesdropper • Evil attacker knows only ga and gb Keep a secret Transmit ga Keep b secret Transmit gb
  • 17. The Computational Diffie- Hellman Problem (CDH) • Consider an eavesdropper • Compute the shared secret gab • Given only the public values ga and gb • And not the secrets a or b • This might be easier than the DLP • We don't know for sure
  • 18. Number Sieve • DH protocol with 2048 bit prime p provides 90 bits of security • Same as RSA with a 2048-bit n • Fastest known attack on Computational Diffie- Hellman is the number field sieve • Similar to the fastest known attack on RSA: the "general number field sieve"
  • 19. Decisional Diffie-Hellman Problem (DDH) • Stronger than CDH's hardness assumption • If DDH is hard, the attacker can't learn anything about the shared secret from the public information • Not even a few bits of it • Because it appears completely random • Both DDH and CDH are hard if the parameters are well-chosen
  • 21. A Non-DH Key Agreement Protocol • Authenticated Key Agreement (AKA) • Used by 3G and 4G • To establish secure communication between a SIM card and a telecom operator • Uses only symmetric-key operations • Relies on a pre-shared secret K
  • 23. Replay Attack • Attacker captures pair (R, V1) • Sends it to SIM card to open a new session impersonating the telco • To precent this, protocol checks to make sure R isn't reused
  • 24. Compromised K • Attacker who gets K • Can perform MiTM attack and listen to all cleartext communications • Can impersonate either party • Can record communications and later decrypt them using the captured R values
  • 25. Attack Models for Key Agreement Protocols • Eavesdropper • Attacker is a MiTM • Can record, modify, drop or inject messages • To stop: protocol must not leak any information about the shared secret • Data leak • Attacker gets the session key and all temporary secrets • But not long-term secret K
  • 26. Attack Models for Key Agreement Protocols • Breach • Attacker learns long-term key K • Impossible to protect current session from this attack • But a protocol can protect other sessions
  • 27. Security Goals • Authentication • Mutual authentication: each party can authenticate to the other party • Authenticated Key Agreement happens when a protocol authenticates both parties
  • 28. Security Goals • Key control • Neither party can control the final shared secret • The 3G/4G protocol lacks this property • Because the operator chooses R • Which entirely determines the final shared key
  • 29. Security Goals • Forward secrecy • Even if all long-term secrets are exposed • Shared secrets from previous sessions are not available • 3G/4G protocol doesn't provide this
  • 30. Performance • Number of messages exchanged • Message length • Computations required • Possibility of pre-computation • The main cause of latency is usually round- trip time • Computation required also counts
  • 31. Performance of 3G/4G • Exchanges two messages of a few hundred bits each • Pre-computation is possible • Operator can pick many values of R in advance
  • 33. Anonymous Diffie-Hellman • Not authenticated • Vulnerable to MiTM attack (next slide)
  • 35. Authenticated Diffie-Hellman • Uses public-key signatures to sign messages • With a system such as RSA-PSS
  • 36. Security Against Eavesdroppers • Authenticated DH stops eavesdroppers • Attacker can't learn the shared secret gab • Neither party can control the shared secret
  • 37. Replay • Eve can record and replay previous values of A and sigA • To pretend to be Alice • Key confirmation prevents this • Alice and Bob send a message to prove that they both own the shared secret
  • 38. Security Against Data Leaks • If Eve has a, she can impersonate Alice • To prevent this, integrate long-term keys into the shared secret computation
  • 39. Memezes-Qu-Vanstone MQV • Designed in 1998 • NSA included it in Suite B • Designed to protect classified information • More secure than authenticated DH • Better performance
  • 40. MQV • x and y are long-term private keys • X and Y are long-term public keys
  • 41. Data Leak • Attacker who gets the ephemeral secrets a and b • Can't find the shared secret • That would require knowing the long-term private keys
  • 42. Breach • Attacker gets Alice's long-term private key x • Previous sessions are still safe • Because they used Alice's ephemeral private keys • There is an attack that could compromise a targeted old session • It can be mitigated by a key-confirmation step
  • 43. MQV Rarely Used • Was encumbered by patents • Complex and difficult to implement • Authenticated DH is simpler and regarded as good enough
  • 44. How Things Can Go Wrong
  • 45. Not Hashing the Shared Secret • The shared secret gab is not a session key • A symmetric key should look random • Every bit should be 50% likely to be 0 • But gab is in the range 1, 2, ... p • High-order bit more likely to be 0 • Use a KDF to convert the secret to a key
  • 46. Legacy DH in TLS • Old cipher suites uses Anonymous DH • TLS_DH_anon_WITH_AES_128_CBC_SHA • TLS_DH_ANON_AES_128_CBC_SHA1 • TLS_DH_anon_WITH_AES_128_CBC_SHA • ADH-AES128-SHA • Link Ch 11i
  • 47. Unsafe Group Parameters • OpenSSL allowed unsafe primes p • Attacker can craft DH parameters that reveal information about the private key • Fixed in 2016