From 3e90a9f854bbe1f2f74b216d536da267e30db460 Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Thu, 16 Apr 2026 23:10:41 -0400 Subject: [PATCH] crypto/tls: expose HelloRetryRequest state This commit adds fields to the ClientHelloInfo and ConnectionState structures to represent hello retry request state information. ClientHelloInfo gains a new HelloRetryRequest bool field that indicates if the client hello was sent in response to a TLS 1.3 hello retry request message previously emitted by the server. ConnectionState gains a new HelloRetryRequest bool field that indicates (depending on the connection role) whether the client received a TLS 1.3 hello retry request message from the server, or whether the server sent such a message to a client. Fixes #74425 Change-Id: Ic1a5290b8a4ba1568da1d2c2cf9f148150955fa5 Reviewed-on: https://go-review.googlesource.com/c/go/+/717440 Reviewed-by: Roland Shoemaker LUCI-TryBot-Result: Go LUCI Reviewed-by: Filippo Valsorda Reviewed-by: Cherry Mui Auto-Submit: Daniel McCarney --- common.go | 11 ++++++++--- conn.go | 2 +- handshake_server.go | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/common.go b/common.go index ed0d1ee..9c86eb7 100644 --- a/common.go +++ b/common.go @@ -304,12 +304,13 @@ type ConnectionState struct { // client side. ECHAccepted bool + // HelloRetryRequest indicates whether we sent a HelloRetryRequest if we + // are a server, or if we received a HelloRetryRequest if we are a client. + HelloRetryRequest bool + // ekm is a closure exposed via ExportKeyingMaterial. ekm func(label string, context []byte, length int) ([]byte, error) - // testingOnlyDidHRR is true if a HelloRetryRequest was sent/received. - testingOnlyDidHRR bool - // testingOnlyPeerSignatureAlgorithm is the signature algorithm used by the // peer to sign the handshake. It is not set for resumed connections. testingOnlyPeerSignatureAlgorithm SignatureScheme @@ -469,6 +470,10 @@ type ClientHelloInfo struct { // connection to fail. Conn net.Conn + // HelloRetryRequest indicates whether the ClientHello was sent in response + // to a HelloRetryRequest message. + HelloRetryRequest bool + // config is embedded by the GetCertificate or GetConfigForClient caller, // for use with SupportsCertificate. config *Config diff --git a/conn.go b/conn.go index 73267f9..0b4fedd 100644 --- a/conn.go +++ b/conn.go @@ -1677,7 +1677,7 @@ func (c *Conn) connectionStateLocked() ConnectionState { state.Version = c.vers state.NegotiatedProtocol = c.clientProtocol state.DidResume = c.didResume - state.testingOnlyDidHRR = c.didHRR + state.HelloRetryRequest = c.didHRR state.testingOnlyPeerSignatureAlgorithm = c.peerSigAlg state.CurveID = c.curveID state.NegotiatedProtocolIsMutual = true diff --git a/handshake_server.go b/handshake_server.go index 63ebfc0..f67ba4f 100644 --- a/handshake_server.go +++ b/handshake_server.go @@ -1004,6 +1004,7 @@ func clientHelloInfo(ctx context.Context, c *Conn, clientHello *clientHelloMsg) SupportedVersions: supportedVersions, Extensions: clientHello.extensions, Conn: c.conn, + HelloRetryRequest: c.didHRR, config: c.config, ctx: ctx, }