Documentation ¶
Overview ¶
Package crypto provides common crypto libraries for V2Ray.
Index ¶
- func NewAesDecryptionStream(key []byte, iv []byte) cipher.Stream
- func NewAesEncryptionStream(key []byte, iv []byte) 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 IncreasingAEADNonceGenerator
- type NoOpBytesGenerator
- type PlainChunkSizeParser
- type StaticBytesGenerator
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.
Types ¶
type AEADAuthenticator ¶
type AEADAuthenticator struct { cipher.AEAD NonceGenerator BytesGenerator AdditionalDataGenerator BytesGenerator }
func (*AEADAuthenticator) Open ¶
func (v *AEADAuthenticator) Open(dst, cipherText []byte) ([]byte, error)
func (*AEADAuthenticator) Seal ¶
func (v *AEADAuthenticator) Seal(dst, plainText []byte) ([]byte, error)
type AEADChunkSizeParser ¶
type AEADChunkSizeParser struct {
Auth *AEADAuthenticator
}
func (*AEADChunkSizeParser) Decode ¶
func (p *AEADChunkSizeParser) Decode(b []byte) (uint16, error)
func (*AEADChunkSizeParser) Encode ¶
func (p *AEADChunkSizeParser) Encode(size uint16, b []byte) []byte
func (*AEADChunkSizeParser) SizeBytes ¶
func (p *AEADChunkSizeParser) SizeBytes() int32
type AuthenticationReader ¶
type AuthenticationReader struct {
// contains filtered or unexported fields
}
func NewAuthenticationReader ¶
func NewAuthenticationReader(auth Authenticator, sizeParser ChunkSizeDecoder, reader io.Reader, transferType protocol.TransferType) *AuthenticationReader
func (*AuthenticationReader) ReadMultiBuffer ¶
func (r *AuthenticationReader) ReadMultiBuffer() (buf.MultiBuffer, error)
type AuthenticationWriter ¶
type AuthenticationWriter struct {
// contains filtered or unexported fields
}
func NewAuthenticationWriter ¶
func NewAuthenticationWriter(auth Authenticator, sizeParser ChunkSizeEncoder, writer io.Writer, transferType protocol.TransferType) *AuthenticationWriter
func (*AuthenticationWriter) WriteMultiBuffer ¶
func (w *AuthenticationWriter) WriteMultiBuffer(mb buf.MultiBuffer) error
type Authenticator ¶
type ChunkSizeDecoder ¶
ChunkSizeDecoder is a utility class to decode size value from bytes.
type ChunkSizeEncoder ¶
ChunkSizeEncoder is a utility class to encode size value into bytes.
type ChunkStreamReader ¶
type ChunkStreamReader struct {
// contains filtered or unexported fields
}
func NewChunkStreamReader ¶
func NewChunkStreamReader(sizeDecoder ChunkSizeDecoder, reader io.Reader) *ChunkStreamReader
func (*ChunkStreamReader) ReadMultiBuffer ¶
func (r *ChunkStreamReader) ReadMultiBuffer() (buf.MultiBuffer, error)
type ChunkStreamWriter ¶
type ChunkStreamWriter struct {
// contains filtered or unexported fields
}
func NewChunkStreamWriter ¶
func NewChunkStreamWriter(sizeEncoder ChunkSizeEncoder, writer io.Writer) *ChunkStreamWriter
func (*ChunkStreamWriter) WriteMultiBuffer ¶
func (w *ChunkStreamWriter) WriteMultiBuffer(mb buf.MultiBuffer) error
type CryptionReader ¶ added in v1.11.1
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.11.1
func (r *CryptionReader) Read(data []byte) (int, error)
type CryptionWriter ¶ added in v1.11.1
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.11.1
func (w *CryptionWriter) Write(data []byte) (int, error)
Write implements io.Writer.Write().
func (*CryptionWriter) WriteMultiBuffer ¶
func (w *CryptionWriter) WriteMultiBuffer(mb buf.MultiBuffer) error
WriteMultiBuffer implements buf.Writer.
type IncreasingAEADNonceGenerator ¶
type IncreasingAEADNonceGenerator struct {
// contains filtered or unexported fields
}
func NewIncreasingAEADNonceGenerator ¶
func NewIncreasingAEADNonceGenerator() *IncreasingAEADNonceGenerator
func (*IncreasingAEADNonceGenerator) Next ¶
func (g *IncreasingAEADNonceGenerator) Next() []byte
type NoOpBytesGenerator ¶
type NoOpBytesGenerator struct {
// contains filtered or unexported fields
}
func (NoOpBytesGenerator) Next ¶
func (v NoOpBytesGenerator) Next() []byte
type PlainChunkSizeParser ¶
type PlainChunkSizeParser struct{}
func (PlainChunkSizeParser) Decode ¶
func (PlainChunkSizeParser) Decode(b []byte) (uint16, error)
func (PlainChunkSizeParser) Encode ¶
func (PlainChunkSizeParser) Encode(size uint16, b []byte) []byte
func (PlainChunkSizeParser) SizeBytes ¶
func (PlainChunkSizeParser) SizeBytes() int32
type StaticBytesGenerator ¶
type StaticBytesGenerator struct {
Content []byte
}
func (StaticBytesGenerator) Next ¶
func (v StaticBytesGenerator) Next() []byte
Source Files ¶
Click to show internal directories.
Click to hide internal directories.