Package: libchipcard
Version: 4.2.4-2
Severity: normal
Tags: patch

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Micha,

the patch appended to
https://devel.aqbanking.de/trac/libchipcard/ticket/15
makes the GemPC Express reader, and probably other libccid based
readers, work.

Thanks,
Joachim

- -- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.28-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAknBJKIACgkQ9ijrk0dDIGyRqwCeKS4845COFUTb2TEh/S7gCobZ
ds0AoMIYEtNq2CHYm3qxzatuMbvjXnrO
=lBzq
-----END PGP SIGNATURE-----
#! /bin/sh /usr/share/dpatch/dpatch-run
## 20_gemexpress.dpatch by Joachim Breitner <[email protected]>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
diff -urNad libchipcard-4.2.4~/data/drivers/posix/ccid_ifd/ccid_ifd.xml libchipcard-4.2.4/data/drivers/posix/ccid_ifd/ccid_ifd.xml
--- libchipcard-4.2.4~/data/drivers/posix/ccid_ifd/ccid_ifd.xml	2009-01-22 00:20:49.000000000 +0100
+++ libchipcard-4.2.4/data/drivers/posix/ccid_ifd/ccid_ifd.xml	2009-03-18 10:43:25.000000000 +0100
@@ -47,6 +47,13 @@
 
   <readers>
   
+    <reader name="ccid_gempc_express" busType="UsbRaw"
+            addressType="devicePath"
+            devicePathTmpl="usb:$(vendorId:04x)/$(productId:04x):libusb:$(busName):$(deviceName)"
+            vendor="0x08e6" product="0x34ec" >
+      <short>GemPC Express</short>
+    </reader>
+
     <reader name="ccid_gempc_key" busType="UsbRaw"
             addressType="devicePath"
             devicePathTmpl="usb:$(vendorId:04x)/$(productId:04x):libusb:$(busName):$(deviceName)"
diff -urNad libchipcard-4.2.4~/src/drivers/ifd/driverifd.c libchipcard-4.2.4/src/drivers/ifd/driverifd.c
--- libchipcard-4.2.4~/src/drivers/ifd/driverifd.c	2008-04-09 09:39:21.000000000 +0200
+++ libchipcard-4.2.4/src/drivers/ifd/driverifd.c	2009-03-18 10:43:25.000000000 +0100
@@ -285,6 +285,9 @@
   case CCID_ICC_NOT_PRESENT:
     s="Card not present";
     break;
+  case CCID_COMMUNICATION_ERROR:
+    s="Communication error";
+    break;
   default:
     s="Unknow error code";
   };
@@ -511,7 +514,7 @@
 
 
 
-long DriverIFD__ConnectSlot(LCD_DRIVER *d, LCD_SLOT *sl) {
+uint32_t DriverIFD_ConnectSlot(LCD_DRIVER *d, LCD_SLOT *sl) {
   long retval;
   unsigned char atrBuffer[300];
   DWORD atrLen;
@@ -584,6 +587,27 @@
       LCD_Slot_AddFlags(sl, LCD_SLOT_FLAGS_PROCESSORCARD);
     }
     LCD_Slot_SetProtocolInfo(sl, proto);
+
+    int ccid_proto;
+    switch (proto) {
+      case 0: ccid_proto = 1; break;
+      case 1: ccid_proto = 2; break;
+      default:
+	DBG_ERROR(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)),
+	         "CCID: Unkown Protocol in ATR: T=%d", proto);
+	break;
+    }
+    DBG_INFO(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)),
+	     "CCID: Setting Protocol T=%d", proto);
+    retval=dct->setProtoFn(LCD_Slot_GetSlotNum(sl),
+			   ccid_proto, 0, 0, 0, 0);
+    if (retval) {
+      DBG_ERROR(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)),
+	       "CCID: Error setting protocol T=%d (%d)",
+	       proto, (int)retval);
+      return retval;
+    }
+
   }
   else if (retval==CCID_ICC_NOT_PRESENT) {
     DBG_NOTICE(LCD_Reader_GetLogger(r), "No card inserted");
@@ -600,57 +624,6 @@
   return 0;
 }
 
-
-
-uint32_t DriverIFD_ConnectSlot(LCD_DRIVER *d, LCD_SLOT *sl) {
-  int i;
-  DRIVER_IFD *dct;
-  long retval;
-
-  assert(d);
-  dct=GWEN_INHERIT_GETDATA(LCD_DRIVER, DRIVER_IFD, d);
-  assert(dct);
-
-  retval=DriverIFD__ConnectSlot(d, sl);
-  if (retval!=CCID_ERROR_POWER_ACTION) {
-    DBG_INFO(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)),
-	     "CCID: Result is not POWER_ACTION (%d)",
-	     (int)retval);
-    return retval;
-  }
-
-  if (dct->setProtoFn==NULL)
-    return retval;
-
-  /* try protocols 0 through 15 */
-  for (i=0; i<16; i++) {
-    /* set protocol bt don't change PTS */
-    retval=dct->setProtoFn(LCD_Slot_GetSlotNum(sl),
-			   i, 0, 0, 0, 0);
-    if (retval) {
-      DBG_INFO(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)),
-	       "CCID: Error setting protocol %d (%d)",
-	       i, (int)retval);
-    }
-    else {
-      retval=DriverIFD__ConnectSlot(d, sl);
-      if (retval!=CCID_ERROR_POWER_ACTION) {
-	DBG_INFO(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)),
-		 "CCID: Result is not POWER_ACTION (%d, proto=%d)",
-		 (int)retval, i);
-	return retval;
-      }
-    }
-  }
-
-  /* assuming no card inserted */
-  DBG_INFO(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)),
-	   "Assuming no card is inserted");
-  return 0;
-}
-
-
-
 uint32_t DriverIFD_DisconnectSlot(LCD_DRIVER *d, LCD_SLOT *sl) {
   long retval;
   unsigned char atrBuffer[300];
@@ -716,6 +689,29 @@
   else if (retval==0) {
     LCD_Slot_AddStatus(sl, LCD_SLOT_STATUS_CARD_INSERTED);
     LCD_Slot_AddStatus(sl, LCD_SLOT_STATUS_CARD_CONNECTED);
+
+    int proto;
+    proto=DriverIFD_ExtractProtocolInfo(atrBuffer, atrLen);
+    // Or should it be read from LCD_Slot_GetProtocolInfo?
+    int ccid_proto;
+    switch (proto) {
+      case 0: ccid_proto = 1; break;
+      case 1: ccid_proto = 2; break;
+      default:
+	DBG_ERROR(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)),
+	         "CCID: Unkown Protocol in ATR: T=%d", proto);
+	break;
+    }
+    DBG_INFO(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)),
+	     "CCID: Setting Protocol T=%d", proto);
+    retval=dct->setProtoFn(LCD_Slot_GetSlotNum(sl),
+			   ccid_proto, 0, 0, 0, 0);
+    if (retval) {
+      DBG_ERROR(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)),
+	       "CCID: Error setting protocol T=%d (%d)",
+	       proto, (int)retval);
+      return retval;
+    }
   }
   else {
     DBG_NOTICE(LCD_Reader_GetLogger(LCD_Slot_GetReader(sl)),

Reply via email to