ProtoCore v0.0.2
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
aes_cmac.h File Reference

AES-128-CMAC (RFC 4493 / NIST SP800-38B) one-shot MAC. More...

#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Macros

#define PC_AES_CMAC_LEN   16
 AES-128-CMAC output length (one AES block).
 

Functions

void pc_aes_cmac (const uint8_t key[16], const uint8_t *msg, size_t msg_len, uint8_t mac[PC_AES_CMAC_LEN])
 Compute the AES-128-CMAC of msg under key (RFC 4493).
 

Detailed Description

AES-128-CMAC (RFC 4493 / NIST SP800-38B) one-shot MAC.

The CMAC construction over the AES-128 block cipher: derive two subkeys K1/K2 from AES-128(key, 0^128), CBC-MAC the message, and XOR the final block with K1 (message a whole number of blocks) or the 10*-padded last block with K2. SMB 3.x uses it as the message-signing MAC when the negotiated signing algorithm is AES-CMAC (MS-SMB2 §3.1.4.1, dialects 3.0 / 3.0.2 / 3.1.1); it is a general primitive, not SMB-specific.

On ESP32/Arduino the AES-128 block runs on the mbedTLS context (hardware AES accelerator); on the native host build it uses the shared table-free software AES (crypto/cipher/aes_block.h). Pure, zero heap. Verified against the RFC 4493 §4 worked examples.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file aes_cmac.h.

Macro Definition Documentation

◆ PC_AES_CMAC_LEN

#define PC_AES_CMAC_LEN   16

AES-128-CMAC output length (one AES block).

Definition at line 29 of file aes_cmac.h.

Function Documentation

◆ pc_aes_cmac()

void pc_aes_cmac ( const uint8_t  key[16],
const uint8_t *  msg,
size_t  msg_len,
uint8_t  mac[PC_AES_CMAC_LEN] 
)

Compute the AES-128-CMAC of msg under key (RFC 4493).

Parameters
keythe 16-byte AES-128 key.
msgthe message (may be null iff msg_len is 0).
msg_lenmessage length in bytes (0 is valid - the empty-message CMAC).
macreceives the 16-byte tag.

Definition at line 110 of file aes_cmac.cpp.