quicutils

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxVarintLen64 = 8

	MaxPacketNumberLength = 4
	SampleSize            = 16
)
View Source
const (
	Quic_FrameType_Padding          = 0
	Quic_FrameType_Ping             = 1
	Quic_FrameType_Crypto           = 6
	Quic_FrameType_ConnectionClose  = 0x1c
	Quic_FrameType_ConnectionClose2 = 0x1d
)
View Source
const (
	Version_Draft = iota
	Version_V1
	Version_V2
)

Variables

View Source
var (
	UnknownFrameTypeError = fmt.Errorf("unknown frame type")
	OutOfRangeError       = fmt.Errorf("index out of range")
)
View Source
var (
	InitialClientLabel = []byte("client in")
)

Functions

func BigEndianUvarint

func BigEndianUvarint(buf []byte) (uint64, int, error)

BigEndianUvarint decodes a uint64 from buf and returns that value and the number of bytes read (> 0).

func DecryptQuicFromPool_

func DecryptQuicFromPool_(header []byte, blockEnd int, destConnId []byte) (plaintext []byte, err error)

func HkdfExpandLabelFromPool

func HkdfExpandLabelFromPool(h func() hash.Hash, secret, label []byte, context []byte, length int) ([]byte, error)

HkdfExpandLabelFromPool HKDF expands a label. Since this implementation avoids using a cryptobyte.Builder, it is about 15% faster than the hkdfExpandLabel in the standard library.

func ReassembleCryptoToBytesFromPool

func ReassembleCryptoToBytesFromPool(plaintextPayload []byte) (b []byte, err error)

Types

type BuiltinBytesLocator

type BuiltinBytesLocator []byte

func (BuiltinBytesLocator) At

func (l BuiltinBytesLocator) At(i int) byte

func (BuiltinBytesLocator) Len

func (l BuiltinBytesLocator) Len() int

func (BuiltinBytesLocator) Range

func (l BuiltinBytesLocator) Range(i, j int) []byte

func (BuiltinBytesLocator) Slice

func (l BuiltinBytesLocator) Slice(i, j int) Locator

type CryptoFrameOffset

type CryptoFrameOffset struct {
	UpperAppOffset int
	// Offset of data in quic payload.
	Data []byte
}

func ExtractCryptoFrameOffset

func ExtractCryptoFrameOffset(remainder []byte, transportOffset int) (offset *CryptoFrameOffset, frameSize int, err error)

type CryptoFrameRelocation

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

func NewCryptoFrameRelocation

func NewCryptoFrameRelocation(plaintextPayload []byte) (cryptoRelocation *CryptoFrameRelocation, err error)

func (*CryptoFrameRelocation) At

func (r *CryptoFrameRelocation) At(i int) byte

func (*CryptoFrameRelocation) BinarySearch

func (r *CryptoFrameRelocation) BinarySearch(iUpper int, leftOuter, rightOuter int) (iOuter int, iInner int, err error)

func (*CryptoFrameRelocation) BytesFromPool

func (r *CryptoFrameRelocation) BytesFromPool() []byte

func (*CryptoFrameRelocation) Len

func (r *CryptoFrameRelocation) Len() int

func (*CryptoFrameRelocation) RangeFromPool

func (r *CryptoFrameRelocation) RangeFromPool(i, j int) []byte

RangeFromPool copy bytes from iUpperAppOffset to jUpperAppOffset. It is not suggested to use it for large range and frequent copy.

type Keys

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

func NewKeys

func NewKeys(clientDstConnectionId []byte, version Version, newAead func(key []byte) (cipher.AEAD, error)) (keys *Keys, err error)

func (*Keys) Close

func (k *Keys) Close() error

func (*Keys) HeaderProtection_

func (k *Keys) HeaderProtection_(sample []byte, longHeader bool, firstByte *byte, potentialPacketNumber []byte) (packetNumber []byte, err error)

HeaderProtection_ encrypt/decrypt firstByte and packetNumber in place.

func (*Keys) PayloadDecryptFromPool

func (k *Keys) PayloadDecryptFromPool(ciphertext []byte, packetNumber []byte, header []byte) (plaintext []byte, err error)

type LinearLocator

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

LinearLocator only searches forward and have no boundary check.

func NewLinearLocator

func NewLinearLocator(cfr *CryptoFrameRelocation) (linearLocator *LinearLocator)

func (*LinearLocator) At

func (ll *LinearLocator) At(i int) byte

func (*LinearLocator) Len

func (ll *LinearLocator) Len() int

func (*LinearLocator) Range

func (ll *LinearLocator) Range(i, j int) []byte

func (*LinearLocator) Slice

func (ll *LinearLocator) Slice(i, j int) Locator

type Locator

type Locator interface {
	Range(i, j int) []byte
	Slice(i, j int) Locator
	At(i int) byte
	Len() int
}

type Version

type Version int

func ParseVersion

func ParseVersion(version uint32) (Version, error)

func (Version) HpLabel

func (v Version) HpLabel() []byte

func (Version) InitialSalt

func (v Version) InitialSalt() []byte

func (Version) IvLabel

func (v Version) IvLabel() []byte

func (Version) KeyLabel

func (v Version) KeyLabel() []byte

Jump to

Keyboard shortcuts

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