[Pcsclite-cvs-commit] r1860 - trunk/Drivers/ccid/src

Ludovic Rousseau rousseau at costa.debian.org
Mon Feb 6 15:44:28 UTC 2006


Author: rousseau
Date: 2006-02-06 15:44:27 +0000 (Mon, 06 Feb 2006)
New Revision: 1860

Modified:
   trunk/Drivers/ccid/src/commands.c
Log:
SecurePINVerify/SecurePINModify: get the data from a T=1 TPDU block only
if the exchange was successful (with special treatment for timeout and
cancel cases)


Modified: trunk/Drivers/ccid/src/commands.c
===================================================================
--- trunk/Drivers/ccid/src/commands.c	2006-02-06 15:26:28 UTC (rev 1859)
+++ trunk/Drivers/ccid/src/commands.c	2006-02-06 15:44:27 UTC (rev 1860)
@@ -286,13 +286,24 @@
 	ret = CCID_Receive(reader_index, RxLength, RxBuffer);
 
 	/* T=1 Protocol Management for a TPDU reader */
-	if ((SCARD_PROTOCOL_T1 == ccid_descriptor->cardProtocol)
+	if ((IFD_SUCCESS == ret)
+		&& (SCARD_PROTOCOL_T1 == ccid_descriptor->cardProtocol)
 		&& (CCID_CLASS_TPDU == (ccid_descriptor->dwFeatures & CCID_CLASS_EXCHANGE_MASK)))
 	{
-		/* get only the T=1 data */
-		/* FIXME: manage T=1 error blocks */
-		memmove(RxBuffer, RxBuffer+3, *RxLength -4);
-		*RxLength -= 4;	/* remove NAD, PCB, LEN and CRC */
+		/* timeout and cancel cases are faked by CCID_Receive() */
+		if (2 == *RxLength)
+		{
+			/* Decrement the sequence numbers since no TPDU was sent */
+			get_ccid_slot(reader_index)->t1.ns ^= 1;
+			get_ccid_slot(reader_index)->t1.nr ^= 1;
+		}
+		else
+		{
+			/* get only the T=1 data */
+			/* FIXME: manage T=1 error blocks */
+			memmove(RxBuffer, RxBuffer+3, *RxLength -4);
+			*RxLength -= 4;	/* remove NAD, PCB, LEN and CRC */
+		}
 	}
 
 	ccid_descriptor -> readTimeout = old_read_timeout;
@@ -463,13 +474,24 @@
  	ret = CCID_Receive(reader_index, RxLength, RxBuffer);
 
 	/* T=1 Protocol Management for a TPDU reader */
-	if ((SCARD_PROTOCOL_T1 == ccid_descriptor->cardProtocol)
+	if ((IFD_SUCCESS == ret)
+		&& (SCARD_PROTOCOL_T1 == ccid_descriptor->cardProtocol)
 		&& (CCID_CLASS_TPDU == (ccid_descriptor->dwFeatures & CCID_CLASS_EXCHANGE_MASK)))
 	{
-		/* get only the T=1 data */
-		/* FIXME: manage T=1 error blocks */
-		memmove(RxBuffer, RxBuffer+3, *RxLength -4);
-		*RxLength -= 4;	/* remove NAD, PCB, LEN and CRC */
+		/* timeout and cancel cases are faked by CCID_Receive() */
+		if (2 == *RxLength)
+		{
+			/* Decrement the sequence numbers since no TPDU was sent */
+			get_ccid_slot(reader_index)->t1.ns ^= 1;
+			get_ccid_slot(reader_index)->t1.nr ^= 1;
+		}
+		else
+		{
+			/* get only the T=1 data */
+			/* FIXME: manage T=1 error blocks */
+			memmove(RxBuffer, RxBuffer+3, *RxLength -4);
+			*RxLength -= 4;	/* remove NAD, PCB, LEN and CRC */
+		}
 	}
 
 	ccid_descriptor -> readTimeout = old_read_timeout;




More information about the Pcsclite-cvs-commit mailing list