Hello! Welcome to your fifth lesson in the "Cellular Network Foundations" module.
Introduction
In our last lesson, we focused on subscriber identifiers, distinguishing between the permanent IMSI/SUPI and the temporary TMSI/GUTI. A key point was that these permanent identifiers are stored on the SIM card, and in 5G, the USIM is responsible for encrypting the SUPI into a SUCI to protect your identity. This highlighted that the SIM card is much more than a passive piece of plastic; it's an active participant in network security.
Today, we'll pull back the curtain on this tiny but powerful component. This lesson addresses the learning outcome: Describe the role of the SIM/USIM card in authentication and key storage. We will explore what a SIM card truly is, what critical secrets it holds, and how it functions as the root of trust for your device in the cellular network.
For your goal of understanding telecommunication hacking, this is a critical piece of the puzzle. The SIM card is the vault where the "crown jewels" of subscriber identity and authentication are kept. Understanding its design and function is fundamental to grasping attacks like SIM cloning, and it lays the groundwork for understanding how the core authentication process works—and how it can be attacked.
The SIM as a Secure Computer
First, let's update our mental model of the SIM card. It's not just a memory chip; it's a complete, self-contained computer called a smart card.
How do SIM Cards work? - SIMtrace
The YouTuber LiveOverflow has a great series on SIM card hacking. Let's watch a short clip where he introduces this very concept.
Watch from 01:35 to 02:38. The main takeaway is that the SIM card is a tiny computer that your phone's main processor communicates with.
This tiny computer has its own processor, operating system, and different types of memory (ROM for the OS, RAM for execution, and EEPROM for persistent data storage like your keys and contacts).
The term SIM (Subscriber Identity Module) originally referred to the smart card used in 2G/GSM networks. The modern cards used in 3G, 4G, and 5G networks are technically called UICC (Universal Integrated Circuit Card) running a USIM (Universal Subscriber Identity Module) application. The USIM is backward compatible but supports more advanced features and stronger cryptographic algorithms necessary for modern networks. For simplicity, we often use "SIM" or "USIM" interchangeably to refer to the card itself.
This video provides a more detailed look at the internal components and the evolution from SIM to USIM.
Watch from 00:01 to 03:20. Pay attention to the distinction between SIM and USIM and the description of the internal components like the processor, EEPROM, RAM, and ROM.
The Secrets Within: Key Storage
So, what sensitive information does this secure computer hold? The data is stored in a hierarchical file system, much like directories on a Linux system, consisting of a Master File (MF), Dedicated Files (DFs), and Elementary Files (EFs).
Let's return to the previous video to understand how this file system is structured.
Watch from 03:20 to 06:27. You don't need to memorize the file names, but understand the concept of a hierarchical structure (MF -> DF -> EF) where the actual data resides in the Elementary Files.
Within this file system, the USIM stores several pieces of data critical for security.

These are:
- K (Secret Key): This is a 128-bit secret key, sometimes called
Ki. It is unique to each individual USIM card and is the primary secret shared between the subscriber and the home network's authentication center (AuC). - OPc (Operator Code): This key is derived from a master Operator Key (
OP) that is specific to the mobile network operator. In older systems, theOPkey was the same for many SIMs, which was a security risk. If theOPkey and a subscriber'sKwere compromised, it could weaken the security of other subscribers. Modern systems compute a uniqueOPcfor each SIM by combiningKandOP. This means that even if one SIM's secrets are exposed, the blast radius is limited to that single subscriber. StoringOPcinstead ofOPis a crucial security enhancement. - SQN (Sequence Number): This is a counter that the USIM and the network's HSS/AuC maintain. Each time you authenticate, the SQN increments. The USIM will reject any authentication challenge from the network that uses an old (lower) SQN. This is a vital defense against replay attacks, where an attacker captures a valid authentication challenge and tries to reuse it later.
The following reading explains the importance of using OPc and the role of the SQN. Given your interest in attack vectors, pay close attention to the potential exploits discussed.
This article from Nick vs Networking provides a clear, practical explanation of these concepts from a security perspective.
First, read the section titled 'OPc vs OP in SIM keys'. Focus on why deriving OPc improves security. Then, read the section '5G / LTE Milenage Security Exploit – Dumping the Vectors', specifically the subsection 'Why the SQN is important for Milenage Security'. This will explain its role in preventing replay attacks.
Besides these keys, the USIM also stores the IMSI/SUPI we discussed previously, along with network configuration data and, optionally, user data like contacts and SMS messages.
The Guardian at the Gate: The USIM in Authentication
The most important security principle of the USIM is that the secret keys (K and OPc) are designed to never leave the card. You cannot simply read them out. The USIM acts as a secure "black box" or crypto-processor.
The phone's baseband processor doesn't perform the authentication cryptography itself. Instead, it acts as a messenger, passing challenges from the network to the USIM and returning responses from the USIM to the network.
How do SIM Cards work? - SIMtrace
Let's see this 'black box' principle in action.
Watch from 02:38 to 03:32. This clip clearly explains that the phone asks the SIM card to perform cryptographic operations, and the private key never leaves the chip.
This secure design is protected by several mechanisms:
- PIN Protection: The PIN you enter when you turn on your phone is not for the phone itself; it's for the USIM. The USIM's operating system will refuse to perform critical functions (like authentication) until the correct Card Holder Verification (CHV) code—the PIN—is provided.
- File Access Control: The USIM's internal operating system enforces strict access control rules on its file system. A file containing a key might have an access condition of "NEVER," meaning it cannot be read from the outside at all. Other files might require a PIN (CHV) or special administrator keys.
- Physical Security: Smart cards are built with some level of tamper resistance to make physical extraction of the keys (e.g., by probing the chip) extremely difficult and expensive.
Your experience with Wireshark will make this next part particularly interesting. It shows how the phone "talks" to the SIM to verify the PIN. The communication happens via a command-response protocol using APDUs (Application Protocol Data Units).
How do SIM Cards work? - SIMtrace
This clip from the same LiveOverflow video demonstrates PIN verification by intercepting the communication between the phone and the SIM using a tool called SIMtrace and analyzing it in Wireshark.
Watch from 03:32 to 07:59. Notice how the phone sends a VERIFY CHV command (the APDU for PIN verification) and the SIM's internal logic handles the attempt counter and blocking mechanism. This is a perfect illustration of the SIM as an independent computer enforcing its own security rules.
The authentication process, which we will detail in the next lesson, follows this same command-response pattern. In essence, the network challenges the USIM to prove it possesses the correct keys, and the USIM provides a valid response without ever revealing the keys themselves.

Conclusion
You now have a solid understanding of the USIM's central role as the secure anchor of your mobile identity. It's not just a placeholder for your phone number but an active, intelligent guardian of your most critical secrets.
Key Takeaways:
- A SIM/USIM card is a smart card—a secure, self-contained computer with its own CPU, OS, and memory.
- It securely stores crucial cryptographic material in a protected file system, most importantly the unique secret key K, the derived operator key OPc, and the anti-replay SQN.
- The fundamental security principle is that secret keys never leave the USIM. It acts as a "black box" that performs cryptographic calculations on demand.
- The USIM enforces its own security policies, such as requiring a PIN to unlock its functions and controlling access to its internal files.
- It actively participates in authenticating you to the network by processing challenges and generating responses, proving its identity without revealing its secrets.
Preview of the Next Lesson:
In this lesson, we saw a high-level view of the challenge-response flow. In our next and final lesson of this module, we will dive into the specifics of this process. The topic will be: Explain the high-level purpose of the Authentication and Key Agreement (AKA) protocol. We'll connect all the pieces—the identifiers, the keys stored on the USIM, and the network's authentication center—to see how they work together to establish a secure connection.