Preserve leading zeros in Diffie-Hellman secrets. #462
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Every other use of Diffie-Hellman preserves leading zeros. See PKCS #3 section
8.3, RFC 2631 section 2.1.2, and SP 800-56A section C.1. I assume X9.42 says
something similar to RFC 2631, but I do not have a copy of it. This discrepancy
has caused sporadic interoperability issues in TLS 1.2's DHE construction, so
clearly it's confusing.
Moreover, having variable-length secrets is generally dubious. It exposes an
unnecessary side channel.
Since TLS 1.2's server-fiat DHE and TLS 1.3's negotiated DHE are already very
different animals (1.3 DHE is more like 1.2 ECDHE than anything else), change
it to the more reasonable scheme going forward. This is not compatible with 1.2
and does risk a different set of sporadic interop issues if implementations do
not realize this changed, but we already have those with 1.2 implementations
today.