Android Smartcard reader through USB Error: PROCEDURE BYTE CONFLICT

Android Smartcard reader through USB Error: PROCEDURE BYTE CONFLICT

我正在使用通过 USB 连接到 Android 设备的 GEMALTO IDBRIDGE K30。

首先,我要像这样发送 PC_to_RDR_IccPowerOff 消息。

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)));

作为回应我得到

收到长度为 64 且内容为:[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]

在此之后我等待 5 秒,然后我尝试使用 PC_to_RDR_XfrBlock.

发送 APDU Select 命令
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,};

作为响应,我得到了一个错误 F4,描述为 PROCEDURE BYTE CONFLICT:

收到长度为 64 且内容为:[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]

有人可以帮助我吗?我不明白我做错了什么。

PROCEDURE BYTE CONFLICT 错误有点棘手,因为它发生在 reader 的固件内部,并通过 CCID 升级给您。基本上这意味着 reader 通过 T=1 协议与智能卡通信,并且在 reader 和智能卡之间没有正确接收或发送一些 T=1 过程字节。在我看来,您在申请中无能为力。你可以做什么:

  • 如果您的智能卡支持 T=0 协议,请尝试执行它
  • 将您的 reader 更新到最新固件
  • 可能你的智能卡坏了,换一张相同类型的(或更新版本的)试试

  • 另外 here 它指出某些 USB 端口有时会出现问题。尝试将 reader 连接到 Android 设备的 USB 集线器。

更新

您的智能卡 reader GEMALTO IDBRIDGE K30 报告 TPDU 交换级别 (请参阅 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

如果您未绑定到 GEMALTO IDBRIDGE K30 reader,您可以获得另一个 reader,它具有 扩展 APDUshort APDU 交换级别。在这些情况下,您不必关心软件中的协议。

PROCEDURE BYTE CONFLICT 是 CCID 错误。 C文件的源代码在http://ccid.sourcearchive.com/documentation/0.9.3/ccid_8c-source.html

Communicate with smartcard reader through Android USB host