From 3d404919cd69acd36985b35d7268d52dcefc44fb Mon Sep 17 00:00:00 2001 From: Amir Khan Date: Thu, 7 Nov 2024 11:40:31 -0500 Subject: [PATCH] Fixed KeySharesParams reset on subsequent ApplyPreset calls * This fixes an issue where servers that selected a key_share other than CurveP256 would cause TLS handshake to fail. This is because the precomputed key_shares are thrown away and not replaced if ApplyPreset is called more than once. --- u_parrots.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/u_parrots.go b/u_parrots.go index 86b8a19e..e55cd807 100644 --- a/u_parrots.go +++ b/u_parrots.go @@ -2636,7 +2636,9 @@ func (uconn *UConn) ApplyPreset(p *ClientHelloSpec) error { } else if kemKey, ok := clientKeySharePrivate.(*kemPrivateKey); ok { uconn.HandshakeState.State13.KEMKey = kemKey.ToPublic() } - uconn.HandshakeState.State13.KeySharesParams = NewKeySharesParameters() + if uconn.HandshakeState.State13.KeySharesParams == nil { + uconn.HandshakeState.State13.KeySharesParams = NewKeySharesParameters() + } hello := uconn.HandshakeState.Hello switch len(hello.Random) {