Documentation
¶
Overview ¶
Package sessionparams is the Matter SessionParameters structure the secure-channel handshakes exchange: Sigma1's initiatorSessionParams, Sigma2's and Sigma2_Resume's responderSessionParams, and the PASE PBKDFParamRequest / PBKDFParamResponse fields of the same tag (5).
Mirrors matter.js packages/protocol/src/session/pase/PaseMessages.ts:28-58 (TlvSessionParameters: nine optional context-tagged fields; the same schema is reused by CaseMessages.ts:34, :46, :55) and packages/protocol/src/session/SessionParameters.ts (the fallbacks, the Matter 1.5 gate on TCP and the rule that MAX_TCP_MESSAGE_SIZE is present only when SUPPORTED_TRANSPORTS names TCP).
Index ¶
Constants ¶
const ( // TransportTCPClient: the node implements the TCP client mode and may // connect to a peer that is a TCP server. TransportTCPClient uint16 = 1 << 1 // TransportTCPServer: the node implements the TCP server mode and // listens for incoming TCP connections. TransportTCPServer uint16 = 1 << 2 )
Transport bits of the SupportedTransports bitmap (tag 8). Mirrors matter.js packages/protocol/src/common/SupportedTransportsBitmap.ts:9-22: bit 0 is reserved, tcpClient is BitFlag(1), tcpServer is BitFlag(2).
const DefaultMaxTCPMessageSize uint32 = 64000
DefaultMaxTCPMessageSize is matter.js's fallback for MaxTCPMessageSize when a TCP-capable node states none (SessionParameters.ts:152, PaseMessages.ts:54 "default: 64000").
const MaxUnauthenticatedInterval uint32 = 3_600_000
MaxUnauthenticatedInterval is the largest SessionIdleInterval and SessionActiveInterval, in milliseconds, a node adopts from a peer that has not authenticated: one hour, the bound this module already puts on the intervals it advertises (mdns/service.go:726, maxAdvertisedInterval). The active threshold needs no bound: its field is 16 bits wide.
This module's own rule (review II, owner decision 45): a stated 0xFFFFFFFF ms would otherwise pace a handshake's retransmissions — and the wait for their acknowledgement — over weeks. Both references take the intervals of a PASE or CASE message as stated (matter.js packages/protocol/src/session/SessionIntervals.ts:52-53 at b25ed960, "accepted unbounded"; connectedhomeip src/protocols/secure_channel/PairingSession.cpp:175-189 at 6170af84). A DNS-SD interval above one hour connectedhomeip reads as not stated (src/lib/dnssd/TxtFields.cpp:210-218 GetRetryInterval, kMaxRetryInterval at TxtFields.h:38), and matter.js keeps from a discovered record only an interval an advertisement can carry (SessionIntervals.ts:99-118 advertisable, in toLongForm at packages/node/src/behavior/system/commissioning/RemoteDescriptor.ts:223-227).
const MinTCPSpecificationVersion uint32 = 0x01050000
MinTCPSpecificationVersion is the first specification version whose peers may be offered TCP: matter.js SessionParameters.ts:17 (MIN_TCP_SPEC_VERSION = 0x01050000) clears the transport bits of a peer below it (:50-54, "TCP is only honored for Matter 1.5.0+ peers").
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Parameters ¶
type Parameters struct {
SessionIdleInterval uint32 // [1] TlvUInt32, milliseconds
SessionActiveInterval uint32 // [2] TlvUInt32, milliseconds
SessionActiveThreshold uint16 // [3] TlvUInt16, milliseconds
DataModelRevision uint16 // [4] TlvUInt16
InteractionModelRevision uint16 // [5] TlvUInt16
SpecificationVersion uint32 // [6] TlvUInt32, e.g. 0x01060100
MaxPathsPerInvoke uint16 // [7] TlvUInt16
// SupportedTransports is the SUPPORTED_TRANSPORTS bitmap (TlvUInt16),
// the transports the node supports in addition to MRP over UDP.
SupportedTransports uint16 // [8]
// MaxTCPMessageSize (matter.js `maxTcpMessageSize`) is the largest message the node accepts over TCP
// in bytes (TlvUInt32). Encoded only when SupportedTransports names
// TCP (SessionParameters.ts:58-63: "The MAX_TCP_MESSAGE_SIZE field
// SHALL only be present if the SUPPORTED_TRANSPORTS field indicates
// that TCP is supported").
MaxTCPMessageSize uint32 // [9]
}
Parameters is one SessionParameters structure. A zero field is "not stated": it is omitted on the wire and a reader falls back to the spec default for that field. Field tags and widths follow PaseMessages.ts:28-58.
func ClampUnauthenticated ¶
func ClampUnauthenticated(p Parameters) Parameters
ClampUnauthenticated returns p with SessionIdleInterval and SessionActiveInterval reduced to MaxUnauthenticatedInterval; every other field, and an interval within the bound or not stated, is kept. It is for the parameters of a peer that has not authenticated, at the point a node adopts them for the handshake's own session; the parameters a secure session is established with are the peer's as stated.
func DecodeFields ¶
func DecodeFields(dec *tlv.Decoder) (Parameters, error)
DecodeFields reads the fields of a structure whose opening element the caller has already consumed, up to and including its end. The session parameters are decoded strictly, as matter.js decodes TlvSessionParameters (PaseMessages.ts:28-55 at db021da0) without the relaxed number checks: every member must carry a context tag (TlvObject.ts:212-214); a known field must be an unsigned integer (TlvNumber.ts:124-131); a value of fields 1-7 and 9 must fit the field (:145-155). Any of these refuses the whole structure. The bitmap, field 8, is refused as well when its value does not fit 16 bits — the module's own, as connectedhomeip reads it (src/protocols/secure_channel/PairingSession.cpp:247-248 at 6170af84); matter.js's bitmap wrapper does not bound the wire value. A member at an unknown context tag is skipped, a container included (TlvObject.ts:215-220), so a future field does not break the handshake; an encoding wider than the field whose value fits is accepted; a repeated field keeps its last value (:233).
func (Parameters) EffectiveMaxTCPMessageSize ¶
func (p Parameters) EffectiveMaxTCPMessageSize() uint32
EffectiveMaxTCPMessageSize is the TCP message bound a reader may act on: the stated size, matter.js's fallback when a TCP-capable peer stated none (SessionParameters.ts:60-63), and 0 when the effective transports name no TCP.
func (Parameters) EffectiveTransports ¶
func (p Parameters) EffectiveTransports() uint16
EffectiveTransports is the SupportedTransports bitmap a reader may act on: the stated bits with TCP cleared when the peer's SpecificationVersion is below Matter 1.5.0 or unknown (SessionParameters.ts:49-56 — "clear it for older or unknown spec versions so supportedTransports is the single source of truth for transport selection").
func (Parameters) Encode ¶
func (p Parameters) Encode(enc *tlv.Encoder, outer tlv.Tag)
Encode writes the structure as a sub-structure tagged outer: every stated field at its spec width (PaseMessages.ts:28-58), the SUPPORTED_TRANSPORTS bitmap (tag 8) always — 0 for a node without TCP — and tag 9 only when the bitmap names TCP. matter.js states the bitmap in every session parameters it sends: SessionManager's getter keeps it and drops only the TCP message size without a TCP role (packages/protocol/src/session/SessionManager.ts:391-400 at db021da0), ServerNetworkRuntime sets it whatever the role (packages/node/src/behavior/system/network/ServerNetworkRuntime.ts:204-210), and its encoder writes {tcpClient: false, tcpServer: false} as 0 (secure/sessionparams/testdata/session-params-fixtures.json, review II, R2-P6-par-2905). A reader here cannot tell an absent bitmap from 0 (DecodeFields). matter.js itself encodes the minimal width and its decoder checks only the element type (TlvNumber.ts:118-143 at b25ed960), so either width is accepted on the wire; the fixed width keeps the fixtures stable.
func (Parameters) IsEmpty ¶
func (p Parameters) IsEmpty() bool
IsEmpty reports whether no field is stated. An empty structure is omitted on the wire so the peer behaves as if none was supplied.
func (Parameters) SupportsTCP ¶
func (p Parameters) SupportsTCP() bool
SupportsTCP reports whether the bitmap names TCP in either role, as stated — see Parameters.EffectiveTransports for the version gate.