martinpaljak / GlobalPlatformPro

🌐 πŸ” Manage applets and keys on JavaCard-s like a pro (via command line or from your Java project)
https://javacard.pro/globalplatform
GNU Lesser General Public License v3.0
683 stars 211 forks source link

Command gp -l invokes error response 0x57 #160

Closed martinftlsx closed 5 years ago

martinftlsx commented 5 years ago

Describe the bug On use of gp -l command, on some cards, I encounter error stating: "Failed to communicate with card in apdu4j.LoggingCardTerminal@483bf400: SCardTransmit got response 0x57 (null: null)".

I tried this command on other PCs and everything worked fine, so it looks like there is no problem in Global Platform PRO, but I had to ask anyway because it gets even more confusing. On other cards this command works as it should. I did some search[1] for this error response (0x57) and it looks like there is a problem with winscard.dll. I checked my dlls and these are on the newest version and I compared them with other PCs dlls.

I would like to ask whether there might be a problem in programme itself or there is a problem with my dlls. Have you ever encountered problem like this or do you know how to fix dlls?

[1]https://stackoverflow.com/questions/7174340/unknown-response-from-winscard-dll-method-scardtransmit-on-o2micro-reader-with-r

Information about your card Cards I encounter this error on are: Oberthur Cosmo Dual, Oberthur Cosmo64 RSA v5.4, Infineon JTOP v2, SIMoME Vault.

On other cards I had no problem with communication, for example on: Feitian JavaCOS A40, NXP J3A081, G+D SmartCafe 6.0.

Expected behavior I expected that gp -l would work as on the other cards.

Full log GlobalPlatformPro 19.01.22-0-gf94d7f5 Running on Windows 10 10.0 amd64, Java 1.8.0_201 by Oracle Corporation

Detected readers from JNA2PCSC

[] Gemplus USB Smart Card Reader 0 SCardConnect("Gemplus USB Smart Card Reader 0", T=) -> T=0, 3B6D000080318065409086015183079000 SCardBeginTransaction("Gemplus USB Smart Card Reader 0") Reader: Gemplus USB Smart Card Reader 0 ATR: 3B6D000080318065409086015183079000 More information about your card: http://smartcard-atr.appspot.com/parse?ATR=3B6D000080318065409086015183079000

A>> T=0 (4+0000) 00A40400 00 A<< (0027+2) (125ms) 6F198408A000000003000000A50D9F6E064091323405019F6501FF 9000 [TRACE] GlobalPlatform - [6F] [TRACE] GlobalPlatform - [84] A000000003000000 [TRACE] GlobalPlatform - [A5] [TRACE] GlobalPlatform - [9F6E] 409132340501 [TRACE] GlobalPlatform - [9F65] FF [DEBUG] GlobalPlatform - Auto-detected ISD: A000000003000000 [TRACE] GPData - GET DATA(CPLC) A>> T=0 (4+0000) 80CA9F7F 00 A<< (0045+2) (106ms) 9F7F2A409066564091323405016357270B051B2EEA409233124093331921347143444703430000000000000000 9000 CPLC: ICFabricator=4090 ICType=6656 OperatingSystemID=4091 OperatingSystemReleaseDate=3234 (2013-08-22) OperatingSystemReleaseLevel=0501 ICFabricationDate=6357 (2016-12-22) ICSerialNumber=270B051B ICBatchIdentifier=2EEA ICModuleFabricator=4092 ICModulePackagingDate=3312 (2013-11-08) ICCManufacturer=4093 ICEmbeddingDate=3319 (2013-11-15) ICPrePersonalizer=2134 ICPrePersonalizationEquipmentDate=7143 (2017-05-23) ICPrePersonalizationEquipmentID=44470343 ICPersonalizer=0000 ICPersonalizationDate=0000 (2010-01-01) ICPersonalizationEquipmentID=00000000

[TRACE] GPData - GET DATA(IIN) A>> T=0 (4+0000) 80CA0042 00 A<< (0000+2) (40ms) 6A88 [DEBUG] GPData - GET DATA(IIN): N/A [TRACE] GPData - GET DATA(CIN) A>> T=0 (4+0000) 80CA0045 00 A<< (0000+2) (42ms) 6A88 [DEBUG] GPData - GET DATA(CIN): N/A Card Data: [TRACE] GPData - GET DATA(Card Data) A>> T=0 (4+0000) 80CA0066 00 A<< (0000+2) (41ms) 6A88 [DEBUG] GPData - GET DATA(Card Data): N/A Card Capabilities: [TRACE] GPData - GET DATA(Card Capabilities) A>> T=0 (4+0000) 80CA0067 00 A<< (0000+2) (42ms) 6A88 [DEBUG] GPData - GET DATA(Card Capabilities): N/A [TRACE] GPData - GET DATA(Key Info Template) A>> T=0 (4+0000) 80CA00E0 00 A<< (0002+2) (56ms) E000 9000 [TRACE] GPData - [E0] Warning: no keys given, using default test key 404142434445464748494A4B4C4D4E4F [TRACE] GlobalPlatform - Generated host challenge: 1DB5F202ED268DF7 A>> T=0 (4+0008) 80500000 08 1DB5F202ED268DF7 00 << SCardTransmit got response 0x57 (null: null) Failed to communicate with card in apdu4j.LoggingCardTerminal@483bf400: SCardTransmit got response 0x57 (null: null) SCardEndTransaction(Gemplus USB Smart Card Reader 0) SCardDisconnect("Gemplus USB Smart Card Reader 0", true)

martinpaljak commented 5 years ago

Are you using the Windows CCID driver or Gemalto driver?

A functioning PC/SC layer is a pre-requisite for GPPro, so my recommendation is to get another opsystem/reader/driver. 0x57 is a generic "invalid parameter" that has to do with Windows and driver internals.

Sorry, nothing that can be done AFAIK, in GPPro context. Unless you come up with a PR or root cause description.

martinftlsx commented 5 years ago

Thank you for reply,

I checked the driver in Device manager and I found out it uses default Gemalto driver. I tried to update this driver but it did not help. I am afraid there is some problem with OS. I also tried other reader and the problem remains all the same. But it is really confusing as other cards work well.

Edit: To sum this up, it really looks like there is a problem somewhere in libraries used for transition of apdu command or perhaps in the driver. Replacing winscard.dll did not help. I tried 5 laptops and there always occured some problem (all with windows 10).

Solution However, I have tried gpj and it worked. Commands gpj -list and gpj -load ... -install did the job. I have successfully installed my .cap files on cards and finally I used Global Platform Pro for communication with applet (gp --applet ... --apdu ...).