2

I'm using a GEMALTO IDBRIDGE K30 connected over USB to an Android device.

First I'm sending a PC_to_RDR_IccPowerOff message like this.

byte[] data= new byte[]{
                    (byte) 0x62,
                    (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
                    (byte) 0x00,
                    (byte) 0x00,
                    (byte) 0x00,
                    (byte) 0x00, (byte) 0x00};


            UsbInterface intf = _usbDevice.getInterface(0);
            UsbEndpoint outputEndpoint = intf.getEndpoint(1);
            UsbEndpoint inputEndpoint = intf.getEndpoint(0);
            intf.getEndpointCount();
            UsbDeviceConnection connection = _usbManager.openDevice(_usbDevice);

            connection.claimInterface(intf, forceClaim);

            //activate card for apdu
            final int dataTransferred = connection.bulkTransfer(inputEndpoint, data, data.length, TIMEOUT);

            Log.e(SIGNATURE_LOG, String.format("Written %s bytes to the dongle. Data written: %s", data.length, byteArrayToHexArrayString(data)));

As response i get

Message received of lengths 64 and content: [80, 18, 00, 00, 00, 00, 00, 00, 00, 00, 3B, DF, 18, 00, 81, 31, FE, 58, 80, 31, 90, 52, 41, 01, 64, 05, C9, 03, AC, 73, B7, B1, D4, 44, 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]

After this i wait 5 seconds and than i try to send an APDU Select command with PC_to_RDR_XfrBlock.

byte[] data2= new byte[]{
                        (byte) 0x6F,
                        (byte) 0x10, (byte) 0x00, (byte) 0x00, (byte) 0x00,
                        (byte) 0x00,
                        (byte) 0x01,
                        (byte) 0x00,
                        (byte) 0x00, (byte) 0x00,
                        (byte) 0x00,
                        (byte) 0x00,
                        (byte) 0x0C,
                        (byte) 0x00, (byte) 0xA4, (byte) 0x04, (byte) 0x00,
                        (byte) 0x07, (byte) 0xA0, (byte) 0x00, (byte) 0x00,
                        (byte) 0x01, (byte) 0x18, (byte) 0x45, (byte) 0x4E,
                        (byte) 0x15,};

As Response I get this what is an Error F4 with the Description PROCEDURE BYTE CONFLICT:

Message received of lengths 64 and content: [80, 00, 00, 00, 00, 00, 01, 40, F4, 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]

Can anybody help me? I don´t understand what i am doing wrong.

user2270079
  • 127
  • 1
  • 1
  • 7

2 Answers2

2

PROCEDURE BYTE CONFLICT error is a little bit tricky because it happens inside the reader's firmware and is escalated to you via CCID. Basically it means that the reader talks to the smartcard via T=1 protocol and some T=1 procedure byte were not received or sent correctly between reader and smartcard. In my opinion there is nothing you can do in your application. What you can do:

  • If your smartcard supports T=0 protocol try to enforce it
  • Update your reader to the latest firmware
  • Maybe your smartcard is broken, try another one of identical type (or a newer version of it)

  • Also here it states sometimes there can be problems with some USB ports. Try to connect your reader to a USB hub to the Android device.

Update

Your smart card reader GEMALTO IDBRIDGE K30 reports TPDU exchange level (see here). Since in TPDU exchange level all data sent to the reader is forwarded to the smart card as-is, you have to handle T=1 protocol inside your software. Normally a driver would take care of this task, but in your case you are communicating directly to the smart card reader on USB level. So there is no driver in between. So you will have to implement and handle T=1 protocol by yourself in your code or find an existing Java implementation. The ISO-7816-3 is the standard which defines the T=1 protocol. Unfortunately it is not available for free so I cannot provide links to it (try Google search). You can find an existing implementation of T=1 protocol in C language in the opensource Linux CCID driver.

If you are not bound to GEMALTO IDBRIDGE K30 reader, you can get an other reader which has extended APDU or short APDU exchange level. In these cases you don't have to care about the protocol in your software.

arminb
  • 2,036
  • 3
  • 24
  • 43
  • Thanks for your response. I tried now on my PC/Windows and the reader worked with a different software. Are you sure i am doing nothing wrong in my application? And how can i enforce T=0 protocol? I have a miniusb to usb cable between device and reader could that cause the problem? – user2270079 Mar 12 '17 at 19:26
  • No, the miniusb-to-usb-cable should not be the problem BUT try to connect an external USB hub in between. You can enforce T=0 protocol by `PC_to_RDR_SetParameters` command. – arminb Mar 12 '17 at 19:42
  • 1
    I tried with an external USB hub in between but i still get the same error. I am using a Card OS 5.3 smart card. And in the documentation it is written. "Communication with the smart card should use the T1 protocol". Does it only support T=1 or can i still try T=0? When i use the PC_to_RDR_SetParameters where to i set the APDU? – user2270079 Mar 15 '17 at 11:05
  • Just found out your reader is a **TPDU** reader. Take a look at my updated answer. – arminb Mar 15 '17 at 11:53
0

PROCEDURE BYTE CONFLICT is CCID error. the source code of the C file is in http://ccid.sourcearchive.com/documentation/0.9.3/ccid_8c-source.html

Communicate with smartcard reader through Android USB host

Community
  • 1
  • 1
ralf htp
  • 9,149
  • 4
  • 22
  • 34