Sector Select over PC/SC interface with APDU

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Sector Select over PC/SC interface with APDU

2,599 Views
saschawinkler
Contributor I

Hi all,

I am trying to write data to EEPROM of my NTAG I2C 2K chip over RF Interface.

In order to this I use an NFC Reader with PC/SC interface and write an Java Application on top of Java Smartcard API. Because the EEPROM/User Memory is located on two 2 sectors, I have to change the sector number in order to get access to full eeprom. My problem is now that the SmartCard API sends APDU with an required header of 4 bytes (class, instruction, parameter 1, parameter 2). After looking into the datasheet I tried to send an APDU with following header : Class=Cmd=0xC2, Instruction=0xFF and without parameter 1 and parameter 2. This process throws an error because of the missing parameter bytes. My next attempt was to sent an header with empty parameter field but I also get an error. 

Can somebody gives me advice?

with kind regards

Sascha Winkler

0 Kudos
2 Replies

1,811 Views
saschawinkler
Contributor I

Problem solved: 

In order to send any command which is not defined in        you have to use the following APDU Command : 

FF C2 00 01 DataLen DataObject.

This command is called Transparent Exchange Command and ist used to transmit and receive any bit or bytes from Integrated Circuit Card. 

As DataObject you have to select the tag 0x95 which define an transceive command. That means after transmission is complete the reader will wait until an optional timer data object is over or an default time is passed. 

In case of the sector select command the complete APDU command is as follows: 

0xFF 0xC2 0x00 0x01  [0x5F  0x46 0x04 0x20 0x4E 0x00 0x00] 0x95  0x02 0xC2 0xFF

0x5F  0x46 0x04 0x20 0x4E 0x00 0x00 is the optional timer data object which defines an timeout after 20 ms (0x4E20 = 20000 as multiple of 1 us).   

0x95  0x02 0xC2 0xFF is the transceive command with data length 0x02 bytes and as data 0xC2 0xFF which are the sector select command packet 1. 

After receiving the ACK message you have to send the second sector select command packet as follows: 

0xFF 0xC2 0x00 0x01  [0x5F 0x46 0x04 0x20 0x4E 0x00 0x00 ] 0x95 0x04 SectorNumber 0x00 0x000x00

Again [0x5F 0x46 0x04 0x20 0x4E 0x00 0x00 ]  is the optional timer data object. 

After this the sector is changed to the selected SectorNumber. 

 

 

0 Kudos

1,811 Views
doyle_nickless
Contributor I

Hi Sascha,

I'm using the information you posted here to implement the SECTOR_SELECT command in some code I wrote for retrieving data from the NXP NT3H2211, and so far I have only been able to get the first 1 KB because I didn't have the SECTOR_SELECT implemented.

I am using an ACS ACR1252U NFC reader to process the APDU commands and haven't been successful in getting the SECTOR_SELECT to work.  I'm using two ADPU byte sequences as follows (assuming I don't need the optional timer object)

To select Sector 1:

CLA     INS       P1       P2      Lc       Le   --  Data

0xFF   0xC2    0x00   0x01   0x04   0x08 -- 0x95 0x02 0xC2 0xFF

0xFF   0xC2    0x00   0x01   0x06   0x08 -- 0x95 0x04 0x01 0x00 0x00 0x00

To try this out before writing code to do it, I am using the ACS "Smart Card and Reader Tool" to issue the two command byte sequences to the chip using the program GUI, so that takes several seconds to send both APDUs when hand-entering the values.  Could that be the problem?

In this case, is the optional timer object actually required?  I didn't see that in the ACS API documentation.

0 Kudos