Documentation ¶
Index ¶
- Variables
- func NewConn(c net.Conn, ciph Cipher) net.Conn
- func NewPacketConn(c net.PacketConn, ciph Cipher) net.PacketConn
- func NewReader(r io.Reader, aead cipher.AEAD) io.Reader
- func NewWriter(w io.Writer, aead cipher.AEAD) io.Writer
- func Pack(dst, plaintext []byte, ciph Cipher) ([]byte, error)
- func Unpack(dst, pkt []byte, ciph Cipher) ([]byte, error)
- type Cipher
- type KeySizeError
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrShortPacket = errors.New("short packet")
ErrShortPacket means that the packet is too short for a valid encrypted packet.
Functions ¶
func NewPacketConn ¶
func NewPacketConn(c net.PacketConn, ciph Cipher) net.PacketConn
NewPacketConn wraps a net.PacketConn with cipher
Types ¶
type Cipher ¶
type Cipher interface { KeySize() int SaltSize() int Encrypter(salt []byte) (cipher.AEAD, error) Decrypter(salt []byte) (cipher.AEAD, error) }
Cipher generates a pair of stream ciphers for encryption and decryption.
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 XChacha20Poly1305 ¶
XChacha20Poly1305 creates a new Cipher with a pre-shared key. len(psk) must be 32.
type KeySizeError ¶
type KeySizeError int
KeySizeError is an error about the key size.
func (KeySizeError) Error ¶
func (e KeySizeError) Error() string
Click to show internal directories.
Click to hide internal directories.