MatterEx.Crypto.Session (matter_ex v0.3.1)

Copy Markdown View Source

AES-128-CCM authenticated encryption for Matter session security.

Matter uses AES-128-CCM with:

  • 16-byte key
  • 13-byte nonce
  • 16-byte tag (128-bit MIC)

Summary

Functions

Decrypt ciphertext with AES-128-CCM.

Encrypt plaintext with AES-128-CCM.

Functions

decrypt(ciphertext, tag, key, nonce, aad \\ <<>>)

@spec decrypt(binary(), binary(), <<_::128>>, <<_::104>>, binary()) ::
  {:ok, binary()} | :error

Decrypt ciphertext with AES-128-CCM.

Returns {:ok, plaintext} on success, :error if authentication fails.

encrypt(plaintext, key, nonce, aad \\ <<>>)

@spec encrypt(binary(), <<_::128>>, <<_::104>>, binary()) :: {binary(), binary()}

Encrypt plaintext with AES-128-CCM.

Returns {ciphertext, tag} where tag is 16 bytes.