Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrShortPacket = errors.New("short packet")
ErrShortPacket means that the packet is too short for a valid encrypted packet.
var ErrZeroChunk = errors.New("zero chunk")
Functions ¶
Types ¶
type Cipher ¶
type Cipher interface { KeySize() int SaltSize() int Encrypter(salt []byte) (cipher.AEAD, error) Decrypter(salt []byte) (cipher.AEAD, error) }
func AESCCM ¶ added in v1.18.7
AESCCM creates a new Cipher with a pre-shared key. len(psk) must be one of 16, 24, or 32 to select AES-128/196/256-GCM.
func AESGCM ¶
AESGCM creates a new Cipher with a pre-shared key. len(psk) must be one of 16, 24, or 32 to select AES-128/196/256-GCM.
func Chacha20Poly1305 ¶
Chacha20Poly1305 creates a new Cipher with a pre-shared key. len(psk) must be 32.
func Chacha8Poly1305 ¶ added in v1.18.7
Chacha8Poly1305 creates a new Cipher with a pre-shared key. len(psk) must be 32.
func XChacha20Poly1305 ¶
XChacha20Poly1305 creates a new Cipher with a pre-shared key. len(psk) must be 32.
func XChacha8Poly1305 ¶ added in v1.18.7
XChacha8Poly1305 creates a new Cipher with a pre-shared key. len(psk) must be 32.
type KeySizeError ¶
type KeySizeError int
func (KeySizeError) Error ¶
func (e KeySizeError) Error() string
type PacketConn ¶
type PacketConn struct { N.EnhancePacketConn Cipher }
func NewPacketConn ¶
func NewPacketConn(c N.EnhancePacketConn, ciph Cipher) *PacketConn
NewPacketConn wraps an N.EnhancePacketConn with cipher
func (*PacketConn) WaitReadFrom ¶
func (c *PacketConn) WaitReadFrom() (data []byte, put func(), addr net.Addr, err error)