Provided by: libtowitoko-dev_2.0.7-9_amd64
NAME
CT-BCS — Cardterminal basic command set for integrated circuit card applications.
DESCRIPTION
This manpage describes the subset of the Cardterminal Basic Command Set (CT-BCS) used to control cardterminals with one or more integrated circuit card slots, without key pad and display. This manpage is not a complete specification of the CT-BCS, but a general overview of the most common functionalities. The CT-BCS commands are constructed in compliance with ISO/IEC 7816-4 interindustry commands and are used to control cardterminal utilizing the CT-API function CT_data().
COMMAND STRUCTURE
A CT-BCS command is an array of bytes that is sent to the cardterminal to perform an administrative action. The CT-BCS response is an array of bytes returned by the cardterminal that informs of the completion status of the action requested. The following diagram shows the general structure of a CT-BCS command: |<------------------------------------------>| | Header (4 Bytes) and body | | (mandatory) (optional) | |<----------------->|<---------------------->| |___________________|________________________| |CLA |INS |P1 |P2 |Lc |Data |Le | |____|____|____|____|____|______________|____| The following diagram shows the general structure of a CT-BCS response: |<------------------------------>|<--------->| | Body Trailer | | (optional) (2 Bytes) | | (mandatory)| |________________________________|___________| |Data |SW1-SW2 | |________________________________|___________| The fields within a CT-BCS command and response are equivalent to those defined by ISO/IEC 7816-4: CLA Class. The CLA value used for CT-BCS commands is 0x20. INS Instruction. Defines the action to be performed by the cardterminal. P1, P2 Command parameters 1 and 2. Lc Length of command data field. Le Length of expected data: Case 1: No command data, no response data (no Lc and no Le). Case 2: Command data, no response data (0<=Lc<=254 and no Le). Case 3: No command data, response data (no Lc and 0<=Le<=254). Case 4: Command data, response data (0<=Lc<=254 and 0<=Le<=254) SW1, SW2 Status bytes. Completion status of the command. The address value 0x01 (CT) shall be used as destination address (dad) given to CT_data() when sending CT-BCS commands (See CT_data (3)). The following commands are present in every CT-BCS implementation: Basic CT commands ┌─────────────────────┬───────────┐ │Cardterminal Command │ INS Code │ │RESET CT │ 0x11 │ │REQUEST ICC │ 0x12 │ │GET STATUS │ 0x13 │ │EJECT ICC │ 0x15 │ └─────────────────────┴───────────┘ The following general return codes SW1-SW2 may occur: General return codes ┌────────┬──────────────────────────┐ │SW1-SW2 │ Description │ │ 0x6700 │ Wrong length │ │ 0x6900 │ Command not allowed │ │ 0x6A00 │ Wrong parameters P1, P2 │ │ 0x6D00 │ Wrong instruction │ │ 0x6E00 │ Class not supported │ └────────┴──────────────────────────┘
FUNCTIONAL UNITS
Functional units are entities that can be addressed as target of CT-BCS commands. In some CT-BCS commands a target functional unit needs to be specified. Functional units ┌────────────────┬─────────┐ │Functional Unit │ Coding │ │CT kernel │ 0x00 │ │CT/ICC slot 1 │ 0x01 │ │CT/ICC slot 2 │ 0x02 │ │... │ ... │ │CT/ICC slot 14 │ 0x0E │ └────────────────┴─────────┘ Support for slots 2-14 depends on the cardterminal. Functional units for keypad and display are defined for some cardterminals but are not described here.
COMMANDS DESCRIPTION
RESET CT The RESET CT command asks the cardterminal to perform a reset of the specified functional unit. If the functional unit is the CT kernel, a software reset is carried out, meaning that all status information (f.i. information of inserted cards) is cleared and gathered again. For ICC functional units, an card reset is performed. Optionally the answer to reset of the functional unit is returned in the response data. A RESET CT command can be issued after initialization of the cardterminal or after the occurrence of a communication error. The command structure is as follows: CLA 0x20 INS 0x11 (=RESET CT) P1 Functional unit: 0x00 = CT 0x01 - 0x0E = ICC Interface 1-14 P2 Command qualifier: In case P1 = 0x00: 0x00 = No response In case P1 = 0x01 - 0x0E: 0x00 = No response data 0x01 = Return complete ATR 0x02 = Return Historical Bytes Lc field Empty Le field Empty or 0x00: return full length of requested information The response structure is as follows: Data Empty, ATR or Historical Bytes SW1-SW2 Status Bytes When functional unit is CT (0x00) the following status bytes can be returned: 0x9000 Reset successful 0x6400 Reset not successful When functional unit is a ICC slot (0x01 - 0x0E) the following status bytes can be returned: 0x9000 Synchronous ICC, reset successful 0x9001 Asynchronous ICC, reset successful 0x6400 Reset not successful REQUEST ICC The REQUEST ICC command asks the cardterminal to wait for the presence of an ICC on the specified cardterminal slot during a specified time limit. The command synchronously blocks the caller application unless time limit 0 is specified. When an ICC is presented it is automatically activated and reset. The command structure is as follows: CLA 0x20 INS 0x12 (=REQUEST ICC) P1 Functional unit: 0x01 - 0x0E = ICC-Interface 1 - 14 P2 Command qualifier: Request handling instructions for the CT Lc field Empty or length of subsequent data field Data field Empty (= immediate response required) or max. waiting time in seconds (1 byte, binary coding) for presenting the ICC Le field Empty or 0x00 = Return full length of requested information The parameter P2 carries the request handling instructions for the CT. The value of P2 is constructed of two 4-bits subfields: Bits b8-b5 • 0x0 = No meaning • Other values reserved for future use Bits b4-b1 • 0x0 = No response data • 0x1 = Return complete ATR • 0x2 = Return Historical Bytes The response structure is as follows: Data Empty, ATR or Historical Bytes SW1-SW2 Status Bytes The following status bytes can be returned: 0x9000 Synchronous ICC presented, reset successful 0x9001 Asynchronous ICC, reset successful 0x6200 No card presented within specified time 0x6201 Card already present and activated 0x6400 Reset not successful 0x6900 Command with timer not supported GET STATUS The GET STATUS command is used to gather cardterminal manufacturer information and ICC status information from the cardterminal. The information is represented by TLV (tag, length, value) encoded data objects. The tag of the data object to be retrieved is specified in the command and the value is returned in the response. The command structure is as follows: CLA 0x20 INS 0x13 (=GET STATUS) P1 Functional unit: 0x00 = CT P2 Command qualifier: Tag of data object to be returned Lc field Empty Data field Empty Le field Hx00 = Return full length of requested information The response structure is as follows: Data Status information (only value field of data object) SW1-SW2 Status Bytes The following data objects are defined. Note that only value field is returned in the response: Cardterminal manufacturer data object • Tag = 0x46 • Length >= 15 • Value: CTM: Cardterminal manufacturer (5 bytes ASCII encoded). It consists of 2 bytes with the country code and 3 bytes with the manufacturer acronym CTT: Cardterminal type (5 bytes ASCII encoded). The value is manufacturer dependant CTSV: Cardterminal software version (5 bytes ASCII encoded). The value is manufacturer dependant DD: Discretionary data (any number of bytes including 0) ICC status data object • Tag = 0x80 • Length • Value: One ICC status byte per ICC slot in the cardterminal. If b8-b1 = 0x00 then no ICC is present in the slot. If b1 = 1 and ICC is present in the slot and the bytes b3-b2 indicate whether the ICC is electrically connected (value 10) or electrically disconnected (value 01). The following status bytes can be returned: 0x9000 Command successful EJECT ICC The EJECT ICC command asks the cardterminal to deactivate the ICC. It must be used at the end of the communication with the card or when a irreparable communication error occur. The command structure is as follows: CLA 0x20 INS 0x15 (=EJECT ICC) P1 Functional unit: 0x01 - 0x0E = ICC-Interface 1-14 P2 Command qualifier: Eject handling instructions for the CT (0x00 for cardterminals without keypad and display) Lc field Empty or length of subsequent data field Data field Empty or time in seconds for removing the ICC Le field Empty The response structure is as follows: Data Empty SW1-SW2 Status Bytes The following status bytes can be returned 0x9000 Command successful 0x9001 Command successful, card removed 0x6200 Card not removed within specified time
SEE ALSO
ctapi (3). The MKT (Multifunktionale KartenTerminals) specifications, available for download from Teletrust web site http://www.teletrust.de (link to URL http://www.teletrust.de) . In special the documents: Part 3: CT-API. Cardterminal Applications Programming Interface. Part 4: CT-BCS. Cardterminal Basic Command Set. Part 7: IC cards with synchronous transmission Part3: Usage of interindustry Commands. ISO/IEC 7816: Identification cards - Integrated circuit(s) cards with contacts: Part 4: Interindustry commands for interchange.
AUTHOR
This manual page was written by Carlos Prados <cprados@yahoo.com>. CT-BCS(3)