CMAC & Poly1305: Block-Cipher MACs
Compare CMAC and Poly1305 as alternatives to hash-based MACs.
CMAC & Poly1305: Block-Cipher MACs is a free Cryptology Academy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Cryptology Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
What Is a MAC?
A Message Authentication Code (MAC) takes a key and a message and produces a tag. The tag proves the message has not been tampered with and was produced by someone who holds the key.
HMAC vs Block-Cipher MACs
HMAC uses a hash function as its primitive. CMAC and Poly1305 instead use block ciphers or polynomial arithmetic. Block-cipher MACs avoid hash-function dependency and integrate naturally with AES hardware.
CMAC Construction
CMAC (Cipher-based MAC) is defined in NIST SP 800-38B. It pads the message to a block boundary, derives two subkeys K1/K2 from the cipher, XORs them into the final block, then runs CBC mode without storing intermediate ciphertext.
CMAC Subkey Derivation
K1 = AES_K(0^128) left-shifted by 1 bit, XORed with a constant if the MSB was 1. K2 = K1 similarly shifted. These subkeys bind the final partial block securely against length-extension.
Poly1305 Overview
Poly1305 is a one-time authenticator designed by Daniel Bernstein. It evaluates a polynomial over the prime 2^130-5, treating the message as polynomial coefficients and using a one-time key pair (r, s).
Poly1305 Math
Tag = (sum of (m_i * r^i) mod 2^130-5) + s mod 2^128. The key r is clamped to 22 specific bits to prevent timing attacks. s is a 16-byte one-time addition mask.
ChaCha20-Poly1305
Poly1305 is almost always paired with ChaCha20. ChaCha20 generates the one-time (r, s) from the stream cipher keystream, making the combined AEAD scheme provably secure and extremely fast on ARM/mobile CPUs.
AES-GCM vs AES-CMAC
AES-GCM authenticates using GHASH, a polynomial MAC over GF(2^128). AES-CMAC is simpler and used in IEEE 802.11i (WPA2) and TLS 1.2 cipher suites. GCM provides both encryption and authentication in one pass.
Performance Comparison
Poly1305 on ARM Cortex-A achieves ~1 cycle/byte using NEON intrinsics. AES-CMAC requires one AES block operation per 16-byte block. For bulk data, Poly1305 outperforms CMAC on hardware without AES-NI.
Security Properties
CMAC is existentially unforgeable under chosen-message attack assuming AES is a pseudorandom permutation. Poly1305 is information-theoretically secure given a truly random one-time key — forgery probability is at most 8*ceil(L/16)/2^106.
Use Cases
CMAC: WPA2, S/MIME, filesystem integrity. Poly1305: TLS 1.3 via ChaCha20-Poly1305, WireGuard VPN, Signal Protocol, Noise Protocol Framework. Both are widely deployed in high-security modern systems.
Quick Check
Which MAC is used in ChaCha20-Poly1305 AEAD?
Recap
You have learned CMAC's CBC-based construction and Poly1305's polynomial arithmetic. Both are constant-time, secure MACs used in real-world protocols. Next: TLS/HTTPS and how all these primitives compose.
Frequently asked questions
Is the “CMAC & Poly1305: Block-Cipher MACs” lesson free?
Yes — the full text of “CMAC & Poly1305: Block-Cipher MACs” is free to read here on the web, and the Cryptology Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Cryptology Academy course, upgrade to CoddyKit PRO.
What will I learn in “CMAC & Poly1305: Block-Cipher MACs”?
Compare CMAC and Poly1305 as alternatives to hash-based MACs. You practise Cryptology Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Cryptology Academy?
No prior experience is required. Cryptology Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “CMAC & Poly1305: Block-Cipher MACs” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Cryptology Academy lesson?
Yes. Every Cryptology Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- MAC Concepts & Length-Extension Attacks
- HMAC Construction & Security Proof
- HMAC in APIs: Request Signing
- CMAC & Poly1305: Block-Cipher MACs