Documentation ¶
Overview ¶
Package crypto provides common crypto libraries for V2Ray.
Index ¶
- func NewAesCTRStream(key []byte, iv []byte) cipher.Stream
- func NewAesDecryptionStream(key []byte, iv []byte) cipher.Stream
- func NewAesEncryptionStream(key []byte, iv []byte) cipher.Stream
- func NewAesGcm(key []byte) cipher.AEAD
- func NewAesStreamMethod(key []byte, iv []byte, f func(cipher.Block, []byte) cipher.Stream) cipher.Stream
- func NewChaCha20Stream(key []byte, iv []byte) cipher.Stream
- type AEADAuthenticator
- type AEADChunkSizeParser
- type AuthenticationReader
- type AuthenticationWriter
- type Authenticator
- type BytesGenerator
- type ChunkSizeDecoder
- type ChunkSizeEncoder
- type ChunkStreamReader
- type ChunkStreamWriter
- type CryptionReader
- type CryptionWriter
- type PaddingLengthGenerator
- type PlainChunkSizeParser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAesDecryptionStream ¶
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 ¶
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 NewAesStreamMethod ¶ added in v1.1.0
Types ¶
type AEADAuthenticator ¶ added in v1.1.0
type AEADAuthenticator struct { cipher.AEAD NonceGenerator BytesGenerator AdditionalDataGenerator BytesGenerator }
type AEADChunkSizeParser ¶ added in v1.1.0
type AEADChunkSizeParser struct {
Auth *AEADAuthenticator
}
func (*AEADChunkSizeParser) Decode ¶ added in v1.1.0
func (p *AEADChunkSizeParser) Decode(b []byte) (uint16, error)
func (*AEADChunkSizeParser) Encode ¶ added in v1.1.0
func (p *AEADChunkSizeParser) Encode(size uint16, b []byte) []byte
func (*AEADChunkSizeParser) SizeBytes ¶ added in v1.1.0
func (p *AEADChunkSizeParser) SizeBytes() int32
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, paddingLen PaddingLengthGenerator) *AuthenticationReader
func (*AuthenticationReader) ReadMultiBuffer ¶ added in v1.1.0
func (r *AuthenticationReader) ReadMultiBuffer() (buf.MultiBuffer, error)
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, padding PaddingLengthGenerator) *AuthenticationWriter
func (*AuthenticationWriter) WriteMultiBuffer ¶ added in v1.1.0
func (w *AuthenticationWriter) WriteMultiBuffer(mb buf.MultiBuffer) error
WriteMultiBuffer implements buf.Writer.
type Authenticator ¶ added in v1.1.0
type BytesGenerator ¶ added in v1.1.0
type BytesGenerator func() []byte
func GenerateEmptyBytes ¶ added in v1.1.0
func GenerateEmptyBytes() BytesGenerator
func GenerateIncreasingNonce ¶ added in v1.1.0
func GenerateIncreasingNonce(nonce []byte) BytesGenerator
func GenerateInitialAEADNonce ¶ added in v1.1.0
func GenerateInitialAEADNonce() BytesGenerator
func GenerateStaticBytes ¶ added in v1.1.0
func GenerateStaticBytes(content []byte) BytesGenerator
type ChunkSizeDecoder ¶ added in v1.1.0
ChunkSizeDecoder is a utility class to decode size value from bytes.
type ChunkSizeEncoder ¶ added in v1.1.0
ChunkSizeEncoder is a utility class to encode size value into bytes.
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 NewChunkStreamReaderWithChunkCount ¶ added in v1.1.0
func NewChunkStreamReaderWithChunkCount(sizeDecoder ChunkSizeDecoder, reader io.Reader, maxNumChunk uint32) *ChunkStreamReader
func (*ChunkStreamReader) ReadMultiBuffer ¶ added in v1.1.0
func (r *ChunkStreamReader) ReadMultiBuffer() (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) WriteMultiBuffer ¶ added in v1.1.0
func (w *ChunkStreamWriter) WriteMultiBuffer(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
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
WriteMultiBuffer implements buf.Writer.
type PaddingLengthGenerator ¶ added in v1.1.0
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() int32