mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-12-19 16:30:07 +08:00
chore: output vless hash11 in generater
This commit is contained in:
parent
b56068ee1c
commit
e4dfe09744
@ -51,12 +51,13 @@ func Main(args []string) {
|
|||||||
if len(args) > 1 {
|
if len(args) > 1 {
|
||||||
seed = args[1]
|
seed = args[1]
|
||||||
}
|
}
|
||||||
seedBase64, clientBase64, err := encryption.GenMLKEM768(seed)
|
seedBase64, clientBase64, hash11Base64, err := encryption.GenMLKEM768(seed)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
fmt.Println("Seed: " + seedBase64)
|
fmt.Println("Seed: " + seedBase64)
|
||||||
fmt.Println("Client: " + clientBase64)
|
fmt.Println("Client: " + clientBase64)
|
||||||
|
fmt.Println("Hash11: " + hash11Base64)
|
||||||
case "vless-x25519":
|
case "vless-x25519":
|
||||||
var privateKey string
|
var privateKey string
|
||||||
if len(args) > 1 {
|
if len(args) > 1 {
|
||||||
|
|||||||
@ -89,7 +89,7 @@ func TestInboundVless_TLS(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestInboundVless_Encryption(t *testing.T) {
|
func TestInboundVless_Encryption(t *testing.T) {
|
||||||
seedBase64, clientBase64, err := encryption.GenMLKEM768("")
|
seedBase64, clientBase64, _, err := encryption.GenMLKEM768("")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
return
|
return
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/metacubex/utls/mlkem"
|
"github.com/metacubex/utls/mlkem"
|
||||||
|
"golang.org/x/crypto/sha3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const MLKEM768SeedLength = mlkem.SeedSize
|
const MLKEM768SeedLength = mlkem.SeedSize
|
||||||
@ -14,7 +15,7 @@ const MLKEM768ClientLength = mlkem.EncapsulationKeySize768
|
|||||||
const X25519PasswordSize = 32
|
const X25519PasswordSize = 32
|
||||||
const X25519PrivateKeySize = 32
|
const X25519PrivateKeySize = 32
|
||||||
|
|
||||||
func GenMLKEM768(seedStr string) (seedBase64, clientBase64 string, err error) {
|
func GenMLKEM768(seedStr string) (seedBase64, clientBase64, hash11Base64 string, err error) {
|
||||||
var seed [MLKEM768SeedLength]byte
|
var seed [MLKEM768SeedLength]byte
|
||||||
if len(seedStr) > 0 {
|
if len(seedStr) > 0 {
|
||||||
s, _ := base64.RawURLEncoding.DecodeString(seedStr)
|
s, _ := base64.RawURLEncoding.DecodeString(seedStr)
|
||||||
@ -31,9 +32,11 @@ func GenMLKEM768(seedStr string) (seedBase64, clientBase64 string, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
key, _ := mlkem.NewDecapsulationKey768(seed[:])
|
key, _ := mlkem.NewDecapsulationKey768(seed[:])
|
||||||
pub := key.EncapsulationKey()
|
client := key.EncapsulationKey().Bytes()
|
||||||
|
hash32 := sha3.Sum256(client)
|
||||||
seedBase64 = base64.RawURLEncoding.EncodeToString(seed[:])
|
seedBase64 = base64.RawURLEncoding.EncodeToString(seed[:])
|
||||||
clientBase64 = base64.RawURLEncoding.EncodeToString(pub.Bytes())
|
clientBase64 = base64.RawURLEncoding.EncodeToString(client)
|
||||||
|
hash11Base64 = base64.RawURLEncoding.EncodeToString(hash32[:11])
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user