Skip to main content

CaseResponder

Struct CaseResponder 

Source
pub struct CaseResponder { /* private fields */ }
Available on crate feature rustcrypto only.
Expand description

The device side of CASE: receives Sigma1, answers Sigma2, accepts Sigma3 (§4.14.2.3).

Implementations§

Source§

impl CaseResponder

Source

pub fn new(session_id: SessionId, session_params: Option<SessionParams>) -> Self

A responder that will listen on session_id and announce session_params.

Source

pub fn handle_sigma1<K: KeyStore>( &mut self, sigma1: &Sigma1<'_>, fabric: &Fabric, noc: &[u8], icac: Option<&[u8]>, keys: &mut K, ephemeral_random: &[u8; 32], responder_random: &[u8; 32], resumption_random: &[u8; 16], out: &mut [u8], ) -> Result<usize>

Handles a Sigma1 and writes the reply into out.

fabric is the one whose destinationId matched — found with FabricTable::find_by_destination_identifier, which is a search this function deliberately does not do: it needs the fabric table, and threading the whole table through here would make the protocol depend on how a node stores its fabrics.

ephemeral_random is 32 octets of entropy for the ephemeral key pair, resumption_random 16 for the new resumption ID.

Source

pub fn accept_sigma3<C: Config, const N: usize>( &mut self, sigma3: &Sigma3<'_>, fabrics: &FabricTable<C, N>, fabric: FabricIndex, at: Option<u32>, out: &mut [u8], ) -> Result<(CaseOutcome, usize)>

Validates a Sigma3 against the root of the fabric Sigma1 resolved, and writes the SigmaFinished status report (§4.14.2.3).

fabric is the index accept_sigma1 returned, and using any other is the mistake this exists to prevent: §4.14.2.3’s Validate Sigma3 checks the initiator’s certificate chain against this fabric’s trusted root, and a chain that verifies against another root is a chain from another administrator. Taking whichever root the table lists first works perfectly on a node with one fabric and refuses every peer on the second — as chain does not validate, which reads like a bad certificate and is not one.

at is the current Matter epoch-s, or None on a node without a clock (§6.4.5.1).

Source

pub fn handle_sigma3( &mut self, sigma3: &Sigma3<'_>, root: &MatterCertificate<'_>, at: Option<u32>, ) -> Result<CaseOutcome>

Handles a Sigma3, verifying the initiator’s chain and establishing the session.

root is the fabric’s trusted root certificate; at the current Matter epoch-s, or None on a node without a clock (§6.4.5.1). Prefer accept_sigma3, which takes the root from the fabric the handshake is on rather than from the caller’s memory.

Source

pub fn finished(&self, out: &mut [u8]) -> Result<usize>

The SigmaFinished a responder sends once Sigma3 has been accepted (Appendix D).

Source

pub const fn is_failed(&self) -> bool

Whether the exchange has failed and the responder must not be reused.

Source§

impl CaseResponder

Source

pub fn handle_sigma1_resumption( &mut self, sigma1: &Sigma1<'_>, previous: &ResumptionState, resumption_random: &[u8; 16], out: &mut [u8], ) -> Result<(usize, CaseOutcome)>

Handles a Sigma1 that asks for resumption, writing a Sigma2_Resume (§4.14.2.3).

previous is the remembered state the message’s resumptionID names — a lookup the caller does, for the same reason the fabric lookup is the caller’s.

If the MIC does not verify, this returns ErrorCode::IntegrityCheckFailed and the responder is still usable: the caller should fall back to CaseResponder::handle_sigma1 with the same message, which is exactly what §4.14.2.2 requires — “the information included in the Sigma1 with Resumption message SHALL be processed as a Sigma1 message without any resumption fields.”

Trait Implementations§

Source§

impl Debug for CaseResponder

Source§

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

Formats the value using the given formatter. 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.