Skip to Content
oxcrypto

CBC-MAC

Authenticate fixed-length messages with CBC-MAC.

from oxcrypto.mac.cbc_mac import CBC_MAC

key = CBC_MAC.AES128.generate_key()
tag = CBC_MAC.AES128.mac(key, b"exactly sixteen!")

CBC-MAC is ISO/IEC 9797-1 MAC algorithm 1 with padding method 1: a trailing partial block is padded with zero bytes, and the empty message yields an all-zero tag. Tags can be forged when messages of different lengths share a key, so use CBC-MAC only for messages of one fixed length known to both parties and CMAC otherwise.

It is offered over the CMAC ciphers plus Speck96 and Threefish-512/1024.