Closed LudovicRousseau closed 1 year ago
Like in https://github.com/cryptographix/pcsc-deno/issues/6 we have a problem with the size of DWORD.
Another problem is that you hard code the protocol value to 1 (for T=0) in https://github.com/cryptographix/pcsc-deno/blob/master/deno-pcsc-ffi/pcsc-ffi-wrapper.ts#L282 This will NOT work for a T=1 card.
You must use the protocol value returned by SCardConnect() in the pdwActiveProtocol parameter.
pdwActiveProtocol
Here is a patch to be able to send an APDU to a T=1 card on GNU/Linux:
diff --git a/deno-pcsc-ffi/pcsc-ffi-wrapper.ts b/deno-pcsc-ffi/pcsc-ffi-wrapper.ts index 54ef493..682a450 100644 --- a/deno-pcsc-ffi/pcsc-ffi-wrapper.ts +++ b/deno-pcsc-ffi/pcsc-ffi-wrapper.ts @@ -278,11 +278,11 @@ export function SCardDisconnect( } function prepareTransmit(recvLength: DWORD) { - const pioSendPci = new Uint8Array(8); - new DataView(pioSendPci.buffer).setUint32(0, 1, true); - new DataView(pioSendPci.buffer).setUint32(4, 8, true); + const pioSendPci = new Uint8Array(16); + new DataView(pioSendPci.buffer).setUint32(0, 2, true); + new DataView(pioSendPci.buffer).setUint32(8, 16, true); - const pioRecvPci = new Uint8Array(8); + const pioRecvPci = new Uint8Array(16); pioRecvPci.set(pioSendPci); const recvBuffer = new Uint8Array(recvLength + 2);
I had to:
pioSendPci
pioRecvPci
cbPciLength
Thanks for the issue.
Deno has recently including "static" data imports from DLL, so maybe can use pcsc exports for pioRecv and pioSend.
I'll have a look,
It works for me now
Like in https://github.com/cryptographix/pcsc-deno/issues/6 we have a problem with the size of DWORD.
Another problem is that you hard code the protocol value to 1 (for T=0) in https://github.com/cryptographix/pcsc-deno/blob/master/deno-pcsc-ffi/pcsc-ffi-wrapper.ts#L282 This will NOT work for a T=1 card.
You must use the protocol value returned by SCardConnect() in the
pdwActiveProtocol
parameter.Here is a patch to be able to send an APDU to a T=1 card on GNU/Linux:
I had to:
pioSendPci
andpioRecvPci
cbPciLength
value from 8 to 16