ddn.net.dtls.session
DTLS 1.3 session resumption and 0-RTT early data (RFC 9147 §8).
Implements session ticket management for DTLS 1.3 session resumption. After a successful handshake, the server issues a NewSessionTicket containing an encrypted PSK that the client can use to resume the session in a subsequent connection.
Key components:
DtlsSessionTicket: Ticket encryption/decryption using AES-GCMDtlsReplayCache: Anti-replay protection for 0-RTT early dataDtlsSessionStore: Client-side session ticket storage
Types 4
Encrypted session ticket for DTLS 1.3 resumption.
The ticket contains:
- Encrypted PSK and metadata (encrypted with server's ticket key)
- Ticket nonce (for key derivation)
- Lifetime and early data limits
ubyte[] nonceubyte[] ciphertextuint lifetimeSecondssize_t maxEarlyDataSizeushort cipherSuiteSession ticket encryption key manager.
Server-side component that manages ticket encryption keys. Keys are rotated periodically for forward secrecy.
SecureRandom rng_ubyte[][32] keys_size_t activeKeyIndex_Duration keyRotationInterval_MonoTime lastRotation_size_t keyCount_void rotateKey()Rotates to a new ticket encryption key.ubyte[] activeKey()Returns: the active encryption key.DtlsEncryptedTicket encryptTicket(const(ubyte)[] psk, ushort cipherSuite,
uint lifetimeSeconds, size_t maxEarlyData)Encrypts session data into a ticket.auto decryptTicket(DtlsEncryptedTicket ticket)Decrypts a session ticket.this(SecureRandom rng, Duration rotationInterval = dur!"hours"(1))Constructs a ticket key manager.Anti-replay cache for 0-RTT early data.
Tracks seen session tickets to prevent replay attacks. Supports multiple strategies as defined by EarlyDataReplayProtection.
Duration timeWindow_ubyte[][32] seenTickets_MonoTime[32] seenTimes_size_t seenCount_size_t nextSlot_bool checkAndRecord(const(ubyte)[] ticket)Checks if a ticket has been seen (replay check).void prune()Prunes expired entries (for TIME_WINDOWED mode).this(EarlyDataReplayProtection mode = EarlyDataReplayProtection.SINGLE_USE_TICKETS,
Duration timeWindow = dur!"seconds"(DtlsSessionConstants.DEFAULT_EARLY_DATA_WINDOW_S))Constructs a replay cache.Client-side session store.
Stores session tickets received from servers for later resumption. Supports multiple server endpoints with at most one active session per endpoint.
void store(scope ref const DtlsSessionInfo session)Stores a session ticket.DtlsSessionInfo * get(DatagramEndpoint serverAddr)Retrieves a session for the given server.void remove(DatagramEndpoint serverAddr)Removes a stored session.void prune()Removes all expired sessions.