[Pcsclite-git-commit] [CCID] 01/01: Negociate maximum baud rate when bNumDataRatesSupported = 0

Ludovic Rousseau rousseau at moszumanska.debian.org
Wed Oct 5 13:06:05 UTC 2016


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

rousseau pushed a commit to branch master
in repository CCID.

commit 33888a88cdcdf16e98c3d0d42593ebc743719e11
Author: Ludovic Rousseau <ludovic.rousseau at free.fr>
Date:   Wed Oct 5 14:57:42 2016 +0200

    Negociate maximum baud rate when bNumDataRatesSupported = 0
    
    From CCID 1.1 page 18:
    " bNumDataRatesSupported
    The number of data rates that are supported by the CCID.
    If the value is 00h, all data rates between the default data rate
    dwDataRate and the maximum data rate dwMaxDataRate are supported. "
    
    Before, if the card baud rate was greater than the reader dwMaxDataRate
    then the driver used the default (lowest) baud rate.
    
    Now the driver tries to find the maximal baud rate supported by both the
    card and the driver.
    
    The algorithm was already used when the reader reports a baud rate list
    but not when the reader reports bNumDataRatesSupported = 0.
    
    Thanks to Abraham Macías Paredes for the bug report
    "[Pcsclite-muscle] Bug in CCID library"
    https://lists.alioth.debian.org/pipermail/pcsclite-muscle/Week-of-Mon-20161003/000729.html
    
    Thanks to Godfrey Chung for the patch idea
    "Fix the optimal baud rate problem in IFDHSetProtocolParameters()."
    https://github.com/acshk/acsccid/commit/4a7631d014781d36a2d21210b0b8768c07ef8c6d
---
 src/ifdhandler.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/ifdhandler.c b/src/ifdhandler.c
index 0db60ef..991e6b0 100644
--- a/src/ifdhandler.c
+++ b/src/ifdhandler.c
@@ -831,9 +831,7 @@ EXTERNAL RESPONSECODE IFDHSetProtocolParameters(DWORD Lun, DWORD Protocol,
 				/* the card is too fast for the reader */
 				if ((card_baudrate > ccid_desc->dwMaxDataRate +2)
 					/* but TA1 <= 97 */
-					&& (atr.ib[0][ATR_INTERFACE_BYTE_TA].value <= 0x97)
-					/* and the reader has a baud rate table */
-					&& ccid_desc->arrayOfSupportedDataRates)
+					&& (atr.ib[0][ATR_INTERFACE_BYTE_TA].value <= 0x97))
 				{
 					unsigned char old_TA1;
 
@@ -850,8 +848,15 @@ EXTERNAL RESPONSECODE IFDHSetProtocolParameters(DWORD Lun, DWORD Protocol,
 						card_baudrate = (unsigned int) (1000 *
 							ccid_desc->dwDefaultClock * d / f);
 
-						if (find_baud_rate(card_baudrate,
+						/* the reader has a baud rate table */
+						if ((ccid_desc->arrayOfSupportedDataRates
+							/* and the baud rate is supported */
+							&& find_baud_rate(card_baudrate,
 							ccid_desc->arrayOfSupportedDataRates))
+							/* or the reader has NO baud rate table */
+							|| ((NULL == ccid_desc->arrayOfSupportedDataRates)
+							/* and the baud rate is bellow the limit */
+							&& (card_baudrate <= ccid_desc->dwMaxDataRate)))
 						{
 							pps[1] |= 0x10; /* PTS1 presence */
 							pps[2] = atr.ib[0][ATR_INTERFACE_BYTE_TA].value;

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