pokusew / node-pcsclite

Bindings over pcsclite to access Smart Cards
ISC License
60 stars 55 forks source link

Error in macOS #1

Open gjuchault opened 7 years ago

gjuchault commented 7 years ago

Hi !

I'm trying to use node-pcsclite on macOS. I'm having an issue trying to use desfire. I have an error which is : SCardTransmit error: Invalid parameter given.(0x80100004)

The code that fails is this one: return transmit(Buffer.from([0x1a, config.desfire.keyId]), 40, protocol); (I promisified transmit).

Running the code on Linux works.

pokusew commented 7 years ago

Hi @gjuchault,

That's strange. There can be some kind of inconsistency in pcsclite implementations on different OS. It is possible, that there is a buffer size limit on macOS, because of the error is thrown.

Could you please provide me your full working code? I will try to debug it and find out where the problem is.

Thank you.

Btw. I recommend you my another library for working with NFC – nfc-pcsc. It is a wrapper around this library which makes working working with NFC cards much easier. And it the newest version (branch led-control-support), it provides full Promise based (async/await compatible) API.

gjuchault commented 7 years ago

http://pastebin.com/eUMNwHCN

This is the script I used (and also one I got that I need to refactor). I had huge trouble trying to get nfc-pcsc inside Electron, so I went to node for testing and also directly with pcsclite, but nfc-pcsc is the next step.

The failing line is 70

note: for compatibility purposes, I'm trying mifare classic before desfire.

pokusew commented 7 years ago

@gjuchault I will look into your script as soon as possible.

I am using nfc-pcsc in a big production Electron app (for startup NFCtron). We have builds even for different OS (Windows and macOS) and everything works fine. Our Electron app was successfully deployed to tons of devices.

I can help you to set it up to work correctly in Electron if you want.

You can join here https://discord.gg/bg3yazg and we can chat.

pokusew commented 7 years ago

Hi @gjuchault,

as I have written in chat, I have an idea, how to solve your issue.

Because your APDU requests are not PC/SC compliant (and the responses too), you should use ENCAPSULATE instruction for the Contactless slot, see API doc for your reader here, part 3.3.7 http://files.springcard.com/pub/pmd2271-bb.pdf, more about accessing DESFIRE in section 4.2.1.

Let me know if it works.

Thank you.

gjuchault commented 7 years ago

Indeed, that is implementation/hardware issue we are now fixing without any issue with the library.

gjuchault commented 7 years ago

@pokusew I'm reopening the issue here as I've raised something in private, I might explain more here if needed