pub struct Channel { /* private fields */ }rustcrypto only.Expand description
The secure channel of one node: §5.5’s admission rules, PASE, CASE, and session installation.
One at a time by construction — §5.5’s first rule is that a node runs one handshake at a time, so there is one slot for each kind and the type cannot represent two.
Implementations§
Source§impl Channel
impl Channel
Sourcepub fn attestation_challenge(&self) -> Option<&SymmetricKey>
pub fn attestation_challenge(&self) -> Option<&SymmetricKey>
§6.2.3’s attestation challenge from the PASE session in progress or just established.
Sourcepub const fn is_established(&self) -> bool
pub const fn is_established(&self) -> bool
Whether §5.5’s channel is currently held by an established PASE session.
Sourcepub const fn reopen(&mut self)
pub const fn reopen(&mut self)
Re-admits PASE, which is what opening a commissioning window means (§5.5).
A node commissioned once is not admitting anybody: the channel stays shut from the moment
PASE succeeded until something says otherwise. Without this a node can never be
commissioned twice — OpenCommissioningWindow succeeds, the node advertises, and every
PBKDFParamRequest comes back Busy.
Sourcepub fn closed(&mut self, session: SessionId)
pub fn closed(&mut self, session: SessionId)
Releases the channel when the PASE session on it closes (§5.5).
“until session establishment fails or the successfully established PASE session is
terminated on the commissioning channel” — and a commissioner is under no obligation to
say so politely, which is why Received::SessionClosed
and a closed commissioning window both end up here.
Sourcepub fn release(&mut self)
pub fn release(&mut self)
Releases the channel without naming a session.
§5.5 releases it when “the successfully established PASE session is terminated on the
commissioning channel” — and a commissioner is under no obligation to terminate it
politely. The CHIP controller calls StopPairing, evicts its own session, says nothing,
and opens a fresh PASE five seconds later; a node holding the channel answers Busy for
ever, which looks exactly like a device ignoring its own open commissioning window.
So a device that can see commissioning has finished — an open window with a disarmed
fail-safe is the honest reading — says so here. Channel::closed is the tidier path
and applies when the session id is known.
Sourcepub const fn deadline(&self) -> Option<Instant>
pub const fn deadline(&self) -> Option<Instant>
When §5.5’s sixty seconds runs out on the handshake in flight, if one is.
A deadline like any other, so it goes where the loop’s other deadlines go rather than
into a special case: None means nothing is waiting.
Sourcepub fn poll(&mut self, now: Instant, window: &RefCell<CommissioningWindow>)
pub fn poll(&mut self, now: Instant, window: &RefCell<CommissioningWindow>)
Drives the deadlines §5.5 puts on a handshake in flight.
Call it from the run loop. A handshake that was abandoned holds the channel until it is reaped, and one unanswered request would otherwise lock a device out of commissioning for good.
Sourcepub fn on_message<C, const S: usize, const X: usize, const N: usize, K, R>(
&mut self,
stack: &mut Messaging<C, S, X>,
opcode: u8,
body: &[u8],
ctx: &ChannelContext<'_, C, N, K, R>,
buffers: &mut ChannelBuffers<'_>,
) -> Result<ChannelReply>
pub fn on_message<C, const S: usize, const X: usize, const N: usize, K, R>( &mut self, stack: &mut Messaging<C, S, X>, opcode: u8, body: &[u8], ctx: &ChannelContext<'_, C, N, K, R>, buffers: &mut ChannelBuffers<'_>, ) -> Result<ChannelReply>
Answers one Secure Channel message (§4.11’s opcodes).
reply is where the answer is written. frame and evict are the two buffers
Messaging::install_session needs when a session has to be evicted to make room —
§4.11.1.1’s report is framed under the evicted session’s own keys, so it has to be built
before that session goes away, and the caller sends it afterwards.
An opcode this channel does not serve comes back with no reply at all, rather than an error: a message for a handshake that is not running tells a stranger nothing about the node, and a node that answered would say which handshake it is in the middle of.