Mobile Application based on (U)SIM Java Card Applet
Technologies
Bantry
Patrick Biget CNAM 17th of December 2007
CNAM 17-Dec-2007 Bantry Technologies Ltd. 16 Dec 2007
25 Ballsbridge Terrace, Ballsbridge, Dublin 4, Ireland Tel: +353 (0)1 6642930 / Fax: +353 (0)1 6642933 www.bantry-technologies.com
Slide 1
Presentation Overview
SIM Cards & GSM Networks
SIM Technology
SIM Card Applications
SIM Toolkit Technology
Java Card Enabler for SIM Card Applications
Java Card SIM API
Demonstration (tools and cards) Questions & Answers
Bantry Technologies Ltd. 16 dc. 2007 Mobile Applications based on (U)SIM Java Card Applets Slide
SIM Card & GSM Networks
Technologies
Bantry
SIM Technology (3GPP TS 11. 11)
CNAM 17-Dec-2007 Bantry Technologies Ltd. 16 Dec 2007
25 Ballsbridge Terrace, Ballsbridge, Dublin 4, Ireland Tel: +353 (0)1 6642930 / Fax: +353 (0)1 6642933 www.bantry-technologies.com
Slide 3
Overview
Introduction to GSM Introduction to the SIM card
Functional role in the GSM Network Physical characteristics
SIM Card Services
Data management Security Content data
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
Introduction to GSM
History of GSM Services Provided by GSM Architecture of GSM Networks
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
History of GSM (1/3)
Analog cellular telephone systems experienced rapid growth in Europe (early 1980s) Each country developed its own system incompatible with everyone elses Consequences
mobile equipment were limited within national boundaries very limited market for each system (no possible economies of scale)
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
History of GSM (2/3)
Creation of the Groupe Spcial Mobile (GSM) Proposed system had to meet certain criteria:
Good subjective speech quality Low terminal and service cost Support for international roaming Ability to support handheld terminal Support for range of new services and facilities Spectral efficiency ISDN compatibility
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
History of GSM (3/3)
1989: GSM responsibility transferred to ETSI
(European Telecommunication Standards Institute)
1990: Publication of the GSM specs phase I 1991: Starting of commercial service 1993: 36 GSM networks in 22 countries 1995: 114 GSM networks in 66 countries 1998: 304 GSM networks in 120 countries 2001: 445 GSM networks in 170 countries 2006: 700 GSM networks in 218 countries Over 2 billions GSM subscribers (June 2006)
Bantry Technologies Ltd. 16 dc. 2007 Mobile Applications based on (U)SIM Java Card Applets Slide
Services Provided by GSM
Telephony Services (voices services)
Basic GSM voice telephony service
Bearer Services (data services)
Facsimile Service Short Message Service Data Exchange Service (CSD, GPRS)
Supplementary Services
Call Forward Call Barring (roaming) Others like caller identification, call waiting, multiparty conversations
Bantry Technologies Ltd. 16 dc. 2007 Mobile Applications based on (U)SIM Java Card Applets Slide
Architecture of GSM Networks
SIM ME BTS SIM ME BTS SIM ME Mobile Station EIR AuC Network Subsystem BSC HLR VLR PSTN ISDN MSC
Base Station Subsystem
MSC = Mobile services Switching Center SIM = BTS Subscriber = Base Identity Transceiver PSTN Module = Station Public Switched Telephone Network HLR = Home Location Register EIR = Equipment Identity Register ME BSC = Mobile = BaseEquipment Station ISDN Controller = Integrated Services Digital Network VLR = Visitor Location Register AuC =Authentication Center
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
10
Mobile Station
The Mobile Station is composed of
The Mobile Equipment (ME) The Subscriber Identity Module (SIM)
The SIM card allows the user to get access to the subscribed services irrespective of a specific terminal Both components are uniquely identified
ME through the IMEI (International Mobile Equipment Identity) SIM through the IMSI (International Mobile Subscriber Identity)
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
11
Base Station Subsystem
The Base Station Subsystem is composed of
The Base Transceiver Station The Base Station Controller
Base Transceiver Station
Houses the radio transceivers that define a cell Handles the radio-link protocols with the Mobile Station
Base Station Controller
Manages the radio resources for one or more BTSs (radio-channel setup, frequency hopping and handovers)
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
12
Network Subsystem (1/3)
Central Component: Mobile services Switching Center (MSC)
Acts like a normal switching node (PSTN or ISDN) Provides functionalities to handle mobility
Registration Authentication Location updating Handovers Call routing to roaming subscribers
Provides the connection to the fixed networks (PSTN or ISDN)
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
13
Network Subsystem (2/3)
Home Location Register (HLR)
Administrative information on each subscriber of the local GSM network Current location of the mobile Logically one single HLR per GSM network
Visitor Location Register (VLR)
Selected administrative information of each subscriber currently located in the geographical area controlled by the VLR
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
14
Network Subsystem (3/3)
Equipment Identity Register (EIR)
Contains a list of all valid ME on the network ME is invalid if:
It has been reported stolen Its type is not approved
Each ME is identified by its IMEI
Authentication Center (AuC)
Contains a copy of the secret key stored in each SIM card Used for authentication and encryption over the radio channel
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
15
Introduction to the SIM Card
Functional role in the GSM Network
Personal mobility Security services Download of other services
Physical characteristics
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
16
Role of the SIM Card
Personal mobility
Hold the users subscription details to make any mobile phone his/her personal phone
Security services
Hold the secrets necessary to prove that the user is the one he/she claims to be (and optionally to cipher the communications)
Download of other services
More recently, the SIM card environment has been enhanced to let the user download on his/her SIM card his/her preferred mobile services
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
17
Personal Mobility
Subscription details are stored in the card
IMSI: unique identifier of the subscriber Ki: secret key for authentication
Other subscriber-related information can be stored in the card
Address book Language preferences And much more information
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
18
Security Services
Secret codes (PIN)
User authentication Operator authentication (for administrative operations)
7 4 1 C 8 5 2 0 9 6 3 V
Secret keys
Authentication of the SIM card by the network Communication ciphering
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
19
Authentication Services
(IMSI, Ki) IMSI Ki
SIM ME BTS BSC MSC HLR AuC
IMSI Rnd Rnd Ki Rnd Ki
A3
A3
SIM Result
Check Accepte d Refused
Network Result
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
20
Ciphering Services
(IMSI, Ki) IMSI Ki
SIM ME BTS BSC MSC HLR AuC
IMSI Rnd Rnd Ki Rnd Ki
A8
A8
Session Key
Session Key
Encrypted Voice Channel
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
21
Download of Services
Secure execution environment for trusted applications
Able to interact with the mobile phone
Display information on the screen Get inputs from the user Place phone calls
Able to interact with the network
Send and receive messages (SMS, CSD, GPRS, etc.) Get localization information
Able to interact with the SIM file system
Read/write into SIM files
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
22
Physical Characteristics
Two different formats
ID-1 SIM (standard credit card format) Plug-in SIM (specific SIM format)
54 mm
15 mm
25 mm
Plug-in SIM
85.6 mm
ID-1 SIM
Bantry Technologies Ltd. 16 dc. 2007 Mobile Applications based on (U)SIM Java Card Applets Slide
23
SIM Card Services
Data management
File management
Security
Data protection Authentication/Ciphering
Content data
Overall file structure Details of the file contents
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
24
File Management
Logical file model File identifiers File selection
SELECT command STATUS command
File access commands
READ BINARY command UPDATE BINARY command READ RECORD command UPDATE RECORD command SEEK command
Bantry Technologies Ltd. 16 dc. 2007 Mobile Applications based on (U)SIM Java Card Applets Slide
25
Logical File Model (1/2)
2 different classes of file
Dedicated files (directories) Elementary files (data files)
3 different types of elementary files
Transparent files Linear fixed files Cyclic files
Record #1 Record #2 Sequence of bytes Record #3 etc Record #n Record #1 Record #2 Record #3 etc Record #n
Transparent
Bantry Technologies Ltd. 16 dc. 2007
Linear Fixed
Cyclic
Slide
Mobile Applications based on (U)SIM Java Card Applets
26
Logical File Model (2/2)
MF DF2 DF22 EF DF21 DF1 EF EF EF EF
EF
EF
EF EF
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
27
Data Protection
File access conditions CHV management commands
VERIFY CHV command CHANGE CHV command DISABLE CHV command ENABLE CHV command UNBLOCK CHV command
File invalidation commands
INVALIDATE command REHABILITATE command
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
28
File Access Conditions
Every EF has its own access conditions for each command
Read Update Invalidate Rehabilitate
Access conditions can be
Always:no restrictions CHV1: the CHV1 code must have been presented CHV2: the CHV2 code must have been presented ADM: an admin. code must have been presented Never: no access
Bantry Technologies Ltd. 16 dc. 2007 Mobile Applications based on (U)SIM Java Card Applets Slide
29
PIN Codes
The SIM card uses two different types of PIN codes
CHV codes (subscribers responsibility) ADM codes (telcos responsibility)
CHV
2 CHVs are defined (only one used today) No hierarchy between the 2 codes Unblock code available for each CHV
ADM
Up to 14 ADM codes can be defined Generally 2/4 are defined and only 1 really used ADM code verification is not defined in the standard
Bantry Technologies Ltd. 16 dc. 2007 Mobile Applications based on (U)SIM Java Card Applets Slide
30
Authentication/Ciphering
A3/A8 GSM algorithm used for
Authentication (A3) Ciphering (A8)
One single command
RUN GSM ALGORITHM command
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
31
Overall File Structure
MF DF GSM EF LP EF IMSI EF Kc EF PLMNsel EF HPLMN EF ACMmax EF SST EF ACM EF GID1 etc
Bantry Technologies Ltd. 16 dc. 2007
DF Telecom EF ADN EF FDN EF SMS EF CCP EF MSISDN EF SMSP EF SMSS DF Graphics EF IMG etc
EF ICCID
EF ELP
MF
ID = 3F00 General information
DF GSM
ID = 7F20 Network-related information
DF Telecom
ID = 7F10 Service-related information
Mobile Applications based on (U)SIM Java Card Applets
Slide
32
SIM Card Applications
Technologies
Bantry
SIM Toolkit Technology (3GPP TS 11. 14)
CNAM 17-Dec-2007 Bantry Technologies Ltd. 16 Dec 2007
25 Ballsbridge Terrace, Ballsbridge, Dublin 4, Ireland Tel: +353 (0)1 6642930 / Fax: +353 (0)1 6642933 www.bantry-technologies.com
Slide 33
Overview
Introduction to SIM Toolkit SIM Toolkit Processing Proactive SIM commands Profile download mechanism Event management
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
34
Introduction to SIM Toolkit
Allow applications in the SIM to interact with any ME ETSI GSM 11.14 standard defines the interface between the SIM and the ME to have a full interoperability STK applications can
Initiate actions
pro-active commands
Be triggered on external actions
event management
Get the characteristics of the ME
ME profile
Bantry Technologies Ltd. 16 dc. 2007 Mobile Applications based on (U)SIM Java Card Applets Slide
35
SIM Toolkit Processing
SIM has to be pro-active Smart card protocols doesnt allow this
The card is never active It only answers to APDU commands coming from the terminal (master/slave relation)
4 new APDU commands are defined to manage SIM Toolkit features
FETCH TERMINAL RESPONSE ENVELOPE TERMINAL PROFILE
Slide
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
36
Processing Proactive Commands
FETCH
Proactive Command (e.g. display text)
TERMINAL RESPONSE
SIM
Status & Response (if any)
ME
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
37
Processing Events
ENVELOPE (e.g. menu selection)
Status
SIM
ME
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
38
Processing Profile Download
TERMINAL PROFILE
Status & Profile Information
SIM
ME
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
39
Proactive Polling
STATUS Response with SW=90 00
Poll Intervall
STATUS Response with SW=90 00
STATUS Response with SW=91 XX
SIM
ME
FETCH
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
40
Proactive Commands
Man-Machine Interface
Display Text Get Inkey Get Input Select Item More Time Play Tone Set Up Menu Set Up Idle Mode Text
Dual-Slot
Perform Card APDU Power Off Card Power On Card Get Reader Status
Miscellaneous
Provide Local Information Timer Management Set Up Event List Refresh Poll Interval Polling Off Run AT Command Language Notification Launch Browser
Communication
Send Short Message Send SS Send USSD Set Up Call Send DTMF Open Channel Close Channel Receive Data Send Data Get Channel Status
Bantry Technologies Ltd. 16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
41
Proactive Command Examples
NETWORK BANKING NEWS WEATHER The weather today is going to be fine. ok Please enter name: ok
Setup Menu
Display Text
SMS in progress. Please Wait...
Get Input
CALLING 01 4746 6667 Please Wait...
BANKING BALANCE PURCHASE TRANSFER
Select Item
Send SMS
Setup Call
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
42
Display Text
This command instructs the ME to display a text message and/or an icon. It allows the SIM to define the priority of that message and the text string format.
Description
Proactive SIM command tag Length (A+B+C+D+E) Command details TLV Device identities TLV Text string TLV Icon identifier TLV Immediate response TLV
M/O
M M M M M O O
Len
1 1 or 2 A B C D E
Command Qualifier
Bit Description
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 Normal priority High priority RFU RFU RFU RFU RFU RFU RFU RFU RFU RFU RFU RFU Clear after delay Wait for user to clear
1 2 3 4 5 6 7 8
Immediate Command Device Icon Text Identifier Identities String Response Details TLV TLV TLV TLV TLV
Byte(s) 1 1 2 2 to (Y-1)+2 2 3 (Y-1)+3 3 4 to (Y-1)+4 4 5 (Y-1)+X+2 Description Command details tagtag Text string tagtagtag Device Icon Immediate identifier identities response Length Length (=03) (=X) Length (=00) (=02) Command number Data coding scheme Source Icon qualifier device identities Type of command Text string qualifier Destination Icon identifier device identities Command
16 dc. 2007
Len 1 1 1 Y 1 1 1 1 1 X-1 1
Device Identities
Source Dest. SIM Display
Slide
Bantry Technologies Ltd.
Mobile Applications based on (U)SIM Java Card Applets
43
Display Text (example)
Byte(s)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 - 17
Value
D0 0F 81 03 01 21 00 82 02 81 02 8D 04 04 53 41 54 Length
Description
Proactive SIM command tag Command details tag Length Command number Type of command (display text) Command qualifier (normal priority, clear after delay) Device identities tag Length Source = SIM Destination = Display Text string tag Length Data coding scheme (8-bit default SMS) Text string (SAT) T L V V T L V V T L T L
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
44
Profile Download Mechanism
ME sends to the SIM card (if Phase 2+) during initialization procedure This profile states the facilities relevant to SIM Application Toolkit that are supported by the ME
STK commands supported STK events managed Options managed
Alpha-identifier, UCS2 CSD, GPRS Soft keys Screen sizing, text wrapping & scrolling
45
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
Event Management
Menu selection Data download to SIM
SMS-PP Download Cell Broadcast Download
Event download
MT call Call connected Call disconnected Location status User activity Idle screen available Card reader status Language selection Browser termination Data available Channel status
Slide
Control by SIM
Call control MO SMS control
Timer expiration
Bantry Technologies Ltd. 16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
46
Java Card Enabler for SIM Card Applications
Technologies
Bantry
Java Card SIM API (3GPP TS 43.019)
CNAM 17-Dec-2007 Bantry Technologies Ltd. 16 Dec 2007
25 Ballsbridge Terrace, Ballsbridge, Dublin 4, Ireland Tel: +353 (0)1 6642930 / Fax: +353 (0)1 6642933 www.bantry-technologies.com
Slide 47
Overview
SIM Toolkit Framework SIM Toolkit Management
sim.toolkit package
SIM File Management
sim.access package
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
48
SIM Toolkit Framework
Toolkit Applet 1 Applet 2
Proactive commands P/C responses
Toolkit Applet 3
Applet n
SIM-API
Install Uninstall
Activation
File access
SIM API Framework Applet triggering Proactive command manager Applet security manager Applet install/uninstall
Security
APDU e.g. Envelopes
Proactive polling, 91XX, Fetch, Proactive commands, Terminal Response
File access
GSM SIM Kernel
APDU Interface to terminal
Files
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
49
Java Card SIM API Overview
Packages
sim.toolkit
Provides classes that enable to communicate with the Toolkit application (3GPP TS 11.14 functions), e.g. GUI management, SMS management, etc Provides classes that enable to communicate with the GSM application (3GPP TS 11.11 functions), mainly file management
sim.access
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
50
sim.toolkit Interfaces
Interface Summary
ToolkitConstants ToolkitConstants encapsulates constants related to the Toolkit applets. ToolkitInterface must be implemented by a Toolkit applet so that it can be triggered by the Toolkit Handler according to the registration information.
ToolkitInterface
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
51
sim.toolkit Classes (1/2)
Class Summary
EditHandler EnvelopeHandler EnvelopeResponseHandler This class is the basic class for the construction of a list of simple TLV elements The EnvelopeHandler class contains basic methods to handle the Envelope data field. The EnvelopeResponseHandler class contains basic methods to handle the Envelope response data field. This class is the basic class for the definition of Proactive commands.
ProactiveHandler
ProactiveResponseHandler The ProactiveResponseHandler class contains basic methods to handle the Terminal Response data field. ViewHandler The ViewHandler class offers basic services and contains basic methods to handle TLV list.
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
52
sim.toolkit Classes (2/2)
Class Summary
ToolkitRegistry The Registry class offers basic services and methods to allow any Toolkit applet to register its configuration during the install phase and possibly to change it during all the applet life time. The MEProfile class contains methods to question the handset profile.
MEProfile
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
53
sim.toolkit Exceptions
Exception Summary
ToolkitException This exception extends the Throwable class and allows the classes of this package to throw specific exceptions in case of problems.
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
54
Toolkit Registry
public class MyToolkitApplet extends Applet implements ToolkitInterface, ToolkitConstants { private ToolkitRegistry reg; private byte[] menuEntry = { ... }; private byte menuId; public MyToolkitApplet() { reg = ToolkitRegistry.getEntry(); menuId = reg.initMenuEntry(menuEntry, (short)0, (short)menuEntry.length, PRO_CMD_SET_UP_CALL, false, 0, 0); reg.disableMenuEntry(menuId); reg.setEvent(EVENT_FORMATTED_SMS_PP_ENV); reg.setEvent(EVENT_CALL_CONTROL_BY_SIM); } public static void install(byte bArray[], short bOffset, byte bLength) throws ISOException { MyToolkitApplet applet = new MyToolkitApplet(); applet.register(); } public void processToolkit(byte event) throws ToolkitException { if (event == EVENT_FORMATTED_SMS_PP_ENV) { reg.enableMenuEntry(menuId); } else if (event == EVENT_MENU_SELECTION) { Bantry Technologies Ltd. 16 dc. 2007 Mobile Applications based on (U)SIM Java Card Applets //...
Slide
55
Proactive Handler
private static final byte MY_COMMAND = (byte)0x33; private static final byte MY_TAG = (byte)0x45; ProactiveHandler proHdlr; proHdlr = ProactiveHandler.getTheHandler(); proHdlr.init(MY_COMMAND, (byte)0, DEV_ID_ME); proHdlr.appendTLV((byte)(MY_TAG | TAG_SET_CR), (byte)0); short len = proHdlr.getLength(); byte result = proHdlr.send(); private text[0] text[1] text[2] byte[] text = new byte[12]; = (byte)'S'; = (byte)'A'; = (byte)'T';
result = proHdlr.initDisplayText((byte)0x80, DCS_8_BIT_DATA, text, (short)0, (short)3); result = proHdlr.send();
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
56
Proactive Response Handler
private byte[] data; data = new byte[32]; ProactiveResponseHandler ProRespHdlr; ProRespHdlr = ProactiveResponseHandler.getTheHandler(); byte result = ProRespHdlr.getGeneralResult(); respHdlr.findTLV(TAG_DEVICE_IDENTITIES, 1); byte sourceDev = ProRespHdlr.getValueByte((short)0); byte destinDev = ProRespHdlr.getValueByte((short)1); if (ProRespHdlr.findTLV(TAG_TEXT_STRING, (byte)1) == TLV_FOUND_CR_SET) { if ((short len = ProRespHdlr.getValueLength()) > 1) { ProRespHdlr.copyValue((short)1, data, (short)0, (short)(len - 1)); } }
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
57
Envelope Handler
private static final byte MY_TAG = (byte)0x54; private byte[] data; data = new byte[32]; void processToolkit(byte event) throws ToolkitException { // get the EnvelopeHandler system instance EnvelopeHandler theEnv = EnvelopeHandler.getTheHandler(); // look for MY_TAG TLV if (theEnv.findTLV(MY_TAG, (byte)1) != TLV_NOT_FOUND) { // check first element byte if (theEnv.getValueByte((short)0) == (byte)1) { // copy element part into data buffer theEnv.copyValue((short)1, data, (short)0, (short)(theEnv.getValueLength() - 1)); } } }
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
58
HelloWorld SIM Toolkit Applet
import javacard.framework.*; import sim.toolkit.*; public class HelloWorld extends Applet implements ToolkitConstants, ToolkitInterface { private final byte COMMAND_QUALIFIER = (byte)0x80; private final byte[] MENU_ENTRY = {'S','e','r','v','i','c','e','1'}; private final byte[] HELLO_WORLD = {'H','e','l','l','o',' ','w','o','r','l','d',' ','!'}; private ToolkitRegistry registry; public HelloWorld() { registry = ToolkitRegistry.getEntry(); registry.initMenuEntry(menuEntry, (short)0, (short) MENU_ENTRY.length, PRO_CMD_DISPLAY_TEXT, false, 0, 0); }
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
59
HelloWorld SIM Toolkit Applet
public static void install(byte bArray[], short bOffset, byte bLength) throws ISOException { HelloWorld applet = new HelloWorld(); applet.register(); } public void processToolkit(byte event) throws ToolkitException { ProactiveHandler proHdlr = ProactiveHandler.getTheHandler(); if (event == EVENT_MENU_SELECTION) { proHdlr.init((byte) PRO_CMD_DISPLAY_TEXT, (byte)COMMAND_QUALIFIER, DEV_ID_ME); proHdlr.appendTLV((byte)(TAG_TEXT_STRING), HELLO_WORLD,(short)0, (short) HELLO_WORLD.length); proHdlr.send(); } }
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
60
sim.access Interfaces
Interface Summary
SIMView SIMView is the interface between the GSM application and any SIM Toolkit applet.
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
61
sim.access Classes
Class Summary
SIMSystem The Class SIMSystem provides a way to get access to the GSM file system. In any case, the SIM Toolkit applet will only access to methods of the SIMView interface. No instance of this class is needed.
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
62
sim.access Exceptions
Exception Summary
SIMView Exception SIMViewException encapsulates specific exceptions which can be generated by the methods of the SIMView interface in case of error.
Bantry Technologies Ltd.
16 dc. 2007
Mobile Applications based on (U)SIM Java Card Applets
Slide
63
Example
import javacard.framework.*; import sim.toolkit.*; public class MyApplet extends Applet implements ToolkitInterface { private SIMView simView; private byte[] buffer; private ToolkitRegistry registry; public MyApplet () { registry = ToolkitRegistry.getEntry(); simView = SIMSystem.getTheSIMView(); buffer = new byte[32]; } public static void install(APDU apdu) throws ISOException { MyApplet applet = new MyApplet(); applet.register(); } public void getADN(short adnNumber) { simView.select(SIMView.FID_EF_TELECOM); simView.select(SIMView.FID_EF_ADN); simView.readRecord((short)adnNumber, SIMView.MODE_ABSOLUTE,(short)0, buffer, (short)0, (short)32); } }
Bantry Technologies Ltd. 16 dc. 2007 Mobile Applications based on (U)SIM Java Card Applets Slide
64
Demonstrations
Technologies
Bantry
VirtuoSimo Development Tool maXim/jTOP SIM Cards
CNAM 17-Dec-2007 Bantry Technologies Ltd. 16 Dec 2007
25 Ballsbridge Terrace, Ballsbridge, Dublin 4, Ireland Tel: +353 (0)1 6642930 / Fax: +353 (0)1 6642933 www.bantry-technologies.com
Slide 65
Questions & Answers
Technologies
Bantry
[email protected]
CNAM 17-Dec-2007 Bantry Technologies Ltd. 16 Dec 2007
25 Ballsbridge Terrace, Ballsbridge, Dublin 4, Ireland Tel: +353 (0)1 6642930 / Fax: +353 (0)1 6642933 www.bantry-technologies.com
Slide 66