Summary: | unable to read data that is more than 256 bytes from smartcard. | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | kamala kumar <skamalakumar> |
Component: | [OLD] Unspecified | Assignee: | Crypto team [DISABLED] <crypto+disabled> |
Status: | RESOLVED NEEDINFO | ||
Severity: | normal | CC: | leho, ludovic.rousseau |
Priority: | High | ||
Version: | unspecified | ||
Hardware: | x86 | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Attachments: | gentoo vmware config |
Description
kamala kumar
2007-02-28 12:46:56 UTC
Which version of pcsc-lite and ccid you are using in gentoo and the other distributions? Do you run all under VMWare? VMWare has a bug in its USB implementation for specific APDUs sizes. Starting from pcsc-lite-1.3.2 your module should support extended APDUs in order to access >= 256 bytes APDUs. In gentoo please paste the output of: # equery list pcsc-lite # equery list ccid I have given the output of equery command you asked. localhost admin # equery list pcsc-lite [ Searching for package 'pcsc-lite' in all categories among: ] * installed packages [I--] [M~] sys-apps/pcsc-lite-1.3.1-r1 (0) localhost admin # equery list ccid [ Searching for package 'ccid' in all categories among: ] * installed packages [I--] [M~] app-crypt/ccid-1.0.1-r1 (0) These packages are installed by using ACCEPT_KEYWORDS=~x86 MAKEOPTS=-j1 emerge sys-apps/pcsc-lite ACCEPT_KEYWORDS=~x86 emerge app-crypt/ccid =================================== I also tried with latest pcsc-lite-1.3.3 and ccid1.2.1. These packages i installed by getting the source from its web site and build and installed the packages. I got same result using these package also. I have installed Gentoo system in VMWare 5.5. I also installed my other linux distributions in VMWare 5.5. I did not get this error in other Linux distributions. Perform: echo "app-crypt/ccid" >> /etc/portage/package.keywords echo "sys-apps/pcsc-lite" >> /etc/portage/package.keywords emerge --update --deep world /etc/init.d/pcscd restart To install the latest, I use: app-crypt/ccid-1.2.1 sys-apps/pcsc-lite-1.4.0 Please use equery again to verify that you are using the latest. My smartcard provider uses > 256 bytes APDU, I know this because I had problems with this issue in the past. It is very strange that you have problems when compiling from source. You did not answer which version did you find working in other distributions. In other linux distributions i am using pcsc-lite version 1.3.2 and ccid version 1.2.1. I tried with less version also. It was working well with all the versions. I think you have misunderstood the issue. I did not mean APDU size of 256 bytes. I mean when trying to read data which is more than 256 bytes, SCardTransmit function returns error. Following is the list of APDU tranfererd according to the attached log >> 00 CB 3F FF 05 5C 03 5F C1 07 (read data apdu) << 61 47 (status code returned) >> 00 C0 00 00 47 (Get Response APDU for getting 0x47 bytes of data) << 53 45 F0 10 73 6F 6D 65 20 63 63 63 20 63 61 72 64 20 69 64 F1 01 21 F2 01 21 F3 00 F4 01 11 F5 01 10 F6 11 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 F7 01 00 FA 01 00 FB 01 00 FC 01 00 FD 01 00 FE 01 00 90 00 (data bytes returned) >> 00 CB 3F FF 05 5C 03 5F C1 02 (read data apdu for another object which has more than 256 bytes of data) << 61 00 (status code) >> 00 C0 00 00 00 (get response APDU for getting 256 bytes of data) -- SCardTranmit function returns 0x80100016 error code at this point Both ccid and pcsc-lite are clean upstream implementation. The only dependency I can think of is libusb. Current stable libusb is: dev-libs/libusb-0.1.12 Maybe this different between other distributions, or other distributions added patches for ccid and/or pcsc-lite. Have you tried to compile the same version which did not work for you in Gentoo on other distributions? It will help me understand if the problem is within the packages or in the infrastructure. Anyway... You can also debug the ccid driver by modifying the /usr/lib/readers/usb/ifd-ccid.bundle/Contents/Info.plist. But since we use upstream release as-is I think it is safe to ask the question at muscle mailing list. I installed dev-libs/libusb-0.1.12 package and tried with this also. I am getting same result. In other Linux distribution we tried same version of pcsc-lite, ccid, libusb package. It is working fine in that platforms. Since this error is only occuring in Gentoo system, i thought it will be appropriate to consult you. Can you please verify the scenario by writing small program. Ludovic: I see you on bug#168942, thanks for the help! I will appreciate any help here too :) We use your packages as-is so I really don't know how I can help here... http://sources.gentoo.org/viewcvs.py/gentoo-x86/sys-apps/pcsc-lite/pcsc-lite-1.4.0.ebuild?rev=1.1&view=markup http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-crypt/ccid/ccid-1.2.1.ebuild?rev=1.1&view=markup Thanks! (In reply to comment #4) > I think you have misunderstood the issue. I did not mean APDU size of 256 > bytes. > I mean when trying to read data which is more than 256 bytes, SCardTransmit > function returns error. Your application is not trying to read more than 256 bytes but exactly 256 bytes. > >> 00 C0 00 00 00 (get response APDU for getting 256 bytes of data) -- SCardTranmit function returns 0x80100016 error code at this point Here Le is 00 for 256 bytes. As you say this is working on other Linux distributions so the problem is not with pcsc-lite or the ccid driver. (In reply to comment #7) > We use your packages as-is so I really don't know how I can help here... I suspect a bug in the kernel. Could you try with a vanilla Linux kernel instead of a Gentoo kernel? (In reply to comment #9) > (In reply to comment #7) > > We use your packages as-is so I really don't know how I can help here... > > I suspect a bug in the kernel. > > Could you try with a vanilla Linux kernel instead of a Gentoo kernel? > Thanks! But Gentoo is almost vanilla, no usb related issue. You can see the small patch list at: http://dev.gentoo.org/~dsd/genpatches/patches-2.6.19-7.htm http://dev.gentoo.org/~dsd/genpatches/patches-2.6.20-1.htm libusb has one patch to make it support freebsd: http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-libs/libusb/files/0.1.12-fbsd.patch?rev=1.1&view=markup So I don't think the problem is here... Unless other distributions fixed some problem without reporting upstream. Can you please tell me whether you can reproduce the issue? I think based on that we can easily issolate the problem module. Who? me? I don't have your smartcard, I don't have your reader, and I don't have a test program. So what do you want me to test? I think this error will occur in any smartcard provided the data in the container stored on the smart card is more than 256. And I think it should occur in any smartcard reader. I have given small program that reads the data from the card. You have to change the Read data APDU according to the smartcard you use and other things will be same. ============================================================================= #include <stdio.h> #include <wintypes.h> #include <winscard.h> void PrintHex(const BYTE* buf, DWORD len) { for (DWORD i = 0; i < len; i++) printf("%.2X ", buf[i] & 0xFF); printf("\n"); } int main(int argc, char* argv[]) { LONG rv; char mszReaders[4096]; DWORD cchReaders = sizeof(mszReaders)/sizeof(char); DWORD dwActiveProtocol; SCARDCONTEXT hContext; SCARDHANDLE hCard; BYTE recv[256]; DWORD buf_len, recv_len; const SCARD_IO_REQUEST* io; rv = SCardEstablishContext(SCARD_SCOPE_USER, NULL, NULL, &hContext); printf("Establish: %#x\n", rv); rv = SCardListReaders(hContext, NULL, mszReaders, &cchReaders); printf("ListReaders: %#x \"%s\"\n", rv, mszReaders); rv = SCardConnect(hContext, mszReaders, SCARD_SHARE_SHARED, SCARD_PROTOCOL_T0|SCARD_PROTOCOL_T1, &hCard, &dwActiveProtocol); printf("Connect: %#x\n", rv); if (dwActiveProtocol == SCARD_PROTOCOL_T0) io = SCARD_PCI_T0; else io = SCARD_PCI_T1; int tmplen; //Read Data APDU { BYTE buf[] = { 0x00, 0xCB, 0x3F, 0xFF, 0x05, 0x5C, 0x03, 0x5F,0xC1,0x02 }; recv_len = sizeof(recv); rv = SCardTransmit(hCard, io, buf, sizeof(buf), NULL, recv, &recv_len); if (rv != SCARD_S_SUCCESS) { printf("Transmit failed: %#x\n", rv); return(1); } printf("-> "); PrintHex(buf, sizeof(buf)); printf("<- "); PrintHex(recv, recv_len); tmplen = recv[recv_len-1]; } { BYTE buf[] = { 0x00, 0xC0, 0x00, 0x00, 0x00 }; buf[4]=tmplen; recv_len = sizeof(recv); rv = SCardTransmit(hCard, io, buf, sizeof(buf), NULL, recv, &recv_len); if (rv != SCARD_S_SUCCESS) { printf("Transmit failed: %#x\n", rv); return(1); } printf("-> "); PrintHex(buf, sizeof(buf)); printf("<- "); PrintHex(recv, recv_len); } SCardDisconnect(hCard, SCARD_RESET_CARD); SCardReleaseContext(hContext); return 0; } ============================================================================= # use "gcc" to compile source files. CC = g++ # the linker is also "gcc". It might be something else with other compilers. LD = g++ # Compiler flags go here. CFLAGS = -g -Wall #CFLAGS = # Linker flags go here. Currently there aren't any, but if we'll switch to # code optimization, we might add "-s" here to strip debug info and symbols. LDFLAGS = -lpcsclite # use this command to erase files. RM = /bin/rm -f # list of generated object files. OBJS = read_data.o # program executable file name. PROG = read_data # include directory INC = -I/usr/include/PCSC # top-level rule, to compile everything. all: $(PROG) # rule to link the program $(PROG): $(OBJS) $(LD) $(LDFLAGS) $(OBJS) -o $(PROG) # rule for file "StdAfx.o". read_data.o: read_data.cpp $(CC) $(INC) $(CFLAGS) -c read_data.cpp # rule for cleaning re-compilable files. clean: $(RM) $(PROG) $(OBJS) ============================================================================== (In reply to comment #13) > I think this error will occur in any smartcard provided the data in the > container stored on the smart card is more than 256. And I think it should > occur in any smartcard reader. I have given small program that reads the data > from the card. You have to change the Read data APDU according to the smartcard > you use and other things will be same. > ============================================================================= > BYTE recv[256]; > recv_len = sizeof(recv); > rv = SCardTransmit(hCard, io, buf, sizeof(buf), NULL, recv, &recv_len); You will never receive more than 256 bytes if your receive buffer is 256 bytes. And you must include the 2 status word so data will be limited to 254 bytes. If you want to receive 256 bytes of data you need a buffer of 258 bytes. Sorry, The test program I attached in the bug is wrong. I changed the size of recv buffer to BYTE recv[260]; and Retested the program. I am getting error as described previously. I have to remove and insert the reader and restart the pcscd service for the programs to start working with smartcard again. Please try by changing the recv buffer size to BYTE recv[260]; in the attached test program. (In reply to comment #15) > I am getting error as described previously. I have to remove and insert the > reader and restart the pcscd service for the programs to start working with > smartcard again. Can you send the output of the execution of your test program under gentoo (with the problem) and also under another Linux distribution (without the problem)? I have given the pcscd log taken in the another linux distribution here. Here reading data from the object having more than 256 bytes of data succeed. ================================================================== pcscdaemon.c:258:main() pcscd set to foreground with debug send to stderr pcscdaemon.c:463:main() pcsc-lite 1.2.9-beta9 daemon ready. hotplug_libusb.c:404:HPAddHotPluggable() Adding USB device: 001:002 readerfactory.c:1097:RFInitializeReader() Attempting startup of SCM SCR 331 00 00. readerfactory.c:971:RFBindFunctions() Loading IFD Handler 3.0 ifdhandler.c:1090:init_driver() LogLevel: 0x0003 ifdhandler.c:1100:init_driver() DriverOptions: 0x0000 ifdhandler.c:74:IFDHCreateChannelByName() lun: 0, device: usb:04e6/e001:libusb:001:002 ccid_usb.c:220:OpenUSBByName() Manufacturer: Ludovic Rousseau (ludovic.rousseau@free.fr) ccid_usb.c:230:OpenUSBByName() ProductString: Generic CCID driver v0.9.4 ccid_usb.c:236:OpenUSBByName() Copyright: This driver is protected by terms of the GNU General Public License version 2, or (at your option) any later version. ccid_usb.c:375:OpenUSBByName() Found Vendor/Product: 04E6/E001 (SCM SCR 331) ccid_usb.c:377:OpenUSBByName() Using USB bus/device: 001/002 ccid_usb.c:720:get_data_rates() IFD does not support GET_DATA_RATES request: Broken pipe ifdhandler.c:250:IFDHGetCapabilities() lun: 0, tag: 0xFAE ifdhandler.c:292:IFDHGetCapabilities() Reader supports 1 slots ifdhandler.c:725:IFDHPowerICC() lun: 0 Card ATR: 3B DB 96 00 81 B1 FE 45 1F 03 80 F9 A0 00 00 03 08 00 00 10 00 18 prothandler.c:129:PHSetProtocol() Attempting PTS to T=1 ifdhandler.c:375:IFDHSetProtocolParameters() lun: 0, protocol T=1 ifdhandler.c:1171:extra_egt() Extra EGT patch applied APDU: 00 CB 3F FF 05 5C 03 5F C1 02 ifdhandler.c:831:IFDHTransmitToICC() lun: 0 SW: 61 00 APDU: 00 C0 00 00 00 ifdhandler.c:831:IFDHTransmitToICC() lun: 0 SW: 53 82 04 8D 30 19 D4 32 48 58 21 0C 2D 31 71 B5 25 A1 68 58 21 0C 26 2E 36 A4 84 32 48 43 F3 34 10 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 35 08 32 30 31 31 30 34 31 30 3D 00 3E 82 04 4E 30 82 04 4A 06 09 2A 86 48 86 F7 0D 01 07 02 A0 82 04 3B 30 82 04 37 02 01 03 31 0B 30 09 06 05 2B 0E 03 02 1A 05 00 30 0A 06 08 60 86 48 01 65 03 06 01 A0 82 02 9B 30 82 02 97 30 82 02 00 A0 03 02 01 02 02 01 01 30 0D 06 09 2A 86 48 86 F7 0D 01 01 05 05 00 30 2F 31 0B 30 09 06 03 55 04 06 13 02 55 53 31 0D 30 0B 06 03 55 04 0A 13 04 4E 49 53 54 31 11 30 0F 06 03 55 04 03 13 08 46 41 53 43 4E 20 43 41 30 1E 17 0D 30 35 30 35 32 37 31 34 35 37 32 30 5A 17 0D 31 35 30 38 31 39 31 34 35 37 32 30 5A 30 2F 31 0B 30 09 06 03 55 04 06 13 02 55 53 31 0D 30 0B 06 03 55 04 0A 61 00 ifdhandler.c:725:IFDHPowerICC() lun: 0 pcscdaemon.c:528:signal_trap() Preparing for suicide hotplug_libusb.c:358:HPEstablishUSBNotifications() Hotplug stopped readerfactory.c:1352:RFCleanupReaders() entering cleaning function readerfactory.c:1361:RFCleanupReaders() Stopping reader: SCM SCR 331 00 00 eventhandler.c:120:EHDestroyEventHandler() Stomping thread. eventhandler.c:149:EHDestroyEventHandler() Thread stomped. readerfactory.c:1144:RFUnInitializeReader() Attempting shutdown of SCM SCR 331 00 00. ifdhandler.c:201:IFDHCloseChannel() lun: 0 readerfactory.c:1014:RFUnloadReader() Unloading reader driver. pcscdaemon.c:488:at_exit() cleaning /var/run ========================================================================== (In reply to comment #17) > I have given the pcscd log taken in the another linux distribution here. Here > reading data from the object having more than 256 bytes of data succeed. > ================================================================== > pcscdaemon.c:463:main() pcsc-lite 1.2.9-beta9 daemon ready. > ccid_usb.c:230:OpenUSBByName() ProductString: Generic CCID driver v0.9.4 You are using pcsc-lite 1.2.9-beta and ccid 0.9.4 on this distribution. Can you install a recent pcsc-lite (1.4.0) and a recent ccid (1.2.1) and try again? I also note that your logs contains two different ATRs - 3B DB 96 00 81 B1 FE 45 1F 03 00 F9 A0 00 00 03 08 00 00 10 00 98 (fails) - 3B DB 96 00 81 B1 FE 45 1F 03 80 F9 A0 00 00 03 08 00 00 10 00 18 (works) ^ difference here Is it the same physical card in both cases? And the same physical reader (with the same firmware) in both cases? Previously i used different card to take the log. Now I have used the same card used in the gentoo OS. Also I am using same pcsc-lite version as in the gentoo OS. ========================================================================= pcscdaemon.c:259:main() pcscd set to foreground with debug send to stderr pcscdaemon.c:464:main() pcsc-lite 1.3.1 daemon ready. hotplug_libusb.c:407:HPAddHotPluggable() Adding USB device: 001:003 readerfactory.c:1095:RFInitializeReader() Attempting startup of SCM SCR 331 (2000012F) 00 00. readerfactory.c:967:RFBindFunctions() Loading IFD Handler 3.0 ifdhandler.c:1155:init_driver() LogLevel: 0x0003 ifdhandler.c:1165:init_driver() DriverOptions: 0x0000 ifdhandler.c:76:IFDHCreateChannelByName() lun: 0, device: usb:04e6/e001:libusb:001:003 ccid_usb.c:231:OpenUSBByName() Manufacturer: Ludovic Rousseau (ludovic.rousseau@free.fr) ccid_usb.c:241:OpenUSBByName() ProductString: Generic CCID driver v1.0.1 ccid_usb.c:247:OpenUSBByName() Copyright: This driver is protected by terms of the GNU General Public License version 2, or (at your option) any later version. ccid_usb.c:395:OpenUSBByName() Found Vendor/Product: 04E6/E001 (SCM SCR 331) ccid_usb.c:397:OpenUSBByName() Using USB bus/device: 001/003 ccid_usb.c:747:get_data_rates() IFD does not support GET_DATA_RATES request: Broken pipe ifdhandler.c:252:IFDHGetCapabilities() lun: 0, tag: 0xFAE ifdhandler.c:294:IFDHGetCapabilities() Reader supports 1 slots ifdhandler.c:787:IFDHPowerICC() lun: 0 Card ATR: 3B DB 96 00 81 B1 FE 45 1F 03 00 F9 A0 00 00 03 08 00 00 10 00 98 prothandler.c:130:PHSetProtocol() Attempting PTS to T=1 ifdhandler.c:377:IFDHSetProtocolParameters() lun: 0, protocol T=1 ifdhandler.c:1260:extra_egt() Extra EGT patch applied APDU: 00 CB 3F FF 05 5C 03 5F C1 02 ifdhandler.c:894:IFDHTransmitToICC() lun: 0 SW: 61 00 APDU: 00 C0 00 00 00 ifdhandler.c:894:IFDHTransmitToICC() lun: 0 SW: 53 82 04 8D 30 19 D4 32 48 58 21 0C 2D 31 71 B5 25 A1 68 58 21 0C 26 2E 36 A4 84 32 48 43 F3 34 10 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 35 08 32 30 31 31 30 34 31 30 3D 00 3E 82 04 4E 30 82 04 4A 06 09 2A 86 48 86 F7 0D 01 07 02 A0 82 04 3B 30 82 04 37 02 01 03 31 0B 30 09 06 05 2B 0E 03 02 1A 05 00 30 0A 06 08 60 86 48 01 65 03 06 01 A0 82 02 9B 30 82 02 97 30 82 02 00 A0 03 02 01 02 02 01 01 30 0D 06 09 2A 86 48 86 F7 0D 01 01 05 05 00 30 2F 31 0B 30 09 06 03 55 04 06 13 02 55 53 31 0D 30 0B 06 03 55 04 0A 13 04 4E 49 53 54 31 11 30 0F 06 03 55 04 03 13 08 46 41 53 43 4E 20 43 41 30 1E 17 0D 30 35 30 35 32 37 31 34 35 37 32 30 5A 17 0D 31 35 30 38 31 39 31 34 35 37 32 30 5A 30 2F 31 0B 30 09 06 03 55 04 06 13 02 55 53 31 0D 30 0B 06 03 55 04 0A 61 00 APDU: 00 C0 00 00 00 ifdhandler.c:894:IFDHTransmitToICC() lun: 0 SW: 13 04 4E 49 53 54 31 11 30 0F 06 03 55 04 03 13 08 46 41 53 43 4E 20 43 41 30 81 9F 30 0D 06 09 2A 86 48 86 F7 0D 01 01 01 05 00 03 81 8D 00 30 81 89 02 81 81 00 91 CF 6E F0 4D D3 F2 EB 46 1E B9 1B A4 25 47 E4 88 8D E6 89 85 A8 E5 86 E7 E8 9D EA 62 7B 73 74 7B 89 55 13 82 B6 45 53 99 F2 36 72 6A 48 7A 59 ED C8 F0 70 3C 04 2C 33 AD 21 0C 32 00 BD F1 F4 F1 FA 9B 02 CB 3F AA 7B 89 C1 A4 D0 D4 C8 29 94 7A B0 E2 3E 69 C6 3C 71 43 DF A6 1D 55 18 21 CC AE 40 E3 CD 89 E2 62 A2 10 68 67 3B 56 24 4E C1 43 ED A4 48 64 73 E4 78 4C 0B 0E 69 6A 30 61 11 02 03 01 00 01 A3 81 C2 30 81 BF 30 1D 06 03 55 1D 0E 04 16 04 14 D6 42 7A 0E A3 07 B0 FC 23 93 B4 4D 9C F6 8B 22 C8 0F 89 40 30 0E 06 03 55 1D 0F 01 01 FF 04 04 03 02 01 06 30 0F 06 03 55 1D 13 01 01 FF 04 05 30 03 01 01 61 00 APDU: 00 C0 00 00 00 ifdhandler.c:894:IFDHTransmitToICC() lun: 0 SW: FF 30 7D 06 08 2B 06 01 05 05 07 01 0B 04 71 30 6F 30 6D 06 08 2B 06 01 05 05 07 30 05 86 61 6C 64 61 70 3A 2F 2F 77 77 77 2E 65 78 61 6D 70 6C 65 2E 63 6F 6D 2F 63 6E 3D 46 41 53 43 4E 25 32 30 43 41 2C 6F 3D 4E 49 53 54 2C 63 3D 55 53 3F 63 41 43 65 72 74 69 66 69 63 61 74 65 3B 62 69 6E 61 72 79 2C 63 72 6F 73 73 43 65 72 74 69 66 69 63 61 74 65 50 61 69 72 3B 62 69 6E 61 72 79 30 0D 06 09 2A 86 48 86 F7 0D 01 01 05 05 00 03 81 81 00 21 EE F6 02 D8 A0 CD E5 A7 34 F9 87 ED B8 76 D5 AC D2 A3 0A F7 EF 36 83 3E 67 6F E2 42 B3 34 92 46 C1 F5 5A 80 05 22 FF 97 66 25 02 0D 21 02 6A B7 BD 49 CB 95 5E 8F C7 82 6A 2A A9 CD 03 35 4D F5 7C CA 4C EB 0B 61 DB 8F 9E C2 D6 7C 80 41 79 5F 5D 28 25 4C 8E 33 72 20 B1 6B A2 18 5F 25 95 B6 8C 2C 6E 07 78 C9 32 15 35 28 A9 46 61 00 APDU: 00 C0 00 00 00 ifdhandler.c:894:IFDHTransmitToICC() lun: 0 SW: B1 28 68 7F 08 14 12 C7 4A 1A B2 5F ED 34 57 22 6B A5 08 31 82 01 78 30 82 01 74 02 01 01 30 34 30 2F 31 0B 30 09 06 03 55 04 06 13 02 55 53 31 0D 30 0B 06 03 55 04 0A 13 04 4E 49 53 54 31 11 30 0F 06 03 55 04 03 13 08 46 41 53 43 4E 20 43 41 02 01 01 30 09 06 05 2B 0E 03 02 1A 05 00 A0 81 9B 30 17 06 09 2A 86 48 86 F7 0D 01 09 03 31 0A 06 08 60 86 48 01 65 03 06 01 30 1C 06 09 2A 86 48 86 F7 0D 01 09 05 31 0F 17 0D 30 36 30 34 31 30 31 38 30 33 34 39 5A 30 23 06 09 2A 86 48 86 F7 0D 01 09 04 31 16 04 14 35 87 72 F2 AE 27 6A 60 46 9A 29 04 6E 35 8E 0E 71 A8 43 F1 30 3D 06 08 60 86 48 01 65 03 06 05 31 31 30 2F 31 0D 30 0B 06 03 55 04 0A 13 04 4E 49 53 54 31 0B 30 09 06 03 55 04 06 13 02 55 53 31 11 30 0F 06 03 55 04 03 13 08 46 41 53 43 4E 20 43 41 30 0D 06 61 91 APDU: 00 C0 00 00 91 ifdhandler.c:894:IFDHTransmitToICC() lun: 0 SW: 09 2A 86 48 86 F7 0D 01 01 01 05 00 04 81 80 6B B1 4E CA 24 B9 44 A1 4C B8 14 F2 AE 6E AB 37 96 E2 BC 2F FD 09 3B 31 08 8D 2F 5A EA 53 29 27 9B FF 11 BF 4E E2 DF CF 6B 6E 40 6D 15 AB E1 52 F1 BA 6C 5A FF 71 7D 74 38 B1 6B 73 1C C8 05 8D B4 32 5F FD 64 76 F8 96 12 55 09 8D 63 A3 B7 CE 21 91 8B FA F2 60 3B 1C 00 72 5A 3E 1C 2D 7F 04 FA 79 AD 25 F5 F1 85 02 10 72 BB 58 68 4A D0 6E 9A 08 E7 19 C5 2A F3 71 C3 6B 2B EA D3 3B 01 03 FE 00 90 00 pcscdaemon.c:529:signal_trap() Preparing for suicide hotplug_libusb.c:361:HPEstablishUSBNotifications() Hotplug stopped readerfactory.c:1350:RFCleanupReaders() entering cleaning function readerfactory.c:1359:RFCleanupReaders() Stopping reader: SCM SCR 331 (2000012F) 00 00 eventhandler.c:121:EHDestroyEventHandler() Stomping thread. eventhandler.c:150:EHDestroyEventHandler() Thread stomped. readerfactory.c:1142:RFUnInitializeReader() Attempting shutdown of SCM SCR 331 (2000012F) 00 00. ifdhandler.c:203:IFDHCloseChannel() lun: 0 readerfactory.c:1012:RFUnloadReader() Unloading reader driver. pcscdaemon.c:489:at_exit() cleaning /var/run ============================================================================== (In reply to comment #19) > Previously i used different card to take the log. Now I have used the same card > used in the gentoo OS. Also I am using same pcsc-lite version as in the gentoo > OS. OK. Can you also use the same version for the CCID driver? I think both are using same CCID version. Generic CCID driver v1.0.1. Is n't it? One difference between other distributions and Gentoo is that we add --enable-extendedapdu to pcsc-lite-1.3.1-r1 configure. But why don't you use the latest (and same) versions for testing in all distributions and then regress backward? (In reply to comment #21) > I think both are using same CCID version. Generic CCID driver v1.0.1. Is n't > it? No. The latest version of my ccid driver is 1.2.1. Get it from http://pcsclite.alioth.debian.org/ccid.html I would like you to redo the tests on Gentoo and on the working distribution with the same versions of pcsc-lite (1.4.0) and ccid (1.2.1) so we can compare things. kamala: Please follow the instructions at comment#3 to get latest version for Gentoo system. Please make sure the output is the same on your side. # equery list pcsc-lite [I--] [ ~] sys-apps/pcsc-lite-1.4.0 (0) # equery list ccid [I--] [ ~] app-crypt/ccid-1.2.1 (0) Thanks! I have attached the logs as you have asked for. I downloaded the source and build and installed the required module. I used libusb version 0.1.12. pcscd log in gentoo Linux distribution ========================================================================== pcscdaemon.c:328:main() pcscd set to foreground with debug send to stderr pcscdaemon.c:542:main() pcsc-lite 1.4.0 daemon ready. hotplug_libusb.c:448:HPAddHotPluggable() Adding USB device: 001:002 readerfactory.c:1108:RFInitializeReader() Attempting startup of SCM SCR 331 (2000012F) 00 00 using /usr/pcsc/drivers/ifd-ccid.bundle/Contents/Linux/libccid.so.1.2.1 readerfactory.c:977:RFBindFunctions() Loading IFD Handler 3.0 ifdhandler.c:1231:init_driver() LogLevel: 0x0003 ifdhandler.c:1241:init_driver() DriverOptions: 0x0000 ifdhandler.c:77:IFDHCreateChannelByName() lun: 0, device: usb:04e6/e001:libusb:001:002 ccid_usb.c:229:OpenUSBByName() Manufacturer: Ludovic Rousseau (ludovic.rousseau@free.fr) ccid_usb.c:239:OpenUSBByName() ProductString: Generic CCID driver v1.2.1 ccid_usb.c:245:OpenUSBByName() Copyright: This driver is protected by terms of the GNU Lesser General Public License version 2.1, or (at your option) any later version. ccid_usb.c:393:OpenUSBByName() Found Vendor/Product: 04E6/E001 (SCM SCR 331) ccid_usb.c:395:OpenUSBByName() Using USB bus/device: 001/002 ccid_usb.c:743:get_data_rates() IFD does not support GET_DATA_RATES request: Broken pipe ccid_usb.c:507:ReadUSB() usb_bulk_read(001/002): Resource temporarily unavailable ccid_usb.c:507:ReadUSB() usb_bulk_read(001/002): Resource temporarily unavailable ifdhandler.c:271:IFDHGetCapabilities() lun: 0, tag: 0xFAE ifdhandler.c:313:IFDHGetCapabilities() Reader supports 1 slots hotplug_libusb.c:395:HPEstablishUSBNotifications() Driver ifd-ccid.bundle does not support IFD_GENERATE_HOTPLUG hotplug_libusb.c:404:HPEstablishUSBNotifications() Polling forced every 1 second(s) ifdhandler.c:841:IFDHPowerICC() lun: 0, action: PowerUp Card ATR: 3B DB 96 00 81 B1 FE 45 1F 03 00 F9 A0 00 00 03 08 00 00 10 00 98 prothandler.c:130:PHSetProtocol() Attempting PTS to T=1 ifdhandler.c:418:IFDHSetProtocolParameters() lun: 0, protocol T=1 ifdhandler.c:1336:extra_egt() Extra EGT patch applied APDU: 00 CB 3F FF 05 5C 03 5F C1 02 ifdhandler.c:948:IFDHTransmitToICC() lun: 0 SW: 61 00 APDU: 00 C0 00 00 00 ifdhandler.c:948:IFDHTransmitToICC() lun: 0 ccid_usb.c:507:ReadUSB() usb_bulk_read(001/002): Resource temporarily unavailable openct/proto-t1.c:221:t1_transceive() fatal: transmit/receive failed SW: ifdwrapper.c:762:IFDTransmit() Card not transacted: 612 winscard.c:1616:SCardTransmit() Card not transacted: 0x80100016 pcscdaemon.c:623:signal_trap() Preparing for suicide hotplug_libusb.c:369:HPRescanUsbBus() Hotplug stopped readerfactory.c:1367:RFCleanupReaders() entering cleaning function readerfactory.c:1376:RFCleanupReaders() Stopping reader: SCM SCR 331 (2000012F) 00 00 eventhandler.c:121:EHDestroyEventHandler() Stomping thread. ccid_usb.c:471:WriteUSB() usb_bulk_write(001/002): Resource temporarily unavailable ifdwrapper.c:494:IFDStatusICC() Card not transacted: 612 eventhandler.c:301:EHStatusHandlerThread() Error communicating to: SCM SCR 331 (2000012F) 00 00 eventhandler.c:150:EHDestroyEventHandler() Thread stomped. readerfactory.c:1159:RFUnInitializeReader() Attempting shutdown of SCM SCR 331 (2000012F) 00 00. ifdhandler.c:222:IFDHCloseChannel() lun: 0 ccid_usb.c:471:WriteUSB() usb_bulk_write(001/002): Resource temporarily unavailable readerfactory.c:1022:RFUnloadReader() Unloading reader driver. pcscdaemon.c:567:at_exit() cleaning /var/run ========================================================================== pcscd log taken in another Linux distribution in which the program worked correctly ========================================================================= pcscdaemon.c:328:main() pcscd set to foreground with debug send to stderr pcscdaemon.c:542:main() pcsc-lite 1.4.0 daemon ready. hotplug_libusb.c:448:HPAddHotPluggable() Adding USB device: 001:003 readerfactory.c:1108:RFInitializeReader() Attempting startup of SCM SCR 331 (2000012F) 00 00 using /usr/pcsc/drivers/ifd-ccid.bundle/Contents/Linux/libccid.so.1.2.1 readerfactory.c:977:RFBindFunctions() Loading IFD Handler 3.0 ifdhandler.c:1231:init_driver() LogLevel: 0x0003 ifdhandler.c:1241:init_driver() DriverOptions: 0x0000 ifdhandler.c:77:IFDHCreateChannelByName() lun: 0, device: usb:04e6/e001:libusb:001:003 ccid_usb.c:229:OpenUSBByName() Manufacturer: Ludovic Rousseau (ludovic.rousseau@free.fr) ccid_usb.c:239:OpenUSBByName() ProductString: Generic CCID driver v1.2.1 ccid_usb.c:245:OpenUSBByName() Copyright: This driver is protected by terms of the GNU Lesser General Public License version 2.1, or (at your option) any later version. ccid_usb.c:393:OpenUSBByName() Found Vendor/Product: 04E6/E001 (SCM SCR 331) ccid_usb.c:395:OpenUSBByName() Using USB bus/device: 001/003 ccid_usb.c:743:get_data_rates() IFD does not support GET_DATA_RATES request: Broken pipe ifdhandler.c:271:IFDHGetCapabilities() lun: 0, tag: 0xFAE ifdhandler.c:313:IFDHGetCapabilities() Reader supports 1 slots hotplug_libusb.c:395:HPEstablishUSBNotifications() Driver ifd-ccid.bundle does not support IFD_GENERATE_HOTPLUG hotplug_libusb.c:404:HPEstablishUSBNotifications() Polling forced every 1 second(s) ifdhandler.c:841:IFDHPowerICC() lun: 0, action: PowerUp Card ATR: 3B DB 96 00 81 B1 FE 45 1F 03 00 F9 A0 00 00 03 08 00 00 10 00 98 prothandler.c:130:PHSetProtocol() Attempting PTS to T=1 ifdhandler.c:418:IFDHSetProtocolParameters() lun: 0, protocol T=1 ifdhandler.c:1336:extra_egt() Extra EGT patch applied APDU: 00 CB 3F FF 05 5C 03 5F C1 02 ifdhandler.c:948:IFDHTransmitToICC() lun: 0 SW: 61 00 APDU: 00 C0 00 00 00 ifdhandler.c:948:IFDHTransmitToICC() lun: 0 SW: 53 82 04 8D 30 19 D4 32 48 58 21 0C 2D 31 71 B5 25 A1 68 58 21 0C 26 2E 36 A4 84 32 48 43 F3 34 10 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 35 08 32 30 31 31 30 34 31 30 3D 00 3E 82 04 4E 30 82 04 4A 06 09 2A 86 48 86 F7 0D 01 07 02 A0 82 04 3B 30 82 04 37 02 01 03 31 0B 30 09 06 05 2B 0E 03 02 1A 05 00 30 0A 06 08 60 86 48 01 65 03 06 01 A0 82 02 9B 30 82 02 97 30 82 02 00 A0 03 02 01 02 02 01 01 30 0D 06 09 2A 86 48 86 F7 0D 01 01 05 05 00 30 2F 31 0B 30 09 06 03 55 04 06 13 02 55 53 31 0D 30 0B 06 03 55 04 0A 13 04 4E 49 53 54 31 11 30 0F 06 03 55 04 03 13 08 46 41 53 43 4E 20 43 41 30 1E 17 0D 30 35 30 35 32 37 31 34 35 37 32 30 5A 17 0D 31 35 30 38 31 39 31 34 35 37 32 30 5A 30 2F 31 0B 30 09 06 03 55 04 06 13 02 55 53 31 0D 30 0B 06 03 55 04 0A 61 00 ifdhandler.c:841:IFDHPowerICC() lun: 0, action: Reset pcscdaemon.c:623:signal_trap() Preparing for suicide hotplug_libusb.c:369:HPRescanUsbBus() Hotplug stopped readerfactory.c:1367:RFCleanupReaders() entering cleaning function readerfactory.c:1376:RFCleanupReaders() Stopping reader: SCM SCR 331 (2000012F) 00 00 eventhandler.c:121:EHDestroyEventHandler() Stomping thread. eventhandler.c:150:EHDestroyEventHandler() Thread stomped. readerfactory.c:1159:RFUnInitializeReader() Attempting shutdown of SCM SCR 331 (2000012F) 00 00. ifdhandler.c:222:IFDHCloseChannel() lun: 0 readerfactory.c:1022:RFUnloadReader() Unloading reader driver. pcscdaemon.c:567:at_exit() cleaning /var/run ========================================================================= Thanks! And both tests were done under VMWare, right? And the virtual machines have the EXACT same configuration, right? Can you please ATTACH (not paste) the configuration file of the kernel you are using in Gentoo machine? Can you please also describe how you built your kernel (which sources, genkernel etc). Created attachment 115262 [details]
gentoo vmware config
Attached gentoo vmware config file with this.
We installed gentoo using livecd-i686-installer-2006.1.iso ISO image. Gentoo is installed using GTK+ based Gentoo Linux installer.
Settings:
install type - standard
use flag - symlink (with other defaults)
CFLAGS
======
proc - i686
optimization - o2
custom - pipe
MakeOpts = -j1
Bootloader - grub
Makeopts = -j1
I don't know if it is related but I have a more or less similar problem with vmware and Mandriva 2007. After some APDU exchanges the reader stops responding. Using a real PC solved the "problem". I used the same program, reader and card with a Debian 3.1 OS in the same vmware and I don't have the problem. I strongly suspect a problem in vmware that only happen with some Linux kernels. You should try to run your program on a real PC with the same gentoo. (In reply to comment #28) > I strongly suspect a problem in vmware > that only happen with some Linux kernels. > > You should try to run your program on a real PC with the same gentoo. > Correct, as I said in comment#1 I have problem with VMWare and my own card... When running Windows... VMWare has a bug in their USB emulation which cannot accept some USB packet lengths. This problem was reported to VMWare and never resolved. I am not sure this is the case here since the same VM works with other distros... But we need to eliminate VMWare responsibility before continue. Hello kamala, I am closing this for now. please reopen if you have some new information. Thanks. i think i'm seeing this exact problem when running Gentoo on VMware Fusion 2 on OS X. my smartcard works fine in Windows 7 RC guest, though. pkcs15-tool etc can read data fine, but when starting Firefox and loading /usr/lib/opensc-pkcs11.so, i'm getting blocks of: Jun 11 01:41:15 gentoo pcscd: ifdwrapper.c:638:IFDControl() Card not transacted: 612 Jun 11 01:41:19 gentoo pcscd: ccid_usb.c:530:ReadUSB() usb_bulk_read(002/005): Resource temporarily unavailable Jun 11 01:41:19 gentoo pcscd: ifdwrapper.c:469:IFDStatusICC() Card not transacted: 612 Jun 11 01:41:19 gentoo pcscd: eventhandler.c:333:EHStatusHandlerThread() Error communicating to: SCM SCR 3310 (21120548410401) 00 00 Jun 11 01:41:19 gentoo pcscd: commands.c:1282:CCID_Receive() Can't read all data (0 out of 258 expected) Jun 11 01:41:19 gentoo pcscd: ifdwrapper.c:722:IFDTransmit() Card not transacted: 612 Jun 11 01:41:19 gentoo pcscd: winscard.c:1671:SCardTransmit() Card not transacted: 0x80100016 (In reply to comment #31) > i think i'm seeing this exact problem when running Gentoo on VMware Fusion 2 on > OS X. my smartcard works fine in Windows 7 RC guest, though. You should try VirtualBox instead of Vmware. VirtualBox http://www.virtualbox.org/ is free and is available for GNU/Linux, Windows and Mac OS X. With VirtualBox I do not have the USB problems I have with Vmware. thanks Ludovic, i actually am trying to switch away from VirtualBox, at least until they have a few things fixed that are disturbing my business critical virtualized apps. firstly, there seems to be a bug where VirtualBox cpu usage goes sky high when you use audio in guest Windows. second, USB device on/off switching/connecting "just works" in VMware Fusion while VirtualBox for example tells me that "someone else already has control of the USB card reader". perhaps i havent set up the device filters or something, because my USB stick does work, but like i said, VMware just does it without any prior config. third, running VMware and VirtualBox concurrently = instant kernel panic. so unfortunately that's not an option. |