Package: libccid
Version: 1.3.8-1
Severity: normal
Hi, there.
I think that current implementation for ICCD version A does not work
well. While I am implementing ICCD device, I found some problems.
(Note that I don't have any ICCD version A device other than my own
development device. So, my understanding/interpretation of protocol
would be wrong.)
Here is a patch to discuss issues.
(1) Function CCID_Receive() should change the value pointed by rx_length.
--- ccid-1.3.8.orig/src/commands.c
+++ ccid-1.3.8/src/commands.c
@@ -1121,6 +1121,7 @@
return IFD_COMMUNICATION_ERROR;
}
+ *rx_length = r;
return IFD_SUCCESS;
}
This is needed to let the caller length of actual data received.
(2) Function CmdXfrBlockCHAR_T0() should handle length of received
packet correctly.
(3) It is better for Function CmdXfrBlockCHAR_T0() to check status
before calling CCID_Transmit().
@@ -1727,6 +1728,8 @@
if (ICCD_A == ccid_descriptor->bInterfaceProtocol)
{
unsigned char pcbuffer[SIZE_GET_SLOT_STATUS];
+ unsigned int orig_rcv_len = *rcv_len;
+ unsigned int data_rcvd_len;
/* Command to send to the smart card (must be 5 bytes) */
memset(cmd, 0, sizeof(cmd));
@@ -1743,6 +1746,11 @@
snd_len -= 5;
}
+ /* wait for ready */
+ return_value = CmdGetSlotStatus(reader_index, pcbuffer);
+ if (return_value != IFD_SUCCESS)
+ return return_value;
+
/* at most 5 bytes */
return_value = CCID_Transmit(reader_index, 5, cmd, 0, 0);
if (return_value != IFD_SUCCESS)
@@ -1762,14 +1770,27 @@
}
else
{
- if ((0x20 == pcbuffer[0]) && (*rcv_len > 2))
- /* we will just read SW1-SW2 */
- *rcv_len = 2;
+ return_value = CCID_Receive(reader_index, rcv_len,
rcv_buf, NULL);
+ if (return_value != IFD_SUCCESS)
+ DEBUG_CRITICAL("CCID_Receive failed");
+
+ if ((0x20 == pcbuffer[0])) /* ... was SW1-SW2 */
+ return return_value;
+
+ /* wait for ready */
+ return_value = CmdGetSlotStatus(reader_index, pcbuffer);
+ if (return_value != IFD_SUCCESS)
+ return return_value;
+
+ data_rcvd_len = *rcv_len;
+ rcv_buf += *rcv_len;
+ *rcv_len = orig_rcv_len;
return_value = CCID_Receive(reader_index, rcv_len,
rcv_buf, NULL);
if (return_value != IFD_SUCCESS)
DEBUG_CRITICAL("CCID_Receive failed");
+ *rcv_len += data_rcvd_len;
return return_value;
}
@@ -1778,15 +1799,28 @@
if (return_value != IFD_SUCCESS)
return return_value;
- if ((0x20 == pcbuffer[0]) && (*rcv_len > 2))
- /* we will just read SW1-SW2 */
- *rcv_len = 2;
+ return_value = CCID_Receive(reader_index, rcv_len, rcv_buf,
NULL);
+ if (return_value != IFD_SUCCESS)
+ DEBUG_CRITICAL("CCID_Receive failed");
+
+ if ((0x20 == pcbuffer[0])) /* ... was SW1-SW2 */
+ return return_value;
+
+ /* wait for ready */
+ return_value = CmdGetSlotStatus(reader_index, pcbuffer);
+ if (return_value != IFD_SUCCESS)
+ return return_value;
+
+ data_rcvd_len = *rcv_len;
+ rcv_buf += *rcv_len;
+ *rcv_len = orig_rcv_len;
/* read SW1-SW2 */
return_value = CCID_Receive(reader_index, rcv_len, rcv_buf,
NULL);
if (return_value != IFD_SUCCESS)
DEBUG_CRITICAL("CCID_Receive failed");
+ *rcv_len += data_rcvd_len;
return return_value;
}
-- System Information:
Debian Release: lenny/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.6.26-1-686 (SMP w/1 CPU core)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/bash
Versions of packages libccid depends on:
ii libc6 2.7-15 GNU C Library: Shared libraries
ii libpcsclite1 1.4.102-1 Middleware to access a smart card
ii libusb-0.1-4 2:0.1.12-13 userspace USB programming library
Versions of packages libccid recommends:
ii pcscd 1.4.102-1 Middleware to access a smart card
Versions of packages libccid suggests:
ii pcmciautils 014-4 PCMCIA utilities for Linux 2.6
-- no debconf information
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]