core: v2ray.com/core/common/crypto Index | Files | Directories

package crypto

import "v2ray.com/core/common/crypto"

Package crypto provides common crypto libraries for V2Ray.

Index

Package Files

aes.go auth.go chacha20.go chunk.go crypto.go errors.generated.go io.go

func NewAesCTRStream Uses

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

NewAesCTRStream creates a stream cipher based on AES-CTR.

func NewAesDecryptionStream Uses

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 Uses

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 NewAesGcm Uses

func NewAesGcm(key []byte) cipher.AEAD

NewAesGcm creates a AEAD cipher based on AES-GCM.

func NewAesStreamMethod Uses

func NewAesStreamMethod(key []byte, iv []byte, f func(cipher.Block, []byte) cipher.Stream) cipher.Stream

func NewChaCha20Stream Uses

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.

type AEADAuthenticator Uses

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

func (*AEADAuthenticator) Open Uses

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

func (*AEADAuthenticator) Seal Uses

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

type AEADChunkSizeParser Uses

type AEADChunkSizeParser struct {
    Auth *AEADAuthenticator
}

func (*AEADChunkSizeParser) Decode Uses

func (p *AEADChunkSizeParser) Decode(b []byte) (uint16, error)

func (*AEADChunkSizeParser) Encode Uses

func (p *AEADChunkSizeParser) Encode(size uint16, b []byte) []byte

func (*AEADChunkSizeParser) SizeBytes Uses

func (p *AEADChunkSizeParser) SizeBytes() int32

type AuthenticationReader Uses

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

func NewAuthenticationReader Uses

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

func (*AuthenticationReader) ReadMultiBuffer Uses

func (r *AuthenticationReader) ReadMultiBuffer() (buf.MultiBuffer, error)

type AuthenticationWriter Uses

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

func NewAuthenticationWriter Uses

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

func (*AuthenticationWriter) WriteMultiBuffer Uses

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

WriteMultiBuffer implements buf.Writer.

type Authenticator Uses

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

type BytesGenerator Uses

type BytesGenerator func() []byte

func GenerateEmptyBytes Uses

func GenerateEmptyBytes() BytesGenerator

func GenerateIncreasingNonce Uses

func GenerateIncreasingNonce(nonce []byte) BytesGenerator

func GenerateInitialAEADNonce Uses

func GenerateInitialAEADNonce() BytesGenerator

func GenerateStaticBytes Uses

func GenerateStaticBytes(content []byte) BytesGenerator

type ChunkSizeDecoder Uses

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

ChunkSizeDecoder is a utility class to decode size value from bytes.

type ChunkSizeEncoder Uses

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

ChunkSizeEncoder is a utility class to encode size value into bytes.

type ChunkStreamReader Uses

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

func NewChunkStreamReader Uses

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

func NewChunkStreamReaderWithChunkCount Uses

func NewChunkStreamReaderWithChunkCount(sizeDecoder ChunkSizeDecoder, reader io.Reader, maxNumChunk uint32) *ChunkStreamReader

func (*ChunkStreamReader) ReadMultiBuffer Uses

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

type ChunkStreamWriter Uses

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

func NewChunkStreamWriter Uses

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

func (*ChunkStreamWriter) WriteMultiBuffer Uses

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

type CryptionReader Uses

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

func NewCryptionReader Uses

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

func (*CryptionReader) Read Uses

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

type CryptionWriter Uses

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

func NewCryptionWriter Uses

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

NewCryptionWriter creates a new CryptionWriter.

func (*CryptionWriter) Write Uses

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

Write implements io.Writer.Write().

func (*CryptionWriter) WriteMultiBuffer Uses

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

WriteMultiBuffer implements buf.Writer.

type PaddingLengthGenerator Uses

type PaddingLengthGenerator interface {
    MaxPaddingLen() uint16
    NextPaddingLen() uint16
}

type PlainChunkSizeParser Uses

type PlainChunkSizeParser struct{}

func (PlainChunkSizeParser) Decode Uses

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

func (PlainChunkSizeParser) Encode Uses

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

func (PlainChunkSizeParser) SizeBytes Uses

func (PlainChunkSizeParser) SizeBytes() int32

Directories

PathSynopsis
internal

Package crypto imports 11 packages (graph) and is imported by 15 packages. Updated 2019-03-01. Refresh now. Tools for package owners.