module Matter::Session::SecureMessage

Overview

Secure message encoder/decoder for Matter protocol Uses AES-128-CCM for authenticated encryption

Extended Modules

Defined in:

matter/session/secure_message.cr

Constant Summary

MIC_LENGTH = 16

MIC (Message Integrity Check) length in bytes

NONCE_LENGTH = 13

Nonce size for AES-CCM in Matter (13 bytes)

PRIVACY_NONCE_LENGTH = 13

Privacy nonce for unencrypted header (13 bytes)

Instance Method Summary

Instance Method Detail

def build_aad(packet_header_bytes : Bytes) : Bytes #

Build Additional Authenticated Data (AAD) for AES-CCM AAD = packet header (unencrypted portion)


[View source]
def build_nonce(source_node_id : UInt64, message_counter : UInt32, security_flags : UInt8 = 0_u8) : Bytes #

Build nonce for AES-CCM encryption/decryption Format: source_node_id (8 bytes) | message_counter (4 bytes) | security_flags (1 byte)


[View source]
def decrypt(context : SecureContext, encrypted_payload : Bytes, message_counter : UInt32, packet_header : Codec::MessageCodec::PacketHeader, crypto : Crypto::CryptoBase = Crypto::StandardCrypto.new) : Bytes #

Decrypt a message payload using session context


[View source]
def decrypt_with_params(key : Bytes, encrypted_payload : Bytes, source_node_id : UInt64, message_counter : UInt32, session_id : UInt16, security_flags : UInt8 = 0_u8, crypto : Crypto::CryptoBase = Crypto::StandardCrypto.new) : Bytes #

Decrypt with explicit parameters (for testing)


[View source]
def encrypt(context : SecureContext, payload : Bytes, packet_header : Codec::MessageCodec::PacketHeader, crypto : Crypto::CryptoBase = Crypto::StandardCrypto.new) : Bytes #

Encrypt a message payload using session context


[View source]
def encrypt_with_params(key : Bytes, payload : Bytes, source_node_id : UInt64, message_counter : UInt32, session_id : UInt16, security_flags : UInt8 = 0_u8, crypto : Crypto::CryptoBase = Crypto::StandardCrypto.new) : Bytes #

Encrypt with explicit parameters (for testing)


[View source]