Repository navigation
crypto: assert the negotiated curve in PQ handshake tests, cover PostQuantumStrict - #1811
Open
reservoir-cmyk wants to merge 1 commit into
Open
reservoir-cmyk wants to merge 1 commit into
reservoir-cmyk wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Companion to #1810.
TestSupportedCurvesNegotiationasserts only theSupportedCurveslist the client advertises in its ClientHello; it never asserts which curve the handshake negotiated, and it skipsPostQuantumStrictbecause httptest servers were assumed not to terminate X25519MLKEM768. That assumption predates the standard library's ML-KEM support:crypto/tlsimplements X25519MLKEM768 on both sides since Go 1.24, httptest's TLS stack iscrypto/tls, and this module pins Go 1.27.4.This PR adds
crypto/curves_negotiation_test.gowith three tests that pin the negotiated result via the client-sideConnectionState.CurveID:TestNegotiatedCurveIsMLKEM768— Prefer and Strict both negotiate X25519MLKEM768 against a stock httptest server,TestStrictHasNoClassicalFallback— a Strict client refuses a classical-only server,TestPreferFallsBackToClassical— a Prefer client still negotiates CurveP256 with that server.All three pass locally against the current tree with a stock go1.27.4 toolchain (
go vet ./crypto/clean). The new file is standalone so the existing test file is untouched; happy to fold these intocurves_test.goinstead if that fits the codebase better.One environment note, also raised in #1810: under the same stock toolchain, the existing test's Linux-branch assertion that
P256Kyber768Draft00is advertised does not hold, because the standard library does not implement 0xfe32. That failure reproduces on a pristine checkout (it is not caused by this PR) and may pass under Cloudflare's internal toolchain.— Tomoki Murota, CISSP