Documentation
¶
Index ¶
- Variables
- func Handshake(conn net.Conn, authenticator *auth.Authentication, enableAuth bool) (cipher crypto.SymmetricCipher, authKey tool.AES192Key, err error)
- func ReadReq[T any](conn net.Conn, dataLen int, cipher ...crypto.SymmetricCipher) (T, error)
- func SendHandshakeResp(conn net.Conn, resp HandshakeResp) error
- func SendHeartbeat(conn net.Conn, id string, cipher ...crypto.SymmetricCipher) error
- func SendHeartbeatNoResp(conn net.Conn, cipher ...crypto.SymmetricCipher) error
- func SendRelayStart(conn net.Conn, cipher ...crypto.SymmetricCipher) error
- func SendRespHeadError(conn net.Conn, action Action, msg string, cipher ...crypto.SymmetricCipher) error
- func SendRespHeadOKWithMsg(conn net.Conn, action Action, msg string, cipher ...crypto.SymmetricCipher) error
- func SendRespHeadOk(conn net.Conn, action Action, cipher ...crypto.SymmetricCipher) error
- type Action
- type CommonReq
- type ConnectionReq
- type HandshakeReq
- type HandshakeResp
- type HeartbeatReq
- type RelayReq
- type ReqHead
- type RespHead
- type StatusCode
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrEmptyKDFSalt = errors.New("empty kdf salt")
Functions ¶
func Handshake ¶
func Handshake(conn net.Conn, authenticator *auth.Authentication, enableAuth bool) (cipher crypto.SymmetricCipher, authKey tool.AES192Key, err error)
nil authenticator means no authentication,return nil authKey
func SendHandshakeResp ¶
func SendHandshakeResp(conn net.Conn, resp HandshakeResp) error
func SendHeartbeat ¶
func SendHeartbeatNoResp ¶
func SendHeartbeatNoResp(conn net.Conn, cipher ...crypto.SymmetricCipher) error
func SendRelayStart ¶
func SendRelayStart(conn net.Conn, cipher ...crypto.SymmetricCipher) error
func SendRespHeadError ¶
func SendRespHeadOKWithMsg ¶
func SendRespHeadOk ¶
Types ¶
type ConnectionReq ¶
type ConnectionReq struct {
CommonReq
}
type HandshakeReq ¶
type HandshakeReq struct {
// SecretKeySelector is the selector of the secret key, 4 bytes use hex string(8 bytes in total).
//
// If there is no key verification, this field is not needed
SecretKeySelector string `json:"secretKeySelector"`
// AuthFieldB64 is encrypted with secret key,["AUTH"+RANDOM_STRING(16)]
//
// If there is no key verification, this field is not needed
AuthFieldB64 string `json:"authFieldB64"`
// AuthAAD is the additional authentication data
//
// If there is no key verification, this field is not needed
AuthAAD string `json:"authAAD"`
// KDFSalt is the salt of the KDF
//
// If there is no key verification, this field is not needed
KDFSaltB64 string `json:"kdfSaltB64"`
// EcdhPublicKey is the public key of the ECDH X25519 key exchange
EcdhPublicKeyB64 string `json:"ecdhPublicKeyB64"`
}
func ReadHandshakeReq ¶
func ReadHandshakeReq(conn net.Conn) (HandshakeReq, error)
type HandshakeResp ¶
type HandshakeResp struct {
// RandomSharedKeyB64 string `json:"randomSharedKey"`
Code StatusCode `json:"code"`
Msg string `json:"msg"`
// EcdhPublicKey is the public key of the ECDH X25519 key exchange
EcdhPublicKeyB64 string `json:"ecdhPublicKeyB64"`
// KDFSalt is the salt of the KDF
KDFSaltB64 string `json:"kdfSaltB64"`
}
type HeartbeatReq ¶
type ReqHead ¶
func ReadReqHead ¶
type RespHead ¶
type RespHead struct {
Code StatusCode `json:"code"`
Msg string `json:"msg"`
Action Action `json:"action"`
DataLen int `json:"dataLen"`
}
type StatusCode ¶
type StatusCode int32
const ( StatusError StatusCode = 0 StatusSuccess StatusCode = -1 StatusAuthFailed StatusCode = 1 // StatusKDFSaltMismatch is the status code for the KDF salt mismatch StatusKDFSaltMismatch StatusCode = 2 )
Click to show internal directories.
Click to hide internal directories.