HandshakeStateMachine class
Manages the TLS 1.3 handshake lifecycle for a single QUIC connection (RFC 8446).
HandshakeStateMachine tracks which handshake messages have been sent and received, enforcing valid state transitions and preventing illegal message sequences. It is used by both client and server endpoints; the exact path is determined by HandshakeRole.
The machine is rate-limited to prevent CPU exhaustion from malicious peers that might flood handshake messages.
Example
final machine = HandshakeStateMachine(HandshakeRole.client);
machine.start();
machine.onMessage(TlsHandshakeType.clientHello, sent: true);
See also:
- HandshakeState — the individual states this machine transitions through.
- TlsHandshakeType — the message types that drive state changes.
- RFC 8446 Section 4 — handshake protocol overview.
Constructors
- HandshakeStateMachine(HandshakeRole _role)
- Creates a HandshakeStateMachine for the given HandshakeRole.
Properties
- hasFailed → bool
-
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- inProgress → bool
-
no setter
- isComplete → bool
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- state → HandshakeState
-
no setter
Methods
-
accept(
) → void - Server-only: transition from HandshakeState.serverStart to HandshakeState.serverWaitClientHello.
-
fail(
) → void - Mark handshake as failed.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onMessage(
TlsHandshakeType messageType, {required bool sent}) → void -
Advance state on sending/receiving handshake messages.
messageTypeis the TLS handshake message type.sentis true if we sent it, false if we received it. -
reset(
) → void - Reset to idle.
-
start(
) → void - Transitions from HandshakeState.idle to HandshakeState.clientStart (client) or HandshakeState.serverStart (server).
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited