Skip to content

Commit

Permalink
Fixed KeySharesParams reset on subsequent ApplyPreset calls
Browse files Browse the repository at this point in the history
* This fixes an issue where servers that selected a key_share other than
  X25519 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.
  • Loading branch information
adotkhan committed Nov 7, 2024
1 parent 443a34d commit e90e3fc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion u_parrots.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e90e3fc

Please sign in to comment.