Smart Card Simulation
This guide uses jCardSim to simulate the following Open Source Java Card Applets:
The description can easily be adapted for other applets as well.
This section describes how to get the official version of jCardSim to work through a PC/SC virtual reader on Windows.
This needs to be done before all below described applet-specific steps.
-
Install virtual smart card reader: Either use the original source code and follow its manual or use the pre-built installer, BixVReaderInstaller.msi, from the Virtual Smart Card project.
-
Enable the Pipe Reader: Change
C:\Windows\BixVReader.ini
to something like this[Driver] NumReaders=1 [Reader0] RPC_TYPE=0 VENDOR_NAME=Fabio Ottavi VENDOR_IFD_TYPE=Pipe Reader DECIVE_UNIT=0
-
Reload the configuration: In the Device Manager, deactivate and activate the Bix Virtual Smart Card Reader to load the modification of
BixVReader.ini
. Alternatively, you can usedevcon.exe
from the Windows Driver Kit:devcon.exe disable root\BixVirtualReader devcon.exe enable root\BixVirtualReader
-
Download and Install Java (
java.exe
andjavac.exe
are required) -
Download jCardSim from their website
Now, configure jCardSim to load and run the applet to make it available via PC/SC (see sections below).
-
Download and build IsoApplet:
git clone https://github.com/philipWendland/IsoApplet javac -classpath jcardsim-3.0.4-SNAPSHOT.jar IsoApplet\src\net\pwendland\javacard\pki\isoapplet\*.java
-
Create
jcardsim_isoapplet.cfg
for IsoApplet:com.licel.jcardsim.card.applet.0.AID=F276A288BCFBA69D34F31001 com.licel.jcardsim.card.applet.0.Class=net.pwendland.javacard.pki.isoapplet.IsoApplet com.licel.jcardsim.card.ATR=3B80800101
-
Run jCardSim with IsoApplet package:
java -classpath jcardsim-3.0.4-SNAPSHOT.jar;IsoApplet\src com.licel.jcardsim.remote.BixVReaderCard jcardsim_isoapplet.cfg
-
Create IsoApplet from the install package:
opensc-tool --card-driver default --send-apdu 80b800001a0cf276a288bcfba69d34f310010cf276a288bcfba69d34f3100100
-
Download and build OpenPGP applet:
git clone https://github.com/Yubico/ykneo-openpgp javac -classpath jcardsim-3.0.4-SNAPSHOT.jar ykneo-openpgp\applet\src\openpgpcard\*.java
-
Create
jcardsim_openpgp.cfg
for OpenPGP applet:com.licel.jcardsim.card.applet.0.AID=D2760001240102000000000000010000 com.licel.jcardsim.card.applet.0.Class=openpgpcard.OpenPGPApplet com.licel.jcardsim.card.ATR=3B80800101
-
Run jCardSim with OpenPGP:
javac -classpath jcardsim-3.0.4-SNAPSHOT.jar;ykneo-openpgp\applet\src com.licel.jcardsim.remote.BixVReaderCard jcardsim_openpgp.cfg
-
Create OpenPGP applet from the install package:
opensc-tool --card-driver default --send-apdu 80b800002210D276000124010200000000000001000010D276000124010200000000000001000000
-
Download and build PivApplet:
git clone https://github.com/arekinath/PivApplet javac -classpath jcardsim-3.0.4-SNAPSHOT.jar PivApplet\src\net\cooperi\pivapplet\*.java
-
Create
jcardsim_piv.cfg
for OpenPGP applet:com.licel.jcardsim.card.applet.0.AID=A000000308000010000100 com.licel.jcardsim.card.applet.0.Class=net.cooperi.pivapplet.PivApplet com.licel.jcardsim.card.ATR=3B80800101
-
Run jCardSim with PivApplet:
javac -classpath jcardsim-3.0.4-SNAPSHOT.jar;PivApplet\src com.licel.jcardsim.remote.BixVReaderCard jcardsim_piv.cfg
-
Create PIV applet from the install package:
opensc-tool --card-driver default --send-apdu 80b80000120ba000000308000010000100050000020F0F7f
-
Download and build GidsApplet:
git clone https://github.com/vletoux/GidsApplet javac -classpath jcardsim-3.0.4-SNAPSHOT.jar GidsApplet\src\com\mysmartlogon\gidsApplet\*.java
-
Create
jcardsim_gids.cfg
for GIDS applet:com.licel.jcardsim.card.applet.0.AID=A000000397425446590201 com.licel.jcardsim.card.applet.0.Class=com.mysmartlogon.gidsApplet.GidsApplet com.licel.jcardsim.card.ATR=3B80800101
-
Run jCardSim with GidsApplet:
javac -classpath jcardsim-3.0.4-SNAPSHOT.jar;GidsApplet\src com.licel.jcardsim.remote.BixVReaderCard jcardsim_gids.cfg
-
Create GIDS applet from the install package:
opensc-tool --card-driver default --send-apdu 80b80000190bA0000003974254465902010bA00000039742544659020100
On Linux, jCardSim needs to be compiled with support for a different virtual reader backend (vpcd)
This needs to be done before all below described applet-specific steps.
-
Download and build the virtual smart card and its reader driver
git clone https://github.com/frankmorgner/vsmartcard.git cd vsmartcard/virtualsmartcard autoreconf -vis && ./configure && sudo make install
-
Restart
pcscd
to load the new reader driver. On Debian based systems, you could do the following:sudo /etc/init.d/pcscd restart;
-
Download the adapted version of jCardSim
git clone https://github.com/arekinath/jcardsim.git
-
Fetch Java Card Classic Development Kit
git clone https://github.com/martinpaljak/oracle_javacard_sdks.git export JC_CLASSIC_HOME=$PWD/oracle_javacard_sdks/jc305u3_kit
-
Build
jcardsim-3.0.5-SNAPSHOT.jar
as described here:git clone https://github.com/arekinath/jcardsim.git cd jcardsim mvn initialize && mvn clean install
For actually simulating the Applets, the steps are almost identical as described in the sections for Windows above (IsoApplet, OpenPGP, PIV, GIDS) with the following modifications:
-
Make sure to use to use
jcardsim-3.0.5-SNAPSHOT.jar
built for vpcd -
Add the following lines to your jCardSim configuration file (
jcardsim_*.cfg
):com.licel.jcardsim.vsmartcard.host=localhost com.licel.jcardsim.vsmartcard.port=35963
-
When running jcardsim, use
VSmartCard
, e.g.java -classpath 'jcardsim-3.0.5-SNAPSHOT.jar:IsoApplet/src' com.licel.jcardsim.remote.VSmartCard jcardsim_isoapplet.cfg
Warning: Due to attempts to plant malicious links to our wiki, it is no longer open to anyone to edit. If you want to contribute to this, wiki, please open a pull request here: https://github.com/OpenSC/Wiki.