[opensc-devel] Wrong check for response APDU buffer

2012-12-07 Thread Frank Morgner
Hi!

Currently, sc_check_apdu checks the length of an R-APDU buffer using
SC_MAX_APDU_BUFFER_SIZE, which defines the maximum length for a C-APDU.
https://github.com/OpenSC/OpenSC/blob/master/src/libopensc/apdu.c#L415
https://github.com/OpenSC/OpenSC/blob/master/src/libopensc/apdu.c#L392

A quick fix would be to use 0xff+1/0x+1 instead. However, in
multiple files I have seen this wrong usage of SC_MAX_APDU_BUFFER_SIZE
(eg, see `grep rbuf *.c | grep SC_MAX_APDU_BUFFER_SIZE`). Unfortunately
I dont have time to check libopensc in depth, so I leave this up to the
community.

-- 
Frank Morgner

Virtual Smart Card Architecture http://vsmartcard.sourceforge.net
OpenPACEhttp://openpace.sourceforge.net
IFD Handler for libnfc Devices  http://sourceforge.net/projects/ifdnfc


pgp9fz0CxMiu6.pgp
Description: PGP signature
___
opensc-devel mailing list
opensc-devel@lists.opensc-project.org
http://www.opensc-project.org/mailman/listinfo/opensc-devel

Re: [opensc-devel] The smart card reader is known as "VMware Virtual USB CCID 00 00" in linux ??!!

2012-12-07 Thread Rns Course


Hello

> In addition to trying to connect the card directly to the VM, you said
> you had built OpenSC-0.12.2. Could you try and build the new 0.13.0
> and test again?

Yes, I had built OpenSC-0.12.2 in linux (fedora 16) and wanted to initialize 
the card with pkcs15-init tool, 
but I was problem in connecting the card to the VM directly!
The VM recognizes the card as shared reader not any USB device, So 
OpenSC-0.13.0 test would not be successful too!

I've tested OpenSC-0.13.0 MSI on Windows7 and had the same problem in pkcs15 
initialization as 0.12.2 version!
If I could initialize the card in  linux or windows by any version of opensc, 
my problem was resolved...

Then because I had no success on windows using 0.13.0 and 0.12.2, I would try 
linux on VM. but the shared reader icon 
in VM doesn't let linux to recognize the reader as Omnikey CardMan 3x21 !!

> Ludovic had said it was strange that pcsc_scan worked but opensc-tool -a did 
> not.

Pcsc_scan finds the reader as Virtual CCID not OMNIKEY, but gets the card's ATR 
correctly.
Opensc-tool doesn't find the card to show the ATR, because the card reader is 
not known for it as OMNIKEY.


> If you could post some debugging output for OpenSC-0.13.0, that would be 
> helpful.
Debug info for OpenSC-0.13.0 on Windows is same as OpenSC-0.12.2 that the main 
reason is "File not found" as I had sent before.

> But since the VMware is changing the name on the card, 
> (and maybe idVendor and idPproduct) things might not work as expected.

How the VM should be set to not change the name?

Thanks beforehand for your helps; 



 From: Douglas E. Engert 
To: opensc-devel@lists.opensc-project.org 
Sent: Wednesday, 5 December 2012, 19:06:34
Subject: Re: [opensc-devel] The smart card reader is known as "VMware Virtual 
USB CCID 00 00" in linux ??!!
 



On 12/5/2012 8:55 AM, Rns Course wrote:

> Thank you Dr. Rousseau,

>

>> It is also possible to connect your reader directly to the VM as any

>> other USB device. It will then not be available from Windows.

>

> Yes, exactly!

> My problem is because of not disconnecting card reader from windows.

> Now, how should I connect the reader directly to the VM as any USB device?

>

> Since, upon connecting the reader to system, shared reader icon appears on 
> the VM task bar!

> Indeed, I have problem in VM setting to recognize the reader just as a USB 
> device.

> Could you guide me about this?

>

> Best Regards.


In addition to trying to connect the card directly to the VM, you said

you had built OpenSC-0.12.2. Could you try and build the new 0.13.0

and test again?


   Tarball and MSI installers can be found on github, sourceforge or the CI 
server:

  https://github.com/OpenSC/OpenSC/tags

  https://sourceforge.net/projects/opensc/files/OpenSC/

  https://opensc.fr/jenkins/


Ludovic had said it was strange that pcsc_scan worked but opensc-tool -a did 
not.


If you could post some debugging output for OpenSC-0.13.0, that would be 
helpful.

Either (1) modify the opensc.conf, changing the debug = 0; to debug = 7;

and uncomment the debug_file = line. (2) add a -v option to the opensc-tool

command line and output would be directed to stderr.


Although then vendor provided the ifdokccid.so driver, it might not be needed

as PCSClite says it is supported as CCID. But since the VMware is changing

the name on the card, (and maybe idVendor and idPproduct) things might

not work as expected.


>

> 

> *From:* Ludovic Rousseau 

> *To:* "opensc-devel@lists.opensc-project.org" 
> 

> *Sent:* Wednesday, 5 December 2012, 16:51:28

> *Subject:* Re: [opensc-devel] The smart card reader is known as "VMware 
> Virtual USB CCID 00 00" in linux ??!!

>

> 2012/12/5 Rns Course mailto:rns_cou...@yahoo.com>>:

>  > Hi all;

>

> Hello,

>

>  > I have a smart card (SmartCafe Expert 3.2 72k) and I've loaded and

>  > initialized Muscle applet (0.9.11) on it.

>  > Now, I have problem with pkcs15 initializing...

>  > In Windows, I couldn't initialize the card using "pkcs15-init" tool, so I

>  > decided to compile opensc-0.12.2 in linux (fedora 16) and use "pkcs15-init"

>  > tool in linux.

>  >

>  > I have fedora on VMWare ( my host OS is Windows7) and installed Card Reader

>  > driver on fedora with name "ifdokccid.so" (my Card Reader is Omnikey 
>CardMan

>  > 3121).

>  > I've got and installed "pcsc-tools" package on linux and run "pcsc_scan"

>  > command on Terminal, the output was as below:

>  >

>  > 
>---

>  > PC/SC device scanner

>  > V 1.4.17 (c) 2001-2009, Ludovic Rousseau >

>  > Compiled with PC/SC lite version: 1.6.6

>  > Scanning present