Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to work with SIM cards (Installing applet)

I have a smart card with the following ATR:

ATR = 3B 9E 94 80 1F 42 80 31 00 73 BE 21 10 66 54 59 53 04 4C 25 CF.

Based on the output of atr-parse.appspot.com I found that it is a MCI (Mobile Communication Company of Iran) SIM card.

These are the info that I gained from Historical Bytes :

(compact TLV data object)

Tag: 3, Len: 1 (card service data byte)

Card service data byte: 0

  • EF.DIR and EF.ATR access services: by GET RECORD(s) command

  • Card with MF

Tag: 7, Len: 3 (card capabilities)

Selection methods: 190

  • Record number supported

  • Short EF identifier supported

  • Implicit DF selection

  • DF selection by file identifier

  • DF selection by path

  • DF selection by full DF name

Data coding byte: 33

  • Behaviour of write functions: proprietary

  • Value 'FF' for the first byte of BER-TLV tag fields: valid

  • Data unit in quartets: 1

Command chaining, length fields and logical channels: 16

  • Logical channel number assignment: by the card

  • Maximum number of logical channels: 1

Tag: 6, Len: 6 (pre-issuing data)

Data: 54 59 53 04 4C 25 "TYS.L%"

As you see above it is mentioned that the card has a MF.

The problem is I can't do anything with this card. In the first step I want to list its contents. I took a look at TS 11.11, TS 102.221,TS 131.102 and TS 151.011 specifications.

As far as I understand from above documents the system file of the card consist of an Master File that its AID is 3F00 and Some DF-s and EF-s. For example base on this below table of TS 151.011 specification I tried to select some DF-s :

enter image description here

These are the results :

Connected to RTP CCID USB Reader 0
ATR: 3B 9E 94 80 1F 42 80 31 00 73 BE 21 10 66 54 59 53 04 4C 25 CF

> APDU
> A0 A4 04 00 02 5F 30
< 6A 82

> APDU
> A4 A4 04 00 00
< 6E 00

> APDU
> A0 A4 04 00 00
< 67 00

> APDU
> 00 A4 04 00 00
< 61 13

> APDU
> 00 C0 00 00 13
< 6F 11 84 09 A0 00 00 00 62 03 01 08 01 A5 04 9F 65 01 FF
< 90 00

> APDU
> 00 A4 04 00 09 A0 00 00 00 62 03 01 08 01
< 61 13

> APDU
> A0 A4 04 00 09 A0 00 00 00 62 03 01 08 01
< 6E 00

> APDU
> 00 A4 04 00 09 A0 00 00 00 62 03 01 08 01
< 61 13

> APDU
> 00 C0 00 00 13
< 6F 11 84 09 A0 00 00 00 62 03 01 08 01 A5 04 9F 65 01 FF
< 90 00

> APDU
> 00 A4 04 00 02 3F 00
< 6A 82

> APDU
> A0 A4 04 00 02 3F 00
< 6E 00

As you see above I failed all of them and I could find the AID of ISD only.

I tried to list contents with GlobalPlatformPro tool also, but it seems that the card not support Initial Update APDU command :

C:\Users\User\Desktop\today>java -jar gp.jar -visa2 -key 47454D5850524553534F53414D504C45 -unlock -list -v -d -i
# Detected readers from SunPCSC
[*] RTP CCID USB Reader 0
SCardConnect("RTP CCID USB Reader 0", T=*) -> T=0, 3B9E94801F4280310073BE211066545953044C25CF
SCardBeginTransaction("RTP CCID USB Reader 0")
Reader: RTP CCID USB Reader 0
ATR: 3B9E94801F4280310073BE211066545953044C25CF
More information about your card:
    http://smartcard-atr.appspot.com/parse?ATR=3B9E94801F4280310073BE211066545953044C25CF

A>> T=0 (4+0000) 00A40400 00
A<< (0019+2) (249ms) 6F118409A00000006203010801A5049F6501FF 9000
Auto-detected ISD AID: A00000006203010801
***** Card info:
A>> T=0 (4+0000) 80CA9F7F 00
A<< (0000+2) (73ms) 6A86
GET DATA(CPLC) returned SW: 6A86
NO CPLC
***** CARD DATA
A>> T=0 (4+0000) 80CA0066 00
A<< (0000+2) (81ms) 6E00
NO CARD DATA
***** KEY INFO
A>> T=0 (4+0000) 80CA00E0 00
A<< (0000+2) (82ms) 6E00
A>> T=0 (4+0000) 00CA00E0 00
A<< (0000+2) (60ms) 6E00
GET DATA(Key Information Template) not supported
A>> T=0 (4+0008) 80500000 08 FE44F8E8DF60349B 00
A<< (0000+2) (61ms) 6D00
pro.javacard.gp.GPException: INITIALIZE UPDATE failed SW: 6D00
        at pro.javacard.gp.GlobalPlatform.check(GlobalPlatform.java:1092)
        at pro.javacard.gp.GlobalPlatform.openSecureChannel(GlobalPlatform.java:398)
        at pro.javacard.gp.GPTool.main(GPTool.java:371)

C:\Users\User\Desktop\today> 

I want to know what's wrong? How I can install java card applets on this SIM card?

Note that I already worked with Java Card successfully,but I am totally confused about these kind of SIM cards. I appreciate any one could shed any light on this issue. Regards.

like image 830
Ebrahim Ghasemi Avatar asked Apr 01 '15 09:04

Ebrahim Ghasemi


2 Answers

If you obtain the card from market (not your own development card) it's almost impossible to install applet on it since you don't know the keyset of its ISD. It is made so in order to grant only the card issuer and the card owner (MNO) full control over the content of SIM card.

Another possible explanation is that not all SIM card fully support GP nor Javacard. There are existing SIM card that only comply with 2G/3G/4G standard (GSM 11.11, 11.14, 102.222 etc) to be able for its user to authenticate to network only. Such SIMcard could own STK application as well , but it's not necessarily implemented as javacard applet.

like image 163
pradithya aria Avatar answered Nov 14 '22 22:11

pradithya aria


As per your last log of Initialize Update command, there can be some possibilities: 1. Scp02/Scp03 is not supported on your card, less possibility if it supports GP. 2. ISD has not configured with SCP supported parameters. 3. There is another secure channel previously ongoing at the same logical channel, on card.

As per my view there can be last 2 possibilities.

To check the 3rd one, you should try to start Scp02 with following set of steps: 1. Send cold reset (PowerON-Power-OFF) 2. Select ISD 3. Send Initialize Update command.

If it doesn't work then you need the information of ISD application parameters and from these parameters you can identify that is ISD supports SCP02/03 or not?

These parameters can be like: 'C9 04 81 02 XX YY' (here XX-supported SCP and YY-parameter 'i' value for SCP ).

like image 32
Anurag Bajpai Avatar answered Nov 14 '22 20:11

Anurag Bajpai