[Pcsclite-git-commit] [CCID] 02/05: Set timeout to 90 sec for PPDU commands

Ludovic Rousseau rousseau at moszumanska.debian.org
Sun Nov 8 21:01:10 UTC 2015


This is an automated email from the git hooks/post-receive script.

rousseau pushed a commit to branch master
in repository CCID.

commit 7748ae13bf4c48d2f34993dd6086d62aa0a91cf0
Author: Ludovic Rousseau <ludovic.rousseau at free.fr>
Date:   Fri Nov 6 20:21:58 2015 +0100

    Set timeout to 90 sec for PPDU commands
    
    PPDU (Pseudo APDU) commands are described in PC/SC v2 part 10
    supplement document. They are defined as CLA=0xFF, INS=0xC2, P1=0x01.
    When a PPDU is sent through SCardTransmit() the communication timeout is
    changed to 90 seconds (the same as for a SCardControl() command).
    
    This change allows the use of a Secure Verify command sent as a PPDU
    through SCardTransmit(). The calculated timeout of 2.85 seconds was too
    short in this case.
    
    Fix alioth bug [#315217] "Cherry KC 1000 SC direct PIN modification
    timeout Pseudo APDU"
    https://alioth.debian.org/tracker/?func=detail&atid=410085&aid=315217&group_id=30105
    
    Thanks to Roman Pasechnik for the bug report.
---
 src/ifdhandler.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/ifdhandler.c b/src/ifdhandler.c
index f48761b..ea70cb3 100644
--- a/src/ifdhandler.c
+++ b/src/ifdhandler.c
@@ -1273,12 +1273,17 @@ EXTERNAL RESPONSECODE IFDHTransmitToICC(DWORD Lun, SCARD_IO_HEADER SendPci,
 	RESPONSECODE return_value;
 	unsigned int rx_length;
 	int reader_index;
+	int old_read_timeout;
+	int restore_timeout = FALSE;
+	_ccid_descriptor *ccid_descriptor;
 
 	(void)RecvPci;
 
 	if (-1 == (reader_index = LunToReaderIndex(Lun)))
 		return IFD_COMMUNICATION_ERROR;
 
+	ccid_descriptor = get_ccid_descriptor(reader_index);
+
 	DEBUG_INFO3("%s (lun: " DWORD_X ")", CcidSlots[reader_index].readerName,
 		Lun);
 
@@ -1333,6 +1338,16 @@ EXTERNAL RESPONSECODE IFDHTransmitToICC(DWORD Lun, SCARD_IO_HEADER SendPci,
 
 	}
 
+	/* Pseudo-APDU as defined in PC/SC v2 part 10 supplement document
+	 * CLA=0xFF, INS=0xC2, P1=0x01 */
+	if (0 == memcmp(TxBuffer, "\xFF\xC2\x01", 3))
+	{
+		/* Yes, use the same timeout as for SCardControl() */
+		restore_timeout = TRUE;
+		old_read_timeout = ccid_descriptor -> readTimeout;
+		ccid_descriptor -> readTimeout = 90;	/* 90 seconds */
+	}
+
 	rx_length = *RxLength;
 	return_value = CmdXfrBlock(reader_index, TxLength, TxBuffer, &rx_length,
 		RxBuffer, SendPci.Protocol);
@@ -1341,6 +1356,10 @@ EXTERNAL RESPONSECODE IFDHTransmitToICC(DWORD Lun, SCARD_IO_HEADER SendPci,
 	else
 		*RxLength = 0;
 
+	/* restore timeout */
+	if (restore_timeout)
+		ccid_descriptor -> readTimeout = old_read_timeout;
+
 	return return_value;
 } /* IFDHTransmitToICC */
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pcsclite/CCID.git



More information about the Pcsclite-cvs-commit mailing list