Reputation: 105
I need to access the eID information through node. For this I have found a package (https://github.com/santigimeno/node-pcsclite) to do this. The site has an example which seems to work (do something atleast. I have copied the following code :
#!/usr/bin/env node
var pcsc = require('pcsclite');
var pcsc = pcsc();
pcsc.on('reader', function(reader) { console.log('New reader detected', reader.name);
reader.on('error', function(err) {
console.log('Error(', this.name, '):', err.message);
});
reader.on('status', function(status) {
console.log('Status(', this.name, '):', status);
/* check what has changed */
var changes = this.state ^ status.state;
if (changes) {
if ((changes & this.SCARD_STATE_EMPTY) && (status.state & this.SCARD_STATE_EMPTY)) {
console.log("card removed");/* card removed */
reader.disconnect(reader.SCARD_LEAVE_CARD, function(err) {
if (err) {
console.log(err);
} else {
console.log('Disconnected');
}
});
} else if ((changes & this.SCARD_STATE_PRESENT) && (status.state & this.SCARD_STATE_PRESENT)) {
console.log("card inserted");/* card inserted */
reader.connect({ share_mode : this.SCARD_SHARE_SHARED }, function(err, protocol) {
if (err) {
console.log(err);
} else {
console.log('Protocol(', reader.name, '):', protocol);
console.log('info : ' , reader)
reader.transmit(new Buffer([0x00, 0xB0, 0x00, 0x00, 0x20]), 40, protocol, function(err, data) {
if (err) {
console.log(err);
} else {
console.log('Data received', data);
reader.close();
pcsc.close();
}
});
}
});
}
}
});
reader.on('end', function() {
console.log('Reader', this.name, 'removed');
});
});
pcsc.on('error', function(err) {
console.log('PCSC error', err.message);
});
I then navigate to the directory and use node + "filename" and it gives me the following output :
As far as I can tell it is this part (the APDU code):
reader.transmit(new Buffer([0x00, 0xB0, 0x00, 0x00, 0x20])
that will give me a certain piece of information.
I need some more documentation about all of this, specifically a list of APDU's that I can use; for example the APDU to read the eID picture.
I've searched with every keyword I could think of so far, and haven't found anything useful. Really hope someone can point me in the right direction.
Upvotes: 1
Views: 2287
Reputation: 193
You can read this website to learn more about smart card and how it works. I'm not the expert in this matter but the website helps me a lot.
http://www.cardwerk.com/smartcards/smartcard_standard_ISO7816-4_5_basic_organizations.aspx
"3B 98 13 40 0A A5 03 01 01 01 AD 13 11" is your card ATR which probably is "Belgium Electronic ID card". You can check ATR from this website
https://smartcard-atr.apdu.fr/
To retrieve data from smart card:
In you case, 69 is SW1 86 is SW2. The meaning is "Command not allowed (no current EF)"
Upvotes: 1