mirror of
https://github.com/XTLS/REALITY.git
synced 2025-08-23 06:58:39 +00:00
REALITY protocol: Add ChaCha20-Poly1305 auth mode (#4)
Co-authored-by: RPRX <63339210+RPRX@users.noreply.github.com>
This commit is contained in:
parent
176a94313e
commit
e07c3b04b9
14
tls.go
14
tls.go
@ -36,6 +36,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pires/go-proxyproto"
|
"github.com/pires/go-proxyproto"
|
||||||
|
"golang.org/x/crypto/chacha20poly1305"
|
||||||
"golang.org/x/crypto/curve25519"
|
"golang.org/x/crypto/curve25519"
|
||||||
"golang.org/x/crypto/hkdf"
|
"golang.org/x/crypto/hkdf"
|
||||||
)
|
)
|
||||||
@ -189,11 +190,16 @@ func Server(ctx context.Context, conn net.Conn, config *Config) (*Conn, error) {
|
|||||||
if _, err = hkdf.New(sha256.New, hs.c.AuthKey, hs.clientHello.random[:20], []byte("REALITY")).Read(hs.c.AuthKey); err != nil {
|
if _, err = hkdf.New(sha256.New, hs.c.AuthKey, hs.clientHello.random[:20], []byte("REALITY")).Read(hs.c.AuthKey); err != nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if config.Show {
|
var aead cipher.AEAD
|
||||||
fmt.Printf("REALITY remoteAddr: %v\ths.c.AuthKey[:16]: %v\n", remoteAddr, hs.c.AuthKey[:16])
|
if aesgcmPreferred(hs.clientHello.cipherSuites) {
|
||||||
}
|
|
||||||
block, _ := aes.NewCipher(hs.c.AuthKey)
|
block, _ := aes.NewCipher(hs.c.AuthKey)
|
||||||
aead, _ := cipher.NewGCM(block)
|
aead, _ = cipher.NewGCM(block)
|
||||||
|
} else {
|
||||||
|
aead, _ = chacha20poly1305.New(hs.c.AuthKey)
|
||||||
|
}
|
||||||
|
if config.Show {
|
||||||
|
fmt.Printf("REALITY remoteAddr: %v\ths.c.AuthKey[:16]: %v\tAEAD: %T\n", remoteAddr, hs.c.AuthKey[:16], aead)
|
||||||
|
}
|
||||||
ciphertext := make([]byte, 32)
|
ciphertext := make([]byte, 32)
|
||||||
plainText := make([]byte, 32)
|
plainText := make([]byte, 32)
|
||||||
copy(ciphertext, hs.clientHello.sessionId)
|
copy(ciphertext, hs.clientHello.sessionId)
|
||||||
|
Loading…
Reference in New Issue
Block a user