Showing posts with label smart card. Show all posts
Showing posts with label smart card. Show all posts

Saturday, February 23, 2008

Create File with Java Card code

You should read
  • ETSI TS 102.226 (8.2.1.3.2.2.2 and 8.2.1.3.2.2.4) that explains the UICC access parameters. The Application is only granted to access files according UICC access parameters.
  • ETSI TS 102.241(8) that describes AdminFIleView objects and operation
  • Each file operation is mentioned at ETSI TS 102.222 (8)
2 different classes of file
  • Dedicated files DF (directories)
  • Elementary files EF (data files)
3 different types of elementary files
  • Transparent files
  • Linear fixed files
  • Cyclic files
Package : uicc.access

EF TAG
  1. File descriptor(TS 102.221 11.1.1.4.3)*
    • Tag = '82'
    • Length = '02' or '04'
    • value :
      • Data Coding ='21'
      • File Desc value :
        • No Information given = '20'
        • Transparent Structure ='41'
        • Linear Fixed = '42'
        • Cyclic = '46'
      • Record length = '0001' to '00FF'
      • Number of record = '01' to 'FE'
  2. File ID*
    • Tag = '83'
    • Length = '02'
  3. Life Cycle Status Information*
    • Tag = '8A'
    • Length = '01'
  4. Security attribute *
    • Tag Compact ='8A', Expanded = 'AB', Referenced ='8B'
    • Length = n
  5. File Size *
    • Tag = '80'
    • Length = n
  6. Short File Identifier
    • Tag ='88'
    • Length = '00' or '01'
  7. Proprietary
    • Tag = 'A5' or '85'
DF TAG
  1. File descriptor*
    • Tag = '82'
    • Length = '02'
  2. File ID*
    • Tag = '83'
    • Length = '02'
  3. DF Name(AID)
    • Tag = '84'
    • Length
    • Value 1-16 byte
  4. Life Cycle Status Information*
    • Tag = '8A'
    • Length = '01'
  5. Total File Size*
    • tag ='81'
    • length
  6. Security Atribute*
    • Tag Compact ='8C', Expanded = 'AB', Referenced ='8B'
    • Length = n
  7. Pin Status Template *
    • Tag = 'C6'
    • length
    • Length = n
  8. Data Coding Byte
    • Tag ='21'
  9. Proprietary
    • Tag = 'A5' or '85'


Thursday, February 21, 2008

Device Identities SCWS











CommandSourceDestination
Open ChannelUICCTerminal
Set Up Event ListUICCTerminal
Close ChannelUICCChannel x
Receive dataUICCChannel x
Send DataUICCChannel x
Get Channel StatusUICCTerminal
Event Download Data AvailableTerminalUICC
Event Download Channel StatusTerminalUICC

Wednesday, February 20, 2008

RECEIVE DATA

  1. Command details*
    1. command details tag = '81'
    2. length = '03' (1 byte)
    3. command number 01 - FE (1 byte)
    4. Type of Command ='42' (RECEIVE DATA)
    5. Command Qualifier : RFU
  2. Device identities*
    1. device identities tag = '82'
    2. Length = '02'
    3. Source Device identity = '81' --> UICC
    4. Destination Device Identity = '21'-'27' --> channel ID (PRE_ID _CHANNEL_BASE='20')
  3. Channel Data Length
    1. Channel Data Length Tag = '37'
    2. Length = '01'
    3. Channel data length
  4. Alpha Identifier
    1. Alpha identifier TAG = '05'
    2. Length = 0
    3. Alpha Identifier (TS 131 102)
  5. Icon Identifier
    1. Icon Identifier Tag
    2. Length = '02'
    3. Icon Qualifier
      1. bit 1, 0 = self explanatory, 1 = non self explanatory
      2. bit 2-8 =0 (RFU)
    4. Icon Identifier (TS 131 102)
  6. Text Attribute
    1. Text Attribute Tag = '50'
    2. Length
    3. Text formatting ( TS 123 040)
  7. Frame Identifier
    1. Frame Identifier Tag
    2. Length = '03'
    3. Identifier of Frame, the value is between '00' - '0F'
You don't need to remember the tag value if you use appendTLV function. All of the tag value are explained briefly in uicc.toolkit.ToolkitConstant library.

note :
* mark means mandatory

OPEN CHANNEL BIP TCP Server Mode

I have already posted BIP TCP client mode requirement before. Here are my little explanation for TCP Server mode.
  1. Command details*
    1. command details tag = '81'
    2. length = '03' (1 byte)
    3. command number 01 - FE (1 byte)
    4. Type of Command ='40' (OPEN CHANNEL)
    5. Command Qualifier : RFU
  2. Device identities*
    1. device identities tag = '82'
    2. Length = '02'
    3. Source Device identity = '81' --> UICC
    4. Destination Device Identity = '82' --> Terminal
  3. Alpha Identifier
    1. Alpha identifier TAG = '05'
    2. Length = 0
    3. Alpha Identifier (TS 131 102)
  4. Icon Identifier
    1. Icon Identifier Tag
    2. Length = '02'
    3. Icon Qualifier
      1. bit 1, 0 = self explanatory, 1 = non self explanatory
      2. bit 2-8 =0 (RFU)
    4. Icon Identifier (TS 131 102)
  5. Buffer Size*
    1. Buffer Size Tag = '39'
    2. Length = '02'
    3. Byte 3-4 = Buffer size, for example 1000 bytes = 03E8
  6. UICC/ Terminal Interface
    1. UICC/ Terminal Interface level tag = '3C'
    2. Length = '03'
    3. Transport Protocol Type = '03' (TCP,UICC in server mode)
    4. Port Number(2 bytes) = '0DBC' (3516)
  7. Text Attribute
    1. Text Attribute Tag = '50'
    2. Length
    3. Text formatting ( TS 123 040)
  8. Frame Identifier
    1. Frame Identifier Tag
    2. Length = '03'
    3. Identifier of Frame, the value is between '00' - '0F'
You don't need to remember the tag value if you use appendTLV function. All of the tag value are explained briefly in uicc.toolkit.ToolkitConstant library.

note :
* mark means mandatory

OPEN CHANNEL BIP TCP Client Mode

According to TS 102 223(6.6.27.2), the requirement for setting up Open Channel command in BIP TCP Client are
  1. Command details*
    1. command details tag = '81'
    2. length = '03' (1 byte)
    3. command number 01 - FE (1 byte)
    4. Type of Command ='40' (OPEN CHANNEL)
    5. Command Qualifier :
      • bit 1 : 0 = for Demand link establishment, 1 = immediate link establishment
      • bit 2 : 0 = no automatic reconnection, 1 = automatic reconnection
      • bit 3 : 0 = no background mode, 1 = immediate link establishment in background mode
      • bit 4-8 = RFU
  2. Device identities*
    1. device identities tag = '82'
    2. Length = '02'
    3. Source Device identity = '81' --> UICC
    4. Destination Device Identity = '82' --> Terminal
  3. Alpha Identifier
    1. Alpha identifier TAG = '05'
    2. Length = 0
    3. Alpha Identifier (TS 131 102)
  4. Icon Identifier
    1. Icon Identifier Tag
    2. Length = '02'
    3. Icon Qualifier
      1. bit 1, 0 = self explanatory, 1 = non self explanatory
      2. bit 2-8 =0 (RFU)
    4. Icon Identifier (TS 131 102)
  5. Bearer Description*
    1. Bearer Description Tag = '35'
    2. Length
    3. Bearer Type = '02' (GSM/3GPP) --> GPRS
    4. Bearer Parameter
      1. Precedence Class ( Priority) = '00'
      2. Delay Class = '00'
      3. Reability Class = '03'
      4. Peak Throughput '00'
      5. Mean Throughput = '00'
      6. PDP IP = '02'
  6. Buffer Size*
    1. Buffer Size Tag = '39'
    2. Length = '02'
    3. Byte 3-4 = Buffer size, for example 1000 bytes = 03E8
  7. Network Access Name
    1. Network Access Name Tag = '47'
    2. Length
    3. Network Access Name
  8. Other Data Destination Address (local)
    1. Other Data Destination Address Tag = '3E'
    2. Length = '05'
    3. Type of Address = '21' (IPv4)
    4. Address ( 4 byte , XX.XX.XX.XX)
  9. Login
    1. Text String Tag = '0D'
    2. Length
    3. Data Coding Scheme = null
    4. Text String = your username
  10. Password
    1. Text String Tag = '0D'
    2. Length
    3. Data Coding Scheme = null
    4. Text String = your password
  11. UICC/ Terminal Interface
    1. UICC/ Terminal Interface level tag = '3C'
    2. Length = '03'
    3. Transport Protocol Type = '02' (TCP,UICC in client mode)
    4. Port Number(2 bytes) = '00' '50' (80)
  12. Data destination address
    1. Data Destination Address Tag = '3E'
    2. Length = '05'
    3. Type of Address = '21' (IPv4)
    4. Address ( 4 byte , XX.XX.XX.XX)
  13. Text Attribute
    1. Text Attribute Tag = '50'
    2. Length
    3. Text formatting ( TS 123 040)
  14. Frame Identifier
    1. Frame Identifier Tag
    2. Length = '03'
    3. Identifier of Frame, the value is between '00' - '0F'
You don't need to remember the tag value if you use appendTLV function. All of the tag value are explained briefly in uicc.toolkit.ToolkitConstant library.

note :
* mark means mandatory

Friday, January 4, 2008

Declaration String to bytes variable in Smart Card Coding


/**

* This program is really useful for programmer who is so lazy

* to type word/ sentence in bytes when he/she codes in Smart card

*/



import java.lang.*;

/**

* @version 1.0

* @author kapulaga

*

*/

public class stringtobyte {



public stringtobyte(String variablename, String variablevalue)

{

int i;

System.out.print("byte[] "+variablename+"={");

for(i=0;i

{

if(i

System.out.print("'"+variablevalue.charAt(i)+"'"+",");

else

System.out.print("'"+variablevalue.charAt(i)+"'"+"};");

}



}





public static void main(String[] args) {

stringtobyte stb = new stringtobyte("variable","byte value");



}



}




Monday, November 19, 2007

CANNOT_PLAY_SCRIPT

If you get this error :
An internal error occurred during: "Launching baru".
Can't find resource for bundle java.util.PropertyResourceBundle, key CANNOT_PLAY_SCRIPT

Just restart your developer suit

It works for me :D

Friday, November 16, 2007

No String No Integer

I have just known that there is no integer and string in Smart Card program.
So what are the data type ?

  • byte
  • ByteString
  • short
We should be aware with memory management :)

Wednesday, November 14, 2007

doGet()

I wrote my first servlet code in Smart Card Web Server.
Firstly, here is my html code :




Username:





and this following code is part of my servlet code :

public void doGet(HttpCardServletRequest req, HttpCardServletResponse resp)
throws Exception {

try {

ByteString queryString = req.getQueryString();
if (queryString != null) {

byte[] hello = { 'h', 'e', 'l', 'l','o' ,' '};


ByteString temp=queryString.substring((short)5, queryString.length());

// set header
resp.setStatus(HttpCardServletResponse.SC_OK);
resp.setContentType(stringContainer
.getConstantString(HttpStringContainer.TEXT_PLAIN_KEY));

int length = hello.length+temp.length();

resp.setContentLength(length);
// write body

HttpCardServletOutputStream out = resp.getOutputStream();
out.write(hello,(short)0,(short)hello.length);
out.write(temp);

}
} catch (Exception e) {
resp.setStatus(HttpCardServletResponse.SC_BAD_REQUEST);
}

}
This is the capture of the result :

testing by typing such username
Hey, it works now :D