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

Ludovic Rousseau rousseau at costa.debian.org
Mon Feb 6 15:23:41 UTC 2006


Author: rousseau
Date: 2006-02-06 15:23:41 +0000 (Mon, 06 Feb 2006)
New Revision: 1858

Modified:
   trunk/Drivers/ccid/src/commands.c
Log:
SecurePINModify(): add support of T=1 cards with TPDU readers


Modified: trunk/Drivers/ccid/src/commands.c
===================================================================
--- trunk/Drivers/ccid/src/commands.c	2006-02-06 15:14:01 UTC (rev 1857)
+++ trunk/Drivers/ccid/src/commands.c	2006-02-06 15:23:41 UTC (rev 1858)
@@ -376,6 +376,32 @@
 	}
 #endif
 
+	/* T=1 Protocol Management for a TPDU reader */
+	if ((SCARD_PROTOCOL_T1 == ccid_descriptor->cardProtocol)
+		&& (CCID_CLASS_TPDU == (ccid_descriptor->dwFeatures & CCID_CLASS_EXCHANGE_MASK)))
+	{
+		ct_buf_t sbuf;
+		unsigned char sdata[T1_BUFFER_SIZE];
+
+		/* Initialize send buffer with the APDU */
+		ct_buf_set(&sbuf,
+			(void *)(TxBuffer + offsetof(PIN_MODIFY_STRUCTURE, abData)),
+			TxLength - offsetof(PIN_MODIFY_STRUCTURE, abData));
+
+		/* Create T=1 block */  
+		ret = t1_build(&((get_ccid_slot(reader_index))->t1),
+			sdata, 0, T1_I_BLOCK, &sbuf, NULL); 
+
+		/* Increment the sequence numbers  */
+		get_ccid_slot(reader_index)->t1.ns ^= 1;
+		get_ccid_slot(reader_index)->t1.nr ^= 1;
+
+		/* Copy the generated T=1 block prologue into the teoprologue
+		 * of the CCID command */
+		memcpy(TxBuffer + offsetof(PIN_MODIFY_STRUCTURE, bTeoPrologue),
+			sdata, 3);
+	}
+
 	/* Build a CCID block from a PC/SC V2.1.2 Part 10 block */
 
 	/* Do adjustments as needed - CCID spec is not exact with some
@@ -435,6 +461,16 @@
 
  	ret = CCID_Receive(reader_index, RxLength, RxBuffer);
 
+	/* T=1 Protocol Management for a TPDU reader */
+	if ((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 */
+	}
+
 	ccid_descriptor -> readTimeout = old_read_timeout;
 	return ret;
 } /* SecurePINModify */




More information about the Pcsclite-cvs-commit mailing list