LudovicRousseau / CCID

CCID driver
https://ccid.apdu.fr/
GNU Lesser General Public License v2.1
229 stars 79 forks source link

libnfc not able to connect to device on macOS #135

Closed ajmas closed 3 months ago

ajmas commented 5 months ago

I am wanting to use my NFC reader via a node.js project, but I am running into an issue with libnfc based tools:

LIBNFC_LOG_LEVEL=3 nfc-list -v                                                                                        ajmas@ghostwalker-echo
debug   libnfc.config   key: [allow_intrusive_scan], value: [yes]
debug   libnfc.config   Unable to open directory: /usr/local/Cellar/libnfc/1.8.0/etc/nfc/devices.d
debug   libnfc.general  log_level is set to 3
debug   libnfc.general  allow_autoscan is set to true
debug   libnfc.general  allow_intrusive_scan is set to true
debug   libnfc.general  0 device(s) defined by user
nfc-list uses libnfc 1.8.0
debug   libnfc.general  0 device(s) found using arygon driver
debug   libnfc.general  0 device(s) found using pn532_uart driver
debug   libnfc.general  0 device(s) found using ACR122S driver
debug   libnfc.general  0 device(s) found using acr122_usb driver
debug   libnfc.driver.acr122_pcsc   PCSC device [Circle CIR315(1)] is not NFC capable or not supported by libnfc.
debug   libnfc.general  0 device(s) found using acr122_pcsc driver
debug   libnfc.general  1 device(s) found using pcsc driver
debug   libnfc.general  0 device(s) found using pn53x_usb driver
debug   libnfc.driver.pcsc  Attempt to open Circle CIR315(1)
debug   libnfc.driver.pcsc  PCSC connect failed
debug   libnfc.general  Unable to open "pcsc:Circle CIR315(1)".
nfc-list: ERROR: Unable to open NFC device: pcsc:Circle CIR315(1)

I am using the forked version of the project here, but I'm hoping this is close enough to the original CCID that I can get some pointers here? I am a newbie here, so I don't totally know whether libnfc is using CCID as a system driver or a bound library?

I did try "NFC Tools for Desktop" which did recognise the reader.

OS: macOS 14.4.1

LudovicRousseau commented 5 months ago

Ask AB Circle for help if you use their driver.

ajmas commented 5 months ago

I have now uninstalled the vendor driver, and built and installed from source, though I am still having issues.

The device should be supported, but I am still getting the same error output as above.

The version of libnfc I have is 1.8.0, which appears to be the latest.

Output of sudo ./src/parse gives:

idVendor: 0x31AA
  iManufacturer: Circle
 idProduct: 0x3001
  iProduct: CIR315
 bcdDevice: 2.01 (firmware release?)
 bLength: 9
 bDescriptorType: 4
 bInterfaceNumber: 0
 bAlternateSetting: 0
 bNumEndpoints: 3
  bulk-IN, bulk-OUT and Interrupt-IN
 bInterfaceClass: 0x0B [Chip Card Interface Device Class (CCID)]
 bInterfaceSubClass: 0
 bInterfaceProtocol: 0
  bulk transfer, optional interrupt-IN (CCID)
 iInterface: CIR315 PICC
 CCID Class Descriptor
  bLength: 0x36
  bDescriptorType: 0x21
  bcdCCID: 1.10
  bMaxSlotIndex: 0x00
  bVoltageSupport: 0x07
   5.0V
   3.0V
   1.8V
  dwProtocols: 0x0000 0x0003
   T=0
   T=1
  dwDefaultClock: 4.800 MHz
  dwMaximumClock: 4.800 MHz
  bNumClockSupported: 0 (will use whatever is returned)
   IFD does not support GET CLOCK FREQUENCIES request: LIBUSB_ERROR_PIPE
  dwDataRate: 12903 bps
  dwMaxDataRate: 412903 bps
  bNumDataRatesSupported: 0 (will use whatever is returned)
   IFD does not support GET_DATA_RATES request: LIBUSB_ERROR_PIPE
  dwMaxIFSD: 512
  dwSynchProtocols: 0x00000000
  dwMechanical: 0x00000000
   No special characteristics
  dwFeatures: 0x000404BA
   ....02 Automatic parameter configuration based on ATR data
   ....08 Automatic ICC voltage selection
   ....10 Automatic ICC clock frequency change according to parameters
   ....20 Automatic baud rate change according to frequency and Fi, Di params
   ....80 Automatic PPS made by the CCID
   ..04.. Automatic IFSD exchange as first exchange (T=1)
   04.... Short and Extended APDU level exchange
  dwMaxCCIDMessageLength: 522 bytes
  bClassGetResponse: 0x00
  bClassEnvelope: 0x00
  wLcdLayout: 0x0000
  bPINSupport: 0x00
  bMaxCCIDBusySlots: 1
 idVendor: 0x31AA
  iManufacturer: Circle
 idProduct: 0x3001
  iProduct: CIR315
 bcdDevice: 2.01 (firmware release?)
 bLength: 9
 bDescriptorType: 4
 bInterfaceNumber: 1
 bAlternateSetting: 0
 bNumEndpoints: 3
  bulk-IN, bulk-OUT and Interrupt-IN
 bInterfaceClass: 0x0B [Chip Card Interface Device Class (CCID)]
 bInterfaceSubClass: 0
 bInterfaceProtocol: 0
  bulk transfer, optional interrupt-IN (CCID)
 iInterface: CIR315 SAM
 CCID Class Descriptor
  bLength: 0x36
  bDescriptorType: 0x21
  bcdCCID: 1.10
  bMaxSlotIndex: 0x00
  bVoltageSupport: 0x01
   5.0V
  dwProtocols: 0x0000 0x0003
   T=0
   T=1
  dwDefaultClock: 0.250 MHz
  dwMaximumClock: 0.250 MHz
  bNumClockSupported: 0 (will use whatever is returned)
   IFD does not support GET CLOCK FREQUENCIES request: LIBUSB_ERROR_PIPE
  dwDataRate: 10752 bps
  dwMaxDataRate: 129032 bps
  bNumDataRatesSupported: 0 (will use whatever is returned)
   IFD does not support GET_DATA_RATES request: LIBUSB_ERROR_PIPE
  dwMaxIFSD: 254
  dwSynchProtocols: 0x00000000
  dwMechanical: 0x00000000
   No special characteristics
  dwFeatures: 0x000200BA
   ....02 Automatic parameter configuration based on ATR data
   ....08 Automatic ICC voltage selection
   ....10 Automatic ICC clock frequency change according to parameters
   ....20 Automatic baud rate change according to frequency and Fi, Di params
   ....80 Automatic PPS made by the CCID
   02.... Short APDU level exchange
  dwMaxCCIDMessageLength: 271 bytes
  bClassGetResponse: 0x00
  bClassEnvelope: 0x00
  wLcdLayout: 0x0000
  bPINSupport: 0x00
  bMaxCCIDBusySlots: 1

BTW "NFC Tools for Desktop" is likely using "Core NFC", so this would be a red herring in my analysis and worked even with the the CIR315A driver uninstalled.

LudovicRousseau commented 5 months ago

To check a reader works fine follow https://blog.apdu.fr/posts/2014/03/level-1-smart-card-support-on-mac-os-x/

ajmas commented 5 months ago

I just tried pcsctest and this appears to have worked:

pcsctest                                                                                                                                                     ajmas@ghostwalker-echo

MUSCLE PC/SC Lite Test Program

Testing SCardEstablishContext    : Command successful.
Testing SCardGetStatusChange 
Please insert a working reader   : Command successful.
Testing SCardListReaders         : Command successful.
Reader 01: Circle CIR315
Enter the reader number          : 0
Invalid Value - try again
Enter the reader number          : 1
Waiting for card insertion         
                                 : Command successful.
Testing SCardConnect             : Command successful.
Testing SCardStatus              : Command successful.
Current Reader Name              : Circle CIR315
Current Reader State             : 0x54
Current Reader Protocol          : 0x1
Current Reader ATR Size          : 13 (0xd)
Current Reader ATR Value         : 3B 88 80 01 00 00 00 00 11 81 71 00 E8 
Testing SCardDisconnect          : Command successful.
Testing SCardReleaseContext      : Command successful.
Testing SCardEstablishContext    : Command successful.
Testing SCardGetStatusChange 
Please insert a working reader   : Command successful.
Testing SCardListReaders         : Command successful.
Reader 01: Circle CIR315
Enter the reader number          : 
LudovicRousseau commented 5 months ago

So the reader and driver work fine.

If you have an issue with libnfc you should ask for help there.

LudovicRousseau commented 3 months ago

No problem in CCID driver. Closing.