ddn.net.dtls.types
DTLS protocol constants and types.
Defines DTLS-specific record headers, handshake headers, version constants, state machine phases, and helper functions for RFC 6347 (DTLS 1.2) and RFC 9147 (DTLS 1.3).
Types 7
DTLS record layer header.
The DTLS record header is 13 bytes on the wire:
- ContentType (1 byte)
- Protocol version (2 bytes)
- Epoch (2 bytes)
- Sequence number (6 bytes, 48-bit)
- Length (2 bytes)
ContentType typeContent type of the record.ubyte[2] protocolVersionProtocol version (2 bytes, big-endian on wire).ushort epochEpoch number for key material.ulong sequenceNumber48-bit sequence number (stored as ulong, only low 48 bits used).ushort lengthLength of the record payload in bytes.Nullable!DtlsRecordHeader parse(const(ubyte)[] data) @safe pure nothrow @nogcParses a DTLS record header from wire format.ubyte[DTLS_RECORD_HEADER_SIZE] serialize() const @safe pure nothrow @nogcSerializes the DTLS record header to wire format.DTLS handshake message header.
The DTLS handshake header is 12 bytes on the wire:
- HandshakeType (1 byte)
- Total message length (3 bytes, 24-bit)
- Message sequence (2 bytes)
- Fragment offset (3 bytes, 24-bit)
- Fragment length (3 bytes, 24-bit)
HandshakeType msgTypeType of handshake message.ubyte[3] lengthTotal length of the handshake message (24-bit, stored as ubyte[3]).ushort messageSeqMessage sequence number for ordering across fragments.ubyte[3] fragmentOffsetOffset of this fragment within the complete message (24-bit).ubyte[3] fragmentLengthLength of this fragment (24-bit).Nullable!DtlsHandshakeHeader parse(const(ubyte)[] data) @safe pure nothrow @nogcParses a DTLS handshake header from wire format.ubyte[DTLS_HANDSHAKE_HEADER_SIZE] serialize() const @safe pure nothrow @nogcSerializes the DTLS handshake header to wire format.DtlsHandshakeHeader create(
HandshakeType msgType,
uint totalLen,
ushort msgSeq,
uint fragOff,
uint fragLen
) @safe pure nothrow @nogcCreates a handshake header with the given parameters.DTLS 1.2 client handshake state machine phases.
Tracks the progress of a DTLS 1.2 handshake from the client's perspective.
DTLS 1.2 server handshake state machine phases.
Tracks the progress of a DTLS 1.2 handshake from the server's perspective.
DTLS 1.3 client handshake state machine phases.
Tracks the progress of a DTLS 1.3 handshake from the client's perspective. DTLS 1.3 (RFC 9147) is closer to TLS 1.3 but with DTLS-specific framing.
DTLS 1.3 server handshake state machine phases.
Tracks the progress of a DTLS 1.3 handshake from the server's perspective.
DTLS 1.3 HKDF label strings (RFC 9147 §5).
DTLS 1.3 uses different HKDF labels than TLS 1.3, prefixed with "dtls13" instead of "tls13".
Functions 4
uint readUint24(const(ubyte)[] data) @safe pure nothrow @nogcReads a 24-bit unsigned integer from 3 bytes (big-endian).void writeUint24(ubyte[] data, uint value) @safe pure nothrow @nogcWrites a 24-bit unsigned integer to 3 bytes (big-endian).ulong readSeq48(const(ubyte)[] data) @safe pure nothrow @nogcReads a 48-bit sequence number from 6 bytes (big-endian).void writeSeq48(ubyte[] data, ulong seq) @safe pure nothrow @nogcWrites a 48-bit sequence number to 6 bytes (big-endian).Variables 2
DTLS_RECORD_HEADER_SIZE = 13Size of the DTLS record header in bytes.
DTLS_HANDSHAKE_HEADER_SIZE = 12Size of the DTLS handshake header in bytes.