ssltls1.2smartcardapdusim-card

How to establish a TLS coonection in TLS-PSK mode between a USIM sim card as client and a server?


I want to establish a tls connection between my sim card and a server in TLS-PSK mode. to achive this, as far as I understood, First I have to send a push command to open a BIP channel, then establish a CAT_TP link by sending another push command and then sim card will start the TLS handshake. So first I want to send a push command to my sim card to open a BIP channel. To do this, the push command will be OPEN CHANNEL command. But first I'm testing this process by sending the OPEN CHANNEL command to sim card via sim card reader to see how it works. I have a sample file which I'm following that first sends an envelope SMS-PP with the following content:

81488346 \
    84 44\ ;Connection parameter tag
    81 03 014001\ ;Command details TLV
    82 02 8182\ ;Device identities TLV
    35 01 03\ ;Bearer description TLV: default
    39 02 0514\ ;Buffer size TLV
    47 14 13696E7465726E65742D656E7472657072697365\ ;Network Access Name
    0D 07 xxxxxxxxxxxxxx\ ;login name 
    0D 07 xxxxxxxxxxxxxx\ ;password
    3C 03 021964\ ; UICC/terminal interface port number
    3E 05 xxxxxxxxxx ;IP address

in sample file it ciphers the above content by sim card's keys and it's RAM TAR value and sends the ciphered data by an envelope command like this:

Command     : 80 C2 00 00  8A 
  Input Data   : D1 81 87 02  02 82 81 06  02 80 01 8B  7D 40 05 81  
               : 12 50 F3 96  F6 22 22 22  22 22 22 22  6D 02 70 00  
               : 00 68 15 16  39 12 12 00  00 01 F0 BD  C0 49 B4 0C  
               : EB A9 7C 4B  04 32 17 BE  A7 2F DA AC  70 93 36 73  
               : 83 FD AC 64  CA 9B 34 9C  2B E6 31 24  A0 D5 11 09  
               : 00 3E E3 F5  43 4B 55 77  98 E5 08 40  A4 CE A9 52  
               : 3E E1 38 6B  44 AC 73 1E  3B CD 49 32  92 B2 C3 22  
               : 25 02 68 90  FD F5 06 23  97 0D BD 5B  1D DE 25 F1  
               : FD 4C 75 C8  37 AC B0 15  05 25

Then it fetches the push sms via a FETCH command and after that get the terminal response with TERMINAL RESPONSE command to see if everything went ok. and finally fetches the open channel with the FETCH command and it says once OPEN CHANNEL is done, card sends CLIENT HELLO to the server to start the TLS handshake. Now I want to implement this but at the first step, where I should send the envelope, I expect to get 9146 as status word which means everything was ok. but I get 6200 which means "State of non-volatile memory is unchanged". Why do I get this respnse? And basically what is the proper way to open a BIP channel and then stablish a CAT-TP link?


Solution

  • You should first send the TERMINAL PROFILE command. With this command, you'll let the UICC know what the terminal is capable of. In this command, you should indicate that the terminal is capable of handling PROACTIVE commands. You can read more about this in ETSI TS 102223