Attacks on composite-order subgroups Failure to
generate Diffie-Hellman primes according to best practices
can result in devastating attacks. Not every TLS server
uses “safe” primes. Out of approximately 70,000 distinct
primes seen across both export and non-export TLS scans,
4,800 were not safe, meaning that (p − 1)/2 was composite.
(Incidentally, we also found 9 composite p.) These groups
are not necessarily vulnerable, as long as g generates a group
with at least one sufficiently large subgroup order to rule out
the Pohlig-Hellman algorithm as an attack.
In some real-life configurations, however, choosing such
primes can lead to an attack. For efficiency reasons, some
implementations use ephemeral keys g
x with a short exponent
x; commonly suggested sizes for x are as small as 160 or 224
bits, intended to match the estimated strength of a 1024- or
2048-bit group. For safe p, such exponent lengths are not
known to decrease security, as the most efficient attack will
be the Pollard lambda algorithm. But if the order of the
subgroup generated by g has small factors, they can be used
to recover information about exponents. From a subset of
factors {q
e1
1
. . . q
ek
k
} with Q
i
q
ei
i = z, Pohlig-Hellman can
recover x mod z in time P
i
ei
√qi. If x ≤ z, this suffices to
recover x. If not, Pollard lambda can use this information
to recover x in time p
x/z. This attack was first described
as hypothetical by van Oorschot and Wiener [51].