node-pcsclite icon indicating copy to clipboard operation
node-pcsclite copied to clipboard

Error in macOS

Open gjuchault opened this issue 9 years ago • 6 comments

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.

gjuchault avatar Nov 22 '16 21:11 gjuchault

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.

pokusew avatar Nov 23 '16 18:11 pokusew

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.

gjuchault avatar Nov 23 '16 19:11 gjuchault

@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 avatar Nov 23 '16 19:11 pokusew

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.

pokusew avatar Nov 27 '16 11:11 pokusew

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

gjuchault avatar Nov 27 '16 23:11 gjuchault

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

gjuchault avatar Dec 06 '16 12:12 gjuchault