Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 26 variants InvalidParameter, InvalidSignatureOrTag, SessionNotFound, SessionExpired, Busy, Codec(Error), InvalidScalar, ConfirmationTagMismatch, UnexpectedMessage { expected: PaseMessageKind, got: PaseMessageKind, }, PinDerivationFailed, KeyDerivationFailed, PbkdfIterationsTooLow(u32), PbkdfIterationsTooHigh { iterations: u32, max: u32, }, PbkdfSaltLengthInvalid(usize), HandshakeIncomplete, InvalidPeerNocChain(Error), FabricIdMismatch { peer: u64, local: u64, }, PeerNodeIdMismatch(u64, u64), EphemeralKeyGenerationFailed, EncryptedBlobDecryptionFailed, EncryptionFailed, PeerSignatureInvalid, ResumptionMacMismatch, Rng, SigningFailed(SignerError), UnexpectedCaseMessage { expected: CaseMessageKind, got: CaseMessageKind, },
}
Expand description

All errors matter-crypto can produce in M3 (PASE). M4 (CASE) will extend this enum; #[non_exhaustive] keeps that addition non-breaking.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

InvalidParameter

Spec §3.10.5 status code: peer’s parameter was malformed or out of range.

§

InvalidSignatureOrTag

Spec §3.10.5 status code: peer’s signature or confirmation tag did not validate.

§

SessionNotFound

Spec §3.10.5 status code: referenced session does not exist.

§

SessionExpired

Spec §3.10.5 status code: referenced session has expired.

§

Busy

Spec §3.10.5 status code: peer is busy.

§

Codec(Error)

TLV codec error propagated from matter-codec.

§

InvalidScalar

SPAKE2+ scalar was zero or out of range after sampling/reduction.

§

ConfirmationTagMismatch

Confirmation tag did not match in constant-time compare.

We never tell the peer which tag failed — that itself would be a side-channel. Local-only abort.

§

UnexpectedMessage

Caller invoked a state-machine method that doesn’t match the current expected message (e.g., handle_pake3 before handle_pake2).

Fields

§expected: PaseMessageKind

The next message kind the state machine was expecting.

§got: PaseMessageKind

The kind the caller tried to feed.

§

PinDerivationFailed

PIN-to-w0/w1 derivation failed.

§

KeyDerivationFailed

Generic HKDF/KDF operation failed (e.g., ring returned an error for an output-length or expand call that should succeed for all valid inputs).

Used by operational identity derivations such as crate::derive_compressed_fabric_id.

§

PbkdfIterationsTooLow(u32)

PBKDF iteration count below the Matter spec minimum (1000).

§

PbkdfIterationsTooHigh

PBKDF iteration count above the accepted ceiling.

The iteration count is peer-controlled and is fed directly into PBKDF2-HMAC-SHA256 (one HMAC pass per iteration). A malicious or spoofed PASE responder could advertise an inflated count (up to u32::MAX) to force the commissioner into billions of HMAC rounds — a single-threaded CPU denial-of-service per handshake. We reject anything above the Matter spec’s published maximum (100000) before any key derivation runs.

Fields

§iterations: u32

The (rejected) iteration count advertised by the peer.

§max: u32

The maximum iteration count we accept.

§

PbkdfSaltLengthInvalid(usize)

PBKDF salt length outside [16, 32] bytes per Matter spec §3.10.3.

§

HandshakeIncomplete

finish() called before the handshake completed all phases.

§

InvalidPeerNocChain(Error)

Peer’s NOC chain failed validation against the trusted RCAC roots.

§

FabricIdMismatch

Peer’s NOC carried a FabricId attribute that does not match the FabricId we expected (i.e., the peer is on a different fabric).

Fields

§peer: u64

FabricId carried by the peer’s NOC.

§local: u64

FabricId we expected (from our own credentials).

§

PeerNodeIdMismatch(u64, u64)

Peer’s NOC carried a NodeId attribute that does not match the NodeId we expected.

§

EphemeralKeyGenerationFailed

Ephemeral P-256 keypair generation failed (RNG failure or repeated zero scalars).

§

EncryptedBlobDecryptionFailed

AEAD decryption of an encrypted blob (Sigma2 or Sigma3 ciphertext) failed — corrupt ciphertext, wrong key, or wrong nonce.

§

EncryptionFailed

AEAD encryption failed — cipher initialisation rejected the key, or the underlying AES-CCM encrypt call failed. Not expected in practice for the spec-bounded key and message sizes.

§

PeerSignatureInvalid

Peer’s ECDSA signature over the SIGMA transcript did not verify.

§

ResumptionMacMismatch

Resumption MAC tag (sigma2_resume_mic / sigma3_resume_mic) did not verify in constant time.

§

Rng

Secure random generation failed.

§

SigningFailed(SignerError)

CaseSigner returned a SignerError.

§

UnexpectedCaseMessage

Caller fed a CASE state machine a message that doesn’t match its current expected-inbound kind (e.g., calling handle_sigma2 before start has been invoked).

A separate variant from Error::UnexpectedMessage keeps M3 PASE callers unchanged while surfacing the correct crate::case::CaseMessageKind.

Fields

§expected: CaseMessageKind

The message kind the state machine was waiting for.

§got: CaseMessageKind

The kind the caller tried to supply.

Trait Implementations§

Source§

impl Debug for Error

Source§

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

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

impl Display for Error

Source§

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

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

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for Error

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

§

impl UnwindSafe for Error

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.