How does WPA2's CCMP use AES in counter mode and CBC-MAC to give each data frame both confidentiality and integrity with one key?
answer
- two passes, one engine
- tag first, then keystream
- K=16, M=8, L=2
- first counter block hides the tag
basics
~20 sCCMP runs AES-CCM with one 128-bit temporal key: CBC-MAC over the protected header fields and the plaintext yields an 8-octet tag, then counter mode encrypts the body and the tag. The receiver decrypts, recomputes the tag and drops mismatches.
solid answer
~50 sCCMP is AES in **CCM mode** (RFC 3610, NIST SP 800-38C) with the 802.11 parameters K=16 (128-bit key), M=8 (8-octet MIC) and L=2, which leaves a 13-octet nonce. For each frame it builds a nonce from the priority, the transmitter address and the packet number, and additional authenticated data (AAD) from the MAC header. **Integrity:** AES-CBC-MAC runs over a first block holding the nonce and length, then the AAD, then the plaintext body, and is truncated to 8 octets. **Confidentiality:** AES in counter mode generates keystream blocks from the nonce and a block counter; block 0 encrypts the tag into the MIC, blocks 1 onward are XORed with the body, so no padding is needed. The receiver reverses it: decrypt, recompute CBC-MAC, compare, and release nothing if they differ. One key serves both jobs because CCM was designed for exactly that.
code
pseudocode · 10 lines# CCMP encapsulation of one MPDU: AES-CCM with K=16, M=8, L=2
PN = PN + 1 # never reused under this TK
ccmp_hdr = PN0, PN1, reserved, ExtIV|KeyID, PN2, PN3, PN4, PN5
nonce = flags(priority), A2, PN # 13 octets
aad = masked(FrameControl), A1, A2, A3, masked(SeqCtl) [, A4] [, TID]
T = CBC_MAC_AES(TK, B0(nonce, len), aad, plaintext)[0:8]
for i in 1..n:
C[i] = P[i] XOR AES(TK, counter_block(nonce, i))
MIC = T XOR AES(TK, counter_block(nonce, 0))[0:8]
send(mac_header, ccmp_hdr, C, MIC)go deeper
Remember the expansion, Counter Mode with CBC-MAC Protocol, and that one 128-bit AES key does both encryption and the integrity check.
Walk through both passes: CBC-MAC over B0, AAD and plaintext gives an 8-octet tag; counter blocks from the nonce encrypt the body and, via S0, the tag.
Explain what the receiver checks and in what order, why a failed MIC releases nothing, and how the nonce ties each tag to the sender and packet number.
Be ready to justify CCMP's design trade: truncated 8-octet tag and serial CBC-MAC in exchange for low overhead and one key, and when a policy should move to a 256-bit suite.
## CCM in one sentence **CCM** — Counter with CBC-MAC, specified in RFC 3610 and NIST SP 800-38C — is an AES mode that produces both a ciphertext and an authentication tag from a single key. **CCMP** is the 802.11 protocol that wraps CCM around a data frame: it decides what goes into the mode's inputs and where the outputs sit in the frame. NIST SP 800-97 describes it as the long-term 802.11 solution for confidentiality and integrity, designed around a single key for both jobs, small per-frame overhead and no patent encumbrance. ## The inputs CCMP feeds to CCM For every MPDU, CCMP hands CCM four things: - the **temporal key (TK)**, 128 bits — the K=16 parameter; - a **nonce** of 13 octets (CCM's nonce is 15-L octets, and 802.11 uses L=2), built from a priority/flags octet, the transmitter address A2 and the 48-bit **packet number (PN)**; - the **additional authenticated data (AAD)**, built from the MAC header with a few changeable bits masked — authenticated, but not encrypted; - the **plaintext frame body**, the payload to be both authenticated and encrypted. The tag length is M=8, so the MIC on the air is 8 octets. With L=2 the length field is two octets, so a single message must be shorter than 2^16 octets, which comfortably fits any 802.11 MPDU body. ## Step 1 — CBC-MAC builds the tag 1. CCM formats a first block, **B0**, holding a flags octet, the nonce and the message length. 2. It appends the AAD (prefixed with its length) and then the plaintext, split into 16-octet blocks and zero-padded internally for the MAC computation only. 3. It runs AES-CBC over those blocks with the TK; the final AES output, truncated to M=8 octets, is the tag **T**. Because the nonce sits in B0, the tag depends on the packet number and the transmitter address as well as on the header and the payload. Changing any of them — a different PN, a different priority, a flipped payload bit — produces a different tag. ## Step 2 — counter mode encrypts the body and the tag 1. CCM forms **counter blocks** A0, A1, A2 and so on, each holding a flags octet, the same nonce and a block counter i. 2. It encrypts each counter block with AES under the same TK, producing keystream blocks S0, S1, S2 and so on. 3. The plaintext is XORed with S1, S2 and onward — the ciphertext is exactly as long as the plaintext, so **no padding** reaches the air. 4. The tag is XORed with the first M octets of **S0**; the result is the **MIC** that CCMP appends after the encrypted body. The frame on the air is therefore: MAC header, 8-octet CCMP header, encrypted body, 8-octet MIC — 16 octets of overhead per MPDU. ## On receipt 1. The receiver rebuilds the AAD from the header it received and the nonce from the priority, A2 and the PN in the CCMP header. 2. It regenerates S0, S1 and onward, decrypts the body and recovers T from the MIC. 3. It recomputes CBC-MAC over B0, the AAD and the decrypted plaintext and compares. If they differ, CCM returns **no plaintext** and the frame is dropped. 4. Only then does the receiver check that the PN is higher than the last one it accepted, which is the replay test. ## Why one key is safe for both jobs here Reusing one key for two different functions needs care, which is why CCM prescribes exactly how its two uses of AES are formatted: the CBC-MAC's B0 and the counter blocks carry different flags, and S0 is reserved for the tag rather than the message. The general theory of modes and nonces is covered with cipher modes; for CCMP the practical points are: | Property | How CCMP gets it | |---|---| | Confidentiality | AES counter-mode keystream XORed with the body | | Integrity of body and header | 8-octet CBC-MAC tag over AAD and plaintext | | Binding to sender and order | Nonce built from A2, priority and PN | | Low overhead | No padding; 8-octet header and 8-octet MIC | Unlike TKIP, which mixed a fresh per-packet RC4 key from its temporal key, CCMP needs no per-packet keys: the nonce does that work. TKIP is retired; CCMP replaced it as the baseline.
- Why is CCMP's MIC only 8 octets when AES produces 16-octet blocks?CCM allows the tag to be truncated to M octets, and 802.11 chose M=8 to keep per-frame overhead small, one of the design goals NIST SP 800-97 lists for CCM. A frame whose tag does not verify is simply discarded. Where a policy wants a longer tag, CCMP-256 and GCMP-256 carry a 16-octet MIC.
- What is CCMP's per-frame overhead, and why is there no padding?Sixteen octets per MPDU: the 8-octet CCMP header and the 8-octet MIC. Counter mode encrypts by XORing a keystream with the plaintext, so the ciphertext is exactly as long as the plaintext; the zero padding used inside the CBC-MAC computation never appears on the air.
- Does CCM authenticate the plaintext or the ciphertext?The plaintext. CBC-MAC runs over B0, the AAD and the plaintext body before counter-mode encryption, and the receiver recomputes it over the decrypted plaintext. The tag itself is then hidden by XOR with keystream block S0, so it is not visible on the air in the clear.
- CCMP encrypts with AES-CBC and pads every payload to 16-octet blocks.
- CCMP derives a separate encryption key and integrity key for every frame.
- The CCMP MIC is HMAC-SHA1, the same as the EAPOL-Key MIC.
- Counter mode alone stops tampering because altered ciphertext decrypts to garbage.
- CCMP's tag is sent in the clear after the encrypted body.