ECO 5000 CT-API and PC/SC Driver

for Linux and Windows 9x/ME/2000/NT

© 2001 CardContact Software & System Consulting


CardContact Software & System Consulting takes no warranty for the use of this program.
It is provided „as is“ and you may use it at your own risk!!



Support/Troubleshooting

If you have any problems with this package feel free to contact us at info@cardcontact.de.

Installation

There is a fully functional version of this driver already included in this package. You do not need to recompile it yourself (but you can).
The linux version is called „libcteco5000.so“. The Windows version is located in the „/windows“ directory of this package and is called „cteco5000.dll“.

Take a look at the following sections how to install this driver on your operating system.

Linux

Extract the source files using tar -xzf eco5000-0.9.6. Change your directory to eco5000-0.9.6 and type make. If the compiler completes, login as root and type make install. This will copy the libcteco5000.so file into /usr/local/lib and the ctapi.h file to /usr/local/include . Either copy the supplied reader.conf to your /etc directory or edit the existing /etc/reader.conf accordingly.

Windows

Extract the source files using WinZip or any other program that can handle compressed tar-files. Change your directory to „eco5000-x.y.z/windows“ and copy the file „cteco5000.dll“ to your „Windows/system32“ directory.
Note that this driver does not support PC/SC under Windows because it does not run in kernel mode.
If you want to build the driver by yourself: There is a project for the Watcom compiler already included in this package. So there should be no problems porting this to another compiler like Visual C.

A small test file has been included, which can be used to test the driver. It is called „test“ or „test.exe“ (for windows).
Connect the ECO 5000 reader to your PC, insert a card and type test 0 if your reader is connected to /dev/ttyS0 or COM1 (change parameter 0 accordingly). The program will reset the card, display the ATR and issue a SELECT MF command.

The ECO 5000 driver has been tested with M.U.S.C.L.E PC/SC Lite Version 0.9.1. and above. It supports

Memory cards are not yet fully supported by PC/SC. I you plan to use the driver with memory cards, we suggest using the CT-API programming interface.

Cards using the SDAP / I2C Protocol should have a header according to ISO 7816. This header is stored in the first four byte of the card and serves as replacement for the synchronous ATR provided by 2 Wire Bus and 3 Wire Bus cards. Common used header in the first 4 byte of a memory card are

ATR

Card / Configuration

82 13 10 00

Serial Data Access Protocol (256 Byte)

82 1B 10 00

Serial Data Access Protocol (512 Byte)

82 23 10 00

Serial Data Access Protocol (1024 Byte)

82 2B 10 00

Serial Data Access Protocol (2048 Byte)

82 33 10 00

Serial Data Access Protocol (4096 Byte)

82 3B 10 00

Serial Data Access Protocol (8192 Byte)

92 23 10 00

3 Wire Bus Protocol (1024 Byte)

A2 13 10 00

2 Wire Bus Protocol (256 Byte)



As an extension to the MKT specification, the application may provide an alternate ATR as part of the REQUEST ICC or RESET ICC command. If such an alternate ATR is provided, then the ATR read from the card is discarded and the alternate ATR used instead to determine the transmission protocol parameter. This is in particular useful, if a memory card does not contain a valid ATR that defines card type and memory size.

Programming Interface

The ECO 5000 driver implements a special command interface for synchronously operated memory cards. This interface uses ISO 7816/4 APDU commands and a mapping that translates the memory areas of the memory card into separate files. Each card contains ate least a Master File (MF) which can be selected using the SELECT FILE command. Once the MF is selected, the application may issue the READ BINARY or UPDATE BINARY commands to read or write the main memory area of the card. If the card uses a Programmable Security Code (PSC) then the application must use the VERIFY command to verify the PSC. The PSC can be changed using the CHANGE VERIFICATION DATA.

Files

The following files can be selected using the SELECT FILE command

Master File (MF, 3F00)

The main memory of the card starting with the byte at offset 0 and extending to the last byte in memory.

Directory File (EF_DIR, 2F00)

The directory file contains a single application identifier or a list of application identifier. The start of the EF_DIR is indicated on B7 - B1 in the fourth byte of the ATR (H4), if B8 of the same byte is set to 1. The length of the directory file is determined by the TLV coding of the field. For example a card containing

92 23 10 88 46 02 81 15 4F 06 D2 80 00 00 01 01 61 ...

has a directory file starting at offset 8 with a length of 8 bytes.

ATR File (EF_ATR, 2F01)

The ATR file contains various informations about the card production process. The content of the file is TLV coded. The file starts directly after the ATR (usually 4) and stops right before the directory file. A card containing

92 23 10 88 46 02 81 15 4F 06 D2 80 00 00 01 01 61 ...

has an ATR file starting at offset 4 with a length of 4 bytes.

Protection Memory (EF_PROT, 3F01)

The Siemens SLE4418, SLE4428, SLE 4432, SLE 4442, Phillips PCB 2032 and 2ß42 have a write protection for individual bytes in the main memory. Write protection is implemented as a bit map. Once a bit is written to 0, the associated byte in the main memory is irreversably write protected.

The SLE 4432/4442 and PCB 2032/2042 contain a 32 bit protection memory that covers the first 32 byte of the main memory. The SLE 4418 / 4428 contain 1024 bit protection memory.

The mapping between the protection memory and the main memory is bit to byte: The least significant bit in the first byte of protection memory addresses the first byte in main memory. The second bit of the first byte of protection memory addresses the second byte in main memory.

The memory can be read only.

Commands

The following commands can be used to access memory cards.

SELECT FILE

Select the file or application for subsequent READ BINARY or UPDATE BINARY commands.


SELECT FILE

CLA

'00'

INS

'A4'

P1

'00' - C-Data contains 2 byte File Identifier (FID)

'04' - C-Data contains the Application Identifier (AID)

P2

'00'

Lc

'02' if P1 == '00'

length of Application Identifier (AID) if P1 == '04'

C-Data

FID or AID

Le

Empty

R-Data

Empty



READ BINARY

Read from the currently selected file.


READ BINARY

CLA

'00'

INS

'B0'

P1

MSB of offset

P2

LSB of offset

Lc

Empty

C-Data

Empty

Le

Number of bytes to be read or '00' to read all (256 byte maximum). To read more than 256 bytes at a time, the Le field shall be encoded as extended format '00 00 00'

R-Data

Empty



UPDATE BINARY

Write to the currently selected file


UPDATE BINARY

CLA

'00'

INS

'D6'

P1

MSB of offset

P2

LSB of offset

Lc

Number of bytes contained in C-Data. '00' = 256 byte. To write more than 256 bytes at a time, the extended format shall be used.

C-Data

Data

Le

Empty

R-Data

Empty



VERIFY

Verify the Programmable Security Code (PSC) for the SLE 4428, SLE 4442 or PCB 2042. The SLE 4428 uses a 16 bit PSC, all other chips have a 24 bit PSC.


VERIFY

CLA

'00'

INS

'20'

P1

'00'

P2

'00'

Lc

Lenght of PSC in C-Data ('02' or '03')

C-Data

PSC

Le

Empty

R-Data

Empty



CHANGE VERIFICATION DATA

Change the Programmable Security Code (PSC) for the SLE 4428, SLE 4442 or PCB 2042. The SLE 4428 uses a 16 bit PSC, all other chips have a 24 bit PSC.


CHANGE VERIFICATION DATA

CLA

'00'

INS

'24'

P1

'00'

P2

'00'

Lc

Lenght of old and new PSC in C-Data ('04' or '06')

C-Data

Old PSC followed by the new PSC

Le

Empty

R-Data

Empty