CRM & Cloud

Issues I faced in CRM & Cloud solutions

Showing posts with label Java Card. Show all posts
Showing posts with label Java Card. Show all posts
I have written a Java Card (Javacard) shell by which you can communicate with a real javacard compliance smart card. This tool is opensource and can be downloaded from github.

I named it as "GPCShell", global platform shell. By using this shell following can be performed:


  • APDUs can be sent and received
  • Status command can be send and received
  • It is complaint to Global Platform and ISO7816-4
  • It can be used to upload .cap files to a real javacard
The project is compiled via Netbeans and can be downloaded and extended.

A demo is presented here:


The tool works as follows:
  • Card is using a XML file for the Card Manager Id and security keys
  • It reads Card Manager Id from the XML and connects to the card
  • Security keys can be updated by providing SH1 256 byte keys in the XML
  • The tool uses provided security keys in the XML to authenticate the Card using SCP01 and SCP02
The structure of the XML file is as below:



ava(smart) Card is considered as future technology. They are getting fame and being used in many secure applications. In many countries like Estonia smart cards are mandatory to have for each citizen. They are being used as a secure transection medium.
Some of the formal definations of the java card are below:
Java Card refers to a technology that allows Java-dd applications (applets) to be run securely on smart cards and similar small memory footprint devices. Java Card is the tiniest of Java targeted for embedded devices. Java Card gives the user ability to program the device and make them application specific
Oracle say that:
Java Card technology provides a secure environment for applications that run on smart cards and other devices with very limited memory and processing capabilities. Multiple applications can be deployed on a single card, and new ones can be added to it even after it has been issued to the end-user. Applications written in the Java programming language can be executed securely on cards from different vendors
Also some site has the definition that:
Java Card is an open standard from Sun Microsystems for a smart card development platform. Smart cards created using the Java Card platform have Java applets stored on them. The applets can be added to or changed after the card is issued.
All above descriptions and definitions of java cards are correct and have meanings. But if we want to summarize them all then we can say that:
A Java Card is a smart card (having a chip) which can be programmed in java programming language using special application programming interface and is obeying set of rules and standards
.
To demonstrate how to write a Java Card basic applet and how to execute it, In the video blow I have wirtten a java card applet, just an example. In this example, Java Card Counter, Java card applet will initialize a variable with '0' and will start incrementing its value upto '4' on each APDU. It is a basic example, and I hope, it will help people who are just beginners in the Java Card field ...




Please write down comment and feel free to ask if you can't understand anything.
Before showing you and explaining how to write a Hello World applet for the java card, I would like to discuss how to set the development envirement for the java card applets.
Fortunately, Oracle has provided all the necessary tools, libraries and set of APIs for the development of the Java Card applets. Go to the Oracle offical website and download java card sdk version 2.2.1.
Note: Please don’t go for java card 3.0 as there is no real java card available for prgramming and there is not use to learn if you don’t have a real time envirement to deploy or test it. For further information click here
When you will download the development kit, you will will find that it also have complete java card specs and API documentation alongwith programemrs note. Mainly following tools are very helpful for development of java card apps:
  • Java Card Converter
  • scriptgen
  • Off-card Tool
  • exp2text tool
  • Off-card verifier
  • capdump
  • Installer
A brief description of all of the above mentioned tools are given below:
  • Java Card Converter
  • The converter tool is a very important tool. This tool tool’s duty is to convert your java source files thats .class files to .cap file. CAP file is a Converted Applet File, and this is the actual file which you load and install on the java card. You can’t directly upload your source files(.class files) onto the card.
    For more information click here
  • scriptgen
  • This tool simple converts your CAP file into a sequence of APDUs which can be send to java card for installation of that particular CAP file.
    For more information click here
  • Off-card Tool
  • The off-card verifier is a combination of three tools, verifycap, verifyexp, and verifyrev.
    For more information click here
  • exp2text tool
  • The exp2text tool is provided to allow you to view any export file in text format or human readable formate.
    For more information click here
  • capdump
  • This tool is similar as exp2text tool. For viewing cap files in the ascii format you will use this tool on the command prompt.
    For more information click here
  • Installer
    The development kit installer can be used to:
  • Dynamically download a Java Card technology package to a Java Card technology-compliant smart card. During development, the CAP file can be installed in the C-language Java Card RE rather than on a Java Card technology-compliant smart card. The installer is capable of downloading version 2.1, 2.2, 2.2.1, and 2.2.2 Java Card technology based CAP files (“Java Card CAP files”).
  • Perform necessary on-card linking.
  • Delete applets and packages from a Java Card technology-compliant smart card. Once the installer is selected, requests for deletion can be sent from the terminal to the Java Card technology-compliant smart card in the form of APDU commands. For more information, see Deleting Packages and Applets.
  • Setting default applets on different logical channels.
  • The installer is not a multiselectable application. On startup, the installer is the default applet on logical channel 0. The default applet on the other logical channels is set to No applet selected.
To set up java card development environment you will need all the tools which I have mentioned in my previous post. To set up all these tools there is a very fine link/book which explains each and everything very clearly. In this blog I will focus on the development/programming and will try to use already provided resources and documentation as there is no use to re-invent the wheel. Please Click here to learn how to set up the development environment for java card.
Another very informative link which will help you for setting your development environment. In this link everything is explain via images and screen shots.
Moreover, the above mentioned link will show you how to set up envirement with JCWD which is a tedious way for settting things up. As a beginner you will find a lot of troubles and problem during settings. To get rid of this mess you should go for JCOP Tools. JCOP is an eclipse plugin which is used for development of java card applets. In this blog my posts will using this tool.
There are many reason that I have recommend this tool, for of all it is very easy to integerate with eclipse. You can watch the video below to see how:
The other few advanges of using JCOP are as below:
  • Easy to use and write your code
  • Automatically converts your source code to cap file
  • Global Platform Compliant
  • Off card simulator
  • Debugging facility
  • Allow to install/delete cap files from card
A brief document of using JCOP is here