Friday, January 25, 2013

SIM (Subscriber Identity Module)

A subscriber identity module or subscriber identification module (SIM) is an integrated circuit that securely stores the IMSI and other related parameters used to identify and authenticate subscribers on mobile telephony devices. A typical SIM card is shown below.
There are two types of SIM cards are there, Native Cards and Java Cards. To generate a byte code in a Native card we can use Wireless Markup Language (WML). Java cards will run Java Scripts and are high cost.
There are two unique parameters for a SIM. Known as IMSI (International Mobile Subscriber Identity) and ICCID (Integrated Circuit Card Identifier).

IMSI (15 digits)

A unique identification associated with all GSM, UMTS and LTE network mobile phone users. It is stored as a 64 bit field in the SIM. It is also used for acquiring other details of the mobile in the HLR or as locally copied in the VLR. The first 3 digits are the Mobile Country Code (MCC), and is followed by the Mobile Network Code (MNC). The remaining digits are the Mobile Subscription Identification Number (MSIN).
We use IMSI for location updates, for charging, etc.  And IMSI is a network internal parameter. So we need to hide it from external parties to avoid any fraud. To access that another key is required (known as ADM). 

ICCID (19 digits)

Each SIM is internationally identified by its ICCID. First two digits named as Major industry identifier (MII), 89 for telecommunication purposes. Other digit representation is given in the image below. Last 12 digits will be defined by the mobile operator in a way they wanted.  For example Etisalat included SIM manufactured vendor (1 digit), date of manufacture, serial number and a random number. We can provide a format to the vendor and they will produce SIM cards according to that format.

Other important parameters

•    MSISDN - Mobile Station International Subscriber Directory Number (the telephone number to the SIM card)
•    Ki – Authentication key
•    KC  - Ciphering key
•    PIN - Personal Identification Number
•    PUK - Personal Unblocking Code
•    ADM Code – To view encrypted details of the SIM

Why MSISDN not unique to a SIM card? If you lose your SIM card you can obtain another SIM card with same MSISDN. In such situation we can remove existing mapping of IMSI, ICCID with MSISDN and redefine a new ICCID for the MSISDN. This is not possible if MSISDN is unique for a SIM.
When a mobile communicates with the Base Station the data will be encrypted using KC as a security measure. That will make it difficult for others to listen to the calls, etc.

Before SIM goes to the customer

According to our previous orders we receive SIM batches from the vendors. They come with their details. To define SIM cards in the HLR we need to upload the corresponding file (Which contains IMSI, ICCID, KC, Ki, etc.).

How the authentication happens

When you switch on the phone a Network Attach Request comes with IMSI. HLR will generate a random number and pass it to the mobile. Then both HLR and mobile independently generate SRES according to the A8 Algorithm using that random number and Ki. It will be passed into VLR where both SRESs will be compared. If the match mobile can attach to that mobile network. If the mobile is using a SIM of a different network SRESs will be different and attachment fails.

Why a Random number instead of a fixed number?

If we use a unique number, generated SRES will be same at all the times. And an outsider may track it and identify Ki so they will be able to make copies of SIM cards. But with the use of random number it is difficult to do so.

What if your SIM locked?

If our SIM gets locked and we may try to unlock it using a PIN. We may fail up to three times and after that SIM will be locked permanently. By entering PUK code we can unlock SIM. That’s why some operators provide the PUK code along with the SIM card.

Inside the SIM

With the use of a SIM card reader we can view parameter of a SIM. To get the correct IMSI we have to interchange each pair of digits named as IMSI in the SIM. Ki and IMSI visible. PIN numbers are invisible. We need ADM code to view them. Our contact list is named as Aggregated Dialing number which can store 250 records each consist of 26Bytes. We can also set Fixed dialing numbers and if we do so we can only dial those numbers using the SIM. Service provider name can be changed too. We can also define VAS applications inside to a SIM. If we are to change internal parameter we have to give them in Hexadecimal format.