Session Resumption Protocol¶
Session resumption enables low-latency reconnection by bypassing the full X25519 handshake. It allows clients to re-establish a secure session using previously negotiated symmetric secrets and a valid session token.
Source Mapping¶
src/Nalix.Codec/DataFrames/SignalFrames/SessionResume.cssrc/Nalix.Runtime/Handlers/SessionHandlers.cssrc/Nalix.Network/Sessions/SessionStoreBase.cssrc/Nalix.Abstractions/Networking/Sessions/ISessionStore.cssrc/Nalix.SDK/Transport/Extensions/ResumeExtensions.cs
1. Design & Rationale¶
Nalix uses the SessionResume packet with a Stage state machine to manage session state. The packet supports REQUEST and RESPONSE stages so the server can restore or reject a session in a single round-trip.
- Atomic Resumption: The server applies the restored session snapshot and returns a fresh response token in a single round-trip.
- Stateless Re-entry: A session can be resumed immediately as long as the 8-byte
SessionTokenand its associatedSecretare valid. - Token Rotation: The server can return a rotated
SessionTokenin a successful response.
2. Handshake vs. Resumption¶
sequenceDiagram
participant C as Client (SDK)
participant S as Server (Runtime)
Note over C, S: Option A: Full Handshake (Standard)
C->>S: CLIENT_HELLO (X25519 PubKey)
S->>C: SERVER_HELLO
C->>S: CLIENT_FINISH
S->>C: SERVER_FINISH (New Token)
Note over C, S: Option B: Session Resume (Fast)
C->>S: SessionResume [Stage=REQUEST, Token=T1]
S->>C: SessionResume [Stage=RESPONSE, Token=T2, Reason=NONE]
3. Protocol Specification¶
Packet Shape¶
SessionResume is a fixed-size signal packet carrying the stage, session token, proof, and result reason needed for resumption.
4. Implementation Details¶
Server Handling Logic¶
When a SessionResume request arrives at SessionHandlers.Handle:
- The incoming packet is validated to ensure the
Stage,SessionToken, andProoffields are structurally sound for aREQUEST. - The server extracts the
SessionTokenfrom the payload. - It resolves and validates a resumable
SessionEntrythrough the activeISessionStore. - It validates
ProofusingHmacKeccak256over the 8-byte session token and the stored session secret. - If validation succeeds, the runtime restores the connection's
Secret,Algorithm,Level, and savedAttributes, then marksConnectionAttributes.HandshakeEstablished = true. - The runtime stores the live connection back into
IConnectionHub.SessionStore, computes a response proof for the new token, and sends aRESPONSEwithProtocolReason.NONE. - If validation, token lookup, or proof verification fails, the server sends an error reason and disconnects.
5. Security & Operations¶
- Token Confidentiality: While the token is not a replacement for the symmetric secret, it should be treated as sensitive material as it identifies an active session.
- Rotation Policy: Clients must update their local
TransportOptions.SessionTokenimmediately upon receiving a successfulRESPONSE. The SDK already does this insrc/Nalix.SDK/Transport/Extensions/ResumeExtensions.cs. - Invalidation: Sessions are invalidated upon explicit disconnect or after the configured session-store TTL (Time-To-Live) expires.