Created
August 4, 2018 12:02
-
-
Save sunnyy02/3c5b09b72d6eea2862f8331b5d5fd436 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onConnected(cardHandle, protocol) | |
{ | |
//Load default encription key FF FF FF FF FF FF | |
APDU_SELECTKEY = [0xFF, 0x82, 0x20, 0x00, 0x06,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF]; | |
api.SCardTransmit( | |
cardHandle, | |
protocol == API.SCARD_PROTOCOL_T0 ? | |
API.SCARD_PCI_T0 : API.SCARD_PCI_T1, | |
APDU_SELECTKEY).then(function(result) { | |
result.get(function (ioRecvPci, response) { | |
// get the 2 last bytes, the success code should be 9000 | |
sw = response.slice(-2); | |
if (sw[0] == 0x90 && sw[1] == 0x00) | |
{ | |
// General Auth | |
APDU_Auth_COMMAND = [0xFF, 0x86, 0x00, 0x00, 0x05,0x01,0x00,0x01,0x60,0x01]; | |
_cardHandle = cardHandle; | |
api.SCardTransmit( | |
cardHandle, | |
protocol == API.SCARD_PROTOCOL_T0 ? | |
API.SCARD_PCI_T0 : API.SCARD_PCI_T1, | |
APDU_Auth_COMMAND).then(function(result) { | |
myLog('pass the authentication: result:' + result); | |
result.get(onAuthenticated, response); | |
}, onRequestFailed); | |
} | |
}, onPcscLiteError); | |
}, onRequestFailed); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment