Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pcsc do not work with Watchdata W5181 #121

Closed
sztsian opened this issue Feb 27, 2022 · 9 comments
Closed

pcsc do not work with Watchdata W5181 #121

sztsian opened this issue Feb 27, 2022 · 9 comments
Assignees

Comments

@sztsian
Copy link

sztsian commented Feb 27, 2022

Versions

  • smart card reader driver name and version
    pcsc-lite-libs-1.9.5-1.fc35.x86_64
    pcsc-lite-ccid-1.4.36-2.fc35.x86_64
    pcsc-lite-1.9.5-1.fc35.x86_64
    pcsc-perl-1.4.14-18.fc35.x86_64
    pcsc-tools-1.5.8-1.fc35.x86_64
    pcsc-lite-devel-1.9.5-1.fc35.x86_64

  • pcsc-lite version See above

  • the output of the command /usr/sbin/pcscd --version

$ pcscd --version
pcsc-lite version 1.9.5.
Copyright (C) 1999-2002 by David Corcoran <[email protected]>.
Copyright (C) 2001-2018 by Ludovic Rousseau <[email protected]>.
Copyright (C) 2003-2004 by Damien Sauveron <[email protected]>.
Report bugs to <[email protected]>.
Enabled features: Linux x86_64-redhat-linux-gnu libsystemd serial usb libudev usbdropdir=/usr/lib64/pcsc/drivers ipcdir=/run/pcscd filter configdir=/etc/reader.conf.d

Platform

  • Operating system or GNU/Linux distribution name and version:
    Fedora 35 x86_64
  • Smart card middleware name and version:
    ccid, as shows above
  • Smart card reader manufacturer name and reader model name:
    Watchdata W5181, which is listed in supported_readers of CCID.
  • Smart card name
    J3R200, but this has nothing to do with smart card yet.

Issue

  • What do you do?
    On Fedora, pcsc_scan cannot detect the card I put on Watchdata w5181 contactless interface. And gp.jar from GlobalPlatformPro cannot detect the card either
  • What result do you expect?
    I should be able to use the contactless interface just like how it work in Windows (without any 3rd part driver).
  • What result do you get instead?
    pcsc_scan simply cannot detect the card. And gp returns like the following.
$ java -jar gp.jar -i -r "Watchdata W5181  [Contactless Reader ]" 
Error: SCardConnect got response 0x8010000c (SCARD_E_NO_SMARTCARD: The operation requires a Smart Card, but no Smart Card is currently in the device.)

Log

watchdata-pcscdlog.txt

I captured the USB pcap on a Windows virtual machine. The capture starts before I redirect the reader to the VM, and then the whole process of runing the following commands. Hope this can be helpful.

C:\Users\user\Desktop>gp.exe -r "Watchdata W5181 Contact Reader" -l
Warning: no keys given, defaulting to 404142434445464748494A4B4C4D4E4F
Error: SCardTransmit got response 0x458 (null: null)

C:\Users\user\Desktop>gp.exe -r "Watchdata W5181 Contactless Reader" -l
Warning: no keys given, defaulting to 404142434445464748494A4B4C4D4E4F
ISD: A000000151000000 (OP_READY)
     Parent:  A000000151000000
     From:    A0000001515350
     Privs:   [SecurityDomain, CardLock, CardTerminate, CardReset, CVMManagement
, TrustedPath, AuthorizedManagement, TokenVerification, GlobalDelete, GlobalLock
, GlobalRegistry, FinalApplication, ReceiptGeneration]

APP: D276000124010304AFAF000000000000 (SELECTABLE)
     Parent:  A000000151000000
     From:    D27600012401
     Privs:   []

PKG: A0000001515350 (LOADED)
     Parent:  A000000151000000
     Version: 255.255
     Applet:  A000000151535041

PKG: A0000000620204 (LOADED)
     Parent:  A000000151000000
     Version: 1.0

PKG: A0000000620202 (LOADED)
     Parent:  A000000151000000
     Version: 1.3

PKG: D27600012401 (LOADED)
     Parent:  A000000151000000
     Version: 1.0
     Applet:  D276000124010304AFAF000000000000

watchdata-pcap-windows.tar.gz

Note: I don't know if this is the right place to submit the bug or not. If not, feel free to let me know where this could be submitted.

And, the card itself works fine with other readers in my Fedora.

@LudovicRousseau
Copy link
Owner

The reader "Watchdata W5181" is listed in the "Should work but untested by me" list
https://ccid.apdu.fr/ccid/shouldwork.html#0x163C0x0A03

Some readers are not compliant with CCID on the contactless interface.

It looks like your Windows trace if for the SAM interface. I see the ATR 3b7d940000574429464186938abf7515143d that corresponds to what you get on Linux for the reader "Watchdata W5181 [SAM Reader ] 02 00"

@LudovicRousseau LudovicRousseau self-assigned this Feb 27, 2022
@LudovicRousseau
Copy link
Owner

Since the problem is with the CCID driver you should have reported the problem to https://github.com/LudovicRousseau/CCID
But since I am also the maintainer of the CCID driver I propose to continue here to not add complexity.

@sztsian
Copy link
Author

sztsian commented Feb 27, 2022

The reader "Watchdata W5181" is listed in the "Should work but untested by me" list https://ccid.apdu.fr/ccid/shouldwork.html#0x163C0x0A03

Some readers are not compliant with CCID on the contactless interface.

Ouch, thanks. I'm not really aware this. I saw in the Windows VM all 3 interfaces shows up as ccid driver so I was thinking this should work.

OTOH, I think the contact interface does not work on the Windows 7 VM either. Not sure what's the cause yet. Maybe it's because the Windows system is inside VM

It looks like your Windows trace if for the SAM interface. I see the ATR 3b7d940000574429464186938abf7515143d that corresponds to what you get on Linux for the reader "Watchdata W5181 [SAM Reader ] 02 00"

Yes. Actually the reader itself contains 3 slots - contact, contactless, SAM. I don't care about the SAM slot so I did not pay much attention to the info there. I confirm there is a SAM card inside the slot (the SAM card inside don't belong to me so I do know know anything about it).

$ pcsc_scan 
Using reader plug'n play mechanism
Scanning present readers...
0: Watchdata W5181  [Contact Reader ] 00 00
1: Watchdata W5181  [Contactless Reader ] 01 00
2: Watchdata W5181  [SAM Reader ] 02 00
 
Sun Feb 27 22:54:23 2022
 Reader 0: Watchdata W5181  [Contact Reader ] 00 00
  Event number: 0
  Card state: Card removed, 
 Reader 1: Watchdata W5181  [Contactless Reader ] 01 00
  Event number: 0
  Card state: Card removed, 
 Reader 2: Watchdata W5181  [SAM Reader ] 02 00
  Event number: 2
  Card state: Card inserted, 
  ATR: 3B 7D 94 00 00 57 44 29 46 41 86 93 8A BF 75 15 14 3D

ATR: 3B 7D 94 00 00 57 44 29 46 41 86 93 8A BF 75 15 14 3D
+ TS = 3B --> Direct Convention
+ T0 = 7D, Y(1): 0111, K: 13 (historical bytes)
  TA(1) = 94 --> Fi=512, Di=8, 64 cycles/ETU
    62500 bits/s at 4 MHz, fMax for Fi = 5 MHz => 78125 bits/s
  TB(1) = 00 --> VPP is not electrically connected
  TC(1) = 00 --> Extra guard time: 0
+ Historical bytes: 57 44 29 46 41 86 93 8A BF 75 15 14 3D
  Category indicator byte: 57 (proprietary format)

@sztsian
Copy link
Author

sztsian commented Feb 27, 2022

Oh by the way, if your conclusion from the capture is that this is really an incompatible device and no way to fix it in CCID, I don't have objections - except that we probably should remove Watchdata W5181 from the supported_readers list in such case.

@LudovicRousseau
Copy link
Owner

If Windows can use the contactless interface then I guess the reader is not completely useless.
But it would take time to do some reverse engineering. So unless you have a budget I do not plan to do much.

I added a note for https://ccid.apdu.fr/ccid/shouldwork.html#0x163C0x0A03

@sztsian
Copy link
Author

sztsian commented Mar 1, 2022

Thanks

If Windows can use the contactless interface then I guess the reader is not completely useless. But it would take time to do some reverse engineering. So unless you have a budget I do not plan to do much.

No worries. I still have other working readers on hand.

I added a note for https://ccid.apdu.fr/ccid/shouldwork.html#0x163C0x0A03

Thanks. But that might be insufficient - in my Fedora 35, none of the interfaces work for me. I only provide the log and capture with contactless interface only because that's the only thing I get it working in Windows 7 VM without anything special.

So, I would suggest to mention it as not supported right now.

@LudovicRousseau
Copy link
Owner

From your pcsc_scan trace I see the 3 interfaces. And you get the ATR of the SAM interface. So at least the SAM interface works.
Have you tried the contact interface?

@sztsian
Copy link
Author

sztsian commented Mar 1, 2022

Actually I've tried contact interface first. But it don't work with pcsc_scan (by this I mean, pcsc_scan cannot detect any card with the contact interface). Then I tried the contact interface inside Windows VM, gp also cannot show my content in the java card. The windows part is already in the log of #121 (comment)

@LudovicRousseau
Copy link
Owner

OK. So the Watchdata W5181 does not work (for you).
Thanks for the notice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants