Skip to main content

Crate matter_crypto

Crate matter_crypto 

Source
Expand description

Matter session-establishment protocols.

§Scope

  • pase: Password Authenticated Session Establishment via SPAKE2+ (spec §3.10). Sans-IO PaseProver / PaseVerifier state machines, PBKDF2 setup-PIN derivation, HKDF session-key derivation, and constant-time confirmation-tag comparison.
  • case: Certificate Authenticated Session Establishment via SIGMA-I (spec §4.13). Sans-IO CaseInitiator / CaseResponder state machines, NOC chain validation via matter-cert, and session resumption (Sigma1 + Sigma2_Resume). Signing goes through the CaseSigner trait, so an HSM, TPM, or secure element can hold the operational key instead of this process.
  • operational: operational identity derivations (spec §4.3) — the Compressed Fabric Identifier, the operational IPK, and the group session/privacy keys and multicast address.
  • checkin: the ICD Check-In message codec (spec §4.18.2), the payload an intermittently-connected device sends a registered client when it briefly wakes.
  • aead: AES-128-CCM-128 AEAD helpers, used by CASE here and by matter-transport’s secured-message framing. Prefer SessionAead over the free functions on any path that encrypts/decrypts more than once per key, to avoid repeating AES key expansion per call.
  • error: the crate error type.

Both handshakes are sans-IO: they consume and produce message bytes, and the caller owns the transport. PASE and CASE are byte-checked against matter.js fixtures.

§Cryptographic discipline

This crate never implements primitives. AES, ECDH, ECDSA, SHA, HKDF, and HMAC come from ring. EC scalar/point arithmetic (which ring deliberately doesn’t expose) comes from p256. We implement only the Matter-defined protocols on top of those primitives.

Re-exports§

pub use aead::SessionAead;
pub use case::CaseCredentials;
pub use case::CaseMessageKind;
pub use case::CaseSessionKeys;
pub use case::CaseSessionOutput;
pub use case::LocalInfo;
pub use case::PeerInfo;
pub use case::ResumptionId;
pub use case::ResumptionRecord;
pub use case::Sigma1Outcome;
pub use error::Error;
pub use error::Result;
pub use operational::derive_compressed_fabric_id;
pub use operational::derive_group_privacy_key;
pub use operational::derive_group_session_id;
pub use operational::derive_operational_ipk;
pub use operational::group_multicast_ipv6;
pub use pase::pake_passcode_verifier;
pub use pase::PaseMessageKind;
pub use pase::PasePbkdfParams;
pub use pase::PaseProver;
pub use pase::PaseSessionKeys;
pub use pase::PaseVerifier;

Modules§

aead
AES-128-CCM-128 (16-byte key, 13-byte nonce, 16-byte tag) AEAD helpers.
case
Matter CASE (Certificate Authenticated Session Establishment) via SIGMA-I.
checkin
Matter Check-In message codec (Matter Core §4.18.2) — the payload an ICD sends unsolicited to a registered client when it briefly wakes. Reuses the crate’s AES-128-CCM AEAD and ring HMAC-SHA256; never implements primitives.
error
Error type for matter-crypto.
operational
Operational identity derivations (Matter Core Spec §4.3).
pase
Matter PASE (Password Authenticated Session Establishment) via SPAKE2+.

Structs§

CaseInitiator
Initiator-side CASE state machine (new-session and resumption paths).
CaseResponder
Responder-side CASE state machine (new-session path).
RingSigner
CaseSigner backed by the p256 crate’s RFC 6979 deterministic ECDSA.

Enums§

SignerError
Errors returned by a CaseSigner implementation.

Traits§

CaseSigner
Pluggable ECDSA-P256-SHA256 signer for CASE.
Signer
Canonical name for the ECDSA-P256-SHA256 signer trait outside CASE.

Functions§

random_bytes
Fill buf with cryptographically secure random bytes (ring SystemRandom).