shadowstream

package
v0.0.0-...-ccb1d63 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package shadowstream implements the original Shadowsocks protocol protected by stream cipher.

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)

func AESCTR

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

func Chacha20

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

func Chacha20IETF

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

func RC4MD5

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

func Xchacha20

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

type KeySizeError

type KeySizeError int

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