- Program a blank Gelmalto PIV card ( Protiva PIV CARD v1.55 DL) so that it contains a certificate, using the RSA keypair generated by the card
- Have Linux wpa_supplicant use the certificate in the card to perform EAP-TLS authentication
Approach 1: Use the NIST PIV card test software
- Download the software from: http://csrc.nist.gov/groups/SNS/piv/download.html
- You need both the “SP 800-73 Reference Implementation” and the “PIV Data Generator and PIV Data Loader”
- Get Java JRE if you don’t have
- unzip both of them to a folder, in my case c:\tools\pivcard
- Open a “Cmd” windows as Administrator,
- cd \tools\pivcard\PIV Middleware\Binaries
- copy c:\windows\system32\piv.dll ..\..\ PIV_Test_Data_Software\Binaries
- Now you can run the program PIV_Test_Data_Software\Binaries\ PIV Data Loader.exe to write to the card; and use the program JPIV Test Data Generator.jar to generate the data
- To piv data loader needs the data from the data generator. Some data generator tips:
- Goto “Crypto Provider”, and point it to your root keystore. If you don’t have one, you can use “keystore explorer” software (open source) to create one, and then create a key-pair, and make it a self-signed root CA. (use standard JKS format).
- The CA Alias is your CA’s name
- The content signer’s alias can be the same as your CA’s alias.
- Now put something random in fields of tab CHUID. GUID has to be 16 chars
- Under “Certificates tab”, pick “piv auth cert”, “valid from” and “valid to” is in the format of “YYYYMMDDHHMMSS”.
- Choose “get public key from file”. This file should be generated by the piv loader program, under “asymmetric key pair”.
- Now hit generate, and check console there is no error, and then “Save”
- The saved certificate format is weird. It adds a header and footer around the standard “DER” format.
- It adds 0x “30 82 LEN1 LEN2” as header. 0x30 in DER format means “sequence of”. “82 LEN1 LEN2” is the “long form” of the “definite form” encoding of the length. For “Signature Certificate”, the header is “70 82”.
- It also adds a footer of 5 bytes “71 01 00 fe 00”, means “application” tag, “set or set of”, length of 1, content of 00. Then another tag “fe”, meaning “private tag” of 0 byte.
- If you want to generate your own certificate instead of using the data generator, I suppose you could generate a DER format certificate, and then wrapper it with header and footer above, then burn to the card using the data loader application. I have not tried this yet.
Approach 2: Use piv-tool inside opensc-tools (piv-tool itself did not work well for me)
- Use opensc-tools 0.12.2 or newer
- To read the certificate of the card, use:
- pkcs11-tool --module=/usr/lib/i386-linux-gnu/opensc-pkcs11.so -r -y cert -a "Certificate for PIV Authentication" > mycert.der (using label to read)
- OR, pkcs11-tool --module=/usr/lib/i386-linux-gnu/opensc-pkcs11.so -r -y cert -d 01 -o my.cert (using id to read)
- To list all the data objects, use: pkcs11-tool --module=/usr/lib/i386-linux-gnu/opensc-pkcs11.so –O
# OpenSSL Engine support
# These options can be used to load OpenSSL engines.
# The two engines that are supported currently are shown below:
# They are both from the opensc project (http://www.opensc.org/)
# By default no engines are loaded.
# make the opensc engine available
# make the pkcs11 engine available
# configure the path to the pkcs11 module required by the pkcs11 engine
It seems that engine_opensc is the old version. The current version should be pkcs11_engine. Opensc-pkcs11.so is the PKCS11 library to access the smartcard.
OpenSC installation under GNU|Linux
- Communication with smartcard reader is managed by pcsc + libccid.
- Smartcard drivers and PKCS#11 library is managed by opensc
installing pcsc + libccid + openscModern smartcard readers are CCID compliant. GNU/Linux can only handle CCID readers. It is recommended to use libccid >= 1.4.5.
$ apt-get install pcscd libccid libpcsclite1 opensc
Some important files:
/usr/lib/i386-linux-gnu/libopensc.so.3, which uses
/usr/lib/i386-linux-gnu/libpcsclite.so.1.0.0Make sure to add your own user to the pcscd group:
$ adduser foo pcscd