shadowaead

package
v0.0.0-...-40f201c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrShortPacket = errors.New("short packet")

Functions

func HKDFSHA1

func HKDFSHA1(secret, salt, info, outkey []byte)

func NewConn

func NewConn(c net.Conn, cipher Cipher) net.Conn

func NewPacketConn

func NewPacketConn(c net.PacketConn, ciph Cipher) net.PacketConn

func NewReader

func NewReader(r io.Reader, aead cipher.AEAD) io.Reader

func NewWriter

func NewWriter(w io.Writer, aead cipher.AEAD) io.Writer

func Pack

func Pack(dst, plaintext []byte, ciph Cipher) ([]byte, error)

func Unpack

func Unpack(dst, pkt []byte, ciph Cipher) ([]byte, error)

Types

type Cipher

type Cipher interface {
	KeySize() int
	SaltSize() int
	Encrypter(salt []byte) (cipher.AEAD, error)
	Decrypter(salt []byte) (cipher.AEAD, error)
}

func AESGCM

func AESGCM(psk []byte) (Cipher, error)

func Chacha20Poly1305

func Chacha20Poly1305(psk []byte) (Cipher, error)

func XChacha20Poly1305

func XChacha20Poly1305(psk []byte) (Cipher, error)

type KeySizeError

type KeySizeError int

func (KeySizeError) Error

func (e KeySizeError) Error() string

type PacketConn

type PacketConn struct {
	net.PacketConn
	Cipher
	sync.Mutex
	// contains filtered or unexported fields
}

func (*PacketConn) ReadFrom

func (c *PacketConn) ReadFrom(b []byte) (int, net.Addr, error)

func (*PacketConn) WriteTo

func (c *PacketConn) WriteTo(b []byte, addr net.Addr) (int, error)

type Reader

type Reader struct {
	io.Reader
	cipher.AEAD
	// contains filtered or unexported fields
}

func (*Reader) Read

func (r *Reader) Read(b []byte) (int, error)

func (*Reader) WriteTo

func (r *Reader) WriteTo(w io.Writer) (n int64, err error)

type StreamConn

type StreamConn struct {
	net.Conn
	Cipher
	// contains filtered or unexported fields
}

func (*StreamConn) Read

func (c *StreamConn) Read(b []byte) (int, error)

func (*StreamConn) ReadFrom

func (c *StreamConn) ReadFrom(r io.Reader) (int64, error)

func (*StreamConn) Write

func (c *StreamConn) Write(b []byte) (int, error)

func (*StreamConn) WriteTo

func (c *StreamConn) WriteTo(w io.Writer) (int64, error)

type Writer

type Writer struct {
	io.Writer
	cipher.AEAD
	// contains filtered or unexported fields
}

func (*Writer) ReadFrom

func (w *Writer) ReadFrom(r io.Reader) (n int64, err error)

func (*Writer) Write

func (w *Writer) Write(b []byte) (int, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL