quic

package
v0.0.0-...-45e847f Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT, MIT Imports: 12 Imported by: 0

README

All crypto parts and header parsing where taken from https://github.com/lucas-clemente/quic-go and heavily modified to work exclusively for this package. As such, I included its license here.

Documentation

Index

Constants

View Source
const (
	VersionDraft22 uint32 = 0xfaceb001
	VersionDraft27 uint32 = 0xfaceb002
	VersionDraft29 uint32 = 0xff00001d
	VersionDraft32 uint32 = 0xff000020
	VersionDraft34 uint32 = 0xff000022
	VersionQ50     uint32 = 0x51303530
	Version1       uint32 = 0x1
)

The version numbers, making grepping easier

Variables

SupportedVersions lists the versions that the server supports must be in sorted descending order

View Source
var UnmarshalNoQUICError = errors.New("not a QUIC packet")
View Source
var UnmarshalNoQUICInitialError = errors.New("not an initial QUIC packet")
View Source
var UnmarshalQUICBitsError = errors.New("unknown bits in QUIC header")
View Source
var UnmarshalQUICError = errors.New("insufficient bytes to unmarshal QUIC")
View Source
var UnmarshalQUICUnsupportedVersion = errors.New("unsupported QUIC version")

Functions

func IsSupportedVersion

func IsSupportedVersion(supported []uint32, v uint32) bool

IsSupportedVersion returns true if the server supports this version

func ReadConnectionID

func ReadConnectionID(r io.Reader, len int) ([]byte, error)

ReadConnectionID reads a connection ID of length len from the given io.Reader. It returns io.EOF if there are not enough bytes to read.

func ReadQuickVarInt

func ReadQuickVarInt(b io.ByteReader) (uint64, error)

func ReadUint16

func ReadUint16(b io.ByteReader) (uint16, error)

ReadUint16 reads a uint16

func ReadUint24

func ReadUint24(b io.ByteReader) (uint32, error)

ReadUint24 reads a uint24

func ReadUint32

func ReadUint32(b io.ByteReader) (uint32, error)

Types

type AESHeaderProtector

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

func (*AESHeaderProtector) DecryptHeader

func (p *AESHeaderProtector) DecryptHeader(sample []byte, firstByte *byte, hdrBytes []byte)

type ExtendedHeader

type ExtendedHeader struct {
	Header

	KeyPhase uint8

	PacketNumberLen uint8
	PacketNumber    int64
}

ExtendedHeader is the header of a QUIC packet.

func UnpackHeader

func UnpackHeader(hd *LongHeaderOpener, hdr *Header, data []byte, version uint32) (*ExtendedHeader, error)

func (*ExtendedHeader) Parse

func (h *ExtendedHeader) Parse(b *bytes.Reader, v uint32) (bool, error)
type Header struct {
	TypeByte     byte
	IsLongHeader bool

	ParsedLen int64

	Version          uint32
	DestConnectionID []byte
	SrcConnectionID  []byte

	Length int64
	Token  []byte
}

func ParseHeader

func ParseHeader(b *bytes.Reader) (*Header, error)

func (*Header) ParseExtended

func (h *Header) ParseExtended(b *bytes.Reader, ver uint32) (*ExtendedHeader, error)

ParseExtended parses the version dependent part of the header. The Reader has to be set such that it points to the first byte of the header.

type LongHeaderOpener

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

func NewInitialAEAD

func NewInitialAEAD(connID []byte, v uint32) *LongHeaderOpener

NewInitialAEAD creates a new AEAD for Initial encryption / decryption.

func (*LongHeaderOpener) DecryptHeader

func (o *LongHeaderOpener) DecryptHeader(sample []byte, firstByte *byte, pnBytes []byte)

func (*LongHeaderOpener) Open

func (o *LongHeaderOpener) Open(dst, src []byte, pn int64, ad []byte) ([]byte, error)

type Quic

type Quic struct {
	Header *ExtendedHeader
	Hello  tls.ClientHello
}

func (*Quic) Unmarshal

func (p *Quic) Unmarshal(payload []byte) error

Jump to

Keyboard shortcuts

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