matter-crypto
Matter protocol session establishment and the key derivations around it — PASE (Password Authenticated Session Establishment) via SPAKE2+, CASE (Certificate Authenticated Session Establishment) via SIGMA-I, operational identity derivations, the ICD check-in codec, and the AES-CCM AEAD the secured-message layer uses. Part of the matter-rust workspace.
Scope
PASE — spec §3.10
- Sans-IO state machines (
PaseProver,PaseVerifier) — drive bytes through method-per-message-type APIs; caller owns the transport. - SPAKE2+ math over P-256 with Matter's M and N constants.
- PBKDF2 setup-PIN derivation; HKDF session-key derivation.
- Constant-time confirmation tag comparison via
subtle. - Byte-for-byte verified against matter.js for three handshake scenarios (negotiation, known-params, max-iterations).
CASE — spec §4.13
- Sans-IO
CaseInitiator/CaseResponderstate machines. - SIGMA-I math: ephemeral P-256 ECDH, mutual ECDSA signatures, AES-CCM-128 encrypted blobs.
- NOC chain validation via
matter-cert::CertificateChain::validate. - Pluggable signing via the
CaseSignertrait — wire your own HSM/TPM/secure-element by implementing one method. - Session resumption: Sigma1 + Sigma2_Resume fast path. The caller
drives record lookup via the
Sigma1Outcomeenum (sans-IO purity). - Byte-for-byte verified against matter.js for three scenarios: new session, resumption accepted, and resumption declined.
Operational identity — spec §4.3
- Compressed Fabric Identifier and operational IPK derivation.
- Group session key, group privacy key, and the group multicast IPv6 address.
ICD check-in — spec §4.18.2
- The Check-In message codec: the payload an intermittently-connected device sends a registered client when it briefly wakes.
AEAD
- AES-128-CCM-128 helpers, used by CASE here and by
matter-transport's secured-message framing.SessionAeadkeeps the expanded AES key across calls; prefer it over the free functions on any path that encrypts or decrypts more than once per key.
Status
0.3.1, published on crates.io. PASE and CASE feature-complete, and
validated against real silicon through the higher-level crates.
Stability: a 0.x crate, so a minor bump may break API.
[]
= "0.3"
Minimal example
use ;
Minimal example — CASE
use ;
use ;
/// Build one side's operational identity.
///
/// `noc` is a `MatterCertificate` from matter-cert (issued by this fabric's
/// CA chain), `signer` holds the NOC private key, `ipk` is the fabric's
/// 16-byte Identity Protection Key, and `rcac_public_key` is the fabric root
/// CA's SEC1-uncompressed public key. Commissioning (matter-commissioning)
/// produces all four.
/// Drive the 3-message Sigma1/2/3 handshake. Both peers are in-process here;
/// in a real deployment the caller pipes each message across the network.
Cryptographic primitives
This crate never implements crypto primitives. Underlying math:
ring— SHA-256, HMAC, HKDF, PBKDF2, ECDSA-verify.p256— P-256 scalar/point arithmetic for SPAKE2+ (ring deliberately doesn't expose these).subtle— constant-time comparison for PASE confirmation tags.aes+ccm— AES-CCM-128 for CASE encrypted blobs (ring 0.17 does not expose AES-CCM).
Cross-verification
PASE messages produced by our PaseProver and PaseVerifier are
byte-identical to matter.js's output for the same inputs. CI runs
this verification on every PR against three captured handshake
scenarios.
CASE messages are byte-identical to matter.js's output for the same
inputs, on all three captured scenarios in test-vectors/case/:
new session (Sigma1/2/3), resumption accepted (Sigma1 →
Sigma2_Resume), and resumption declined (Sigma1 → full Sigma2/3).
License
Apache 2.0. See LICENSE.