Documentation
¶
Overview ¶
Package encryption copy and modify from xray-core https://github.com/XTLS/Xray-core/commit/f61c14e9c63dc41a8a09135db3aea337974f3f37 https://github.com/XTLS/Xray-core/commit/3e19bf9233bdd9bafc073a71c65b737cc1ffba5e https://github.com/XTLS/Xray-core/commit/7ffb555fc8ec51bd1e3e60f26f1d6957984dba80 https://github.com/XTLS/Xray-core/commit/ec1cc35188c1a5f38a2ff75e88b5d043ffdc59da https://github.com/XTLS/Xray-core/commit/5c611420487a92f931faefc01d4bf03869f477f6 https://github.com/XTLS/Xray-core/commit/23d7aad461d232bc5bed52dd6aaa731ecd88ad35 https://github.com/XTLS/Xray-core/commit/3c20bddfcfd8999be5f9a2ac180dc959950e4c61 https://github.com/XTLS/Xray-core/commit/1720be168fa069332c418503d30341fc6e01df7f https://github.com/XTLS/Xray-core/commit/0fd7691d6b28e05922d7a5a9313d97745a51ea63 https://github.com/XTLS/Xray-core/commit/09cc92c61d9067e0d65c1cae9124664ecfc78f43 https://github.com/XTLS/Xray-core/commit/2807ee432a1fbeb301815647189eacd650b12a8b https://github.com/XTLS/Xray-core/commit/bfe4820f2f086daf639b1957eb23dc13c843cad1 https://github.com/XTLS/Xray-core/commit/d1fb48521271251a8c74bd64fcc2fc8700717a3b https://github.com/XTLS/Xray-core/commit/49580705f6029648399304b816a2737f991582a8 https://github.com/XTLS/Xray-core/commit/84835bec7d0d8555d0dd30953ed26a272de814c4 https://github.com/XTLS/Xray-core/commit/373558ed7abdbac3de41745cf30ec04c9adde604 https://github.com/XTLS/Xray-core/commit/38cc306c955c362f044e074049a5e67b6b9fb389 https://github.com/XTLS/Xray-core/commit/b33555cc0a52d0af3c23d2af8fca42f8a685d9af https://github.com/XTLS/Xray-core/commit/ad7140641c44239c9dcdc3d7215ea639b1f0841c https://github.com/XTLS/Xray-core/commit/0199dea39988a1a1b846d0bf8598631bade40902 https://github.com/XTLS/Xray-core/commit/fce1195b60f48ca18a953dbd5c7d991869de9a5e https://github.com/XTLS/Xray-core/commit/b0b220985c9c1bc832665458d5fd6e0c287b67ae https://github.com/XTLS/Xray-core/commit/82ea7a3cc5ff23280b87e3052f0f83b04f0267fa https://github.com/XTLS/Xray-core/commit/e8b02cd6649f14889841e8ab8ee6b2acca71dbe6 https://github.com/XTLS/Xray-core/commit/6768a22f676c9121cfc9dc4f51181a8a07837c8d https://github.com/XTLS/Xray-core/commit/4c6fd94d97159f5a3e740ba6dd2d9b65e3ed320c https://github.com/XTLS/Xray-core/commit/19f890729656bc923ae3dee8426168c93b8ee9c2 https://github.com/XTLS/Xray-core/commit/cbade89ab11af26ba1e480a3688a6c205fa3c3f8
Index ¶
- Constants
- Variables
- func CreatPadding(paddingLens, paddingGaps [][3]int) (length int, lens []int, gaps []time.Duration)
- func DecodeHeader(h []byte) (l int, err error)
- func DecodeLength(b []byte) int
- func EncodeHeader(h []byte, l int)
- func EncodeLength(l int) []byte
- func GenMLKEM768(seedStr string) (seedBase64, clientBase64, hash32Base64 string, err error)
- func GenX25519(privateKeyStr string) (privateKeyBase64, passwordBase64, hash32Base64 string, err error)
- func IncreaseNonce(nonce []byte) []byte
- func NewCTR(key, iv []byte) cipher.Stream
- func ParsePadding(padding string, paddingLens, paddingGaps *[][3]int) (err error)
- type AEAD
- type ClientInstance
- type CommonConn
- type ServerInstance
- type ServerSession
- type XorConn
Constants ¶
const MLKEM768ClientLength = mlkem.EncapsulationKeySize768
const MLKEM768SeedLength = mlkem.SeedSize
const X25519PasswordSize = 32
const X25519PrivateKeySize = 32
Variables ¶
var ErrInvalidHeader = errors.New("invalid header")
var (
HasAESGCMHardwareSupport = hasGCMAsmAMD64 || hasGCMAsmARM64 || hasGCMAsmS390X || hasGCMAsmPPC64
)
var MaxNonce = bytes.Repeat([]byte{255}, 12)
Functions ¶
func CreatPadding ¶
func DecodeHeader ¶
func DecodeLength ¶
func EncodeHeader ¶
func EncodeLength ¶
func GenMLKEM768 ¶
func IncreaseNonce ¶
func ParsePadding ¶
Types ¶
type ClientInstance ¶
type ClientInstance struct {
NfsPKeys []any
NfsPKeysBytes [][]byte
Hash32s [][32]byte
RelaysLength int
XorMode uint32
Seconds uint32
PaddingLens [][3]int
PaddingGaps [][3]int
RWLock sync.RWMutex
Expire time.Time
PfsKey []byte
Ticket []byte
}
func NewClient ¶
func NewClient(encryption string) (*ClientInstance, error)
NewClient new client from encryption string maybe return a nil *ClientInstance without any error, that means don't need to encrypt
func (*ClientInstance) Handshake ¶
func (i *ClientInstance) Handshake(conn net.Conn) (*CommonConn, error)
type CommonConn ¶
type CommonConn struct {
net.Conn
UseAES bool
Client *ClientInstance
UnitedKey []byte
PreWrite []byte
AEAD *AEAD
PeerAEAD *AEAD
PeerPadding []byte
// contains filtered or unexported fields
}
func NewCommonConn ¶
func NewCommonConn(conn net.Conn, useAES bool) *CommonConn
type ServerInstance ¶
type ServerInstance struct {
NfsSKeys []any
NfsPKeysBytes [][]byte
Hash32s [][32]byte
RelaysLength int
XorMode uint32
SecondsFrom int64
SecondsTo int64
PaddingLens [][3]int
PaddingGaps [][3]int
RWLock sync.RWMutex
Closed bool
Lasts map[int64][16]byte
Tickets [][16]byte
Sessions map[[16]byte]*ServerSession
}
func NewServer ¶
func NewServer(decryption string) (*ServerInstance, error)
NewServer new server from decryption string maybe return a nil *ServerInstance without any error, that means don't need to decrypt
func (*ServerInstance) Close ¶
func (i *ServerInstance) Close() (err error)
func (*ServerInstance) Handshake ¶
func (i *ServerInstance) Handshake(conn net.Conn, fallback *[]byte) (*CommonConn, error)