LudovicRousseau / PCSC

pcsc-lite: PC/SC implementation
https://pcsclite.apdu.fr/
Other
254 stars 107 forks source link

Issue with PCSC - Init fail #85

Closed wisbit closed 3 years ago

wisbit commented 3 years ago

card : Yubico 5 NFC OS: Manjaro Linux pcsc version : from pcsclite 1.9.0-1

Hi there,

It all started with Thunderbird hanging for ever when treating an email requiring any level of signature / encryption / decryption. One thing led to another. I tried checking my card using gpg --card-status I got literally zero output. It just hung there. I had to ctrl+c to quit the gpg command I check further systemctl status pcscd

● pcscd.service - PC/SC Smart Card Daemon
     Loaded: loaded (/usr/lib/systemd/system/pcscd.service; indirect; vendor preset: disabled)
     Active: active (running) since Thu 2020-09-17 08:28:41 CEST; 1h 50min ago
TriggeredBy: ● pcscd.socket
       Docs: man:pcscd(8)
   Main PID: 6601 (pcscd)
      Tasks: 7 (limit: 11631)
     Memory: 1.6M
     CGroup: /system.slice/pcscd.service
             └─6601 /usr/bin/pcscd --foreground --auto-exit

sep 17 10:18:03 wisbix-laptop pcscd[6601]: 00069272 ifdhandler.c:150:CreateChannelByNameOrChannel() failed
sep 17 10:18:03 wisbix-laptop pcscd[6601]: 00000025 readerfactory.c:1105:RFInitializeReader() Open Port 0x200001 Failed (usb:1050/0407:libudev:1:/dev/bus>
sep 17 10:18:03 wisbix-laptop pcscd[6601]: 00000007 readerfactory.c:376:RFAddReader() Yubico YubiKey OTP+FIDO+CCID init failed.
sep 17 10:18:25 wisbix-laptop pcscd[6601]: 22076261 ccid_usb.c:857:WriteUSB() write failed (4/13): -4 LIBUSB_ERROR_NO_DEVICE
sep 17 10:18:28 wisbix-laptop pcscd[6601]: 03242571 ifdhandler.c:150:CreateChannelByNameOrChannel() failed
sep 17 10:18:28 wisbix-laptop pcscd[6601]: 00000630 readerfactory.c:1105:RFInitializeReader() Open Port 0x200000 Failed (usb:1050/0407:libudev:0:/dev/bus>
sep 17 10:18:28 wisbix-laptop pcscd[6601]: 00000109 readerfactory.c:376:RFAddReader() Yubico YubiKey OTP+FIDO+CCID init failed.
sep 17 10:18:28 wisbix-laptop pcscd[6601]: 00015076 ifdhandler.c:150:CreateChannelByNameOrChannel() failed
sep 17 10:18:28 wisbix-laptop pcscd[6601]: 00000264 readerfactory.c:1105:RFInitializeReader() Open Port 0x200000 Failed (usb:1050/0407:libudev:1:/dev/bus>
sep 17 10:18:28 wisbix-laptop pcscd[6601]: 00000113 readerfactory.c:376:RFAddReader() Yubico YubiKey OTP+FIDO+CCID init failed.

This is the output of pcsc_scan:

scanning present readers...
Waiting for the first reader...found one
Scanning present readers...
0: Yubico YubiKey OTP+FIDO+CCID 00 00

Thu Sep 17 10:16:38 2020
 Reader 0: Yubico YubiKey OTP+FIDO+CCID 00 00
  Event number: 0
  Card state: Card inserted, 
  ATR: 3B FD 13 00 00 81 31 FE 15 80 73 C0 21 C0 57 59 75 62 69 4B 65 79 40

ATR: 3B FD 13 00 00 81 31 FE 15 80 73 C0 21 C0 57 59 75 62 69 4B 65 79 40
+ TS = 3B --> Direct Convention
+ T0 = FD, Y(1): 1111, K: 13 (historical bytes)
  TA(1) = 13 --> Fi=372, Di=4, 93 cycles/ETU
    43010 bits/s at 4 MHz, fMax for Fi = 5 MHz => 53763 bits/s                                                                                            
  TB(1) = 00 --> VPP is not electrically connected
  TC(1) = 00 --> Extra guard time: 0
  TD(1) = 81 --> Y(i+1) = 1000, Protocol T = 1 

  TD(2) = 31 --> Y(i+1) = 0011, Protocol T = 1 

  TA(3) = FE --> IFSC: 254
  TB(3) = 15 --> Block Waiting Integer: 1 - Character Waiting Integer: 5
+ Historical bytes: 80 73 C0 21 C0 57 59 75 62 69 4B 65 79
  Category indicator byte: 80 (compact TLV data object)
    Tag: 7, len: 3 (card capabilities)
      Selection methods: C0
        - DF selection by full DF name
        - DF selection by partial DF name
      Data coding byte: 21
        - Behaviour of write functions: proprietary
        - Value 'FF' for the first byte of BER-TLV tag fields: invalid
        - Data unit in quartets: 2
      Command chaining, length fields and logical channels: C0
        - Command chaining
        - Extended Lc and Le fields
        - Logical channel number assignment: No logical channel
        - Maximum number of logical channels: 1
    Tag: 5, len: 7 (card issuer's data)
      Card issuer data: 59 75 62 69 4B 65 79
+ TCK = 40 (correct checksum)

Possibly identified card (using /usr/share/pcsc/smartcard_list.txt):
3B FD 13 00 00 81 31 FE 15 80 73 C0 21 C0 57 59 75 62 69 4B 65 79 40
        Yubico YubiKey 5 NFC (PKI)
        https://www.yubico.com/product/yubikey-5-nfc

I read many things online, tried to setup scdaemon to ignore pcsc but I don't have any config file for scdaemon. I tried to reinstall pcsclite, gpg, ccid to no avail.

I don't really know what else to do. I checked lsusb, plugged in removed plugged in ... dev and bus changes everytime so htat's ok.

Thanks for any help.

LudovicRousseau commented 3 years ago

See https://ludovicrousseau.blogspot.com/2019/06/gnupg-and-pcsc-conflicts.html

wisbit commented 3 years ago

Saludovic, (fallait que je la fasse)

Thanks a lot for the link, which I had read before, and that was before I knew a little more about scdaemon.

One thing was that there was no config file for scdaemon in .gnupg folder and I wasn't sure what to do with that info. Since you pushed that article again, I decided to try my luck. I created the file scademon.conf, added the line in it, shut down all that was needed, regardless of theoretical "defaults" I forced scdaemon to look into .gnupg and look at scdaemon.conf rebooted and abracadabra, it's not magic, but all works well.

Thank you very much, hopefully this can be useful to others :-) :+1: