Closed jarodium closed 8 years ago
Hello @santigimeno
Here is a preliminary API spec. This may have to change in the future, but I think as a draft its makes the base class a simple one and I have added an eID child class in the proposal as well, due to my own needs
Regards
@jarodium You should first read ISO 7816-4 document.
You can get an idea of what the document contains at http://www.cardwerk.com/smartcards/smartcard_standard_ISO7816-4.aspx and in particular http://www.cardwerk.com/smartcards/smartcard_standard_ISO7816-4_6_basic_interindustry_commands.aspx
@LudovicRousseau Thank you for pointing me out the spec. I already had taken a look on the Spec, when I was researching APDU. Please refer to #58 in which I "complain" about how hard is for me to build apdu's. I come from a web environment and I am slowy making incursions on the physical world.
The intent of the API, is to have node-pcsclite handle higher level functions, without having developers like myself, bashing around to get APDU's working properly.
I believe node-pcslite will become more powerful in the future and will provide a solid base for IOT and specialized devices.
Best regards
The problem is that the APDU commands understood by a smart card is not standard. Each smart card family (EMV card, SIM card, etc.) have its own set of commands and parameters.
I see, but with the setCardType method one can set one of those types and load their own set of APDU commands. Maybe I should remove the APDU constants and let the methods stay. I think the methods are abstract enough for most card types... What do you think @LudovicRousseau ?
I think node-pcsclite is a low level API. You should create another (or more) library to provide a higher level API.
I think node-pcsclite is a low level API. You should create another (or more) library to provide a higher level API.
@jarodium I agree with @LudovicRousseau.
I see node-pcsclite
as a building block to create more complex API's. For example, I created node-pcsclite
because I needed to operate with SLE4442
cards, but I don't use it directly. I have created a module on top of it with a higher level API specific for this kind of cards: read_main_memory()
, read_security_memory()
, read_protection_memory()
, etc. In fact, I have created multiple modules that implement this interface because different card reader models sometimes access the same kind of cards using different commands.
Now I have understood the goal of this module. I thought i could evolve into a higher level api, from the current status, but if the goal is to keep it low level, I will no longer pursue this matter, but I will try to build a higher level api, but like I said in #58 , that will consume a lot of my time, since I should do lots of trial and error with the ptEID cards... @santigimeno is it possible to share those modules into repos?
Thank you for your time Regards
@jarodium Sorry, at the moment they're private :(
No problem
I'm closing this for the moment. Feel free to reopen though.
Proposal v.0.01 - Base Class
Constants
(taken from Open Smart Card Development Platform (www.openscdp.org)) (Implementation of ISO 7816-4 APDU processing )
APDU.INS_DEACTIVATE = 0x04;
APDU.INS_VERIFY = 0x20;
APDU.INS_MANAGE_SE = 0x22;
APDU.INS_CHANGE_REFERENCE_DATA = 0x24;
APDU.INS_PSO = 0x2A;
APDU.INS_RESET_RETRY_COUNTER = 0x2C;
APDU.INS_ACTIVATE = 0x44;
APDU.INS_GENERATE_KEY_PAIR = 0x46;
APDU.INS_EXTERNAL_AUTHENTICATE = 0x82;
APDU.INS_GET_CHALLENGE = 0x84;
APDU.INS_GENERAL_AUTHENTICATE = 0x86;
APDU.INS_COMPUTE_DIGITAL_SIGN = 0x9E;
APDU.INS_SELECT = 0xA4;
APDU.INS_READBINARY = 0xB0;
APDU.INS_READ_BINARY = 0xB0;
APDU.INS_READ_RECORD = 0xB2;
APDU.INS_VERIFY_CERTIFICATE = 0xBE;
APDU.INS_UPDATE_BINARY = 0xD6;
APDU.INS_TERMINATE = 0xE6;
APDU.SW_OK = 0x9000;
APDU.SW_TIMEOUT = 0x6401;
APDU.SW_OKMOREDATA = 0x6100;
APDU.SW_WARNING = 0x6200;
APDU.SW_WARNING1 = 0x6201;
APDU.SW_DATAINV = 0x6281;
APDU.SW_EOF = 0x6282;
APDU.SW_INVFILE = 0x6283;
APDU.SW_INVFORMAT = 0x6284;
APDU.SW_WARNINGNVCHG = 0x6300;
APDU.SW_WARNINGCOUNT = 0x63C0;
APDU.SW_WARNING0LEFT = 0x63C0;
APDU.SW_WARNING1LEFT = 0x63C1;
APDU.SW_WARNING2LEFT = 0x63C2;
APDU.SW_WARNING3LEFT = 0x63C3;
APDU.SW_EXECERR = 0x6400;
APDU.SW_MEMERR = 0x6501;
APDU.SW_MEMERRWRITE = 0x6581;
APDU.SW_WRONGLENGTH = 0x6700;
APDU.SW_CLANOTSUPPORTED = 0x6800;
APDU.SW_LCNOTSUPPORTED = 0x6881;
APDU.SW_SMNOTSUPPORTED = 0x6882;
APDU.SW_LASTCMDEXPECTED = 0x6883;
APDU.SW_CHAINNOTSUPPORTED = 0x6884;
APDU.SW_COMNOTALLOWED = 0x6900;
APDU.SW_COMINCOMPATIBLE = 0x6981;
APDU.SW_SECSTATNOTSAT = 0x6982;
APDU.SW_AUTHMETHLOCKED = 0x6983;
APDU.SW_REFDATANOTUSABLE = 0x6984;
APDU.SW_CONDOFUSENOTSAT = 0x6985;
APDU.SW_COMNOTALLOWNOEF = 0x6986;
APDU.SW_SMOBJMISSING = 0x6987;
APDU.SW_INCSMDATAOBJECT = 0x6988;
APDU.SW_INVPARA = 0x6A00;
APDU.SW_INVDATA = 0x6A80;
APDU.SW_FUNCNOTSUPPORTED = 0x6A81;
APDU.SW_NOAPPL = 0x6A82;
APDU.SW_FILENOTFOUND = 0x6A82;
APDU.SW_RECORDNOTFOUND = 0x6A83;
APDU.SW_OUTOFMEMORY = 0x6A84;
APDU.SW_INVLCTLV = 0x6A85;
APDU.SW_INVACC = 0x6A85;
APDU.SW_INCP1P2 = 0x6A86;
APDU.SW_INVLC = 0x6A87;
APDU.SW_RDNOTFOUND = 0x6A88;
APDU.SW_FILEEXISTS = 0x6A89;
APDU.SW_DFNAMEEXISTS = 0x6A8A;
APDU.SW_INVP1P2 = 0x6B00;
APDU.SW_INVLE = 0x6C00;
APDU.SW_INVINS = 0x6D00;
APDU.SW_INVCLA = 0x6E00;
APDU.SW_ACNOTSATISFIED = 0x9804;
APDU.SW_NOMORESTORAGE = 0x9210;
APDU.SW_GENERALERROR = 0x6F00;
Methods/Functions
public setPin(int pin)
public setPuk(int puk)
public isVerified(string context)
public getRetriesAvail(string context)
public setCardType(string type)
public getCardType()
Public getCardContents()
public getFS()
private sendAPDU(byte_array buffer)
private decode(string data, string from, string to)
private encode(string data, string from, string to)
SubClass - EID
This describes an object to interact with a eID card.
public setCountry(string country-code, string iso=’DEFAUL_ISO’)
public getPkiCert()
public getSignCert()
public getName()
public getAddress()
public getID(string context);
public getParentage();
public getDateofBirth()
public getFingerPrints()
public getPhoto()
public getFreeField
public setFreeField