Belgian EID

More than a month has passed since I requested my home-address to be changed to Leuven. This week, I finally received my new identitycard, and electronic one (EID).

Nosey as I am, I tried to read everything on that card with the only smartcard reader I have: "Texas Instruments PCI6515 SmartCard Controller" built into my Dell Latitude D610. Unfortunately, there is currentnly no linux-driver for this device yet and I wasn't prepared to write on just for this experiment. So, I borrowed one of the BEID smartcard readers that the Belgian government is apparently giving away.

This is what I installed on Ubuntu Feisty 7.04:

apt-get install beidgui libacr38u libacr38ucontrol0 beid-tools pcscd libpcsclite-dev libengine-pkcs11-openssl libbeid2-dev
ln -s /usr/lib/ /usr/lib/
/etc/init.d/pcscd start

I started beidgui and it worked!

Of course, not every organisation has the ability to read EID cards, and not everyone in Belgium has them. That's why I received a paper with a printout of the data on my EID, with my EID. It's not hard to lose or damage a piece of paper, and I'm sure it will happen to me sooner or later. That's why I scanned in the document and keep it on my laptop.

But, this is totally unnecessary. The beidgui can print out this information aswell, in the exact same layout as the official paper. So, if you've lost this piece of paper, or if it became so trashed that you'd be ashamed to show it to any official instance, you can just print it out yourself.

I wasn't happy yet. The smartcard contains a picture of my face and I wasn't able to retrieve it through the beidgui program. I had a look at the libbeid2 library and discovered that the development files come with an example program. I cleaned it up so it only reads the picture and dumps it to a file and here it is:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "eidlib.h"

int main(int argc, char* argv[])
// Alround test buffer
BYTE buffer[4096] = {0};
BEID_Bytes tBytes = {0};
tBytes.length = 4096; = buffer;

BEID_Status tStatus = {0};
BEID_Certif_Check tCheck = {0};

long lHandle = 0;
tStatus = BEID_Init(""/*"VIRTUAL"*/, 0, 0, &lHandle);

// Read Picture Data
tStatus = BEID_GetPicture(&tBytes, &tCheck);
if(BEID_OK == tStatus.general)
FILE *pf = fopen("photo.jpg", "w+b");
if(pf != NULL)
fwrite(, sizeof(unsigned char), tBytes.length, pf);
printf("Picture written in \"photo.jpg\". Launching picture file ...\n");
} else {
printf("can't read card\n");

return 0;

Copypaste this code into "readpicture.cpp" (or download here) and compile it like this:

g++ -I /usr/include/beid/ -lbeid -o readpicture readpicture.cpp

And execute the "readpicture" program like this:


The only thing that still bugs me now, is that the smartcard reader in my laptop doesn't work under linux yet.
It seems there was a driver for it in an older kernel version, but support has stopped. 02Micro released a GPL driver for this card somewhere. I found a reference to it here:

and some more information here:

Maybe I should look into this driver and see if I can get it working again.