Documentation ¶
Index ¶
- Constants
- Variables
- func ACKRSTStreamErr(err error) bool
- func DecryptErr(err error) bool
- func EncryptErr(err error) bool
- func FINRSTStreamErr(err error) bool
- func New(stream net.Conn, password, method, protoType string) (net.Conn, error)
- func PayloadSizeErr(err error) bool
- func ReadCipherErr(err error) bool
- func ReadPlaintxtErr(err error) bool
- func TimeoutErr(err error) bool
- func WriteCipherErr(err error) bool
- type AEADCipher
- type AEADCipherImpl
- type CipherStream
Constants ¶
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 ¶
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 ¶
ACKRSTStreamErr return true if err is ErrACKRSTStream
func FINRSTStreamErr ¶
FINRSTStreamErr return true if err is ErrFINRSTStream
func PayloadSizeErr ¶
PayloadSizeErr return true if err is ErrPayloadSize
func ReadCipherErr ¶
ReadCipherErr return true if err is ErrReadCipher
func ReadPlaintxtErr ¶
ReadPlaintxtErr return true if err is ErrReadPlaintxt
func WriteCipherErr ¶
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) Release ¶ added in v1.3.0
func (cs *CipherStream) Release()