Work with jCardSim through PC/SC virtual reader

Tags: pcsc, smart-card reader, jcardsim, javacard, pc/sc, Java Card

Recently we have added a quite useful functionality to jCardSim that allow you to work with jCardSim through virtual PC/SC-reader on Windows 7. It also should work on Windows XP but do not tested.

Installing BixVReader UMDF driver

  • Download BixVReader - http://www.codeproject.com/Articles/134010/An-UMDF-Driver-for-a-Virtual-Smart-Card-Reader
  • In order to install BixVReader you need DevCon from WDK. Unfortunately, it can not be distributed separately, but WDK 8 is available for free download here: http://go.microsoft.com/fwlink/p/?LinkID=324284. Download it and install.
  • Depending on your OS architecture copy devcon.exe either from C:\Program Files\Windows Kits\8.0\Tools\x86\ or C:\Program Files\Windows Kits\8.0\Tools\x64\ to the directory that contains extracted BixVReader’s distribution: Win7_x86 or Win7_x64 respectively.
  • Also WUDFUpdate_* files from C:\Program Files\Windows Kits\8.0\Redist\wdf\x86 or C:\Program Files\Windows Kits\8.0\Redist\wdf\x64 should be copied to the directory that contains extracted BixVReader’s distribution: Win7_x86 or Win7_x64 respectively.
  • Open command line with Administrator privileges and change directory to one that contains extracted BixVReader.
  • Execute the command devcon install BixVReader.inf root\BixVirtualReader and confirm installation of unsigned drivers (we believe we can get in touch with the BixVReader's creator Fabio Ottavi and, if he will like it, gift him a certificate to sign the driver).

Configuring jCardSim

Download the new build of desired jCardSim's version: 2.2.1 or 2.2.2.

jCardSim uses named pipes (IPC) to communicate with BixVReader: data communication is through the \\.\\pipe\\SCardSimulatorDriver<CardReaderID> and the \\.\\pipe\\SCardSimulatorDriverEvents<CardReaderID> is used for card state messages.

Launch jCardSim with the command:

java -cp jcardsim-2.2.1-all.jar com.licel.jcardsim.remote.BixVReaderCard jcardsim.cfg

or

java -cp jcardsim-2.2.2-all.jar com.licel.jcardsim.remote.BixVReaderCard jcardsim.cfg

depending on which version you are using.

Installed applets are to be listed in jcardsim.cfg (see the format here), also do not forget to add the necessary classpath of your applets, for example:

java -cp <custom_dir>;jcardsim-2.2.1-all.jar ...

Trying to communicate with jCardSim via PC/SC
Now you can use PC/SC interface in order to communicate with jCardSim, let's see how the HelloWorld Applets’s GPShell script works, for example:

establish_context
enable_trace
enable_timer
card_connect
send_apdu -sc 0 -APDU 80b800001009010203040506070809050000020F0F7f
send_apdu -sc 0 -APDU 00a400000901020304050607080902
send_apdu -sc 0 -APDU 0102000000
card_disconnect
release_context

Result:

establish_context
enable_trace
enable_timer
card_connect
command time: 0 ms
send_apdu -sc 0 -APDU 80b800001009010203040506070809050000020F0F7f
Command --> 80B800001009010203040506070809050000020F0F7F
Wrapped command --> 80B800001009010203040506070809050000020F0F7F
Response <-- 0102030405060708099000
send_APDU() returns 0x80209000 (9000: Success. No error.)
command time: 0 ms
send_apdu -sc 0 -APDU 00a400000901020304050607080902
Command --> 00A400000901020304050607080902
Wrapped command --> 00A400000901020304050607080902
Response <-- 9000
send_APDU() returns 0x80209000 (9000: Success. No error.)
command time: 0 ms
send_apdu -sc 0 -APDU 0102000000
Command --> 0102000000
Wrapped command --> 0102000000
Response <-- 9000
send_APDU() returns 0x80209000 (9000: Success. No error.)
command time: 10 ms
card_disconnect
command time: 0 ms
release_context
command time: 0 ms

Conclusion
Ok, what it is usefull for? It is simple, you can use this jCardSim functionally in order to transparently test operability of your Java Card applet that interracts with a native application, for example.