skip to content

In TKIP, how is each frame's RC4 key built, and how does the TKIP sequence counter let a receiver reject replayed frames?

level: middleimportance: should knowfreq 28%

answer

  1. new RC4 key for every frame
  2. temporal key plus address plus counter
  3. counter must rise, gaps allowed
  4. one counter per priority channel

basics

~20 s

Each TKIP frame gets its own RC4 key, mixed from the temporal key, transmitter address and a 48-bit sequence counter (TSC). The receiver silently drops a frame whose TSC is not higher than the last accepted on that priority channel.

solid answer

~30 s

TKIP replaces WEP's 'IV stuck on the shared key' with a mixing function: the temporal key, the transmitter address and the 48-bit TKIP sequence counter (TSC) produce a different RC4 key for every frame, so the IV is no longer a bare key prefix. The TSC travels in the frame's 8-octet IV field and is also a replay counter: the receiver checks it first and silently drops a frame unless it is higher than the last accepted one. Gaps are allowed, so lost frames do not break the link. The standard keeps a separate TSC for each QoS priority channel.

go deeper

for a junior

Recall that every TKIP frame has its own RC4 key and a rising counter, and that frames with a stale counter are dropped.

for a middle

Name the mixing inputs, place the 48-bit TSC in the 8-octet IV field and give the per-frame order of checks: TSC, ICV, then MIC.

for a senior

Read logs correctly: a counter or ICV drop is silent and only a Michael failure counts toward the countermeasure rule, so the two need different alerting.

for a principal

Judge a legacy cipher by which guarantees it gained: TKIP added replay protection and per-frame key separation while integrity stayed the weak link.

## The problem the mixing function solves In WEP the per-frame RC4 key is the 24-bit IV placed in front of the shared key. Because the IV is sent in the clear and the shared key never changes, related keys come in a pattern an analyst can exploit; the WEP topic covers that. TKIP had to remove the pattern without changing the RC4 hardware, so it changes only what is fed to RC4. ## What goes into the key - **The temporal key (TK):** the 128-bit encryption key carved out of the pairwise transient key when the session is set up. It stays the same until the next rekey. - **The transmitter address:** which makes the two directions of a link, though they share one TK, use different per-frame keys. - **The TSC:** a counter that rises with every frame, so each frame's key differs from the last. NIST describes the mixing as two-phase and its result as a new key for every frame. The output is called the WEP seed, and the unchanged WEP machinery then encrypts with it. ## What a TKIP frame carries | Field | Size | Role | |---|---|---| | TKIP IV field (with the TSC) | 8 octets, of which the TSC is 6 | Sent in the clear, tells the receiver the counter value | | Data | variable | Encrypted payload | | Michael MIC | 8 octets | Integrity of data, addresses and priority | | ICV | 4 octets | CRC-32 error check from the WEP step | The sizes are the Linux header constants `IEEE80211_TKIP_IV_LEN`, `MICHAEL_MIC_LEN` and `IEEE80211_TKIP_ICV_LEN`. The MIC and the ICV sit inside the encrypted part. ## The receive order and the replay rule 1. The receiver checks the TSC. If it is not in order, the frame is silently dropped. 2. It checks the ICV. A wrong ICV also means a silent drop. 3. It reassembles the fragments into the original data unit and verifies the Michael MIC. 4. Only if the MIC is correct is the frame accepted and the TSC replay counter updated. A wrong MIC starts the countermeasure logic covered with Michael. "In order" means the counter must always increase, though gaps are allowed. A replayed copy of an accepted frame carries a counter that is no longer higher, so it fails step 1. QoS adds one wrinkle: the standard defines a separate TSC for each of the QoS channels (traffic identifiers), so ordering is tracked per priority, not per station. ```pseudocode # receiver state: last_accepted_tsc[c] for each priority channel c on TKIP frame f received on priority channel c: if f.tsc <= last_accepted_tsc[c]: drop f silently # replay or reorder: no MIC failure raised elif icv_invalid(f): drop f silently else: msdu = reassemble(f) # simplified: fragments handled together if michael_invalid(msdu): report MIC failure # counts toward the countermeasure rule else: accept msdu last_accepted_tsc[c] = f.tsc ``` ## Observing it hostapd keeps statistics for Michael failures (per station, `dot11RSNAStatsTKIPLocalMICFailures` and `dot11RSNAStatsTKIPRemoteMICFailures`), but its source marks the TKIP replay and ICV error statistics as TODO. The silent drops in steps 1 and 2 therefore leave no hostapd counter, while a Michael failure does, so the two kinds of event need different monitoring. ## What the counter does not do - It is not integrity. It orders frames; it does not prove their content. That is Michael's job. - It does not remove TKIP's other weaknesses. The mixing function repairs the key construction, but RC4 and the weak Michael MIC remain. - It is not a reason to keep TKIP: CCMP has its own packet number for the same purpose, and it replaced TKIP.

  • Why is a sequence counter alone not enough to protect a TKIP frame?
    The counter orders frames but says nothing about their content, and the TSC is sent in the clear in the frame. Detecting modification is Michael's job, with the ICV as an error check. The receiver also updates its counter only after the MIC has been verified, so a frame that fails Michael does not advance it.
  • Why does the TSC check allow gaps instead of demanding exactly the next value?
    Frames are lost on a radio link all the time. A strictly consecutive rule would make every lost frame look like an attack, so the rule is only that the counter must keep increasing.

  • Says the TKIP IV is a counter glued to a static key, as in WEP.
  • Thinks the TSC is secret and encrypted, so a bystander cannot read it.
  • Claims one sequence counter covers every QoS priority of a station.
  • Believes the TSC check also detects modified frames.
  • Says a frame with a valid MIC is accepted even if its counter is not higher.