Skip to content

Conversation

aarvay
Copy link
Contributor

@aarvay aarvay commented Oct 10, 2025

Add AES-CCM (Counter with CBC-MAC) authenticated encryption and CBC-MAC message authentication code implementations to the standard library.

AES-CCM combines CTR mode encryption with CBC-MAC authentication as specified in NIST SP 800-38C and RFC 3610. It provides authenticated encryption with support for additional authenticated data (AAD).

CBC-MAC is a simple MAC construction used internally by CCM, specified in FIPS 113 and ISO/IEC 9797-1.

Includes comprehensive test vectors from RFC 3610 and NIST SP 800-38C.

@aarvay aarvay force-pushed the aes-ccm-implementation branch from 422bf7a to a1fda3b Compare October 10, 2025 09:51
@jedisct1
Copy link
Contributor

For the counter, you can use std.crypto.modes.ctrSlice.

Feel free to copy/paste anything you need from the implementations at https://gist.github.com/jedisct1/140251214fbf3938e5c0196a7fb37f8f and https://gist.github.com/jedisct1/4227b9c5026fb095a0f007e4fad25a34

@aarvay aarvay force-pushed the aes-ccm-implementation branch from a1fda3b to 52c45af Compare October 10, 2025 11:32
@aarvay aarvay force-pushed the aes-ccm-implementation branch 2 times, most recently from 99ec817 to 8c3d7e4 Compare October 11, 2025 20:19
@aarvay aarvay marked this pull request as ready for review October 12, 2025 07:07
@aarvay aarvay force-pushed the aes-ccm-implementation branch from 8c3d7e4 to 5153ced Compare October 13, 2025 11:39
Add AES-CCM (Counter with CBC-MAC) authenticated encryption and
CBC-MAC message authentication code implementations to the standard
library.

AES-CCM combines CTR mode encryption with CBC-MAC authentication as
specified in NIST SP 800-38C and RFC 3610. It provides authenticated
encryption with support for additional authenticated data (AAD).

CBC-MAC is a simple MAC construction used internally by CCM, specified
in FIPS 113 and ISO/IEC 9797-1.

Includes comprehensive test vectors from RFC 3610 and NIST SP 800-38C.
Implements CCM* mode per IEEE 802.15.4 specification, extending
AES-CCM to support encryption-only mode when tag_len=0. This is
required by protocols like ZigBee, Thread, and WirelessHART.

Changes:
- Allow tag_len=0 for encryption-only mode (no authentication)
- Skip CBC-MAC computation when tag_len=0 in encrypt/decrypt
- Correctly encode M'=0 in B0 block for CCM* mode
- Add Aes128Ccm0 and Aes256Ccm0 convenience instances
- Add IEEE 802.15.4 test vectors and CCM* tests
@aarvay aarvay force-pushed the aes-ccm-implementation branch 2 times, most recently from 91f9efb to 9e700f4 Compare October 13, 2025 11:46
@jedisct1
Copy link
Contributor

Looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants