From 68a9945268306efb7ee954f8cef9d0929902d168 Mon Sep 17 00:00:00 2001 From: Vladislav Yarmak Date: Sat, 30 Sep 2023 23:59:50 +0300 Subject: [PATCH] Flight3: respect curves configuration Reuse logic from Flight1 to ensure correct behaviour. Signed-off-by: Vladislav Yarmak --- flight3handler.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/flight3handler.go b/flight3handler.go index 08549fb76..7ba8184e6 100644 --- a/flight3handler.go +++ b/flight3handler.go @@ -249,10 +249,19 @@ func flight3Generate(_ flightConn, state *State, _ *handshakeCache, cfg *handsha RenegotiatedConnection: 0, }, } - if state.namedCurve != 0 { + + var setEllipticCurveCryptographyClientHelloExtensions bool + for _, c := range cfg.localCipherSuites { + if c.ECC() { + setEllipticCurveCryptographyClientHelloExtensions = true + break + } + } + + if setEllipticCurveCryptographyClientHelloExtensions { extensions = append(extensions, []extension.Extension{ &extension.SupportedEllipticCurves{ - EllipticCurves: []elliptic.Curve{elliptic.X25519, elliptic.P256, elliptic.P384}, + EllipticCurves: cfg.ellipticCurves, }, &extension.SupportedPointFormats{ PointFormats: []elliptic.CurvePointFormat{elliptic.CurvePointFormatUncompressed},