
© 2009-2010 OMTP Ltd. All rights reserved. OMTP and OMTP BONDI are registered trademarks of OMTP Ltd.
BONDI APDU module
APDUSlotArray
APDUManager
APDUConnection
APDUSlot
| Interface | Method |
|---|---|
| APDUManager | APDUConnection createConnection(APDUSlot slot) |
| APDUConnection | boolean isCardPresent() PendingOperation openLogicalChannel(OpenSuccessCallback successCallback, ErrorCallback errorCallback, DOMString aid) PendingOperation openDefaultChannel(SuccessCallback successCallback, ErrorCallback errorCallback) void close() ByteArray GetAnswerToReset() PendingOperation transmit(TransmitSuccessCallback successCallback, ErrorCallback errorCallback, Byte Class, Byte Instruction, Byte P1, Byte P2, unsigned short Lc, ByteArray message, unsigned short Le) |
| APDUSlot |
This module allows the communication between web application and a smart card by using the Application Protocol Data Units (APDUs). An APDU is a short message represented by bytes. APDU messages are either commands or responses. APDU protocol is defined by ISO 7816-4
This is the list of URIs used to declare this API's features, for use in bondi.requestFeature. For each URL, the list of functions covered is provided.
Access to opening APDU Slot connection, used by APDUManager.createConnection
Device capabilities:
apdu.accessAccess to opening APDU connection to a card application using a logical channel, used by APDUConnection.openLogicalChannel
Device capabilities:
apdu.openLogicalChannelAccess to opening APDU connection to a card the default channel, used by APDUConnection.openDefaultChannel
Device capabilities:
apdu.openDefaultChannelAccess to sending an APDU command, used by APDUConnection.transmit
Device capabilities:
apdu.transmitapdu.accessOpens an connection between the device and a slot.
Security parameters:
slot:
string representing the slot (e.g."slot0")
apdu.openLogicalChannelOpens an APDU connection between the device and an application in the UICC or any other secure element.
Security parameters:
slot:
string representing the slot (e.g."slot0")
aid:
string representing the card application (e.g. "a0 00 00 00 62 03 01 0c 02 01")
apdu.openDefaultChannelOpens an APDU connection between the device and the UICC or any other secure element.
Security parameters:
slot:
string representing the slot (e.g."slot0")
apdu.transmitSend an APDU command.
Security parameters:
Class:
Class of the command
ins:
Command instruction
P1:
First parameter of the command
P2:
Second parameter of the command
APDUSlotArray
Array of smart cards or secure elements slots.
typedef sequence<APDUSlot> APDUSlotArray;
APDUManager
Management of the APDU communication.
interface APDUManager {
readonly attribute APDUSlotArray availableSlots;
APDUConnection createConnection(in APDUSlot slot)
raises(SecurityError, DeviceAPIError);
};
Provides a way to open communication with a smart card or secure element slot.
var slot = availableSlots[0]; var cnx; cnx = APDUManager.createConnection(slot);
readonly
APDUSlotArray availableSlotsThe list of available slots on the device.
Might be updated if a new slot appears (e.g. a bluetooth enabled card reader)
createConnectionCreates an instance of the APDUConnection interface
APDUConnection createConnection(in APDUSlot slot);
PERMISSION_DENIED_ERROR when access is denied by the security policy.
INVALID_ARGUMENT_ERROR if an invalid slot is passed
APDUConnection
Interface to communicate through APDU commands.
interface APDUConnection {
readonly attribute APDUSlot slot;
readonly attribute DOMString aid;
readonly attribute short channel;
boolean isCardPresent();
PendingOperation openLogicalChannel(in OpenSuccessCallback successCallback, in ErrorCallback errorCallback, in DOMString aid);
PendingOperation openDefaultChannel(in SuccessCallback successCallback, in ErrorCallback errorCallback);
void close()
raises(DeviceAPIError, APDUError);
ByteArray GetAnswerToReset();
PendingOperation transmit(in TransmitSuccessCallback successCallback, in ErrorCallback errorCallback, in Byte Class, in Byte Instruction, in Byte P1, in Byte P2, in unsigned short Lc, in ByteArray message, in unsigned short Le);
};
var cnx;
// Define the APDUExchange success callback.
function APDUSuccess(response) {
alert("APDU Response is " + response);
}
// Define the APDUExchange failure callback.
function APDUFailure(e) {
alert("Error while executing the APDU Command");
}
// Define the open success callback.
function openSuccess() {
alert("APDU Connection opened successfully");
// send a select file ( selection of 3F00)
var data = new ByteArray(1);
data[0] = 0x3F;
data[1] = 0x00;
cnx.transmit(APDUSuccess, APDUFailure, 0x00, 0xA4, 0x00, 0x02, data, 0x00);
}
// Define the open failure callback.
function openFailure(e) {
alert("Cannot open the APDUSlot connection");
}
var slot = availableSlots[0];
var aid = "a0 00 00 00 62 03 01 0c 02 01";
cnx = APDUManager.createConnection(slot);
// Get ATR
var ATR = cnx.GetAnswerToReset();
cnx.openLogicalChannel(openSuccess, openFailure, aid);
readonly
APDUSlot slotThe slot used by this connection
readonly
DOMString aidCard application identifier
readonly
short channelThe logical channel used by this connection
isCardPresentTells whether a card is present in this slot
boolean isCardPresent();
openLogicalChannelOpens the APDU Connection to a card application, using a logical channel chosen by the system.
PendingOperation openLogicalChannel(in OpenSuccessCallback successCallback, in ErrorCallback errorCallback, in DOMString aid);
Errors that can be returned in the ErrorCallback: SecurityError PERMISSION_DENIED_ERROR when access is denied by the security policy. DeviceAPIError IO_ERROR if the communication with the slot fails DeviceAPIError INVALID_ARGUMENT_ERROR if an invalid aid is passed DeviceAPIError PENDING_OPERATION_ERROR if another Open APDU operation is being processed APDUError CHANNEL_OPEN_ERROR if the channel is already open
openDefaultChannelOpens the APDU Connection to a card in a slot using the default logical channel if available.
PendingOperation openDefaultChannel(in SuccessCallback successCallback, in ErrorCallback errorCallback);
Errors that can be returned in the ErrorCallback: SecurityError PERMISSION_DENIED_ERROR when access is denied by the security policy. DeviceAPIError IO_ERROR if the communication with the slot fails DeviceAPIError PENDING_OPERATION_ERROR if another Open APDU operation is being processed APDUError CHANNEL_OPEN_ERROR if the channel is already open
closeCloses the APDU Connection
void close();
Closes the APDU Connection.
IO_ERROR if the communication with the slot fails
PENDING_OPERATION_ERROR if an Open APDU operation is being processed
CHANNEL_NOT_OPEN_ERROR if the channel is not open
GetAnswerToResetGet Answer To Reset
ByteArray GetAnswerToReset();
Get Answer To Reset.
transmitSends an APDU command
PendingOperation transmit(in TransmitSuccessCallback successCallback, in ErrorCallback errorCallback, in Byte Class, in Byte Instruction, in Byte P1, in Byte P2, in unsigned short Lc, in ByteArray message, in unsigned short Le);
Sends the APDU command to the card. When the card sends its response APDU, the successCallback is invoked containing the response as another byte array.
Errors that can be returned in the ErrorCallback: DeviceAPIError IO_ERROR if the communication with the slot fails DeviceAPIError INVALID_ARGUMENT_ERROR if any of the parameters is not valid DeviceAPIError PENDING_OPERATION_ERROR if another open or transmit operation is being processed APDUError CHANNEL_NOT_OPEN_ERROR if the channel is not open
APDUSlot
Definition of a card or secure element Slot.
interface APDUSlot {
readonly attribute short id;
readonly attribute DOMString description;
};
readonly
short idthe numerical identifier of the slot. Used internally only.
readonly
DOMString descriptiona human-readable description of the slot (e.g. "(U)SIM Slot". May be displayed to the user in a list so he can select which slot to use.