shadowstream

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

ErrShortPacket means the packet is too short to be a valid encrypted packet.

Functions

func NewConn

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

NewConn wraps a stream-oriented net.Conn with stream cipher encryption/decryption.

func NewPacketConn

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

NewPacketConn wraps a net.PacketConn with stream cipher encryption/decryption.

func NewReader

func NewReader(r io.Reader, s cipher.Stream) io.Reader

NewReader wraps an io.Reader with stream cipher decryption.

func NewWriter

func NewWriter(w io.Writer, s cipher.Stream) io.Writer

NewWriter wraps an io.Writer with stream cipher encryption.

func Pack

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

Pack encrypts plaintext using stream cipher s and a random IV. Returns a slice of dst containing random IV and ciphertext. Ensure len(dst) >= s.IVSize() + len(plaintext).

func Unpack

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

Unpack decrypts pkt using stream cipher s. Returns a slice of dst containing decrypted plaintext.

Types

type Cipher

type Cipher interface {
	IVSize() int
	Encrypter(iv []byte) cipher.Stream
	Decrypter(iv []byte) cipher.Stream
}

Cipher generates a pair of stream ciphers for encryption and decryption.

func AESCFB

func AESCFB(key []byte) (Cipher, error)

AESCFB returns an aescfb cipher.

func AESCTR

func AESCTR(key []byte) (Cipher, error)

AESCTR returns an aesctr cipher.

func ChaCha20

func ChaCha20(key []byte) (Cipher, error)

ChaCha20 returns a ChaCha20 cipher.

func Chacha20IETF

func Chacha20IETF(key []byte) (Cipher, error)

Chacha20IETF returns a Chacha20IETF cipher.

func RC4MD5

func RC4MD5(key []byte) (Cipher, error)

RC4MD5 returns a RC4MD5 cipher.

func Xchacha20

func Xchacha20(key []byte) (Cipher, error)

Xchacha20 returns a Xchacha20 cipher.

type KeySizeError

type KeySizeError int

KeySizeError is an error about the key size.

func (KeySizeError) Error

func (e KeySizeError) Error() string

Jump to

Keyboard shortcuts

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