mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-12-06 16:44:17 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
627e24fb0f | ||
|
|
29cadda803 | ||
|
|
4718b0eabd |
@@ -8,6 +8,7 @@ import (
|
||||
"net"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
utls "github.com/refraction-networking/utls"
|
||||
@@ -159,7 +160,7 @@ func printTLSConnDetail(tabWriter *tabwriter.Writer, tlsConn *utls.UConn) {
|
||||
fmt.Fprintf(tabWriter, "TLS Version:\t%s\n", tlsVersion)
|
||||
curveID := utils.AccessField[utls.CurveID](tlsConn.Conn, "curveID")
|
||||
if curveID != nil {
|
||||
PostQuantum := (*curveID == utls.X25519MLKEM768)
|
||||
PostQuantum := strings.Contains(strings.ToUpper(curveID.String()), "KEM")
|
||||
fmt.Fprintf(tabWriter, "TLS Post-Quantum key exchange:\t%t (%s)\n", PostQuantum, curveID.String())
|
||||
} else {
|
||||
fmt.Fprintf(tabWriter, "TLS Post-Quantum key exchange: false (RSA Exchange)\n")
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"crypto/rand"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"math"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
@@ -18,6 +19,7 @@ import (
|
||||
"github.com/xtls/xray-core/common/ocsp"
|
||||
"github.com/xtls/xray-core/common/platform/filesystem"
|
||||
"github.com/xtls/xray-core/common/protocol/tls/cert"
|
||||
"github.com/xtls/xray-core/common/task"
|
||||
"github.com/xtls/xray-core/transport/internet"
|
||||
"golang.org/x/crypto/x509roots/fallback/bundle"
|
||||
)
|
||||
@@ -525,20 +527,26 @@ 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,
|
||||
"x25519mlkem768": tls.X25519MLKEM768,
|
||||
"secp256r1mlkem768": tls.SecP256r1MLKEM768,
|
||||
"secp384r1mlkem1024": tls.SecP384r1MLKEM1024,
|
||||
}
|
||||
var CurveMap = sync.OnceValue(func() map[string]tls.CurveID {
|
||||
CurveIDs := make(map[string]tls.CurveID)
|
||||
var mu sync.Mutex
|
||||
task.ParallelForN(math.MaxUint16+1, func(i int) error {
|
||||
curveID := tls.CurveID(i)
|
||||
if str := curveID.String(); !strings.HasPrefix(str, "CurveID(") {
|
||||
lower := strings.ToLower(str)
|
||||
mu.Lock()
|
||||
CurveIDs[lower] = curveID
|
||||
mu.Unlock()
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return CurveIDs
|
||||
})
|
||||
|
||||
func ParseCurveName(curveNames []string) []tls.CurveID {
|
||||
var curveIDs []tls.CurveID
|
||||
for _, name := range curveNames {
|
||||
if curveID, ok := curveMap[strings.ToLower(name)]; ok {
|
||||
if curveID, ok := CurveMap()[strings.ToLower(name)]; ok {
|
||||
curveIDs = append(curveIDs, curveID)
|
||||
} else {
|
||||
errors.LogWarning(context.Background(), "unsupported curve name: "+name)
|
||||
|
||||
Reference in New Issue
Block a user