tagger

package
v0.2.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package tagger provides a transparent IPv4 IPID tagger that injects a 16-bit TESLA-derived authentication tag into every outgoing IPv4 packet.

The tagger operates at the Go socket layer and is invisible to the WASM debuglet module. It wraps outgoing net.Conn and net.PacketConn connections via WrappedConn / WrappedPacketConn.

Tag Placement

The 16-bit tag is written into the IPv4 Identification (IPID) field (bytes 4–5 of the IPv4 header, big-endian). The IPv4 header checksum is recomputed after the field is updated.

Platform notes

Tagging is performed in pure Go and runs on all platforms. On Linux an additional eBPF-based tagger is available for in-kernel, zero-copy tagging (see internal/executor/tagger/ebpf).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IPv4Checksum

func IPv4Checksum(header []byte) uint16

IPv4Checksum computes the one's-complement checksum over an IPv4 header (helper exposed for tests).

func ReadIPID

func ReadIPID(pkt []byte) uint16

ReadIPID extracts the IPID field from a raw IPv4 packet. Panics if pkt is shorter than 6 bytes; callers should validate with isIPv4 first.

Types

type Tagger

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

Tagger is the pure-Go IPv4 IPID tagger backed by a TESLA key schedule.

func New

func New(schedule *tesla.KeySchedule, measurementID []byte) *Tagger

New creates a Tagger for the given key schedule and measurement ID. measurementID should be the raw bytes of the measurement UUID string.

func (*Tagger) Close

func (t *Tagger) Close() error

func (*Tagger) Schedule

func (t *Tagger) Schedule() *tesla.KeySchedule

func (*Tagger) SetSocketMark

func (t *Tagger) SetSocketMark(fd int) error

func (*Tagger) TagPacket

func (t *Tagger) TagPacket(pkt []byte) ([]byte, error)

TagPacket rewrites the IPID field of a raw IPv4 packet and recomputes the IPv4 header checksum. The packet is modified in-place; the same slice is returned.

The HMAC tag is computed over the packet in canonical form: both the IPID field (bytes 4–5) and the IPv4 header checksum field (bytes 10–11) are zeroed before hashing. This allows a verifier to reproduce the same hash input without knowing the original checksum or IPID values.

If pkt does not begin with a valid IPv4 header (version 4, IHL ≥ 5) the packet is returned unmodified without error.

type TaggerInterface

type TaggerInterface interface {
	// TagPacket rewrites the IPID field of the raw IPv4 packet bytes in-place
	// and returns the modified slice. The slice may be the same underlying
	// array as pkt (modified in-place) or a copy.
	TagPacket(pkt []byte) ([]byte, error)
	SetSocketMark(fd int) error
	Close() error
	Schedule() *tesla.KeySchedule
}

TaggerInterface is the abstraction used by both the pure-Go tagger and the eBPF tagger, enabling performance comparison.

type WrappedConn

type WrappedConn struct {
	net.Conn
	// contains filtered or unexported fields
}

WrappedConn wraps a net.Conn and tags every Write with the Tagger before sending. Reads pass through unmodified. All other net.Conn methods delegate to the underlying connection.

func WrapConn

func WrapConn(c net.Conn, t TaggerInterface) *WrappedConn

WrapConn returns a WrappedConn that tags outgoing packets.

func (*WrappedConn) Write

func (w *WrappedConn) Write(b []byte) (int, error)

Write tags b before writing it to the underlying connection.

type WrappedPacketConn

type WrappedPacketConn struct {
	net.PacketConn
	// contains filtered or unexported fields
}

WrappedPacketConn wraps a net.PacketConn and tags every WriteTo call.

func WrapPacketConn

func WrapPacketConn(c net.PacketConn, t TaggerInterface) *WrappedPacketConn

WrapPacketConn returns a WrappedPacketConn that tags outgoing packets.

func (*WrappedPacketConn) WriteTo

func (w *WrappedPacketConn) WriteTo(b []byte, addr net.Addr) (int, error)

WriteTo tags b before sending it to addr via the underlying PacketConn.

Directories

Path Synopsis
Package ebpf provides an eBPF-based IPv4 IPID tagger for Linux.
Package ebpf provides an eBPF-based IPv4 IPID tagger for Linux.
Package tesla implements a TESLA-inspired hash-chain key schedule for delayed disclosure of packet authentication keys.
Package tesla implements a TESLA-inspired hash-chain key schedule for delayed disclosure of packet authentication keys.

Jump to

Keyboard shortcuts

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