[Pcsclite-git-commit] [CCID] 01/01: Remove extra_egt() causing problems

Ludovic Rousseau rousseau at moszumanska.debian.org
Fri Oct 20 15:57:18 UTC 2017


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

rousseau pushed a commit to branch master
in repository CCID.

commit 63f13f83b2bac864460eba0a04bcca40750ed879
Author: Ludovic Rousseau <ludovic.rousseau at free.fr>
Date:   Fri Oct 20 17:46:08 2017 +0200

    Remove extra_egt() causing problems
    
    Problem with ATR 3B DF 18 FF 81 F1 FE 43 00 3F 03 83 4D 49 46 41 52 45
    20 50 6C 75 73 20 53 41 4D 3B and reader "Elatec
    TWN4/B1.06/CPF3.05/S1SC1.32/P (Beta 3)".
    
    The card declares TC1=0xFF
    The extra_egt() function replaces the value with 0x02 and the driver
    uses this value in the PC_to_RDR_ResetParameters.
    
    From ISO 7816-3 2006 chapter "11.2 Character frame"
    " If N = 255, CGT = 11 etu in **both directions** of transmission."
    
    So the card uses a CGT = 11 etu but the reader expects a CGT of a bit
    more than 12 etu. The card communicates faster than the reader expect.
    
    This patch was introduced to use non-ISO/bogus cards more than 10 years
    ago. Now the patch is problematic so I remove it.
    
    Thanks to Thomas Vetter for the bug report.
---
 src/ifdhandler.c | 81 --------------------------------------------------------
 1 file changed, 81 deletions(-)

diff --git a/src/ifdhandler.c b/src/ifdhandler.c
index 665681e..ec5c5a3 100644
--- a/src/ifdhandler.c
+++ b/src/ifdhandler.c
@@ -70,7 +70,6 @@ static int DebugInitialized = FALSE;
 
 /* local functions */
 static void init_driver(void);
-static void extra_egt(ATR_t *atr, _ccid_descriptor *ccid_desc, DWORD Protocol);
 static char find_baud_rate(unsigned int baudrate, unsigned int *list);
 static unsigned int T0_card_timeout(double f, double d, int TC1, int TC2,
 	int clock_frequency);
@@ -717,9 +716,6 @@ EXTERNAL RESPONSECODE IFDHSetProtocolParameters(DWORD Lun, DWORD Protocol,
 	if (ATR_MALFORMED == atr_ret)
 		return IFD_PROTOCOL_NOT_SUPPORTED;
 
-	/* Apply Extra EGT patch for bogus cards */
-	extra_egt(&atr, ccid_desc, Protocol);
-
 	if (SCARD_PROTOCOL_T0 == Protocol)
 		pps[1] |= ATR_PROTOCOL_TYPE_T0;
 	else
@@ -2033,83 +2029,6 @@ void init_driver(void)
 } /* init_driver */
 
 
-void extra_egt(ATR_t *atr, _ccid_descriptor *ccid_desc, DWORD Protocol)
-{
-	/* This function use an EGT value for cards who comply with followings
-	 * criterias:
-	 * - TA1 > 11
-	 * - current EGT = 0x00 or 0xFF
-	 * - T=0 or (T=1 and CWI >= 2)
-	 *
-	 * Without this larger EGT some non ISO 7816-3 smart cards may not
-	 * communicate with the reader.
-	 *
-	 * This modification is harmless, the reader will just be less restrictive
-	 */
-
-	unsigned int card_baudrate;
-	unsigned int default_baudrate;
-	double f, d;
-
-	/* if TA1 not present */
-	if (! atr->ib[0][ATR_INTERFACE_BYTE_TA].present)
-		return;
-
-	(void)ATR_GetParameter(atr, ATR_PARAMETER_D, &d);
-	(void)ATR_GetParameter(atr, ATR_PARAMETER_F, &f);
-
-	/* may happen with non ISO cards */
-	if ((0 == f) || (0 == d))
-		return;
-
-	/* Baudrate = f x D/F */
-	card_baudrate = (unsigned int) (1000 * ccid_desc->dwDefaultClock * d / f);
-
-	default_baudrate = (unsigned int) (1000 * ccid_desc->dwDefaultClock
-		* ATR_DEFAULT_D / ATR_DEFAULT_F);
-
-	/* TA1 > 11? */
-	if (card_baudrate <= default_baudrate)
-		return;
-
-	/* Current EGT = 0 or FF? */
-	if (atr->ib[0][ATR_INTERFACE_BYTE_TC].present &&
-		((0x00 == atr->ib[0][ATR_INTERFACE_BYTE_TC].value) ||
-		(0xFF == atr->ib[0][ATR_INTERFACE_BYTE_TC].value)))
-	{
-		if (SCARD_PROTOCOL_T0 == Protocol)
-		{
-			/* Init TC1 */
-			atr->ib[0][ATR_INTERFACE_BYTE_TC].present = TRUE;
-			atr->ib[0][ATR_INTERFACE_BYTE_TC].value = 2;
-			DEBUG_INFO1("Extra EGT patch applied");
-		}
-
-		if (SCARD_PROTOCOL_T1 == Protocol)
-		{
-			int i;
-
-			/* TBi (i>2) present? BWI/CWI */
-			for (i=2; i<ATR_MAX_PROTOCOLS; i++)
-			{
-				/* CWI >= 2 ? */
-				if (atr->ib[i][ATR_INTERFACE_BYTE_TB].present &&
-					((atr->ib[i][ATR_INTERFACE_BYTE_TB].value & 0x0F) >= 2))
-				{
-					/* Init TC1 */
-					atr->ib[0][ATR_INTERFACE_BYTE_TC].present = TRUE;
-					atr->ib[0][ATR_INTERFACE_BYTE_TC].value = 2;
-					DEBUG_INFO1("Extra EGT patch applied");
-
-					/* only the first TBi (i>2) must be used */
-					break;
-				}
-			}
-		}
-	}
-} /* extra_egt */
-
-
 static char find_baud_rate(unsigned int baudrate, unsigned int *list)
 {
 	int i;

-- 
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