[Pcsclite-cvs-commit] CVS Drivers/ccid/src

CVS User rousseau ludovic.rousseau@free.fr
Thu, 13 Jan 2005 02:32:18 -0700


Update of /cvsroot/pcsclite/Drivers/ccid/src
In directory haydn:/tmp/cvs-serv10194

Modified Files:
	commands.c 
Log Message:
SecurePIN(): proprietary command to add the PIN code in the APDU without
any padding (this is not possible with the CCID specs).

Thanks to Martin Paljak for the patch.


--- /cvsroot/pcsclite/Drivers/ccid/src/commands.c	2005/01/09 21:29:57	1.35
+++ /cvsroot/pcsclite/Drivers/ccid/src/commands.c	2005/01/13 09:32:17	1.36
@@ -18,7 +18,7 @@
 */
 
 /*
- * $Id: commands.c,v 1.35 2005/01/09 21:29:57 rousseau Exp $
+ * $Id: commands.c,v 1.36 2005/01/13 09:32:17 rousseau Exp $
  */
 
 #include <string.h>
@@ -180,6 +180,24 @@
 	/* CCID data structure + APDU */
 	memcpy(cmd + 11, TxBuffer, TxLength);
 
+	/* SPR532 and Case 1 APDU */
+	if ((SPR532 == ccid_descriptor->readerID) && (TxLength - 14 == 4))
+	{
+		RESPONSECODE return_value;
+		unsigned char cmd[] = { 0x80,0x02, 0x00 };
+		unsigned char res[1];
+		unsigned int res_length = sizeof(res);
+
+		/* the SPR532 will append the PIN code without any padding */
+		return_value = CmdEscape(reader_index, cmd, sizeof(cmd), res,
+			&res_length);
+		if (return_value != IFD_SUCCESS)
+		{
+			ccid_error(res[ERROR_OFFSET], __FILE__, __LINE__, __FUNCTION__);
+			return return_value;
+		}
+	}
+
 	if (WritePort(reader_index, TxLength+1+10, cmd) != STATUS_SUCCESS)
 		return IFD_COMMUNICATION_ERROR;