Re: [opensc-devel] Fix for O2 Micro CCID SC Reader

2009-02-02 Thread Chaskiel Grundman


On Thu, 29 Jan 2009, Andrey Jivsov wrote:

 I am attaching the tested patch to the file ifd-ccid.c to add support for the 
 reader. The reader's USB IDs that I tested with are 0b97:7762 and 0b97:7772. 
 Without this patch the ifd-ccid.c code will not work with these readers.

 The patch is based on the work done in the pcsc-lite project. The patch is 
 made against openct-0.6.15-svn-r1127. I didn't make corresponding updates to 
 text configuration files.

The patch is good (if a little conservative). I failed to notice this 
badness, despite having one of these devices myself, because the openct 
head includes a (broken, now that I look at it*) patch to the usb 
descriptor handling that replaces the extra data for an interface with the 
extra data for an endpoint, for any endpoint that has extra data (see 
revision 942 of usb-descriptors.c). In the event that a new openct 
release is prepared from the head, only one of these patches should be 
used


* the usb-descriptors.c patch is broken because it will throw away extra 
data that an interface has if an endpoint also has extra data. Also, it 
will leak memory if either a) both the interface and an enpoint have extra 
data, or b) multiple endpoints have extra data. These scenarios are 
unlikely
___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel


Re: [opensc-devel] Fix for O2 Micro CCID SC Reader

2009-02-02 Thread Alon Bar-Lev
Thanks for finding it!
I think best is to revert r942 and ask Kurt Jaeger for a different patch.
What do you think?

On 2/3/09, Chaskiel Grundman c...@andrew.cmu.edu wrote:


  On Thu, 29 Jan 2009, Andrey Jivsov wrote:

   I am attaching the tested patch to the file ifd-ccid.c to add support for 
 the
   reader. The reader's USB IDs that I tested with are 0b97:7762 and 
 0b97:7772.
   Without this patch the ifd-ccid.c code will not work with these readers.
  
   The patch is based on the work done in the pcsc-lite project. The patch is
   made against openct-0.6.15-svn-r1127. I didn't make corresponding updates 
 to
   text configuration files.


 The patch is good (if a little conservative). I failed to notice this
  badness, despite having one of these devices myself, because the openct
  head includes a (broken, now that I look at it*) patch to the usb
  descriptor handling that replaces the extra data for an interface with the
  extra data for an endpoint, for any endpoint that has extra data (see
  revision 942 of usb-descriptors.c). In the event that a new openct
  release is prepared from the head, only one of these patches should be
  used


  * the usb-descriptors.c patch is broken because it will throw away extra
  data that an interface has if an endpoint also has extra data. Also, it
  will leak memory if either a) both the interface and an enpoint have extra
  data, or b) multiple endpoints have extra data. These scenarios are
  unlikely

 ___
  opensc-devel mailing list
  opensc-devel@lists.opensc-project.org
  http://www.opensc-project.org/mailman/listinfo/opensc-devel

___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel


Re: [opensc-devel] Fix for O2 Micro CCID SC Reader

2009-01-30 Thread Ludovic Rousseau
Hello,

2009/1/29 Andrey Jivsov ope...@brainhub.org:
 I am attaching the tested patch to the file ifd-ccid.c to add support for
 the reader. The reader's USB IDs that I tested with are 0b97:7762 and
 0b97:7772. Without this patch the ifd-ccid.c code will not work with these
 readers.

Why do you use OpenCT instead of pcsc-lite + my CCID driver?

Bye

-- 
 Dr. Ludovic Rousseau
___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel


[opensc-devel] Fix for O2 Micro CCID SC Reader

2009-01-29 Thread Andrey Jivsov
I am attaching the tested patch to the file ifd-ccid.c to add support 
for the reader. The reader's USB IDs that I tested with are 0b97:7762 
and 0b97:7772. Without this patch the ifd-ccid.c code will not work with 
these readers.


The patch is based on the work done in the pcsc-lite project. The patch 
is made against openct-0.6.15-svn-r1127. I didn't make corresponding 
updates to text configuration files.


Thank you.
--- openct-0.6.15-svn-r1127/src/ifd/ifd-ccid.c  2009-01-29 13:03:01.0 
-0800
+++ openct-with-fix/src/ifd/ifd-ccid.c  2009-01-29 13:05:00.0 -0800
@@ -583,22 +583,50 @@
bEndpointAddress;
}
}
if (ok == 7)
break;
intf = NULL;
}
if (!intf)
continue;
if (!intf-extralen) {
-   intf = NULL;
-   continue;
+   int i;
+   /* Buggy O2 Micro CCID SC Reader has zero extra 
len at interface level but not endpoint descriptor.
+* Patch the interface level field and proceed.
+* ProdID 7762 reader is in Dell Latitude D620 
and 7772 is in D630.
+*/
+   if( de.idVendor == 0x0b97  (de.idProduct == 
0x7762 || de.idProduct == 0x7772) )  {
+   ct_error(ccid: extra len is zero, 
patching O2 Micro support);
+   for (i=0; iintf-bNumEndpoints; i++)  {
+   /* find the extra[] array */
+   if( intf-endpoint[i].extralen 
== 54 )  {
+   /* get the extra[] from 
the endpoint */
+   intf-extralen = 54;
+   /* avoid double free on 
close, allocate here */
+   intf-extra = 
malloc(54);
+   if( intf-extra )  {
+   memcpy( 
intf-extra, intf-endpoint[i].extra, 54 );
+   break;
+   }
+   else  {
+   intf = NULL;
+   continue;
+   }
+   }
+   }
+   }
+   else  {
+   intf = NULL;
+   ct_error(ccid: extra len is zero, 
continuing);
+   continue;
+   }
}
 
r = intf-extralen;
_class = intf-extra;
i = 0;
p = _class + i;
/* 0x21 == USB_TYPE_CLASS | 0x1 */
/* accept descriptor type 0xFF if force_parse != 0 */
while (i  r  p[0]  2 
   (p[1] != 0x21 
___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel