Matter message frame encode/decode.
Handles the full message wire format: plaintext message header (AAD) followed by protocol header + payload (encrypted for active sessions) and a 16-byte MIC tag.
Summary
Functions
Build a 13-byte AES-CCM nonce per Matter spec.
Decode a plaintext message frame.
Decode an encrypted message frame. The plaintext header is decoded first, then the remaining ciphertext (minus the 16-byte MIC) is decrypted.
Encode a plaintext message (used during PASE setup, session_id = 0).
Encode an encrypted message. The message header becomes AAD, the protocol header + payload are encrypted, and the 16-byte MIC is appended.
Types
@type message() :: %{ header: MatterEx.Protocol.MessageCodec.Header.t(), proto: MatterEx.Protocol.MessageCodec.ProtoHeader.t() }
Functions
@spec build_nonce(byte(), non_neg_integer(), non_neg_integer()) :: binary()
Build a 13-byte AES-CCM nonce per Matter spec.
<<security_flags::8, message_counter::little-32, source_node_id::little-64>>
Decode a plaintext message frame.
Decode an encrypted message frame. The plaintext header is decoded first, then the remaining ciphertext (minus the 16-byte MIC) is decrypted.
@spec encode( MatterEx.Protocol.MessageCodec.Header.t(), MatterEx.Protocol.MessageCodec.ProtoHeader.t() ) :: iodata()
Encode a plaintext message (used during PASE setup, session_id = 0).
@spec encode_encrypted( MatterEx.Protocol.MessageCodec.Header.t(), MatterEx.Protocol.MessageCodec.ProtoHeader.t(), binary(), binary() ) :: iodata()
Encode an encrypted message. The message header becomes AAD, the protocol header + payload are encrypted, and the 16-byte MIC is appended.