cipherstream

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxPayloadSize is the maximum size of payload, set to 16KB.
	MaxPayloadSize = 1<<14 - 1

	// PaddingSize is the http2 payload padding size
	PaddingSize = 256
)

Variables

View Source
var (
	ErrEncrypt      = errors.New("encrypt data error")
	ErrDecrypt      = errors.New("decrypt data error")
	ErrWriteCipher  = errors.New("write cipher data to writer error")
	ErrReadPlaintxt = errors.New("read plaintext data from reader error")
	ErrReadCipher   = errors.New("read cipher data from reader error")
	ErrFINRSTStream = errors.New("receive FIN_RST_STREAM frame")
	ErrACKRSTStream = errors.New("receive ACK_RST_STREAM frame")
	ErrTimeout      = errors.New("net: io timeout error")
	ErrPayloadSize  = errors.New("payload size is invalid")
)

Functions

func ACKRSTStreamErr

func ACKRSTStreamErr(err error) bool

ACKRSTStreamErr return true if err is ErrACKRSTStream

func DecryptErr

func DecryptErr(err error) bool

DecryptErr return true if err is ErrDecrypt

func EncryptErr

func EncryptErr(err error) bool

EncryptErr return true if err is ErrEncrypt

func FINRSTStreamErr

func FINRSTStreamErr(err error) bool

FINRSTStreamErr return true if err is ErrFINRSTStream

func New

func New(stream net.Conn, password, method, protoType string) (net.Conn, error)

func PayloadSizeErr

func PayloadSizeErr(err error) bool

PayloadSizeErr return true if err is ErrPayloadSize

func ReadCipherErr

func ReadCipherErr(err error) bool

ReadCipherErr return true if err is ErrReadCipher

func ReadPlaintxtErr

func ReadPlaintxtErr(err error) bool

ReadPlaintxtErr return true if err is ErrReadPlaintxt

func TimeoutErr

func TimeoutErr(err error) bool

TimeoutErr return true if err is ErrTimeout

func WriteCipherErr

func WriteCipherErr(err error) bool

WriteCipherErr return true if err is ErrWriteCipher

Types

type AEADCipher

type AEADCipher interface {
	Encrypt(plaintext []byte) (ciphertext []byte, err error)
	Decrypt(ciphertext []byte) (plaintext []byte, err error)
	NonceSize() int
	Overhead() int
}

func NewAes256GCM

func NewAes256GCM(password []byte) (AEADCipher, error)

NewAes256GCM creates a aes-gcm AEAD instance

func NewChaCha20Poly1305

func NewChaCha20Poly1305(password []byte) (AEADCipher, error)

NewChaCha20Poly1305 creates a chacha20-poly1305 AEAD instance

type AEADCipherImpl

type AEADCipherImpl struct {
	// contains filtered or unexported fields
}

func (*AEADCipherImpl) Decrypt

func (aci *AEADCipherImpl) Decrypt(ciphertext []byte) (plaintext []byte, err error)

Decrypt decrypts data using 256-bit AEAD. This both hides the content of the data and provides a check that it hasn't been altered. Expects input form nonce|ciphertext|tag where '|' indicates concatenation.

func (*AEADCipherImpl) Encrypt

func (aci *AEADCipherImpl) Encrypt(plaintext []byte) (ciphertext []byte, err error)

Encrypt encrypts data using 256-bit AEAD. This both hides the content of the data and provides a check that it hasn't been altered. Output takes the form nonce|ciphertext|tag where '|' indicates concatenation.

func (*AEADCipherImpl) NonceSize

func (aci *AEADCipherImpl) NonceSize() int

NonceSize return underlying aead nonce size

func (*AEADCipherImpl) Overhead

func (aci *AEADCipherImpl) Overhead() int

Overhead return underlying aead overhead size

type CipherStream

type CipherStream struct {
	net.Conn
	AEADCipher
	// contains filtered or unexported fields
}

func (*CipherStream) Read

func (cs *CipherStream) Read(b []byte) (int, error)

func (*CipherStream) ReadFrom

func (cs *CipherStream) ReadFrom(r io.Reader) (n int64, err error)

func (*CipherStream) Release added in v1.3.0

func (cs *CipherStream) Release()

func (*CipherStream) Write

func (cs *CipherStream) Write(b []byte) (int, error)

Jump to

Keyboard shortcuts

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