protocol

package
v4.0.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 4 Imported by: 2

Documentation

Overview

Package protocol provides the DTLS wire format

Index

Constants

View Source
const ReturnRoutabilityCheckCookieLength = 8

ReturnRoutabilityCheckCookieLength is the wire size of an RRC cookie. https://datatracker.ietf.org/doc/html/rfc9853#section-4

Variables

This section is empty.

Functions

func CompressionMethods

func CompressionMethods() map[CompressionMethodID]*CompressionMethod

CompressionMethods returns all supported CompressionMethods.

func EncodeCompressionMethods

func EncodeCompressionMethods(c []*CompressionMethod) []byte

EncodeCompressionMethods the given compression methods.

func IsDTLS13Ciphertext

func IsDTLS13Ciphertext(ct ContentType) bool

Types

type ACK

type ACK struct {
	// Records is the list of RecordNumbers being acknowledged.
	Records []RecordNumber
}

ACK is the DTLS 1.3 content type used to acknowledge receipt of handshake records.

https://datatracker.ietf.org/doc/html/rfc9147#section-7

func (ACK) ContentType

func (a ACK) ContentType() ContentType

ContentType returns the content type for ACK records (26).

func (*ACK) Marshal

func (a *ACK) Marshal() ([]byte, error)

Marshal encodes the ACK message to its wire format.

func (*ACK) MarshalSize

func (a *ACK) MarshalSize() int

MarshalSize returns the minimal size required for MarshalTo.

func (*ACK) MarshalTo

func (a *ACK) MarshalTo(out []byte) (int, error)

MarshalTo encodes the ACK message into a pre-allocated buffer.

func (*ACK) Unmarshal

func (a *ACK) Unmarshal(data []byte) error

Unmarshal decodes an ACK message from its wire format.

type ApplicationData

type ApplicationData struct {
	Data []byte
}

ApplicationData messages are carried by the record layer and are fragmented, compressed, and encrypted based on the current connection state. The messages are treated as transparent data to the record layer. https://tools.ietf.org/html/rfc5246#section-10

func (ApplicationData) ContentType

func (a ApplicationData) ContentType() ContentType

ContentType returns the ContentType of this content.

func (*ApplicationData) Marshal

func (a *ApplicationData) Marshal() ([]byte, error)

Marshal encodes the ApplicationData to binary.

func (ApplicationData) MarshalSize

func (a ApplicationData) MarshalSize() int

MarshalSize returns the size required for MarshalTo.

func (*ApplicationData) MarshalTo

func (a *ApplicationData) MarshalTo(out []byte) (int, error)

MarshalTo encodes the ApplicationData to binary into a pre-allocated buffer.

func (*ApplicationData) Unmarshal

func (a *ApplicationData) Unmarshal(data []byte) error

Unmarshal populates the ApplicationData from binary.

type ChangeCipherSpec

type ChangeCipherSpec struct{}

ChangeCipherSpec protocol exists to signal transitions in ciphering strategies. The protocol consists of a single message, which is encrypted and compressed under the current (not the pending) connection state. The message consists of a single byte of value 1. https://tools.ietf.org/html/rfc5246#section-7.1

func (ChangeCipherSpec) ContentType

func (c ChangeCipherSpec) ContentType() ContentType

ContentType returns the ContentType of this content.

func (*ChangeCipherSpec) Marshal

func (c *ChangeCipherSpec) Marshal() ([]byte, error)

Marshal encodes the ChangeCipherSpec to binary.

func (ChangeCipherSpec) MarshalSize

func (c ChangeCipherSpec) MarshalSize() int

MarshalSize returns the minimal buffer size required for MarshalTo.

func (*ChangeCipherSpec) MarshalTo

func (c *ChangeCipherSpec) MarshalTo(out []byte) (int, error)

MarshalTo encodes the ChangeCipherSpec to binary into a pre-allocated buffer.

func (*ChangeCipherSpec) Unmarshal

func (c *ChangeCipherSpec) Unmarshal(data []byte) error

Unmarshal populates the ChangeCipherSpec from binary.

type CompressionMethod

type CompressionMethod struct {
	ID CompressionMethodID
}

CompressionMethod represents a TLS Compression Method.

func DecodeCompressionMethods

func DecodeCompressionMethods(buf []byte) ([]*CompressionMethod, error)

DecodeCompressionMethods the given compression methods.

type CompressionMethodID

type CompressionMethodID byte

CompressionMethodID is the ID for a CompressionMethod.

type Content

type Content interface {
	ContentType() ContentType
	Marshal() ([]byte, error)
	MarshalTo([]byte) (int, error)
	MarshalSize() int
	Unmarshal(data []byte) error
}

Content is the top level distinguisher for a DTLS Datagram.

type ContentType

type ContentType uint8

ContentType represents the IANA Registered ContentTypes

https://tools.ietf.org/html/rfc4346#section-6.2.1

const (
	ContentTypeChangeCipherSpec       ContentType = 20
	ContentTypeAlert                  ContentType = 21
	ContentTypeHandshake              ContentType = 22
	ContentTypeApplicationData        ContentType = 23
	ContentTypeConnectionID           ContentType = 25
	ContentTypeACK                    ContentType = 26
	ContentTypeReturnRoutabilityCheck ContentType = 27
)

ContentType enums.

type RecordNumber

type RecordNumber struct {
	Epoch          uint64
	SequenceNumber uint64
}

RecordNumber identifies a specific DTLS record by its epoch and sequence number. The 128-bit value matches the unpacked RecordNumber structure from RFC 9147 Section 4.2.

type ReturnRoutabilityCheck

type ReturnRoutabilityCheck struct {
	MessageType ReturnRoutabilityCheckMessageType
	Cookie      [ReturnRoutabilityCheckCookieLength]byte
}

ReturnRoutabilityCheck carries an RRC path validation message.

func (ReturnRoutabilityCheck) ContentType

func (r ReturnRoutabilityCheck) ContentType() ContentType

ContentType returns the RRC content type (27).

func (*ReturnRoutabilityCheck) Marshal

func (r *ReturnRoutabilityCheck) Marshal() ([]byte, error)

Marshal encodes to wire format.

func (*ReturnRoutabilityCheck) MarshalSize

func (r *ReturnRoutabilityCheck) MarshalSize() int

MarshalSize returns the minimal size required for MarshalTo.

func (*ReturnRoutabilityCheck) MarshalTo

func (r *ReturnRoutabilityCheck) MarshalTo(out []byte) (int, error)

MarshalTo encodes to wire format into a pre-allocated buffer.

func (*ReturnRoutabilityCheck) Unmarshal

func (r *ReturnRoutabilityCheck) Unmarshal(data []byte) error

Unmarshal decodes an RRC message.

type ReturnRoutabilityCheckMessageType

type ReturnRoutabilityCheckMessageType uint8

ReturnRoutabilityCheckMessageType identifies an RFC 9853 RRC message.

const (
	ReturnRoutabilityCheckPathChallenge ReturnRoutabilityCheckMessageType = iota
	ReturnRoutabilityCheckPathResponse
	ReturnRoutabilityCheckPathDrop
)

Return Routability Check message types (rrc_msg_type). https://datatracker.ietf.org/doc/html/rfc9853#section-4

type Version

type Version uint16

Version represents a DTLS protocol version.

const (
	Version1_0 Version = 0xfeff
	Version1_2 Version = 0xfefd
	Version1_3 Version = 0xfefc
)

func VersionFromBytes

func VersionFromBytes(major, minor uint8) Version

VersionFromBytes constructs a Version from major/minor bytes.

func (Version) Major

func (v Version) Major() uint8

Major returns the major version number.

func (Version) Minor

func (v Version) Minor() uint8

Minor returns the minor version number.

Directories

Path Synopsis
Package alert implements TLS alert protocol https://tools.ietf.org/html/rfc5246#section-7.2
Package alert implements TLS alert protocol https://tools.ietf.org/html/rfc5246#section-7.2
Package extension provides TLS extension framing and payload codecs.
Package extension provides TLS extension framing and payload codecs.
dtls12
Package dtls12 implements extension payloads specific to DTLS 1.2.
Package dtls12 implements extension payloads specific to DTLS 1.2.
dtls13
Package dtls13 implements extension payloads specific to DTLS 1.3.
Package dtls13 implements extension payloads specific to DTLS 1.3.
Package handshake provides the DTLS wire protocol for handshakes
Package handshake provides the DTLS wire protocol for handshakes
Package recordlayer frames, inspects, and encodes DTLS wire records.
Package recordlayer frames, inspects, and encodes DTLS wire records.

Jump to

Keyboard shortcuts

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