Skip to main content

Channel

Struct Channel 

Source
pub struct Channel { /* private fields */ }
Available on crate feature 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

Source

pub const fn new() -> Self

A channel with nothing in flight.

Source

pub fn attestation_challenge(&self) -> Option<&SymmetricKey>

§6.2.3’s attestation challenge from the PASE session in progress or just established.

Source

pub const fn is_established(&self) -> bool

Whether §5.5’s channel is currently held by an established PASE session.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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>
where C: Config, K: KeyStore, R: Rng,

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.

Trait Implementations§

Source§

impl Debug for Channel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Channel

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.