Imperfect Forward Secrecy:
How Diffie-Hellman Fails in PracticeDavid Adrian, Karthikeyan Bhargavan, Zakir Durumeric,Pierrick Gaudry, Matthew Green, J. Alex Halderman,
Nadia Heninger, Drew Springall, Emmanuel Thomé,Luke Valenta, Benjamin VanderSloot, Eric Wustrow,
Santiago Zanella-Béguelin, Paul Zimmermann
weakdh.org

Textbook Diffie-Hellman[Diffie Hellman 1976]

Public Parametersp a primeg < p group generator (often 2 or 5)
Key Exchange
g a mod p
g b mod pg ab mod p

g ab mod p

Diffie-Hellman is extremely common on the Internet

Protocol support for “modp” Diffie-Hellman, spring 2015:
HTTPS Alexa Top 1M
HTTPS Trusted cert

68%
24%

SMTP StartTLS
IMAPS
POP3S

41%
75%
75%

SSH

100%

IPsec VPNs

100%

“Perfect Forward Secrecy”“Sites that use perfect forward secrecy can provide better security
to users in cases where the encrypted data is being monitored andrecorded by a third party.”“With Perfect Forward Secrecy, anyone possessing the private key
and a wiretap of Internet activity can decrypt nothing.”“Ideally the DH group would match or exceed the RSA key size
but 1024-bit DHE is arguably better than straight 2048-bit RSA so
you can get away with that if you want to.”“But in practical terms the risk of private key theft, for anon-ephemeral key, dwarfs out any cryptanalytic risk for any RSA
or DH of 1024 bits or more; in that sense, PFS is a must-have and
DHE with a 1024-bit DH key is much safer than RSA-based cipher
suites, regardless of the RSA key size.”Cryptanalysis: number field sieve discrete log algorithm
Goal: Given g x ≡ y mod p, compute x.
polynomialselectionsievingp

linearalgebray, gdescentx

log dbprecomputation

L(1/3, 1.923) = exp(1.923(log p)1/3 (log log p)2/3 )individual log

Cryptanalysis: number field sieve discrete log algorithm
Goal: Given g x ≡ y mod p, compute x.
polynomial
selection

sievingplinearalgebray, gdescentx

log dbprecomputation

L(1/3, 1.923) = exp(1.923(log p)1/3 (log log p)2/3 )individual log

L(1/3, 1.232)

Cryptanalysis: number field sieve discrete log algorithm
Goal: Given g x ≡ y mod p, compute x.
polynomial
selectionlinearalgebrasievingpy, gdescent

xlog db
precomputationindividual log

L(1/3, 1.923) = exp(1.923(log p)1/3 (log log p)2/3 )RSA-512
DH-512L(1/3, 1.232)

Sieving

Linear Algebra

Descent

0.5 core-years
2.5 core-years

0.33 core-years
7.7 core-years

10 core-mins

Precomputation can be done once and reused for many individual logs!

Our Results

Result #1: “Logjam”: Active TLS MITM downgrade attack to512-bit DHE export-grade cipher suites.

Diffie-Hellman TLS Handshake
hello, client random
list of cipher suites [. . . DHE . . . ]Diffie-Hellman TLS Handshake
hello, client random
list of cipher suites [. . . DHE . . . ]hello, server random, [DHE]certificate = public RSA key + CA signaturesp, g , g a , SignRSAkey (p, g , g a )Diffie-Hellman TLS Handshake
hello, client random
list of cipher suites [. . . DHE . . . ]hello, server random, [DHE]certificate = public RSA key + CA signaturesp, g , g a , SignRSAkey (p, g , g a )gb
KDF(g ab ,randoms) →kmc , kms , ke

KDF(g ab ,randoms) →kmc , kms , ke

Diffie-Hellman TLS Handshake
hello, client random
list of cipher suites [. . . DHE . . . ]hello, server random, [DHE]certificate = public RSA key + CA signaturesp, g , g a , SignRSAkey (p, g , g a )gb
KDF(g ab ,client finished: Authkmc (dialog)
randoms) →server finished: Authkms (dialog)
kmc , kms , ke

Encke (request)

KDF(g ab ,randoms) →kmc , kms , keExport cipher suites in TLS
TLS_RSA_EXPORT_WITH_RC4_40_MD5
TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5
TLS_RSA_EXPORT_WITH_DES40_CBC_SHAFREAK attack [BDFKPSZZ 2015]: Implementation flaw; use fast
512-bit factorization to downgrade modern browsers to broken
export-grade RSA.
TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA
TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA
TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA
TLS_DH_Anon_EXPORT_WITH_RC4_40_MD5
TLS_DH_Anon_EXPORT_WITH_DES40_CBC_SHA
April 2015: 8.4% of Alexa top 1M HTTPS support DHE EXPORT.

Logjam: Active downgrade attack to export Diffie-Hellman
Protocol flaw: Server does not sign chosen cipher suite.

hello, client random[. . . DHE . . . ]hello, server random, [DHE]certificate = public RSA key + CA signaturesp, g , g a , SignRSAkey (p, g , g a )gb
KDF(g ab ,client finished: Authkmc (dialog)
randoms) →server finished: Authkms (dialog)
kmc , kms , ke

Encke (request)

KDF(g ab ,randoms) →kmc , kms , keLogjam: Active downgrade attack to export Diffie-Hellman
Protocol flaw: Server does not sign chosen cipher suite.

hello, client random[. . . DHE . . . ] [DHE EXPORT]
hello, server random, [DHE]certificate = public RSA key + CA signaturesp, g , g a , SignRSAkey (p, g , g a )gb
KDF(g ab ,client finished: Authkmc (dialog)randoms) →server finished: Authkms (dialog)
kmc , kms , ke

Encke (request)

KDF(g ab ,randoms) →kmc , kms , ke

Logjam: Active downgrade attack to export Diffie-Hellman
Protocol flaw: Server does not sign chosen cipher suite.

hello, client random[. . . DHE . . . ] [DHE EXPORT]
hello, server random, [DHE EXPORT]
certificate = public RSA key + CA signatures
p512 , g , g a , SignRSAkey (p512 , g , g a )gb
KDF(g ab ,client finished: Authkmc (dialog)randoms) →server finished: Authkms (dialog)
kmc , kms , ke

Encke (request)

KDF(g ab ,randoms) →kmc , kms , ke

Logjam: Active downgrade attack to export Diffie-Hellman
Protocol flaw: Server does not sign chosen cipher suite.

hello, client random[. . . DHE . . . ] [DHE EXPORT]
hello, server random, [DHE EXPORT][DHE]certificate = public RSA key + CA signatures
p512 , g , g a , SignRSAkey (p512 , g , g a )gb
KDF(g ab ,client finished: Authkmc (dialog)
randoms) →server finished: Authkms (dialog)
kmc , kms , ke

Encke (request)

KDF(g ab ,randoms) →kmc , kms , ke

Logjam: Active downgrade attack to export Diffie-Hellman
Protocol flaw: Server does not sign chosen cipher suite.

hello, client random[. . . DHE . . . ] [DHE EXPORT]
hello, server random, [DHE EXPORT][DHE]certificate = public RSA key + CA signatures
p512 , g , g a , SignRSAkey (p512 , g , g a )gb
KDF(g ab ,client finished: Authkmc (modified dialog)randoms) →server finished: Authkms (modified dialog)
kmc , kms , ke

Encke (request)

KDF(g ab ,randoms) →kmc , kms , ke

Most hosts use the same parameters

Parameters hard-coded in implementations or built into standards.
97% of DHE EXPORT hosts choose one of three 512-bit primes.
Hosts

SourceYearBits

80%
13%4%Apache 2.2
mod ssl 2.3.0
JDK

2005
1999
2003

512
512
512

Top ten primes accounted for 99% of hosts.

Computing 512-bit discrete logs
I Carried out precomputation for Apache, mod ssl primes.

polyselDH-512

sieving

linalgdescent

2000-3000 cores

288 cores

36 cores3 hours

120 hours

70 seconds

15 hours

I After 1 week precomputation, median individual log time 70s.
I Many ways attacker can work around delay.
I Logjam and our precomputations can be used to breakconnections to 8% of the HTTPS top 1M sites!

Logjam mitigation

I Major browsers have raised minimum DH lengths:

IE, Chrome, Firefox to 1024 bits; Safari to 768.

I TLS 1.3 draft includes anti-downgrade flag in client random.

Our Results

Result #1: “Logjam”: Active TLS MITM downgrade attack to512-bit DHE “export”-grade cipher suites.

Result #2: 1024-bit discrete log within range for governments.
Parameter reuse allows wide-scale passive decryption.

Cost estimates for 768- and 1024-bit DHE and RSA
Sievingcore-years

Linear Algebracore-years

Descent
core-time

RSA-512
DH-5120.5
2.50.33
7.7

10 mins

RSA-768
DH-768

800
8,000

100
28,500

2 days

RSA-1024
DH-1024

1,000,000
10,000,000

120,000
35,000,000

30 days

I Special-purpose hardware →≈ 80× speedup
I ≈$100Ms machine precomputes for one 1024-bit p every year
I Then, individual logs can be computed in close to real timeJames Bamford, 2012, WiredAccording to another top official also involved with the program,the NSA made an enormous breakthrough several years ago in its
ability to cryptanalyze, or break, unfathomably complex encryption
systems employed by not only governments around the world but
also many average computer users in the US. The upshot,according to this official: “Everybody’s a target; everybody with
communication is a target.”[...]
The breakthrough was enormous, says the former official, and soonafterward the agency pulled the shade down tight on the project,even within the intelligence community and Congress. “Only thechairman and vice chairman and the two staff directors of each
intelligence committee were told about it,” he says. The reason?
“They were thinking that this computing breakthrough was goingto give them the ability to crack current public encryption.”

Parameter reuse for 1024-bit Diffie-Hellman

I Precomputation for a single 1024-bit prime allows passive

decryption of connections to 66% of VPN servers and 26% ofSSH servers.
(Oakley Group 2)
I Precomputation for a second common 1024-bit prime allows

passive decryption for 18% of top 1M HTTPS domains.
(Apache 2.2)

2013 NSA “Black Budget”“Also, we are investing in groundbreaking cryptanalytic capabilities
to defeat adversarial cryptography and exploit internet traffic.”*numbers in thousands

IKE Key Exchange for VPNs/IPsec

IKE chooses Diffie-Hellman parameters from standardized set.
list of cipher suites and parameters
chooses cipher suite, g agb

PSK

KDF (g ab , PSK)KDF (g ab , PSK)PSKI A 1024-bit DH break is a parsimonious explanation for NSA’slarge-scale passive decryption of VPN traffic.
NSA’s on-demand IKE
decryption requires:

Discrete log decryption wouldrequire:

I Known pre-shared key.

I Known pre-shared key.

I Both sides of IKE

I Both sides of IKEhandshake.
I Both IKE handshake andESP traffic.
I IKE+ESP data is sent to

HPC resources.

handshake.
I Both IKE handshake andESP traffic.
I IKE data sent to HPC

resources.

A well-designed “implant” would have fewer requirements.

Results and Mitigations
Result #1: “Logjam”: Active TLS MITM downgrade attack to
512-bit DHE “export”-grade cipher suites.
Mitigations:
I Major browsers raised minimum DH lengths.
I TLS 1.3 draft anti-downgrade mechanism.
Result #2: 1024-bit discrete log within range for governments.
Parameter reuse allows wide-scale passive decryption.
Mitigations:
I Move to elliptic curve cryptography
I If ECC isn’t an option, use ≥ 2048-bit primes.
I If 2048-bit primes aren’t an option, generate afresh 1024-bit prime.

Imperfect Forward Secrecy:
How Diffie-Hellman Fails in PracticeDavid Adrian, Karthikeyan Bhargavan, Zakir Durumeric,Pierrick Gaudry, Matthew Green, J. Alex Halderman,Nadia Heninger, Drew Springall, Emmanuel Thomé,Luke Valenta, Benjamin VanderSloot, Eric Wustrow,
Santiago Zanella-Béguelin, Paul Zimmermann
weakdh.org