Difference between revisions of "Belgian eID"

From YobiWiki
Jump to navigation Jump to search
Line 12: Line 12:
   
 
* [http://www.belgium.be/zip/eid_datacapture_fr.html Middleware & developer's kit]
 
* [http://www.belgium.be/zip/eid_datacapture_fr.html Middleware & developer's kit]
  +
** There are also Debian packages, cf below my tests under Linux
** [http://packages.qa.debian.org/b/belpic.html Debian packaged]
 
 
* [http://developer.novell.com/wiki/index.php/EID-belgium eID configuration toolkit by Novell]
 
* [http://developer.novell.com/wiki/index.php/EID-belgium eID configuration toolkit by Novell]
 
* [http://homes.esat.kuleuven.be/~decockd/wiki/bin/view.cgi/Main/WebHome Danny De Cock's page on eID] (same as http://www.godot.be)
 
* [http://homes.esat.kuleuven.be/~decockd/wiki/bin/view.cgi/Main/WebHome Danny De Cock's page on eID] (same as http://www.godot.be)

Revision as of 18:23, 7 February 2008

Belgian eID is part of the efforts of the government for Belgian eGov

Officials

Usage & Software

Misc

I revoked my certificates

Why?

Because at that time I knew too few on the details of the eID architecture and too much about how a new security architecture can have flaws, so better to stay away for a while, especially given the legal implications that the eID can bring.
I knew they were talking about two certificates without understanding their difference, so let's revoke both.
Note that it doesn't mean my eID is not valid, eID card activation is mandatory. The eID card is a proof of identity and residence of a person in Belgium. eID certificates activation is a choice of the holder of the eID (opt-in), he/she can decide to activate or revoke the certificates. (cf FAQ)

How?

It was quite epic.
I was still a bit prepared, hopefully, so I had printed the Annexes 3 & 10, the legal forms to ask either to renounce to have the certificates or to revoke them just after activation, as well as the relevant parts of the User Manual for the civil servants :-)
I printed both as for me it was not clear from the User Manual how to renounce for the certificates.

  • [Me] Good morning, I come for my eID and... I want to get rid of the certificates
  • [Her] You what? Is it possible? Never heard about that
  • [Me] Yes, yes, see (and I show her what's in her User Manual)
  • ... (takes a while to digest the info)
  • [Her] Ha ok, you've to fill Annex 3, (shouting behind her shoulder) JOSETTE, DO WE HAVE ANNEX 3???
  • [Josette] ANNEX WHAT??
  • [Me] No prob, look (and I pull out my own copy of Annex 3)
  • ... (meanwhile she has no idea what to do on the eID to fulfill renouncement and I agree with her, the Manual was unclear so we went for activation+revocation)
  • [Me] No prob, look (and I pull out my own copy of Annex 10)
  • [Her] Can I take your copies before you fill them? I'll make copies for ourselves.

So today the official Annex 3&10 forms of this civil office are mine :-D
Who knows, maybe I crafted the form... ;-)

It is "funny" to see that everywhere the activation of the certificates is presented as optional, the choice being left to the citizen, blablabla, but in reality most of the citizen just don't know about this possibility (and most of the civil servants, well I hope that since my story, things have evolved a bit) and the civil servants doesn't ask you the question.

Some details about those certificates

The eID contains 2 signature certificates, so you cannot encrypt with them, just sign.

  • One labeled "Authentication" is for daily use
  • One labeled "Signature" is for special cases
    • Apparently it has a equivalent legal value as a hand-written signature and is referred as non-repudiation signature.
    • It's automatically revoked for minors under 18 years as they cannot sign legally yet.
    • From Certipost FAQ:
      Non-repudiation guarantees that one cannot deny having performed an act. E.g. any message signed using a person's digital signature can only have come from this person. The signing person can not claim that the message was not originated by him.
      In other words, non-repudiation means that information cannot be disclaimed, similar to a witnessed handwritten signature on a paper document.

      to be checked in the law
    • Normal pkcs software doesn't seem to be able to use it (?)
    • Should be used only through the Government software which prompts you with a special GUI and warnings about the legal power of this signature
  • CertiPost e-Registered mails is using the non-repudiation signature
  • CertiPost e-Signing is using the non-repudiation signature
  • Both are protected by the same PIN which is typed on your (unsafe) PC

What says the law

Sorry, here are french version abstracts.
9 JUILLET 2001. - Loi fixant certaines règles relatives au cadre juridique pour les signatures électroniques et les services de certification, date de publication au Moniteur: 29 septembre 2001
Morceaux choisis:

  • Art. 4. § 1er. A défaut de dispositions légales contraires, nul ne peut être contraint de poser un acte juridique par voie électronique.
  • § 4. Sans préjudice des articles 1323 et suivants du Code civil, une signature électronique avancée réalisée sur la base d'un certificat qualifié et conçue au moyen d'un dispositif sécurisé de création de signature électronique, est assimilée à une signature manuscrite, qu'elle soit réalisée par une personne physique ou morale.
  • § 5. Une signature électronique ne peut être privée de son efficacité juridique et ne peut être refusée comme preuve en justice au seul motif :
    • que la signature se présente sous forme électronique, ou
    • qu'elle ne repose pas sur un certificat qualifié, ou
    • qu'elle ne repose pas sur un certificat qualifié délivré par un prestataire accrédité de service de certification, ou
    • qu'elle n'est pas créée par un dispositif sécurisé de création de signature.
  • Wait a minute, ANY electronic signature NOT being based on a qualified certificate and NOT created in a secure environment CANNOT be refused as a legal proof???
    Maybe it's me or the triple-negation sentences (lawyers, lawyers...) but it looks like § 5 goes much further than § 4

What do I think today?

Catastrophe scenario:

  • Someone captures your PIN while you're using it for "just authentication" via e.g. malware, virus, trojan, worm on the PC (you know, the kind of stuff that never happens).
  • He gets access to your eID
  • Now he can sign with your legal signature anything you can imagine... and you cannot repudiate what he does.

So what will I do next time?

  • I'll probably accept the Authentication certificate to be able to play around with it.
  • For sure I'll revoke the Signature certificate unless they change their architecture.
    • Not the same PIN than the other certificate.
    • Better than 4 digits (& 3 attempts so 3 chances over 10000)
    • Even then:
      • Then I could use it but only on trusted devices, that's another story...
      • You get the PIN & PUK by post if I remember well, this could be eavesdropped but you can change your PIN... So as the PUK can unlock the PIN 12 times, the attacker has 36 chances over 10000, one over 278, mmm... And who said humans can generate random PINs? ;-)

Another consideration I didn't talk about yet: PRIVACY

  • Whoever sees your public certificate (which happens e.g. if you log to a SSL website with your card or if you simply send a signed email) sees your RRN ("rijksregistratienummer")
  • Tax-on-web announce it but what about the others and your mail correspondants?
    Suite à l'utilisation de votre moyen d'authentification (carte d'identité électronique ou token citoyen), le SPF Finances a connaissance de votre numéro de registre national.
    Conformément à l'arrêté royal du 25/04/1986 autorisant certaines autorités du Ministère des Finances à utiliser le numéro d'identification du registre national des personnes physiques, votre numéro de registre national n'est utilisé dans ce contexte qu'à des fins d'identification pour l'accès aux applications du SPF Finances.
    La loi du 8 décembre 1992 relative à la protection de la vie privée à l'égard des traitements de données à caractère personnel s'applique à ce traitement d'identification dont le responsable est le SPF Finances, Boulevard Albert II, 33 à 1030 Bruxelles.
  • ADAPID project is a consortium of researchers and industry representatives in Flanders decided to take action in an attempt to help avoid a national privacy calamity. After a first (non-public) report, the ADAPID project won the financial support of IWT-Flanders. ADAPID officially started July 1st, 2005 and will run until June 30th, 2009.
  • Normally the third and definitive version of the eID should have been rolled out begin of this year (2008).

My attempts under Linux

I'm using the IDream ID-SMID01 SmartCard reader, bought for 10€

Installing beidgui and dependencies:

apt-get install beidgui beid-tools
=> libopenct1 libpcsclite1 libbeidlibopensc2 libbeid2 beid-tools beidgui libccid pcscd 
less /usr/share/doc/libbeidlibopensc2/README.Debian

The GUI application works well, including OCSP communication, showing me that my eID certificates are revoked, excellent!

UPDATE: There is a version 2.6.0-3 available in unstable

apt-get install -t unstable beidgui beid-tools

Exploring

pkcs15-tool --dump
pkcs15-tool --read-certificate 02 > my_auth.crt
pkcs15-tool --read-certificate 03 > my_sign.crt
pkcs15-tool --read-certificate 04 > belgium.crt
pkcs15-tool --read-certificate 06 >> belgium.crt
openssl x509 -in my_auth.crt -text
pkcs15-tool --read-ssh-key 2
# For a little demo...
beid-pkcs11-tool --slot 0 --login --test

Firefox security module

To add the security module to Firefox:

apt-get install libbeid2-dev libbeidlibopensc2-dev

Visit file:///usr/share/beid/beid-pkcs11-register.html to install the service

Now what?...
cf http://eid.belgium.be/fr_BE/fed_ict/imported_content_eid/pdf/eID-FR-Firefox.pdf
You can see your certificate in Preferences -> Advanced -> Encryption -> View Certificates and you can trust the Belgium Root CA under the "Authorities" tab for e.g. "identifying mail users"

If I try to connect to federal sites like Tax-on-web, being identified by my card, I get an error -12222 even before I'm prompted to type my PIN, is it because my certificates are revoked?

Error establishing an encrypted connection to... Error Code: -12222.

Thunderbird security module

To add the security module to Firefox:

apt-get install libbeid2-dev libbeidlibopensc2-dev

Menu preferences->advanced->certificates->security devices->load

Module name: Belgium Identity Card PKCS#11
Module filename: /usr/lib/libbeidpkcs11.so

You can see your certificate in Preferences -> Advanced -> Encryption -> View Certificates and you can trust the Belgium Root CA under the "Authorities" tab for e.g. "identifying mail users"

Try to sign a first mail:
Menu S-MIME -> Digitally sign this message -> setup certificate -> digital signing -> select your BELPIC auth certif

I could successfully sign (with my PIN) and verify an email but only with the Authentication certificate, not the Signature certificate
According to the snapshots of the official guide of the eID for Outlook, it's ok, the Authentication certificate must be used.

Signing text with pkcs15-crypt

From https://securehomes.esat.kuleuven.be/~decockd/wiki/bin/view.cgi/Main/UsingOpenscTOC#using_opensc_smartcards_to_sign

Signing text and extracting the public certificate:

fortune > data.txt
openssl sha1 -binary data.txt > data.sha1
pkcs15-crypt --key 2 --sign --pkcs1 --sha-1 --input data.sha1 --output data.auth.sig
pkcs15-tool --read-certificate 02 > my_auth.crt

Verifying the signature:

openssl x509 -in my_auth.crt -pubkey -noout > my_auth.pem
openssl dgst -sha1 -verify my_auth.pem -signature data.auth.sig data.txt

I tried to do the same with the signature certificate instead of the authentication certificate but I get an error:

pkcs15-crypt --key 3 --sign --pkcs1 --sha-1 --input data.sha1 --output data.auth.sig
[pkcs15-crypt] sec.c:67:sc_set_security_env: returning with: Not supported
[pkcs15-crypt] pkcs15-sec.c:267:sc_pkcs15_compute_signature: sc_set_security_env() failed: Not supported
Compute signature failed: Not supported

GpgSM

GpgSM is to X.509 what GnuPG is to OpenPGP, cf http://gnupg.org/aegypten/tech.en.html

apt-get install gpgsm dirmngr gnupg-agent pinentry-qt
~/.gnupg/gpg-agent.conf:
no-grab
default-cache-ttl 1800
ignore-cache-for-signing
allow-mark-trusted
~/.bash_profile: (appending this stuff)
# preparing gpg-agent:
if test -f $HOME/.gpg-agent-info && kill -0 `cut -d: -f 2 $HOME/.gpg-agent-info` 2>/dev/null; then
  GPG_AGENT_INFO=`cat $HOME/.gpg-agent-info`
  export GPG_AGENT_INFO
else
  eval `gpg-agent --daemon`
  echo $GPG_AGENT_INFO >$HOME/.gpg-agent-info
fi
~/.gnupg/scdaemon.conf: (we disable internal CCID support as only libccid supports more or less my crappy reader)
disable-ccid
debug-level none
~/.gnupg/gpgsm.conf:
debug-level none

Acquiring the certificates:

$ gpgsm --learn-card

Actually I had to run it several times, the first time only the Belgium CA was extracted, then the Citizen CA and finally the 2 personal certificates. And the behavior is not really reproductible so you've to run it till you've the 4 certificates:

$ gpgsm --list-keys
/home/phil/.gnupg/pubring.kbx
-----------------------------
     Subject: /CN=Belgium Root CA/C=BE
[...] 
     Subject: /CN=Citizen CA/C=BE/SerialNumber=200507
[...] 
     Subject: /CN=Philippe Teuwen (Authentication)/C=BE/SerialNumber=...
[...] 
     Subject: /CN=Philippe Teuwen (Signature)/C=BE/SerialNumber=...

To sign sth:

$ gpgsm --sign mail.txt

Then I get prompted to trust Belgium CA and gpgsm fails "error creating signature: Certificat révoqué <GpgSM>", normal.
During trusting the Belgium CA, it created automatically a .gnupg/trustlist.txt with

# CN=Belgium Root CA,C=BE
DF:DF:AC:89:47:BD:F7:52:64:A9:23:3A:C1:0E:E3:D1:28:33:DA:CC S

Ok let's try again without the CRLs check:

$ gpgsm --disable-crl-checks --armor --sign --output mail.txt.smime mail.txt
[...]
gpgsm: signature created

I was prompted for my PIN during the process.

And trying to verify, with CRLs:

$ gpgsm --verify --output mail.txt mail.txt.smime
gpgsm: Signature made 2008-02-06 21:42:40 using certificate ID 0x80211056
gpgsm: note: non-critical certificate policy not allowed
dirmngr[8994]: error opening `/home/phil/.gnupg/dirmngr_ldapservers.conf': Aucun fichier ou répertoire de ce type
dirmngr[8994]: permanently loaded certificates: 0
dirmngr[8994]:     runtime cached certificates: 0
dirmngr[8994]: command ISVALID failed: Certificat révoqué
gpgsm: certificate #100000000000E144CBC42E9BB2453EE4/2.5.4.5=#323030353037,CN=Citizen CA,C=BE
gpgsm: certificate has been revoked
gpgsm: invalid certification chain: Certificat révoqué

And without CRLs:

$ gpgsm --disable-crl-checks --verify --output mail.txt mail.txt.smime          
gpgsm: Signature made 2008-02-06 21:42:40 using certificate ID 0x80211056
gpgsm: CRLs not checked due to --disable-crl-checks option
gpgsm: Good signature from "/CN=Philippe Teuwen (Authentication)/C=BE/SerialNumber=...

SSH

Inspired from http://simi.be/?page_id=9

Getting the patch from http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=355274 and porting it to v4.7p1
Some rejs easy to solve from v4.2 to v4.7 and one less obvious change in debian/control: fix the debconf dependancies (was ${debconf:Depends} I think):

Package: openssh-client-sc                                                          
Architecture: any                                                                   
Depends: ${shlibs:Depends}, debconf (>= 1.2.0) | debconf-2.0,...


I recompile ssh with smartcard support.

apt-get source openssh-client
cd openssh-4.7p1
patch -p1 < ../mypatch
dpkg-buildpackage -uc -us -rfakeroot

Sending my public key to the ssh server:

pkcs15-tool --read-ssh-key 2 |tail -n1|ssh user@host 'cat - >> ~/.ssh/authorized_keys'

Then logging, being prompted for my PIN:

ssh -I 0 user@host.com

TODO: SSL Auth

http://blog.eikke.com/index.php/ikke/2007/10/29/using_your_belgian_eid_for_ssl_authentic

apt-get install libengine-pkcs11-openssl

To generate a request, open a console and launch openssh. Once at the OpenSSL prompt, issue these 2 commands:

engine -t dynamic -pre SO_PATH:/usr/lib/engines/engine_pkcs11.so -pre ID:pkcs11 -pre LIST_ADD:1 -pre LOAD -pre MODULE_PATH:/usr/lib/opensc-pkcs11.so

Adjust paths if necessary, of course. This loads the pkcs11 engine inside OpenSSL.

req -engine pkcs11 -new -days 100 -key id_02 -keyform engine -out myrequest.csr -subj "/C=BE/ST=O-VL/O=My Organisation/CN=My Name/emailAddress=my@email.tld"

Adjust the days, out and subj parameters, at least. The key ID can be found using

pkcs15-tool -c

Use the ID of the Authentication X509 certificate.


TODO: OpenVPN Auth

http://christophe.vandeplas.com/2008/02/03/openvpn-belgian-eid
But Debian openvpn 2.1_cr4 doesn't support yet --show-pkcs11-ids

TODO: Login

I tried https://securehomes.esat.kuleuven.be/~decockd/wiki/bin/view.cgi/Main/UsingOpenscTOC#logging_in_with_smartcards but with the eID.

apt-get install libpam-p11

See file:///usr/share/doc/libpam-p11/QuickStart.html
Bad side: it conflicts with xlockmore :-(

openssh way:
Preparing the account with .ssh/authorized_keys, cf SSH auth on this page
Edit /etc/pam.d/login and add before "@include common-auth" sth like:

auth sufficient pam_p11_openssh.so /usr/lib/opensc-pkcs11.so

/var/log/auth.log tells: no certificates found or

auth sufficient pam_p11_openssh.so /usr/lib/libbeidpkcs11.so

/var/log/auth.log tells: fatal: pkcs11_sign failed
before I was even prompted for my PIN

opensc way: same results

auth sufficient pam_p11_opensc.so /usr/lib/opensc-pkcs11.so
auth sufficient pam_p11_opensc.so /usr/lib/libbeidpkcs11.so

preparing the account:

mkdir ~/.eid
chmod 0755 ~/.eid
pkcs15-tool -r 2 > ~/.eid/authorized_certificates
chmod 0644 ~/.eid/authorized_certificates

So I still couldn't find a way.

TODO: Apache SSL Reverse Proxy

cf http://www.belgium.be/zip/eid_authentication_proxy_fr.html

TODO: OpenGPG & x509

Old dream is to sign an OpenPGP key with the eID, but even if technically possible, it probably breaks the validation chain as what Citizen CA signed was the entire certificate, not just the key/uid.
Sth to check: OpenPGP Signatures Incorporating X.509 Certificates

TODO: e-Signing plugin for Firefox

cf http://www.certipost.be/dpsolutions/en/e-signing-faq.html