[Pcsclite-cvs-commit] CVS Drivers/ccid/src
CVS User rousseau
ludovic.rousseau@free.fr
Tue, 19 Oct 2004 02:40:43 -0600
Update of /cvsroot/pcsclite/Drivers/ccid/src
In directory haydn:/tmp/cvs-serv3117/src
Modified Files:
Info.plist ccid_ifdhandler.h ccid_usb.c
Log Message:
check firmware version to avoid firmwares with bugs. You can still use a
bigus firmware by setting DRIVER_OPTION_USE_BOGUS_FIRMWARE in Info.plist
--- /cvsroot/pcsclite/Drivers/ccid/src/Info.plist 2004/08/17 16:56:19 1.11
+++ /cvsroot/pcsclite/Drivers/ccid/src/Info.plist 2004/10/19 08:40:42 1.12
@@ -47,6 +47,18 @@
If set the GemPC Twin and GemPC Key readers with be configured
so that the T=1 TPDU protocol is done by the firmware instead of
the driver
+
+ 4: DRIVER_OPTION_USE_BOGUS_FIRMWARE
+ Some reader firmwares have bugs. By default the driver refuses
+ to work with such firmware versions. If your reader is rejected
+ because of the firmware (log message: "Firmware (x.y) is
+ bogus!") you can:
+ - upgrade your reader firmware (not all readers can do that)
+ or
+ - get another reader with a new/bugfree firmware
+ or
+ - activate this option but you will have problems depending on
+ the bug
Default value: 0
-->
--- /cvsroot/pcsclite/Drivers/ccid/src/ccid_ifdhandler.h 2004/07/28 08:33:18 1.12
+++ /cvsroot/pcsclite/Drivers/ccid/src/ccid_ifdhandler.h 2004/10/19 08:40:42 1.13
@@ -18,7 +18,7 @@
*/
/*
- * $Id: ccid_ifdhandler.h,v 1.12 2004/07/28 08:33:18 rousseau Exp $
+ * $Id: ccid_ifdhandler.h,v 1.13 2004/10/19 08:40:42 rousseau Exp $
*/
#ifndef _ccid_ifd_handler_h_
@@ -33,6 +33,7 @@
#define DRIVER_OPTION_CCID_EXCHANGE_AUTHORIZED 1
#define DRIVER_OPTION_GEMPC_TWIN_KEY_APDU 2
+#define DRIVER_OPTION_USE_BOGUS_FIRMWARE 4
extern int LogLevel;
extern int DriverOptions;
--- /cvsroot/pcsclite/Drivers/ccid/src/ccid_usb.c 2004/10/07 20:28:49 1.41
+++ /cvsroot/pcsclite/Drivers/ccid/src/ccid_usb.c 2004/10/19 08:40:42 1.42
@@ -18,7 +18,7 @@
*/
/*
- * $Id: ccid_usb.c,v 1.41 2004/10/07 20:28:49 rousseau Exp $
+ * $Id: ccid_usb.c,v 1.42 2004/10/19 08:40:42 rousseau Exp $
*/
#define __CCID_USB__
@@ -89,6 +89,7 @@
#include "ccid_usb.h"
static int get_end_points(struct usb_device *dev, _usbDevice *usb_device);
+int ccid_check_firmware(struct usb_device *dev);
/* ne need to initialize to 0 since it is static */
static _usbDevice usbDevice[CCID_DRIVER_MAX_READERS];
@@ -97,6 +98,21 @@
#define PCSCLITE_PRODKEY_NAME "ifdProductID"
#define PCSCLITE_NAMEKEY_NAME "ifdFriendlyName"
+struct _bogus_firmware
+{
+ int vendor; /* idVendor */
+ int product; /* idProduct */
+ int firmware; /* bcdDevice: previous firmwares have bugs */
+};
+
+static struct _bogus_firmware Bogus_firmwares[] = {
+ { 0x0b97, 0x7762, 0x0111 }, /* Oz776S */ /* the firmware version if not correct since I don't have received a working reader yet */
+ { 0x04e6, 0x5115, 0x0516 }, /* SCR 331 */
+ { 0x04e6, 0x5115, 0x0620 }, /* SCR 331-DI */
+ { 0x04e6, 0x5115, 0x0514 }, /* SCR 335 */
+ { 0x04e6, 0xe003, 0x0415 }, /* SPR 532 */
+};
+
/*****************************************************************************
*
@@ -358,6 +374,10 @@
DEBUG_INFO3("Using USB bus/device: %s/%s",
bus->dirname, dev->filename);
+ /* check for firmware bugs */
+ if (ccid_check_firmware(dev))
+ return STATUS_UNSUCCESSFUL;
+
/* Get Endpoints values*/
get_end_points(dev, &usbDevice[reader_index]);
@@ -626,3 +646,45 @@
return usb_interface;
} /* get_ccid_usb_interface */
+
+/*****************************************************************************
+ *
+ * ccid_check_firmware
+ *
+ ****************************************************************************/
+int ccid_check_firmware(struct usb_device *dev)
+{
+ int i;
+
+ for (i=0; i<sizeof(Bogus_firmwares)/sizeof(Bogus_firmwares[0]); i++)
+ {
+ if (dev->descriptor.idVendor != Bogus_firmwares[i].vendor)
+ continue;
+
+ if (dev->descriptor.idProduct != Bogus_firmwares[i].product)
+ continue;
+
+ /* firmware too old and buggy */
+ if (dev->descriptor.bcdDevice < Bogus_firmwares[i].firmware)
+ {
+ if (DriverOptions & DRIVER_OPTION_USE_BOGUS_FIRMWARE)
+ {
+ DEBUG_INFO3("Firmware (%X.%02X) is bogus! but you choosed to use it",
+ dev->descriptor.bcdDevice >> 8,
+ dev->descriptor.bcdDevice & 0xFF);
+ return FALSE;
+ }
+ else
+ {
+ DEBUG_CRITICAL3("Firmware (%X.%02X) is bogus! Upgrade the reader firmware or get a new reader.",
+ dev->descriptor.bcdDevice >> 8,
+ dev->descriptor.bcdDevice & 0xFF);
+ return TRUE;
+ }
+ }
+ }
+
+ /* by default the firmware is not bogus */
+ return FALSE;
+} /* ccid_check_firmware */
+