1

What I am doing: I am trying to create an Android application that can connect to an HID reader, read an HID smart card, and authenticate the user who has scanned their smart card.

So far, I am able to detect that a USB device has been connected (via UsbManager), ask for permissions to communicate with the USB device, and detect when permission has been granted to communicate with the USB device.

When I detect that permissions have been granted, I use UsbDeviceConnection to send a PC_to_RDR_IccPowerOn command to the correct UsbEndpoint. I am then receiving back an ATF through a RDR_to_PC_DataBlock response.

This is the PC_to_RDR_IccPowerOn I am sending to the reader: 62 00 00 00 00 00 00 00 00 00

This is the RDR_to_PC_DataBlock response I am receiving: 80 00 00 00 00 00 00 42 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00.

What my problem is: Per this answer, and through referring to the CCID documentation, I've determined that the 42 in the response is "status register" and that there is no error coming back from the response. Still, this status register value should be 00 on success, which it isn't. I am also not getting back any data, so something is definitely off.

What I've tried so far: I've tried incrementing the bPowerSelect field in the PC_to_RDR_IccPowerOn to 1, 2, and 3 (via passing 62 00 00 00 00 00 00 01 00 00, etc.) and am getting back the same RDR_to_PC_DataBlock every time. I've also tried incrementing the slot number (via passing 62 00 00 00 00 01 00 00 00 00, etc.) and am receiving an error (80 00 00 00 00 01 00 42 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00). Finally, I've tried incrementing the sequence number for the PC_to_RDR_IccPowerOn to 1, 2, and 3 (via passing 62 00 00 00 00 00 01 00 00 00, etc.) and am getting the same RDR_to_PC_DataBlock response, but with an incremented sequence number (80 00 00 00 00 00 01 42 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00).

I've tried passing the above strings (beginning with 80 00 ...) into the following ATR Parser but am getting a bad response each time and cannot make much sense of it.

What I'm wondering: How can I go about figuring out the correct way to format my PC_to_RDR_IccPowerOn based on the RDR_to_PC_DataBlock responses I am getting back? I know that the 42 in the "status register" field of the response is a clue, but am unsure how to use this information to construct my PC_to_RDR_IccPowerOn command correctly.

David Chopin
  • 2,780
  • 2
  • 19
  • 40

0 Answers0