import "v2ray.com/core/common/crypto"
Package crypto provides common crypto libraries for V2Ray.
aes.go auth.go chacha20.go chunk.go crypto.go errors.generated.go io.go
NewAesCTRStream creates a stream cipher based on AES-CTR.
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.
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.
NewAesGcm creates a AEAD cipher based on AES-GCM.
func NewAesStreamMethod(key []byte, iv []byte, f func(cipher.Block, []byte) cipher.Stream) 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.
type AEADAuthenticator struct { cipher.AEAD NonceGenerator BytesGenerator AdditionalDataGenerator BytesGenerator }
func (v *AEADAuthenticator) Open(dst, cipherText []byte) ([]byte, error)
func (v *AEADAuthenticator) Seal(dst, plainText []byte) ([]byte, error)
type AEADChunkSizeParser struct { Auth *AEADAuthenticator }
func (p *AEADChunkSizeParser) Decode(b []byte) (uint16, error)
func (p *AEADChunkSizeParser) Encode(size uint16, b []byte) []byte
func (p *AEADChunkSizeParser) SizeBytes() int32
type AuthenticationReader struct {
// contains filtered or unexported fields
}
func NewAuthenticationReader(auth Authenticator, sizeParser ChunkSizeDecoder, reader io.Reader, transferType protocol.TransferType, paddingLen PaddingLengthGenerator) *AuthenticationReader
func (r *AuthenticationReader) ReadMultiBuffer() (buf.MultiBuffer, error)
type AuthenticationWriter struct {
// contains filtered or unexported fields
}
func NewAuthenticationWriter(auth Authenticator, sizeParser ChunkSizeEncoder, writer io.Writer, transferType protocol.TransferType, padding PaddingLengthGenerator) *AuthenticationWriter
func (w *AuthenticationWriter) WriteMultiBuffer(mb buf.MultiBuffer) error
WriteMultiBuffer implements buf.Writer.
type Authenticator interface { NonceSize() int Overhead() int Open(dst, cipherText []byte) ([]byte, error) Seal(dst, plainText []byte) ([]byte, error) }
func GenerateEmptyBytes() BytesGenerator
func GenerateIncreasingNonce(nonce []byte) BytesGenerator
func GenerateInitialAEADNonce() BytesGenerator
func GenerateStaticBytes(content []byte) BytesGenerator
ChunkSizeDecoder is a utility class to decode size value from bytes.
ChunkSizeEncoder is a utility class to encode size value into bytes.
type ChunkStreamReader struct {
// contains filtered or unexported fields
}
func NewChunkStreamReader(sizeDecoder ChunkSizeDecoder, reader io.Reader) *ChunkStreamReader
func NewChunkStreamReaderWithChunkCount(sizeDecoder ChunkSizeDecoder, reader io.Reader, maxNumChunk uint32) *ChunkStreamReader
func (r *ChunkStreamReader) ReadMultiBuffer() (buf.MultiBuffer, error)
type ChunkStreamWriter struct {
// contains filtered or unexported fields
}
func NewChunkStreamWriter(sizeEncoder ChunkSizeEncoder, writer io.Writer) *ChunkStreamWriter
func (w *ChunkStreamWriter) WriteMultiBuffer(mb buf.MultiBuffer) error
type CryptionReader struct {
// contains filtered or unexported fields
}
func (r *CryptionReader) Read(data []byte) (int, error)
type CryptionWriter struct {
// contains filtered or unexported fields
}
NewCryptionWriter creates a new CryptionWriter.
func (w *CryptionWriter) Write(data []byte) (int, error)
Write implements io.Writer.Write().
func (w *CryptionWriter) WriteMultiBuffer(mb buf.MultiBuffer) error
WriteMultiBuffer implements buf.Writer.
type PlainChunkSizeParser struct{}
func (PlainChunkSizeParser) Decode(b []byte) (uint16, error)
func (PlainChunkSizeParser) Encode(size uint16, b []byte) []byte
func (PlainChunkSizeParser) SizeBytes() int32
Path | Synopsis |
---|---|
internal |
Package crypto imports 11 packages (graph) and is imported by 43 packages. Updated 2020-10-15. Refresh now. Tools for package owners.