ddn.net.dtls.keyschedule

DTLS key schedule and transcript hash utilities.

Provides DTLS-specific transcript hashing that includes the full handshake header with message_seq and fragment fields per RFC 6347 §4.2.6. Also provides label conversion utilities for DTLS 1.3 (RFC 9147).

Types 1

Transcript hash for DTLS handshakes.

Unlike TLS, DTLS includes the full handshake header with message_seq and fragment fields in the hash input (RFC 6347 §4.2.6). For hashing purposes, fragment_offset is always 0 and fragment_length equals the total message length, representing a complete unfragmented message.

This ensures that the transcript hash is consistent regardless of how messages were fragmented during transmission.

Fields
private ubyte[] hashState_
private bool frozen_
Methods
void update(ubyte msgType, ushort messageSeq, const(ubyte)[] messageBody) @safe pure nothrowUpdates the transcript with a DTLS handshake message.
ubyte[] current()Gets the current transcript hash value (SHA-256).
void reset() @safe pure nothrowResets the transcript to empty state.
void resetWithMessageHash(const(ubyte)[] hashValue) @safe pure nothrowResets the transcript and replaces it with a synthetic message_hash message per RFC 8446 §4.4.1 (also used by DTLS 1.3, RFC 9147 §4.2.2).
void freeze() @safe pure nothrowFreezes the transcript.
bool isFrozen() const @safe pure nothrow @nogcChecks if the transcript is frozen.
const(ubyte)[] rawData() const @safe pure nothrow @nogcGets the raw accumulated transcript data.
Constructors
this()Constructs a new DtlsTranscriptHash.

Functions 2

fnstring dtls13Label(string tls13Label) pure nothrow @safeConverts a TLS 1.3 label to DTLS 1.3 format.
fnubyte[13] dtls13RecordAad(ubyte contentType, ushort epoch, ulong sequenceNumber, ushort payloadLength) pure nothrow @safe @nogcBuilds the AEAD additional data for a DTLS 1.3 record.

Variables 2

enumvarDtls13LabelPrefix = "dtls13"

DTLS 1.3 label prefix.

RFC 9147 §5.9 replaces the TLS 1.3 label prefix "tls13 " with "dtls13" — note there is no trailing space; this keeps the overall label size identical to TLS 1.3 (within one hash iteration).

enumvarDTLS_1_3_RECORD_VERSION = [0xFE, 0xFD]

DTLS 1.3 record protocol version used in record headers and AAD.

DTLS 1.3 uses the DTLS 1.2 wire version (0xFEFD) for compatibility.