Of course. This is an excellent and specific question that gets to the heart of how mobile networks handle error conditions securely.
In short, the f5star (f5)* function in Milenage is used to generate a special Anonymity Key (AK), but only in the case of a synchronization failure. This key is used by the mobile device (UE/USIM) to securely inform the network that their sequence numbers are out of sync.
Let's break this down in more detail.
1. The Context: Normal Authentication and the f5 Function
First, we need to understand the normal, successful authentication process.
- Goal of Authentication: The network wants to verify the subscriber's identity, and the subscriber wants to verify they are connecting to a legitimate network.
- Sequence Number (SQN): To prevent replay attacks (where an attacker re-uses old authentication data), the network (AuC/HLR) and the subscriber's SIM card (USIM) both maintain a counter called a Sequence Number (SQN). For each new authentication, the network increments its SQN.
- Concealing the SQN: Sending the SQN in the clear would allow an attacker to track a user's location and activity. To prevent this, the SQN is masked (concealed) using an Anonymity Key (AK).
- The
f5 function: In a normal authentication attempt, the network uses the f5 function to generate this AK.
- Input: Shared secret key
K and a random challenge RAND.
- Output: Anonymity Key (
AK = f5(K, RAND)).
- The AUTN Token: The network sends an Authentication Token (
AUTN) to the phone. This token contains the concealed SQN: AUTN = (SQN ⊕ AK) || AMF || MAC.
When the USIM receives this, it independently calculates its own AK using the f5 function and the RAND it received. It then uses this AK to retrieve the original SQN and check if it's valid.
2. The Problem: Synchronization Failure
A synchronization failure happens when the USIM receives an AUTN and determines that the SQN sent by the network is invalid. This usually means the SQN is too old (i.e., lower than the one stored on the USIM), indicating a potential replay attack or that the network's counter has somehow fallen behind.
In this situation:
- The USIM rejects the authentication attempt.
- The USIM must securely tell the network, "We are out of sync. Here is my current SQN so you can reset your counter for me."
- The USIM cannot just send its own SQN (
SQN_USIM) in the clear for the same privacy reasons mentioned before. It must be concealed.
This is where f5star comes into play.
3. The Solution: The f5* Function
When a synchronization failure occurs, the USIM needs a key to conceal its own SQN_USIM in a failure message sent back to the network. It cannot use the AK generated by f5 because that key was derived from the potentially malicious challenge it just rejected. Using it would be a security risk.
Instead, the USIM uses the f5* function.
- Purpose: To generate a special Anonymity Key specifically for the re-synchronization process. Let's call this
AK_sync.
- Trigger: A synchronization failure (invalid SQN received from the network).
- Input: The same shared secret key
K and the RAND from the rejected challenge.
- Output: A new Anonymity Key for re-synchronization (
AK_sync = f5*(K, RAND)).
The USIM then constructs a re-synchronization token (AUTS) and sends it to the network.
AUTS = (SQN_USIM ⊕ AK_sync) || MAC-S
When the network (AuC/HLR) receives this AUTS, it knows a sync failure occurred. It then:
- Uses the original
RAND it sent and the user's K.
- Calculates
AK_sync for itself using the f5* function.
- Uses this
AK_sync to retrieve the SQN_USIM from the AUTS token.
- Resets its internal SQN for that subscriber to the value provided by the USIM and initiates a new, valid authentication attempt.
Summary Table: f5 vs. f5*
| Feature | f5 | f5* (f5star) |
|---|
| Primary Use | Generate the Anonymity Key (AK) for a normal authentication attempt. | Generate the Anonymity Key (AK_sync) for a re-synchronization message. |
| When is it used? | During every standard, successful authentication check. | Only when the USIM detects a synchronization failure (invalid SQN). |
| Purpose of its Output | To conceal the network's SQN in the AUTN token sent to the USIM. | To conceal the USIM's SQN_USIM in the AUTS token sent back to the network. |
| Why is it needed? | Protects user privacy by preventing tracking via the SQN. | Protects user privacy during an error-handling procedure and ensures the failure message is secure. |
Why Two Separate Functions?
Using two different functions (f5 and f5*) is a critical security design principle called Key Separation. You should never use the same cryptographic key for two different purposes. By having a separate function for the failure case, the security of the normal authentication process is isolated from the security of the re-synchronization process, preventing potential cross-protocol attacks.