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 b18909f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion u_parrots.go
Original file line number Diff line number Diff line change
Expand Up @@ -2636,7 +2636,12 @@ 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()

// [Psiphon]
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 b18909f

Please sign in to comment.