quic

package
v0.0.0-...-e1c68ec Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MPL-2.0, BSD-3-Clause Imports: 19 Imported by: 0

README

The code here is from https://github.com/cuonglm/quicsni with various modifications.

Documentation

Index

Constants

View Source
const (
	V1 uint32 = 0x1
	V2 uint32 = 0x6b3343cf
)

Variables

View Source
var ErrNotInitialPacket = errors.New("not initial packet")

Functions

func ReadCryptoPayload

func ReadCryptoPayload(packet []byte) ([]byte, error)

Types

type CryptoFrame

type CryptoFrame struct {
	Offset int64
	Data   []byte
}

func ReadCryptoFrames

func ReadCryptoFrames(packet []byte) ([]CryptoFrame, error)

ReadCryptoFrames decrypts a QUIC Initial client packet and returns CRYPTO frames.

func ReadCryptoFramesWithOptions

func ReadCryptoFramesWithOptions(packet []byte, opts *ReadCryptoFramesOptions) ([]CryptoFrame, error)

ReadCryptoFramesWithOptions decrypts a QUIC Initial packet and returns CRYPTO frames.

type DecryptSuccessHint

type DecryptSuccessHint struct {
	ConnectionID    []byte
	SecretLabel     string
	PacketNumberMax int64
}
type Header struct {
	Type             uint8
	Version          uint32
	SrcConnectionID  []byte
	DestConnectionID []byte
	Length           int64
	Token            []byte
}

The Header represents a QUIC header.

func ParseInitialHeader

func ParseInitialHeader(data []byte) (*Header, int64, error)

ParseInitialHeader parses the initial packet of a QUIC connection, return the initial header and number of bytes read so far.

type PacketProtector

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

PacketProtector is used for protecting a QUIC packet.

See: https://www.rfc-editor.org/rfc/rfc9001.html#name-packet-protection

func NewPacketProtector

func NewPacketProtector(key *ProtectionKey) *PacketProtector

NewPacketProtector creates a new PacketProtector.

func (*PacketProtector) UnProtect

func (pp *PacketProtector) UnProtect(packet []byte, pnOffset, pnMax int64) ([]byte, error)

UnProtect decrypts a QUIC packet.

type ProtectionKey

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

ProtectionKey is the key used to protect a QUIC packet.

func NewInitialProtectionKey

func NewInitialProtectionKey(secret []byte, v uint32) (*ProtectionKey, error)

NewInitialProtectionKey is like NewProtectionKey, but the returned protection key is used for encrypt/decrypt Initial Packet only.

See: https://datatracker.ietf.org/doc/html/draft-ietf-quic-tls-32#name-initial-secrets

func NewProtectionKey

func NewProtectionKey(suite uint16, secret []byte, v uint32) (*ProtectionKey, error)

NewProtectionKey creates a new ProtectionKey.

type ReadCryptoFramesOptions

type ReadCryptoFramesOptions struct {
	AdditionalConnectionIDs [][]byte
	TryServerSecret         bool
	PacketNumberMaxGuesses  []int64
	PreferredConnectionID   []byte
	PreferredSecretLabel    string
	PreferredPNMax          int64
	HasPreferredPNMax       bool
	SuccessHint             *DecryptSuccessHint
}

Jump to

Keyboard shortcuts

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