mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-05-01 01:44:15 +00:00
TLS: Add CurvePreferences (to enable kyber768) (#3991)
Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
This commit is contained in:
parent
1ffb8a92cd
commit
571777483b
4 changed files with 53 additions and 10 deletions
|
@ -344,6 +344,10 @@ func (c *Config) GetTLSConfig(opts ...Option) *tls.Config {
|
|||
config.ServerName = sn
|
||||
}
|
||||
|
||||
if len(c.CurvePreferences) > 0 {
|
||||
config.CurvePreferences = ParseCurveName(c.CurvePreferences)
|
||||
}
|
||||
|
||||
if len(config.NextProtos) == 0 {
|
||||
config.NextProtos = []string{"h2", "http/1.1"}
|
||||
}
|
||||
|
@ -429,3 +433,23 @@ func ConfigFromStreamSettings(settings *internet.MemoryStreamConfig) *Config {
|
|||
}
|
||||
return config
|
||||
}
|
||||
|
||||
func ParseCurveName(curveNames []string) []tls.CurveID {
|
||||
curveMap := map[string]tls.CurveID{
|
||||
"curvep256": tls.CurveP256,
|
||||
"curvep384": tls.CurveP384,
|
||||
"curvep521": tls.CurveP521,
|
||||
"x25519": tls.X25519,
|
||||
"x25519kyber768draft00": 0x6399,
|
||||
}
|
||||
|
||||
var curveIDs []tls.CurveID
|
||||
for _, name := range curveNames {
|
||||
if curveID, ok := curveMap[strings.ToLower(name)]; ok {
|
||||
curveIDs = append(curveIDs, curveID)
|
||||
} else {
|
||||
errors.LogWarning(context.Background(), "unsupported curve name: "+name)
|
||||
}
|
||||
}
|
||||
return curveIDs
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue