mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-12-01 14:18:36 +00:00
Stop removing X25519MLKEM768 from reality ClientHello
Xray-core v26.9.8 and later REALITY servers reject a ClientHello that has no X25519MLKEM768 key share ahead of X25519 and fall back to the target, so sing-box reality clients failed against them with "reality verification failed". Removing the group and share also made the chrome hello differ from the browser it imitates. Send the fingerprint's key shares unchanged, as Xray-core does. The randomized fingerprint picked the X25519MLKEM768 group and key share with separate coin flips. A group without a share makes post-quantum preferring servers send a HelloRetryRequest, which uTLS cannot answer for X25519MLKEM768 and REALITY cannot relay; a share without the group is rejected by OpenSSL with illegal_parameter. Always offer both.
This commit is contained in:
@@ -30,7 +30,6 @@ import (
|
||||
"github.com/sagernet/sing-box/adapter"
|
||||
C "github.com/sagernet/sing-box/constant"
|
||||
"github.com/sagernet/sing-box/option"
|
||||
"github.com/sagernet/sing/common"
|
||||
"github.com/sagernet/sing/common/debug"
|
||||
E "github.com/sagernet/sing/common/exceptions"
|
||||
"github.com/sagernet/sing/common/logger"
|
||||
@@ -146,22 +145,6 @@ func (e *RealityClientConfig) ClientHandshake(ctx context.Context, conn net.Conn
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, extension := range uConn.Extensions {
|
||||
if ce, ok := extension.(*utls.SupportedCurvesExtension); ok {
|
||||
ce.Curves = common.Filter(ce.Curves, func(curveID utls.CurveID) bool {
|
||||
return curveID != utls.X25519MLKEM768
|
||||
})
|
||||
}
|
||||
if ks, ok := extension.(*utls.KeyShareExtension); ok {
|
||||
ks.KeyShares = common.Filter(ks.KeyShares, func(share utls.KeyShare) bool {
|
||||
return share.Group != utls.X25519MLKEM768
|
||||
})
|
||||
}
|
||||
}
|
||||
err = uConn.BuildHandshakeState()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(uConfig.NextProtos) > 0 {
|
||||
for _, extension := range uConn.Extensions {
|
||||
|
||||
@@ -363,6 +363,8 @@ func init() {
|
||||
weights := utls.DefaultWeights
|
||||
weights.TLSVersMax_Set_VersionTLS13 = 1
|
||||
weights.FirstKeyShare_Set_CurveP256 = 0
|
||||
weights.CurveIDs_Append_X25519 = 1
|
||||
weights.KeyShare_Append_RandomGroups = 1
|
||||
randomizedFingerprint = utls.HelloRandomized
|
||||
randomizedFingerprint.Seed, _ = utls.NewPRNGSeed()
|
||||
randomizedFingerprint.Weights = &weights
|
||||
|
||||
Reference in New Issue
Block a user