crypto

package
v2.43.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2017 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package crypto provides common crypto libraries for V2Ray.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAesDecryptionStream

func NewAesDecryptionStream(key []byte, iv []byte) cipher.Stream

NewAesDecryptionStream creates a new AES encryption stream based on given key and IV. Caller must ensure the length of key and IV is either 16, 24 or 32 bytes.

func NewAesEncryptionStream

func NewAesEncryptionStream(key []byte, iv []byte) cipher.Stream

NewAesEncryptionStream creates a new AES description stream based on given key and IV. Caller must ensure the length of key and IV is either 16, 24 or 32 bytes.

func NewChaCha20Stream added in v1.1.0

func NewChaCha20Stream(key []byte, iv []byte) cipher.Stream

NewChaCha20Stream creates a new Chacha20 encryption/descryption stream based on give key and IV. Caller must ensure the length of key is 32 bytes, and length of IV is either 8 or 12 bytes.

Types

type AEADAuthenticator added in v1.1.0

type AEADAuthenticator struct {
	cipher.AEAD
	NonceGenerator          BytesGenerator
	AdditionalDataGenerator BytesGenerator
}

func (*AEADAuthenticator) Open added in v1.1.0

func (v *AEADAuthenticator) Open(dst, cipherText []byte) ([]byte, error)

func (*AEADAuthenticator) Seal added in v1.1.0

func (v *AEADAuthenticator) Seal(dst, plainText []byte) ([]byte, error)

type AuthenticationReader added in v1.1.0

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

func NewAuthenticationReader added in v1.1.0

func NewAuthenticationReader(auth Authenticator, sizeParser ChunkSizeDecoder, reader io.Reader, transferType protocol.TransferType) *AuthenticationReader

func (*AuthenticationReader) Read

type AuthenticationWriter added in v1.1.0

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

func NewAuthenticationWriter added in v1.1.0

func NewAuthenticationWriter(auth Authenticator, sizeParser ChunkSizeEncoder, writer io.Writer, transferType protocol.TransferType) *AuthenticationWriter

func (*AuthenticationWriter) Write

type Authenticator added in v1.1.0

type Authenticator interface {
	NonceSize() int
	Overhead() int
	Open(dst, cipherText []byte) ([]byte, error)
	Seal(dst, plainText []byte) ([]byte, error)
}

type BytesGenerator added in v1.1.0

type BytesGenerator interface {
	Next() []byte
}

type ChunkSizeDecoder added in v1.1.0

type ChunkSizeDecoder interface {
	SizeBytes() int
	Decode([]byte) (uint16, error)
}

type ChunkSizeEncoder added in v1.1.0

type ChunkSizeEncoder interface {
	SizeBytes() int
	Encode(uint16, []byte) []byte
}

type ChunkStreamReader added in v1.1.0

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

func NewChunkStreamReader added in v1.1.0

func NewChunkStreamReader(sizeDecoder ChunkSizeDecoder, reader io.Reader) *ChunkStreamReader

func (*ChunkStreamReader) Read

func (r *ChunkStreamReader) Read() (buf.MultiBuffer, error)

type ChunkStreamWriter added in v1.1.0

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

func NewChunkStreamWriter added in v1.1.0

func NewChunkStreamWriter(sizeEncoder ChunkSizeEncoder, writer io.Writer) *ChunkStreamWriter

func (*ChunkStreamWriter) Write

func (w *ChunkStreamWriter) Write(mb buf.MultiBuffer) error

type CryptionReader added in v1.1.0

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

func NewCryptionReader

func NewCryptionReader(stream cipher.Stream, reader io.Reader) *CryptionReader

func (*CryptionReader) Read added in v1.1.0

func (r *CryptionReader) Read(data []byte) (int, error)

type CryptionWriter added in v1.1.0

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

func NewCryptionWriter

func NewCryptionWriter(stream cipher.Stream, writer io.Writer) *CryptionWriter

NewCryptionWriter creates a new CryptionWriter.

func (*CryptionWriter) Write added in v1.1.0

func (w *CryptionWriter) Write(data []byte) (int, error)

Write implements io.Writer.Write().

func (*CryptionWriter) WriteMultiBuffer added in v1.1.0

func (w *CryptionWriter) WriteMultiBuffer(mb buf.MultiBuffer) error

type NoOpBytesGenerator

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

func (NoOpBytesGenerator) Next

func (v NoOpBytesGenerator) Next() []byte

type PlainChunkSizeParser added in v1.1.0

type PlainChunkSizeParser struct{}

func (PlainChunkSizeParser) Decode added in v1.1.0

func (PlainChunkSizeParser) Decode(b []byte) (uint16, error)

func (PlainChunkSizeParser) Encode added in v1.1.0

func (PlainChunkSizeParser) Encode(size uint16, b []byte) []byte

func (PlainChunkSizeParser) SizeBytes added in v1.1.0

func (PlainChunkSizeParser) SizeBytes() int

type StaticBytesGenerator

type StaticBytesGenerator struct {
	Content []byte
}

func (StaticBytesGenerator) Next

func (v StaticBytesGenerator) Next() []byte

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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