Offcard apis

I am currently looking at the JCOP tools plugin for eclipse. I have the plugin and it's registered. I have created a very simple applet which allows me to send and receive information. It works fine using the simulator provided. I now wish to write a an application which communicates with the applet using APDUs. As I understand I should be able to use classes within com.ibm.jc to communicate with the emulator and/or a card reader. I can't however find the offcard apis (com.ibm.jc). The libraries were not included in the zip file which I downloaded from here http://download.boulder.ibm.com/ibmdl/pub/software/dw/jcop/tools.zip.
This may seem a silly question, but where do I get the offcard libraries from?

You can find the JAR file: \plugins\com.ibm.bluez.jcop.eclipse_3.1.1.b\lib\offcard.jar and the API doc in Eclipse under Help, Help Contents, JCOP Tools User Guide.

Similar Messages

  • Find reader through Offcard API

    Hi friends,
    System.out.println("Search readers..... ");
    Context context = new Context();
    context.EstablishContext(PCSC.SCOPE_GLOBAL, null, null);
    String[] readers = context.ListReaders();
    if (readers.length <= 0) {
         System.err.println("No readers found...");
         return;
    System.out.println("Current using reader..... ");
    System.out.println(readers[0]);
    Card card = context.Connect(readers[0]);In IBM offcard API, is there any code like this for checking current reader name...because i couldnt find out my reder name... my reader is "Gemplus USB Smart Card Reader o"... can any body help me....

    Ask in the Reader forum. However, the process should be a property of the print driver for your printer, not Reader.

  • Native OffCard API's

    Hello everyone.
    From topics posted int his forum I found out that there is ability to write OffCard-side application for working with JCOP card not inly Java, but also in C/ C++?I am right?
    What are the native languages and interfaces/classes, that I can use to program host-side application for sending APDU's to my Applet installed on JCOP card?
    Where can i find more info about that?
    It would be very nice,
    if you could tell me more about such OffCard solutions.
    Bes regards,
    Eve

    To make it more clear,
    I decided to explain, why I am so interested in alternative offCard solutions.
    See, I have already developed an Java Card Applet.
    I implemented Java OffCard API program, that enables to call to the Applet functions, installed on card.
    But I also have a project, written in C++. So, I need to write some C functions, that just would send several APDU's to my implemented applet on-card.
    I suppose, that communicating to the card is something quite similar to communication through sockets, just sending predefined APDU array. (simulation works just like that). So I think there must be some possibility in C/C++/.Net to send APDU's to the pcsc reader to use my applet. But there is no documentation to jct.dll that is used.
    I hadn't been able to find more concrete information in the Internet.
    Could you help me?
    Best regards,
    Eve

  • How to download the cap file to the smartcard with my own program

    good morning | afternoon | evening my friends,
    I can download applet with JCop now, but I have to do it with my program,can someone tell me how to do it,especially the steps.
    Allen,

    In case you are using JCOP tools plug-in in Eclipse, choose: Help -> Help Contents->JCOP tools user guide -> Reference -> Offcard API's. There you will find all the java API's necessary for wrtiting java program, that enables to upload, install applet, get info about the card and work with your proper applet installed.
    If you look through the older post, you'll also find several samples of off-card java terminal program code.
    P.S. Another choice would be java 6 smart card I/O.
    Some of us still trying to use OCF technologies. But i advice you not to use it, because this technology is dead.
    Best regards,
    Eve

  • JCOP tools on 64-bit platform

    Hello.
    Is there any way to find jct.dll, jcpcsc.dll (those are in the jcop plug-in os/ directory) analogues for 64-bit platform?
    As i know, jcop tools provides only dll's and so libraries for 32-bit platforms to communicate with the card? Are there any 64-bit compatible?
    I want to use Offcard API from JCOP tools on 64-bit platform (it uses mentioned above dlls or shared objects on Linux).
    Best regards,
    eveline-z

    eveline-z wrote:
    Thanks for your reply.
    So, Eclipse IDE with JCOP plug-in work fine on 64-bit platform without any emulation?Yes
    I mean, you had no problems with connecting to a real card through the JCShell or even using JCOP Offcard API (because those are using native dll's for 32-bit platform which reside in com.ibm.bluez.jcop.eclipse_3.1.2\os\win32\x86\ directory)?I tested only on the simulator
    The "com.ibm.bluez.jcop.eclipse_3.1.2\os\win32\x86\" directory is in the folder plugins in your eclipse path.
    example : c:\eclipse\plugins\com.ibm.bluez.jcop.eclipse_3.1.2\os\win32\x86\
    >
    >
    Thanks.
    Best regards,
    eveline-zMaDmEd

  • Wrong CAP file version error message

    I'm trying to write a loader application that will send a CAP file into JavaCard, and then install it automatically.
    I have developed my JavaCard Applet by using Eclipse3.1.0 and JCOP30.
    After running my JavaCard Applet by Eclipse, I got its CAP file in folder [b\bin\FVSCardPkg\javacard\[/b]
    But when I run my loader application with this CAP file, the error message will display:
    EX: msg Wrong CAP file version, class class com.ibm.jc.JCException
    Wrong CAP file version
         at com.ibm.jc.CapFile.parseHeader(Unknown Source)
         at com.ibm.jc.CapFile.readCapFile(Unknown Source)
         at com.ibm.jc.CapFile.<init>(Unknown Source)
         at LoaderPkg.loader.load(loader.java:35)
         at LoaderPkg.loader.main(loader.java:20)
    This is my loader application source code:
    import java.io.*;
    import com.ibm.jc.*;
    import com.ibm.jc.terminal.*;
    *  Sample /**
    *  Sample loader. Demonstrates how to use the offcard API to download
    *  a cap-file on a JCOP41V22 Engineering sample card and listing of applets loaded will
    * follow.
    public class loader{
         private final static String termName = "pcsc:4"; // Real card
    //     private final static String termName = "Remote"; // Simulator
         protected static final byte[] JCOP_CARD_MANAGER_AID = { (byte) 0xa0, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00};
         protected static final byte defaultInstallParam[] = { -55, 0 };
         static String[] capFileName={"D:/MyCardPkg.cap"};
         public static void main(String[] args){
              try{
                   loader l = new loader();
                   l.load();
              }catch(Exception e){
                   System.err.println("EX: msg " + e.getMessage() + ", class " + e.getClass());
                   e.printStackTrace(System.err);
              System.exit(0);
              //Likewise for simulation, be patient the port takes time to close.
              //Use command line "netstate" to check the disapperance of the port before
              // activating JCShell command to read the simulated card.
         private loader(){}
         private void load() throws Exception{
              CapFile capFile = new CapFile(capFileName[0], null);
              System.out.println("Package name: " + capFile.pkg);
              byte[][] applets = capFile.aids;
              if ((applets == null) || (applets.length == 0)){
                   throw new RuntimeException("no applets in cap file");
              // Get connection to terminal, take note that jcop.exe is required to be activated
              // in simulation mode.
              System.out.println("Open terminal ...");
              //Make sure that the simulator jcop.exe is activated before unmarking this satement
              //Remember to delete the downloaded applet before running otherwise error is
              //expected if the simulator finds the existence of the applet with the
              //same pakage name ID and AID
              //Issue /close command at "cm" prompt if the card is in use,, ie it should
              //have "-" prompt. Be patient that the port takes time to close. Use command line
              //"netstate" to check the disapperance of the port before running.
              // pcsc:4=Card Terminal  Or  Remote=LocalHost Terminal
              JCTerminal term = JCTerminal.getInstance(termName, null);
              //For real JCOP41V22 card, please unmark this statement and delete the downloaded
              //applet before running. Error expected if the card finds the existence of the applet
              //with the same pakage name ID and AID
              //Issue /close command at "cm" prompt if the card is in use,, ie it should
              //have "-" prompt.
              term.open();
              // Add in this statement for real card which requires some response time
              term.waitForCard(5000);
              // Create a logging terminal spitting out the APDUs on standard out
              TraceJCTerminal _term = new TraceJCTerminal();
              _term.setLog(new PrintWriter(System.out));
              _term.init(term);
              term = _term;
              // Get JavaCard representative, passing NULL resets card and returns ATR
              System.out.println("Get card ...");
              JCard card = new JCard(term, null, 2000);
              // Get the off-card representative for the card manager and use it to
              // select the on-card CardManager
              System.out.println("Select card manager ...");
              CardManager cardManager = new CardManager(card, CardManager.daid);
              cardManager.select();
              // For downloading something, we have to be authenticated to card manager.
              // For this, the keys must be set. The keys to use should of course
              // be configurable as well.
              byte[] dfltKey = c2b("404142434445464748494a4b4c4d4e4f");
              cardManager.setKey(new OPKey(255, 1, OPKey.DES_ECB, dfltKey));
              cardManager.setKey(new OPKey(255, 2, OPKey.DES_ECB, dfltKey));
              cardManager.setKey(new OPKey(255, 3, OPKey.DES_ECB, dfltKey));
              cardManager.setKey(new OPKey(1, 1, OPKey.DES_ECB, c2b("707172737475767778797a7b7c7d7e7f")));
              cardManager.setKey(new OPKey(1, 2, OPKey.DES_ECB, c2b("606162636465666768696a6b6c6d6e6f")));
              cardManager.setKey(new OPKey(1, 3, OPKey.DES_ECB, c2b("505152535455565758595a5b5c5d5e5f")));
              System.out.println("init Update ...");
              cardManager.initializeUpdate(255,0);
              System.out.println("Authenticate to card manager ...");
              cardManager.externalAuthenticate(OPApplet.APDU_CLR);
              // And load the cap-file, do not forget to call installForLoad
              System.out.println("Loading cap-file ...");
              byte[] cardManagerAid = cardManager.getAID();
              cardManager.installForLoad(capFile.pkgId,0, capFile.pkgId.length, cardManagerAid, 0, cardManagerAid.length, null, 0, null, 0, 0, null, 0);
              cardManager.load(capFile, null, CardManager.LOAD_ALL, null, cardManager.getMaxBlockLen());
              byte[] capaid = capFile.aids[0];
              System.out.println("Finished loading !");
              // Install applet, we try to install the first applet given in the
              // cap file, and try to instantiate it under the same AID as given for its
              // representation in the cap file. No installation data is passed.
              System.out.println("Installing applet ...");
              cardManager.installForInstallAndMakeSelectable(capFile.pkgId, 0, capFile.pkgId.length, capaid,0, capaid.length, capaid, 0, capaid.length, 0, defaultInstallParam, 0, defaultInstallParam.length, null, 0);
              System.out.println("Install succeeded!");
              // synchronize state with on-card card manager
              System.out.println("Update!");
              cardManager.update();
              // Print information regarding card manager, applets and packages on-card
              JCInfo info = JCInfo.INFO;
              System.out.println("\nCardManager AID : " + JCInfo.dataToString(cardManager.getAID()));
              System.out.println("CardManager state : " + info.toString("card.status", (byte) cardManager.getState()) + "\n");
              //Echountered error 6A 86 with this statement:Object[] app = cardManager.getApplets(CardManager.GET_APPLETS,
              //CardManager.CVM_FORMAT_HEX, true);
              //Solved the bug by playing the integers in arg0 and arg1.
              Object[] app = cardManager.getApplets(1, true);
              if (app == null) {
                   System.out.println("No applets installed on-card");
              } else {
                   System.out.println("Applets:");
                   for (int i = 0; i < app.length; i++) {
                        System.out.println(info.toString("applet.status", (byte) ((OPApplet) app).getState()) + " " + JCInfo.dataToString(((OPApplet) app[i]).getAID()));
              // List packages on card
              // Encountered error with this statement:Object[] lf = cardManager.getLoadFiles(CardManager.CVM_FORMAT_HEX, true);
              // Solved the bug by setting arg0 = 0,
              Object[] lf = cardManager.getLoadFiles(true);
              if (lf == null) {
                   System.out.println("No packages installed on-card");
              } else {
                   System.out.println("Packages:");
                   for (int i = 0; i < lf.length; i++) {
                        System.out.println(info.toString("loadfile.status", (byte)((LoadFile) lf[i]).getState()) + " " + JCInfo.dataToString(((LoadFile) lf[i]).getAID()));
              term.close();
         static String numbers = "0123456789abcdef";
         private byte[] c2b(String s) {
              if (s == null) return null;
              if (s.length() % 2 != 0) throw new RuntimeException("invalid length");
              byte[] result = new byte[s.length() / 2];
              for (int i = 0; i < s.length(); i += 2) {
                   int i1 = numbers.indexOf(s.charAt(i));
                   if (i1 == -1) throw new RuntimeException("invalid number");
                   int i2 = numbers.indexOf(s.charAt(i + 1));
                   if (i2 == -1) throw new RuntimeException("invalid number");
                   result[i / 2] = (byte) ((i1 << 4) | i2);
              return result;
    How to solve this problem?
    Thank you in advance.

    I'm not understanding if your cap file is in "b\bin\FVSCardPkg\javacard\", then why are you loading "D:/MyCardPkg.cap"?
    The issue isn't with your off card application, but the cap file version. Look at the cap file components in JCVM specification. I believe it's the Header component. The major, minor should match your card but not greater. In other words, your can't load a 2.2 on a 2.1 card, but a 2.1 can load on a 2.2

  • OCF Vs pcsc

    Hi,
    I just want to check that I am on the right track with my understanding of host-side development.
    Both OCF and pcsc are standards for developing host-side software that can talk to smart card applets via readers and APDUs. OCF is java based and comes with a set of APIs to develop with.
    pcsc is a set of specifications, not a set of APIs and therefor you either write your own libraries to use for development or else you use someone elses e.g. SmartCard Subsembly, MUSCLE pc/sc toolkit or JCOP offcard API.
    I understand that there is much greater support for pcsc compliand card readers but there is also a lot more support out there for OCF development.
    I would like to write a host app that would run on my PC(Windows 2000) and am most familiar with Java and/or C# programming languages. My card applets are being developed using JCOP and my reader is pcsc compliant.
    Can anyone suggest what development tools and/or drviers I should use for my host app development?
    Thanks in advance,
    Ann

    Hi Ann,
    JPCSC is a JNI wrapper around the official PC/SC API. For pretty much every SCard* call in the original C API, there's a corresponding Java method. In other words, it's a bridge between Java and the native PC/SC library. On Windows this would be winscard.dll, on Linux PCSClite. PC/SC offers only basic functionality for smart card communications: Enumeration of readers, status change notifications, connect to cards, exchange APDUs.
    The JCOP offcard API is a bit more comprehensive, because it was designed specifically for use with OpenPlatform compliant smart cards. The interface to different readers is extensible, and already contains some implementations -- in particular one that uses JPCSC. However, the strength of the JCOP offcard API lies in the offcard implementation for GP functions such as card management, secure channels, etc.
    If you're only sending basic APDUs back and forth, (J)PCSC may be enough for you, but for anything more complex, you'll best use some middleware such as the JCOP offcard API.

  • Problem during loadgae of file

    Hello,
    I am trying to modify Loader.java sample to load simple HelloWorld applet to the
    JCOP simulator.
    During the execution the problem with call to the installForInstallAbdMakeSelectable aperas. The error code returned by he simulator is just 6a80 (Wrong data). I cant't find out what is the problem... Maybe anyone could help me?
    So here is the code of my program, that shoul load and install applet, also make it selectable:
    public class Loader
        private Loader(){}
        private void load(String capFileName) throws Exception
              CapFile capFile = new CapFile(capFileName, null);
              System.out.println("Package name: " + capFile.pkg);
              byte[][] applets = capFile.aids;
              if ((applets == null) || (applets.length == 0))
                  throw new RuntimeException("no applets in cap file");
              // Get connection to terminal, we look for the simulation.
              // As you might want to use "pcsc", "4" or "tcl", "10" in case of
              // Windows or "PCSC", null in case of Linux, you should pass the name
              // of the terminal on the command line or in a properties file
              System.out.println("Open terminal ...");
              JCTerminal term = JCTerminal.getInstance("Remote", null);
              term.open();
              // Create a logging terminal spitting out the APDUs on standard out
              TraceJCTerminal _term = new TraceJCTerminal();
              _term.setLog(new PrintWriter(System.out));
              _term.init(term);
              term = _term;
              // Get JavaCard representative, passing NULL resets card and returns ATR
              System.out.println("Get card ...");
              JCard card = new JCard(term, null, 2000);
              // Get the off-card representative for the card manager and use it to
              // select the on-card CardManager
              System.out.println("Select card manager ...");
              CardManager cardManager = new CardManager(card, CardManager.daid);
              cardManager.select();
              // For downloading something, we have to be authenticated to card manager.
              // For this, the keys must be set. The keys to use should of course
              // be configurable as well.
              byte[] dfltKey = c2b("404142434445464748494a4b4c4d4e4f");
              cardManager.setKey(new OPKey(255, 1, OPKey.DES_ECB, dfltKey));
              cardManager.setKey(new OPKey(255, 2, OPKey.DES_ECB, dfltKey));
              cardManager.setKey(new OPKey(255, 3, OPKey.DES_ECB, dfltKey));
              //cardManager.setKey(new OPKey(1, 1, OPKey.DES_ECB, c2b("707172737475767778797a7b7c7d7e7f")));
              //cardManager.setKey(new OPKey(1, 2, OPKey.DES_ECB, c2b("606162636465666768696a6b6c6d6e6f")));
              cardManager.setKey(new OPKey(1, 3, OPKey.DES_ECB, c2b("505152535455565758595a5b5c5d5e5f")));
              System.out.println("Authenticate to card manager ...");
              cardManager.initializeUpdate(255, 0, OPApplet.SCP_UNDEFINED);
              cardManager.externalAuthenticate(OPApplet.APDU_CLR);
              System.out.println("deleting applets");
              cardManager.deleteObject(capFile.pkgId, 0, capFile.pkgId.length, true);
              System.out.println("applets deleted");
              // And load the cap-file, do not forget to call installForLoad
              System.out.println("Loading cap-file ..."+capFile.pkg);
              cardManager.installForLoad(capFile.pkgId, 0, capFile.pkgId.length, null, 0, 0, null, 0, null, 0, 0, null, 0);
              cardManager.load(capFile, null, SecurityDomain.LOAD_ALL, new PrintWriter(System.out), 250);
              System.out.println("Finished loading !");
              // Install applet, we try to install the first applet given in the
              // cap file, and try to instantiate it under the same AID as given for its
              // representation in the cap file. No installation data is passed.
              System.out.println("Installing applet ...");
              cardManager.installForInstallAndMakeSelectable     //HERE EXCEPTION APPEARS
                        capFile.pkgId,
                        0,
                        capFile.pkgId.length,
                        applets[0],
                        0,
                        applets[0].length, /* applet */
                        applets[0],
                        0,
                        applets[0].length, /* instance aid */
                        OPApplet.NO_PRIVS,  /* no special priviledges */
                        null,
                        0,
                        0,   /* install data */
                        null,
                        0
              System.out.println("Install succeeded!");
              // synchronize state with on-card card manager
              cardManager.update();
              // Print information regarding card manager, applets and packages on-card
              JCInfo info = JCInfo.INFO;
              System.out.println("\nCardManager AID   :  " + info.dataToString(cardManager.getAID()));
              System.out.println("CardManager state :  " + info.toString("card.status", (byte) cardManager.getState()) + "\n");There is the reaply of the smulator:
    Open terminal ...
    Get card ...
    --Waiting for card...
    Select card manager ...
    ATR=3B FA 13 00 00 81 31 FE 45 4A 43 4F 50 34 31 56    ;.....1.EJCOP41V
        32 32 31 96                                        221.
    => 00 A4 04 00 07 A0 00 00 00 03 00 00 00             .............
    (0 msec)
    <= 6F 10 84 08 A0 00 00 00 03 00 00 00 A5 04 9F 65    o..............e
        01 FF 90 00                                        ....
    Status: No Error
    Authenticate to card manager ...
    => 80 50 00 00 08 A9 2D 23 0F 2E CD 55 7A 00          .P....-#...Uz.
    (0 msec)
    <= 00 00 57 F3 97 D9 7F 72 88 55 FF 02 00 20 BA 9A    ..W....r.U... ..
        16 94 77 B9 81 CE 96 61 84 55 71 73 90 00          ..w....a.Uqs..
    Status: No Error
    => 84 82 00 00 10 18 F1 1A 0C 97 BD D1 66 8B 43 41    ............f.CA
        46 39 44 85 9C                                     F9D..
    (0 msec)
    <= 90 00                                              ..
    Status: No Error
    deleting applets
    => 80 E4 00 80 0C 4F 0A 48 65 6C 6C 6F 57 6F 72 6C    .....O.HelloWorl
        64 00                                              d.
    (0 msec)
    <= 00 90 00                                           ...
    Status: No Error
    applets deleted
    Loading cap-file ...com.sun.javacard.samples.HelloWorld
    => 80 E6 02 00 0F 0A 48 65 6C 6C 6F 57 6F 72 6C 64    ......HelloWorld
        00 00 00 00 00                                     .....
    (0 msec)
    <= 00 90 00                                           ...
    Status: No Error
    => 80 E8 00 00 FA C4 82 01 57 01 00 38 DE CA FF ED    ........W..8....
        02 02 04 00 01 0A 48 65 6C 6C 6F 57 6F 72 6C 64    ......HelloWorld
        23 63 6F 6D 2F 73 75 6E 2F 6A 61 76 61 63 61 72    #com/sun/javacar
        64 2F 73 61 6D 70 6C 65 73 2F 48 65 6C 6C 6F 57    d/samples/HelloW
        6F 72 6C 64 02 00 21 00 38 00 21 00 12 00 0B 00    orld..!.8.!.....
        36 00 0E 00 65 00 0A 00 13 00 00 00 6E 02 9A 00    6...e.......n...
        00 00 00 00 00 01 01 00 04 00 0B 01 02 01 07 A0    ................
        00 00 00 62 01 01 03 00 12 01 0E 48 65 6C 6C 6F    ...b.......Hello
        57 6F 72 6C 64 41 70 70 6C 00 14 06 00 0E 00 00    WorldAppl.......
        00 80 03 01 00 01 07 01 00 00 00 1D 07 00 65 00    ..............e.
        02 10 18 8C 00 07 18 11 01 00 90 0B 87 00 18 8B    ................
        00 05 7A 01 30 8F 00 03 8C 00 0A 7A 05 23 19 8B    ..z.0......z.#..
        00 08 2D 19 8B 00 02 32 03 29 04 70 19 1A 08 AD    ..-....2.).p....
        00 16 04 1F 8D 00 01 3B 16 04 1F 41 29 04 19 08    .......;...A)...
        8B 00 09 32 1F 64 E8 19 8B 00 06 3B 19 16 04 08    ...2.d.....;....
        41 8B 00 04 19 03 08 8B 00 0B 19 AD 00 03 16 00    A...............
    (0 msec)
    <= 00 90 00                                           ...
    Status: No Error
    => 80 E8 80 01 61 04 8B 00 0C 7A 08 00 0A 00 00 00    ....a....z......
        00 00 00 00 00 00 00 05 00 36 00 0D 02 00 02 00    .........6......
        06 80 10 02 03 80 0A 06 01 00 02 00 03 80 0A 09    ................
        03 80 03 01 03 80 0A 07 06 80 03 00 03 80 0A 01    ................
        03 80 0A 03 06 00 00 01 03 80 0A 04 03 80 0A 05    ................
        09 00 13 00 03 0E 23 2C 00 0C 05 0C 06 03 07 05    ......#,........
        10 0C 08 09 06 09 00                               .......
    (16 msec)
    <= 00 90 00                                           ...
    Status: No Error
    Finished loading !
    Installing applet ...
    => 80 E6 0C 00 2D 0A 48 65 6C 6C 6F 57 6F 72 6C 64    ....-.HelloWorld
        0E 48 65 6C 6C 6F 57 6F 72 6C 64 41 70 70 6C 0E    .HelloWorldAppl.
        48 65 6C 6C 6F 57 6F 72 6C 64 41 70 70 6C 01 00    HelloWorldAppl..
        00 00 00                                           ...
    (0 msec)
    <= 6A 80                                              j.
    Status: Wrong data
    EX: msg null, class class com.ibm.jc.JCException
    com.ibm.jc.JCException:
      Error: 6a80
      APDU:  6A80
            at com.ibm.jc.JCUtil.check9000(Unknown Source)
            at com.ibm.jc.SecurityDomain.handleInstall(Unknown Source)
            at com.ibm.jc.SecurityDomain.installForInstallAndMakeSelectable(Unknown
    Source)
            at loader.Loader.load(Loader.java:93)
            at loader.Loader.main(Loader.java:187)Please, help me, I don't get it, ehat could be wrong in this sample?

    Yes, I did.
    Below are the results of HelloWorldAppl loading to Java Card in JCOP Shell simulations process.
    -  /term "Remote|localhost:1175"
    --Opening terminal
    /card -a a000000003000000 -c com.ibm.jc.CardManagerresetCard with timeout: 0 (ms)
    --Waiting for card...
    ATR=3B FA 13 00 00 81 31 FE 45 4A 43 4F 50 34 31 56    ;.....1.EJCOP41V
        32 32 31 96                                        221.
    ATR: T=1, FI=1/DI=3 (93clk/etu), N=0, IFSC=254, BWI=4/CWI=5, Hist="JCOP41V221"
    => 00 A4 04 00 08 A0 00 00 00 03 00 00 00 00          ..............
    (0 msec)
    <= 6F 10 84 08 A0 00 00 00 03 00 00 00 A5 04 9F 65    o..............e
        01 FF 90 00                                        ....
    Status: No Error
    cm>  set-key 255/1/DES-ECB/404142434445464748494a4b4c4d4e4f 255/2/DES-ECB/404142434445464748494a4b4c4d4e4f 255/3/DES-ECB/404142434445464748494a4b4c4d4e4f
    cm>  init-update 255
    => 80 50 00 00 08 E6 F0 56 27 06 B6 C6 42 00          .P.....V'...B.
    (0 msec)
    <= 00 00 57 F3 97 D9 7F 72 88 55 FF 02 00 00 3D 02    ..W....r.U....=.
        9C 31 C7 89 6E 2E 4E BD 56 FB A4 9A 90 00          .1..n.N.V.....
    Status: No Error
    cm>  ext-auth plain
    => 84 82 00 00 10 6B FC E2 0E 7D 91 7F 9E DD 09 6A    .....k...}.....j
        90 D0 2C D6 E9                                     ..,..
    (16 msec)
    <= 90 00                                              ..
    Status: No Error
    cm>  delete 48656c6c6f576f726c644170706c
    => 80 E4 00 00 10 4F 0E 48 65 6C 6C 6F 57 6F 72 6C    .....O.HelloWorl
        64 41 70 70 6C 00                                  dAppl.
    (0 msec)
    <= 6A 88                                              j.
    Status: Reference data not found
    jcshell: Error code: 6a88 (Reference data not found)
    jcshell: Wrong response APDU: 6A88
    Ignoring expected error
    cm>  delete 48656c6c6f576f726c64
    => 80 E4 00 00 0C 4F 0A 48 65 6C 6C 6F 57 6F 72 6C    .....O.HelloWorl
        64 00                                              d.
    (0 msec)
    <= 6A 88                                              j.
    Status: Reference data not found
    jcshell: Error code: 6a88 (Reference data not found)
    jcshell: Wrong response APDU: 6A88
    Ignoring expected error
    cm>  upload -b 250 "C:\Documents and Settings\Ieva\workspace\HelloWorld\bin\com\sun\javacard\samples\HelloWorld\javacard\HelloWorld.cap"
    => 80 E6 02 00 17 0A 48 65 6C 6C 6F 57 6F 72 6C 64    ......HelloWorld
        08 A0 00 00 00 03 00 00 00 00 00 00 00             .............
    (31 msec)
    <= 00 90 00                                           ...
    Status: No Error
    => 80 E8 00 00 FA C4 82 01 57 01 00 38 DE CA FF ED    ........W..8....
        02 02 04 00 01 0A 48 65 6C 6C 6F 57 6F 72 6C 64    ......HelloWorld
        23 63 6F 6D 2F 73 75 6E 2F 6A 61 76 61 63 61 72    #com/sun/javacar
        64 2F 73 61 6D 70 6C 65 73 2F 48 65 6C 6C 6F 57    d/samples/HelloW
        6F 72 6C 64 02 00 21 00 38 00 21 00 12 00 0B 00    orld..!.8.!.....
        36 00 0E 00 65 00 0A 00 13 00 00 00 6E 02 9A 00    6...e.......n...
        00 00 00 00 00 01 01 00 04 00 0B 01 02 01 07 A0    ................
        00 00 00 62 01 01 03 00 12 01 0E 48 65 6C 6C 6F    ...b.......Hello
        57 6F 72 6C 64 41 70 70 6C 00 14 06 00 0E 00 00    WorldAppl.......
        00 80 03 01 00 01 07 01 00 00 00 1D 07 00 65 00    ..............e.
        02 10 18 8C 00 07 18 11 01 00 90 0B 87 00 18 8B    ................
        00 05 7A 01 30 8F 00 03 8C 00 0A 7A 05 23 19 8B    ..z.0......z.#..
        00 08 2D 19 8B 00 02 32 03 29 04 70 19 1A 08 AD    ..-....2.).p....
        00 16 04 1F 8D 00 01 3B 16 04 1F 41 29 04 19 08    .......;...A)...
        8B 00 09 32 1F 64 E8 19 8B 00 06 3B 19 16 04 08    ...2.d.....;....
        41 8B 00 04 19 03 08 8B 00 0B 19 AD 00 03 16 00    A...............
    (16 msec)
    <= 00 90 00                                           ...
    Status: No Error
    => 80 E8 80 01 61 04 8B 00 0C 7A 08 00 0A 00 00 00    ....a....z......
        00 00 00 00 00 00 00 05 00 36 00 0D 02 00 02 00    .........6......
        06 80 10 02 03 80 0A 06 01 00 02 00 03 80 0A 09    ................
        03 80 03 01 03 80 0A 07 06 80 03 00 03 80 0A 01    ................
        03 80 0A 03 06 00 00 01 03 80 0A 04 03 80 0A 05    ................
        09 00 13 00 03 0E 23 2C 00 0C 05 0C 06 03 07 05    ......#,........
        10 0C 08 09 06 09 00                               .......
    (16 msec)
    <= 00 90 00                                           ...
    Status: No Error
    Load report:
      347 bytes loaded in 0.1 seconds
      effective code size on card:
          + package AID       10
          + applet AIDs       21
          + classes           17
          + methods           104
          + statics           0
          + exports           0
            overall           152  bytes
    cm>  install -i 48656c6c6f576f726c644170706c  -q C9#() 48656c6c6f576f726c64 48656c6c6f576f726c644170706c
    => 80 E6 0C 00 2F 0A 48 65 6C 6C 6F 57 6F 72 6C 64    ..../.HelloWorld
        0E 48 65 6C 6C 6F 57 6F 72 6C 64 41 70 70 6C 0E    .HelloWorldAppl.
        48 65 6C 6C 6F 57 6F 72 6C 64 41 70 70 6C 01 00    HelloWorldAppl..
        02 C9 00 00 00                                     .....
    (0 msec)
    <= 90 00                                              ..
    Status: No Error
    cm>  card-info
    => 80 F2 80 00 02 4F 00 00                            .....O..
    (0 msec)
    <= 08 A0 00 00 00 03 00 00 00 01 9E 90 00             .............
    Status: No Error
    => 80 F2 40 00 02 4F 00 00                            [email protected]..
    (0 msec)
    <= 0E 48 65 6C 6C 6F 57 6F 72 6C 64 41 70 70 6C 07    .HelloWorldAppl.
        00 90 00                                           ...
    Status: No Error
    => 80 F2 10 00 02 4F 00 00                            .....O..
    (0 msec)
    <= 07 A0 00 00 00 03 53 50 01 00 01 08 A0 00 00 00    ......SP........
        03 53 50 41 0A 48 65 6C 6C 6F 57 6F 72 6C 64 01    .SPA.HelloWorld.
        00 01 0E 48 65 6C 6C 6F 57 6F 72 6C 64 41 70 70    ...HelloWorldApp
        6C 90 00                                           l..
    Status: No Error
    Card Manager AID   :  A000000003000000
    Card Manager state :  OP_READY
        Application:  SELECTABLE (--------) "HelloWorldAppl"
        Load File  :      LOADED (--------) A0000000035350   (Security Domain)
         Module    :                        A000000003535041
        Load File  :      LOADED (--------) "HelloWorld"   
         Module    :                        "HelloWorldAppl"
    cm>  /select |HelloWorldAppl
    => 00 A4 04 00 0E 48 65 6C 6C 6F 57 6F 72 6C 64 41    .....HelloWorldA
        70 70 6C 00                                        ppl.
    (0 msec)
    <= 00 A4 04 00 0E 48 65 6C 6C 6F 57 6F 72 6C 64 41    .....HelloWorldA
        70 70 6C 90 00                                     ppl..
    Status: No ErrorEverything works fine. That's why, I don't get it, where mistake is made.
    The only logical consumption is, that there are maybe some mistakes in my OffCard API Java code?!
    May be anyone has well-working Java OffCard sample, that loads and installs applet (also makes it selectable)?
    Best regards,
    Eve

  • Help: Loading custom JCShell plugin

    Hi, when I try to register a custom JCShell plugin. I get the following error:
    cm>  /applet
    Nickname   AID                              Plugin
    cm         A000000003000000                 com.ibm.jc.tools.CardManagerPlugin
    eclipse    00000000                         com.ibm.bluez.jcop.eclipse.internal.ui.views.shell.EclipseShellPlugin
    cm>  /register dosf A000010203 com.ibm.jc.tools.DosfShell
    jcshell: Failed to load plugin <com.ibm.jc.tools.DosfShell>: java.lang.ClassNotFoundException: com.ibm.jc.tools.DosfShellI believe it's not finding the jar file I created with the plugin. I have tried putting in a number of directories, including in the D:\eclipse\plugins\com.ibm.bluez.jcop.eclipse_3.1.2\lib where the offcard.jar is placed.
    Help, I am not sure what to try next. Could it be how I created the jar file?
    The documentation does not walk through the entire process (i.e. where to place the jar). I've tried their example and same problem.
    Here is a snip of the code:
    package com.ibm.jc.tools;
    import  com.ibm.jc.*;
    //import  com.ibm.jc.tools.JCShellPlugin; got warnings on this not sure why?
    public class DosfShell extends com.ibm.jc.tools.JCShellPlugin {
         // commands of the plugin
         private static String[] cmdNames = {
              "sampleCommand",
    I am using JCOP 3.1.2 and Eclipse 3.2.1
    Thank you for any help.
    Maguar

    Hi Maguar,
    providing a custom JCShell plugin has been supported by the JCOP-Tools with an own extension point "shellplugins". This extension point is responsible for the integration of individual JCShell plug-in.
    The JCShell (JCOP Offcard API) supports registering and activation of individual plug-ins. Such a plug-in, delivered by any provider, must extend the �com.ibm.jc.tools.JCShellPlugin� class.
    The custom JCShell-plugin class must be declared in a simple Eclipse plug-in. This plug-in contains only a source folder with this Java class (there are no requirements for the package name).
    Add the JCOP-Tools Eclipse plug-in to the required plug-ins in the manifest of your plug-in.
    Add an extension for the extension point "com.ibm.bluez.jcop.eclipse.shellplugins" to the manifest of your plug-in. The entry in the plugin.xml should look like this:
    <plugin>
       <extension
             point="com.ibm.bluez.jcop.eclipse.shellplugins">
             <shellplugin
                  class="com.ibm.jcop.test.MyShellPlugin"/>
       </extension>
    </plugin>It is important that the extension point declares exactly the class file for the extended JCShell plug-in.
    Configure the plug-in build so, that the class file is part of an internal JAR file.
    Start your Eclipse IDE and install this new Eclipse plug-in . Register your applet in the JCShell, select your applet and display the help. Now you will find the command �sample-cmd� in your command list.

  • Developing a Ticket Application - Design Problems

    Hi,
    I didn't want to post this problem in my other thread, because the problems described there are already solves.
    My intention is to write a ticket application which e.g. can store train tickets on a smart card. I will use java card for this, with RMI and the jcop offcard api.
    I have been thinking about how to design the applet(s) and I have come to several issues in maybe you could help me.
    My applet implementation consist of three files: TicketMgrApplet,TicketMgr (interface), and TicketMgrImpl (the Implementation).
    I also wrote a Ticket class which has several member vars (byte arrays to store e.g. source and destination).
    My TicketMgrImpl has a member var: Ticket[] tickets = new Ticket[5];
    I now want a possibility on my offcard app to get this array of tickets. How could I realise that? of course i can't make a method public Ticket[] getTickets(), because Ticket[] is no valid return type. The same is vor inserting a ticket. I can't write a method: public void insertTicket(Ticket t).
    As I am very unexperienced in developing java card, i would like to know if there Is there a way to handle the Tickets by getting them as remote objects or whatever. I don't know how to continue.
    Thanks in advance,
    Matthias

    As I am very unexperienced in developing java card, i
    would like to know if there Is there a way to handle
    the Tickets by getting them as remote objects or
    whatever. No, that is not possible. JC-RMI can only send java primitives or an array of java primitives to the card or receive from it. If you want to put a ticket on your card you have to encode it into a byte-stream (array of bytes), send it to the card and reconstruct it there or make your ticket class hold this byte-arryay and add methods for interpretating the ticket data.
    Note: The size of an byte-array that can be transfered via JC-RMI is very limited. I made some tests and found a limit of ~110bytes per RMI method call. If you need to transfer larger arrays you have to split them, transfer the chunks and combine it on the other side.
    For more information about limitations, see the JavaCard Platform Specification:
    http://java.sun.com/products/javacard/specs.html
    Jan

  • Code Sample: cardinfo for JCOP41V22 Card

    Listed below is the code sample, cardinfo.java, deduced from loader.java for JCOP41V22 card:
    import java.io.*;
    import com.ibm.jc.*;
    import com.ibm.jc.terminal.*;
    * Sample cardinfo. Demonstrates how to use the offcard API to list applets informatoin,
    * JCOP41V22 by shrinking the loader.java code.
    * Modified by: freiheit / 13/10/2005
    public class cardinfo{
         protected static final byte[] JCOP_CARD_MANAGER_AID = { (byte) 0xa0, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00};
         protected static final byte defaultInstallParam[] = { -55, 0 }; // don't know what it's for
         public static void main(String[] args){
         if (args.length == 0){
         System.out.println("cardinfo.main(): missing cap-file argument");
         System.exit(1);
         try{
         cardinfo l = new cardinfo();
         //l.load(args[0]);
         l.getcardinfo();
         }catch(Exception e){
         System.err.println("EX: msg " + e.getMessage() + ", class " + e.getClass());
         e.printStackTrace(System.err);
         System.exit(0);
    private cardinfo(){}
    //private void load(String capFileName) throws Exception{
    private void getcardinfo() throws Exception{
         //CapFile capFile = new CapFile(capFileName, null);
    /*CapFile capFile = new CapFile("C:\\Documents and Settings\\Seah Peng Chew\\workspace\\Helloworld\\bin\\com\\acme\\helloworld\\javacard\\helloworld.cap", null);
         System.out.println("Package name: " + capFile.pkg);
         byte[][] applets = capFile.aids;
         if ((applets == null) || (applets.length == 0)){
         throw new RuntimeException("no applets in cap file");
         // Get connection to terminal, we look for the simulation.
         // As you might want to use "pcsc", "4" or "tcl", "10" in case of
         // Windows or "PCSC", null in case of Linux, you should pass the name
         // of the terminal on the command line or in a properties file
         System.out.println("Open terminal ...");     
         //Make sure the simulator jcop.exe is activated before unmark this satement
         //before running
         //Issue /close command at "cm" prompt if the card is in use,, ie it should
         //have "-" prompt.
         JCTerminal term = JCTerminal.getInstance("Remote", null);
         //For real JCOP41V22 card, please unmark this statement before running
         //Issue /close command at "cm" prompt if the card is in use,, ie it should
         //have "-" prompt.
         //JCTerminal term = JCTerminal.getInstance("pcsc:4", null);
         term.open();
         term.waitForCard(5000);
         TraceJCTerminal _term = new TraceJCTerminal();
         _term.setLog(new PrintWriter(System.out));
         _term.init(term);
         term = _term;
         System.out.println("Get card ...");
         JCard card = new JCard(term, null, 2000);
         System.out.println("Select card manager ...");
         CardManager cardManager = new CardManager(card, CardManager.daid);     
         cardManager.select();
         byte[] dfltKey = c2b("404142434445464748494a4b4c4d4e4f");
         cardManager.setKey(new OPKey(255, 1, OPKey.DES_ECB, dfltKey));
         cardManager.setKey(new OPKey(255, 2, OPKey.DES_ECB, dfltKey));
         cardManager.setKey(new OPKey(255, 3, OPKey.DES_ECB, dfltKey));
         System.out.println("Authenticate to card manager ...");
         cardManager.initializeUpdate(255, 0, CardManager.SCP_UNDEFINED);
         cardManager.externalAuthenticate(OPApplet.APDU_CLR);
         cardManager.update();
         JCInfo info = JCInfo.INFO;
         System.out.println("\nCardManager AID : " + JCInfo.dataToString(cardManager.getAID()));
         System.out.println("CardManager state : " + info.toString("card.status", (byte) cardManager.getState()) + "\n");
         Object[] app = cardManager.getApplets(1, 0, true);
         if (app == null) {
         System.out.println("No applets installed on-card");
         } else {
         System.out.println("Applets:");
         for (int i = 0; i < app.length; i++) {
              System.out.println(info.toString("applet.status", (byte) ((OPApplet) app).getState()) + " " + JCInfo.dataToString(((OPApplet) app[i]).getAID()));
         Object[] lf = cardManager.getLoadFiles(0, true);
         if (lf == null) {
         System.out.println("No packages installed on-card");
         } else {
         System.out.println("Packages:");
         for (int i = 0; i < lf.length; i++) {
              System.out.println(info.toString("loadfile.status", (byte)((LoadFile) lf[i]).getState()) + " " + JCInfo.dataToString(((LoadFile) lf[i]).getAID()));
         term.close();
    static String numbers = "0123456789abcdef";
    private byte[] c2b(String s) {
         if (s == null) return null;
         if (s.length() % 2 != 0) throw new RuntimeException("invalid length");
         byte[] result = new byte[s.length() / 2];
         for (int i = 0; i < s.length(); i += 2) {
         int i1 = numbers.indexOf(s.charAt(i));
         if (i1 == -1) throw new RuntimeException("invalid number");
         int i2 = numbers.indexOf(s.charAt(i + 1));
         if (i2 == -1) throw new RuntimeException("invalid number");
         result[i / 2] = (byte) ((i1 << 4) | i2);
         return result;
    I have tested the code with JCOP Plug-in 3.1.1a in Windows environment.
    Please give your comments and feedback.

    The posted code had some errors in the part which enumerate the installed applets and packages. I corrected that.
    Second I changed the class name from "cardinfo" to "CardInfo", because of java code style.
    import java.io.PrintWriter;
    import com.ibm.jc.CardManager;
    import com.ibm.jc.JCInfo;
    import com.ibm.jc.JCTerminal;
    import com.ibm.jc.JCard;
    import com.ibm.jc.LoadFile;
    import com.ibm.jc.OPApplet;
    import com.ibm.jc.OPKey;
    import com.ibm.jc.terminal.TraceJCTerminal;
    * Sample cardinfo. Demonstrates how to use the offcard API to list applets informatoin, JCOP41V22
    * by shrinking the loader.java code. Modified by: freiheit / 13/10/2005
    public class CardInfo {
        protected static final byte[] JCOP_CARD_MANAGER_AID = { (byte) 0xa0, 0x00, 0x00, 0x00, 0x03,
                0x00, 0x00, 0x00 };
        protected static final byte defaultInstallParam[] = { -55, 0 }; // don't know what it's for
        public static void main(String[] args) {
             * if (args.length == 0){ System.out.println("cardinfo.main(): missing cap-file argument");
             * System.exit(1); }
            try {
                CardInfo l = new CardInfo();
                // l.load(args[0]);
                l.getcardinfo();
            } catch (Exception e) {
                System.err.println("EX: msg " + e.getMessage() + ", class " + e.getClass());
                e.printStackTrace(System.err);
            System.exit(0);
        private CardInfo() {
        // private void load(String capFileName) throws Exception{
        private void getcardinfo() throws Exception {
            // CapFile capFile = new CapFile(capFileName, null);
             * CapFile capFile = new CapFile("C:\\Documents and Settings\\Seah Peng
             * Chew\\workspace\\Helloworld\\bin\\com\\acme\\helloworld\\javacard\\helloworld.cap",
             * null); System.out.println("Package name: " + capFile.pkg); byte[][] applets =
             * capFile.aids; if ((applets == null) || (applets.length == 0)){ throw new
             * RuntimeException("no applets in cap file"); }
            // Get connection to terminal, we look for the simulation.
            // As you might want to use "pcsc", "4" or "tcl", "10" in case of
            // Windows or "PCSC", null in case of Linux, you should pass the name
            // of the terminal on the command line or in a properties file
            System.out.println("Open terminal ...");
            // Make sure the simulator jcop.exe is activated before unmark this satement
            // before running
            // Issue /close command at "cm" prompt if the card is in use,, ie it should
            // have "-" prompt.
            JCTerminal term = JCTerminal.getInstance("Remote", null);
            // For real JCOP41V22 card, please unmark this statement before running
            // Issue /close command at "cm" prompt if the card is in use,, ie it should
            // have "-" prompt.
            // JCTerminal term = JCTerminal.getInstance("pcsc:4", null);
            term.open();
            term.waitForCard(5000);
            TraceJCTerminal _term = new TraceJCTerminal();
            _term.setLog(new PrintWriter(System.out));
            _term.init(term);
            term = _term;
            System.out.println("Get card ...");
            JCard card = new JCard(term, null, 2000);
            System.out.println("Select card manager ...");
            CardManager cardManager = new CardManager(card, CardManager.daid);
            cardManager.select();
            byte[] dfltKey = c2b("404142434445464748494a4b4c4d4e4f");
            cardManager.setKey(new OPKey(255, 1, OPKey.DES_ECB, dfltKey));
            cardManager.setKey(new OPKey(255, 2, OPKey.DES_ECB, dfltKey));
            cardManager.setKey(new OPKey(255, 3, OPKey.DES_ECB, dfltKey));
            System.out.println("Authenticate to card manager ...");
            cardManager.initializeUpdate(255, 0, CardManager.SCP_UNDEFINED);
            cardManager.externalAuthenticate(OPApplet.APDU_CLR);
            cardManager.update();
            JCInfo info = JCInfo.INFO;
            System.out.println("\nCardManager AID : " + JCInfo.dataToString(cardManager.getAID()));
            System.out.println("CardManager state : "
                    + info.toString("card.status", (byte) cardManager.getState()) + "\n");
            OPApplet[] app = (OPApplet[]) cardManager.getApplets(1, 0, true);
            if (app == null) {
                System.out.println("No applets installed on-card");
            } else {
                System.out.println("Applets:");
                for (int i = 0; i < app.length; i++) {
                    System.out.println(info.toString("applet.status", (byte) app.getState()) + " "
    + JCInfo.dataToString(app[i].getAID()));
    LoadFile[] lf = cardManager.getLoadFiles(0, true);
    if (lf == null) {
    System.out.println("No packages installed on-card");
    } else {
    System.out.println("Packages:");
    for (int i = 0; i < lf.length; i++) {
    System.out.println(info.toString("loadfile.status", (byte) lf[i].getState()) + " "
    + JCInfo.dataToString(lf[i].getAID()));
    term.close();
    static String numbers = "0123456789abcdef";
    private byte[] c2b(String s) {
    if (s == null)
    return null;
    if (s.length() % 2 != 0)
    throw new RuntimeException("invalid length");
    byte[] result = new byte[s.length() / 2];
    for (int i = 0; i < s.length(); i += 2) {
    int i1 = numbers.indexOf(s.charAt(i));
    if (i1 == -1)
    throw new RuntimeException("invalid number");
    int i2 = numbers.indexOf(s.charAt(i + 1));
    if (i2 == -1)
    throw new RuntimeException("invalid number");
    result[i / 2] = (byte) ((i1 << 4) | i2);
    return result;

  • Jct.dll with JCOP&Eclipse

    Hi all,
    I am trying to write a host application in Eclipse using JCOP offcard API and keep getting the following error
    java.lang.UnsatisfiedLinkError: no jct in java.library.path
    java.lang.UnsatisfiedLinkError: setup
         at com.ibm.jc.terminal.NativeJCTerminal.setup(Native Method)
         at com.ibm.jc.terminal.NativeJCTerminal.<init>(Unknown Source)
         at com.ibm.jc.JCTerminal.getInstance(Unknown Source)
         at HostApplication.main(HostApplication.java:49)The problem seems to be ocurring during the following section of code
      try {
          /**********************************************error ocurring here****************/
            term = JCTerminal.getInstance(termName, termPara);
            term.open();
            term.waitForCard(5000);
      }catch(Exception e) {
            System.out.println("can't find/open/connect/reset smartcard/reader: " + e.getMessage());
            System.exit(1);
    }Now, I have read the forum and did come across this problem and some solutions but all were related to running the java class file from the command line. What I want to know is how I add the path to jct.dll through the Eclipse environment.
    Thanks in advance,
    Ann

    The Nokia NFC 3220 uses JCOP/SmartMX as second smart card?
    If it is JCOP, then this behavior is that of terminated card. Check out the GP specification. There is no return from the card life cycle TERMINATED. As mkdata mentioned in other posts, just the GET DATA command works to retrieve the CPLC data:=> 00 CA 9F 7F 00                                     .....
    (26926 usec)
    <= ......
    Status: No Error
      IC Fabricator                      : 4790
      IC Type                            : 5017
      Operating System ID                : 4051
      Operating System release date      : xx
      Operating System release level     : xx
      IC Fabrication Date                : xx
      IC Serial Number                   : xx
      IC Batch Identifier                : xx
      IC Module Fabricator               : xx
      IC Module Packaging Date           : xx
      ICC Manufacturer                   : xx
      IC Embedding Date                  : xx
      IC Pre-Personalizer                : xx
      IC Pre-Perso. Equipment Date       : xx
      IC Pre-Perso. Equipment ID         : xx
      IC Personalizer                    : xx
      IC Personalization Date            : xx
      IC Perso. Equipment ID             : xx

  • File system in JCOP

    Is it possible to create and delete files (DF and EF) in JCOP cards? In other words, Is it posibble a file system in JCOP cards? If so, what tool and commands are used for? If not so, what Java card does support a file system?
    Thanks in advance.

    I also posted the question about the file systems some time ago.
    Yes, Java Card doesn't support any type of ISO 7816-4 file systems. The reason is, i suppose, that Java card are not fully compliant with ISO 7816-4, but must comply to the GP 2.1.1/OP 2.0.1 specifications.
    One of the solutions would be to create your own applet that implements file system and performs all the file system management command (delete/actvate/create file and etc.). As i remember, there is an example of file system applet in the Java Card Development Kit v2.2.2.
    Reagrdinf OCF, I have no experience with it. It is not up-to-date technology, but a lot of people still use it for the terminal applications programming. I advice you to use JCOP tools offcard API, or Java 6 smartcard I/O API.
    Best regards,
    Eve
    Message was edited by:
    Ieva

  • Problem working with offline loader

    I made a standalone loader to reload my applets without using Eclipse.
    But I get some problems during my initialisation of the CardManager.
    Do you know what is going wrong; i'm using the follwing call.
    CardManager cardManager = new CardManager(card, CardManager.daid);
    cardManager.select();... and I get the following exception:
    EX: msg Secure Channel Protocol mismatch., class class com.ibm.jc.JCException
    Secure Channel Protocol mismatch.
         at com.ibm.jc.OPApplet.initializeUpdate(Unknown Source)
         at com.ibm.jc.OPApplet.initializeUpdate(Unknown Source)
         at host.Loader.load(Loader.java:82)
         at host.Loader.main(Loader.java:22)
    Do you know what is going wrong ??
    Here is the code of the loader:
    package host;
    import java.io.*;
    import com.ibm.jc.*;
    import com.ibm.jc.terminal.*;
    * Sample loader. Demonstrates how to use the offcard API to download
    * a cap-file on a VOP card.
    public class Loader{
        public static void main(String[] args){
         if (args.length == 0){
             System.out.println("Loader.main(): missing cap-file argument");
             System.exit(1);
         try{
             Loader l = new Loader();
             //l.load(args[0]);
             l.load();
         }catch(Exception e){
             System.err.println("EX: msg " + e.getMessage() + ", class " + e.getClass());
             e.printStackTrace(System.err);
         System.exit(0);
        private Loader(){}
        //private void load(String capFileName) throws Exception{
        private void load() throws Exception{
         //CapFile capFile = new CapFile(capFileName, null);
        CapFile capFile = new CapFile("C:/eclipse_SDK301/workspace/JavaCardApplets/bin/pkDisplayApplet/javacard/pkDisplayApplet.cap", null);
         System.out.println("Package name: " + capFile.pkg);
         byte[][] applets = capFile.aids;
         if ((applets == null) || (applets.length == 0)){
             throw new RuntimeException("no applets in cap file");
         // Get connection to terminal, we look for the simulation.
         // As you might want to use "pcsc", "4" or "tcl", "10" in case of
         // Windows or "PCSC", null in case of Linux, you should pass the name
         // of the terminal on the command line or in a properties file
         System.out.println("Open terminal ...");
         //JCTerminal term = JCTerminal.getInstance("Remote", null);
         //JCTerminal term = JCTerminal.getInstance("Native", "pcsc:4");     
         JCTerminal term = JCTerminal.getInstance("pcsc:4", null);
         term.open();
         // Create a logging terminal spitting out the APDUs on standard out
         TraceJCTerminal _term = new TraceJCTerminal();
         _term.setLog(new PrintWriter(System.out));
         _term.init(term);
         term = _term;
         // Get JavaCard representative, passing NULL resets card and returns ATR
         System.out.println("Get card ...");
         JCard card = new JCard(term, null, 2000);
         // Get the off-card representative for the card manager and use it to
         // select the on-card CardManager
         System.out.println("Select card manager ...");
         CardManager cardManager = new CardManager(card, CardManager.daid);
         cardManager.select();
         // For downloading something, we have to be authenticated to card manager.
         // For this, the keys must be set. The keys to use should of course
         // be configurable as well.
         byte[] dfltKey = c2b("404142434445464748494a4b4c4d4e4f");
         cardManager.setKey(new OPKey(255, 1, OPKey.DES_ECB, dfltKey));
         cardManager.setKey(new OPKey(255, 2, OPKey.DES_ECB, dfltKey));
         cardManager.setKey(new OPKey(255, 3, OPKey.DES_ECB, dfltKey));
         cardManager.setKey(new OPKey(1, 1, OPKey.DES_ECB, c2b("707172737475767778797a7b7c7d7e7f")));
         cardManager.setKey(new OPKey(1, 2, OPKey.DES_ECB, c2b("606162636465666768696a6b6c6d6e6f")));
         cardManager.setKey(new OPKey(1, 3, OPKey.DES_ECB, c2b("505152535455565758595a5b5c5d5e5f")));
         System.out.println("Authenticate to card manager ...");
         cardManager.initializeUpdate(255, 0);
         cardManager.externalAuthenticate(OPApplet.APDU_CLR);
         // And load the cap-file, do not forget to call installForLoad
         System.out.println("Loading cap-file ...");
         cardManager.installForLoad(capFile.pkgId, 0, capFile.pkgId.length, null, 0, 0, null, 0, null, 0, 0, null, 0);
         cardManager.load(capFile, null, SecurityDomain.LOAD_ALL, new PrintWriter(System.out), 255);
         System.out.println("Finished loading !");
         // Install applet, we try to install the first applet given in the
         // cap file, and try to instantiate it under the same AID as given for its
         // representation in the cap file. No installation data is passed.
         System.out.println("Installing applet ...");
         cardManager.installForInstallAndMakeSelectable(
             capFile.pkgId, 0, capFile.pkgId.length,
             applets[0], 0, applets[0].length, /* applet */
             null, 0, 0, /* instance aid */
             OPApplet.NO_PRIVS,  /* no special priviledges */
             null, 0, 0,   /* install data */
             null, 0);   
         System.out.println("Install succeeded!");
         // synchronize state with on-card card manager
         cardManager.update();
         // Print information regarding card manager, applets and packages on-card
         JCInfo info = JCInfo.INFO;
         System.out.println("\nCardManager AID   :  " + JCInfo.dataToString(cardManager.getAID()));
         System.out.println("CardManager state :  " + info.toString("card.status", (byte) cardManager.getState()) + "\n");
         Object[] app = cardManager.getApplets(CardManager.GET_APPLETS, CardManager.CVM_FORMAT_HEX, true);
         if (app == null) {
             System.out.println("No applets installed on-card");
         } else {
             System.out.println("Applets:");
             for (int i = 0; i < app.length; i++) {
              System.out.println(info.toString("applet.status", (byte) ((OPApplet) app).getState()) + " " + JCInfo.dataToString(((OPApplet) app[i]).getAID()));
         // List packages on card
         Object[] lf = cardManager.getLoadFiles(CardManager.CVM_FORMAT_HEX, true);
         if (lf == null) {
         System.out.println("No packages installed on-card");
         } else {
         System.out.println("Packages:");
         for (int i = 0; i < lf.length; i++) {
              System.out.println(info.toString("loadfile.status", (byte)((LoadFile) lf[i]).getState()) + " " + JCInfo.dataToString(((LoadFile) lf[i]).getAID()));
    static String numbers = "0123456789abcdef";
    private byte[] c2b(String s) {
         if (s == null) return null;
         if (s.length() % 2 != 0) throw new RuntimeException("invalid length");
         byte[] result = new byte[s.length() / 2];
         for (int i = 0; i < s.length(); i += 2) {
         int i1 = numbers.indexOf(s.charAt(i));
         if (i1 == -1) throw new RuntimeException("invalid number");
         int i2 = numbers.indexOf(s.charAt(i + 1));
         if (i2 == -1) throw new RuntimeException("invalid number");
         result[i / 2] = (byte) ((i1 << 4) | i2);
         return result;
    When I'm using the build-in loader of the JCOP plugin, everything is working correclty. Here is the log of the JCOP plugin when everything is uploaded correclty:
    - /term "PCSC|Philips Semiconductors TDA8031_SCR1 0"
    /card -a a000000003000000 -c com.ibm.jc.CardManagerATR: 3BE900008131FE454A434F503431563232A7
    ATR: T=1, N=0, IFSC=254, BWI=4/CWI=5, Hist="JCOP41V22"
    cm> set-key 255/1/DES-ECB/404142434445464748494a4b4c4d4e4f 255/2/DES-ECB/404142434445464748494a4b4c4d4e4f 255/3/DES-ECB/404142434445464748494a4b4c4d4e4f
    cm> init-update 0
    cm> ext-auth
    cm> delete 7068696c30446973706c61795761
    cm> delete 7068696c30706b446973706c61795761

    This problem is already solved, but now an exception occurs at the loading of the applet.
    Here is the LOG:
    Package name: pkDisplayApplet
    Open terminal ...
    Get card ...
    --Waiting for card...
    Select card manager ...
    ATR=3B E9 00 00 81 31 FE 45 4A 43 4F 50 34 31 56 32 ;....1.EJCOP41V2
    32 A7 2.
    => 00 A4 04 00 07 A0 00 00 00 03 00 00 00 .............
    (186548 usec)
    <= 6F 19 84 08 A0 00 00 00 03 00 00 00 A5 0D 9F 6E o..............n
    06 40 51 42 04 22 00 9F 65 01 FF 90 00 .@QB."..e....
    Status: No Error
    Authenticate to card manager ...
    => 80 50 00 00 08 65 49 D7 19 88 07 D2 C1 00 .P...eI.......
    (175382 usec)
    <= 00 00 42 44 00 13 85 90 62 10 FF 02 00 6D C7 D8 ..BD....b....m..
    59 E9 80 DC F2 D1 76 58 85 47 20 13 90 00 Y.....vX.G ...
    Status: No Error
    => 84 82 00 00 10 EC 04 45 44 B0 A2 A7 63 69 4E 22 .......ED...ciN"
    F8 6A 6F 06 F9 .jo..
    (124427 usec)
    <= 90 00 ..
    Status: No Error
    Loading cap-file ...
    => 80 E6 02 00 13 0E 70 68 69 6C 30 70 6B 44 69 73 ......phil0pkDis
    70 6C 61 79 00 00 00 00 00 play.....
    (88270 usec)
    <= 69 85 i.
    Status: Conditions of use not satisfied
    EX: msg null, class class com.ibm.jc.JCException
    com.ibm.jc.JCException:
    Error: 6985
    APDU: 6985
         at com.ibm.jc.JCUtil.check9000(Unknown Source)
         at com.ibm.jc.SecurityDomain.installForLoad(Unknown Source)
         at host.Loader.load(Loader.java:86)
         at host.Loader.main(Loader.java:22)
    The code of the Loader is shown here (adapted in comparison with previous version); the line in which it goes wrong is this one:
         cardManager.installForLoad(capFile.pkgId, 0, capFile.pkgId.length, null, 0, 0, null, 0, null, 0, 0, null, 0);
    package host;
    import java.io.*;
    import com.ibm.jc.*;
    import com.ibm.jc.terminal.*;
    * Sample loader. Demonstrates how to use the offcard API to download
    * a cap-file on a VOP card.
    public class Loader{
        public static void main(String[] args){
         if (args.length == 0){
             System.out.println("Loader.main(): missing cap-file argument");
             System.exit(1);
         try{
             Loader l = new Loader();
             //l.load(args[0]);
             l.load();
         }catch(Exception e){
             System.err.println("EX: msg " + e.getMessage() + ", class " + e.getClass());
             e.printStackTrace(System.err);
         System.exit(0);
        private Loader(){}
        //private void load(String capFileName) throws Exception{
        private void load() throws Exception{
         //CapFile capFile = new CapFile(capFileName, null);
        CapFile capFile = new CapFile("C:/eclipse_SDK301/workspace/JavaCardApplets/bin/pkDisplayApplet/javacard/pkDisplayApplet.cap", null);
         System.out.println("Package name: " + capFile.pkg);
         byte[][] applets = capFile.aids;
         if ((applets == null) || (applets.length == 0)){
             throw new RuntimeException("no applets in cap file");
         // Get connection to terminal, we look for the simulation.
         // As you might want to use "pcsc", "4" or "tcl", "10" in case of
         // Windows or "PCSC", null in case of Linux, you should pass the name
         // of the terminal on the command line or in a properties file
         System.out.println("Open terminal ...");
         //JCTerminal term = JCTerminal.getInstance("Remote", null);
         //JCTerminal term = JCTerminal.getInstance("Native", "pcsc:4");     
         JCTerminal term = JCTerminal.getInstance("pcsc:4", null);
         term.open();
         // Create a logging terminal spitting out the APDUs on standard out
         TraceJCTerminal _term = new TraceJCTerminal();
         _term.setLog(new PrintWriter(System.out));
         _term.init(term);
         term = _term;
         // Get JavaCard representative, passing NULL resets card and returns ATR
         System.out.println("Get card ...");
         JCard card = new JCard(term, null, 2000);
         // Get the off-card representative for the card manager and use it to
         // select the on-card CardManager
         System.out.println("Select card manager ...");
         CardManager cardManager = new CardManager(card, CardManager.daid);     
         cardManager.select();
         // For downloading something, we have to be authenticated to card manager.
         // For this, the keys must be set. The keys to use should of course
         // be configurable as well.
         byte[] dfltKey = c2b("404142434445464748494a4b4c4d4e4f");
         cardManager.setKey(new OPKey(255, 1, OPKey.DES_ECB, dfltKey));
         cardManager.setKey(new OPKey(255, 2, OPKey.DES_ECB, dfltKey));
         cardManager.setKey(new OPKey(255, 3, OPKey.DES_ECB, dfltKey));
         //cardManager.setKey(new OPKey(1, 1, OPKey.DES_ECB, c2b("707172737475767778797a7b7c7d7e7f")));
         //cardManager.setKey(new OPKey(1, 2, OPKey.DES_ECB, c2b("606162636465666768696a6b6c6d6e6f")));
         //cardManager.setKey(new OPKey(1, 3, OPKey.DES_ECB, c2b("505152535455565758595a5b5c5d5e5f")));
         System.out.println("Authenticate to card manager ...");
         //cardManager.initializeUpdate(255, 0);
         cardManager.initializeUpdate(255, 0, CardManager.SCP_UNDEFINED);
         cardManager.externalAuthenticate(OPApplet.APDU_CLR);
         // And load the cap-file, do not forget to call installForLoad
         System.out.println("Loading cap-file ...");
         cardManager.installForLoad(capFile.pkgId, 0, capFile.pkgId.length, null, 0, 0, null, 0, null, 0, 0, null, 0);     cardManager.load(capFile, null, SecurityDomain.LOAD_ALL, new PrintWriter(System.out), 255);
         System.out.println("Finished loading !");
         // Install applet, we try to install the first applet given in the
         // cap file, and try to instantiate it under the same AID as given for its
         // representation in the cap file. No installation data is passed.
         System.out.println("Installing applet ...");
         cardManager.installForInstallAndMakeSelectable(
             capFile.pkgId, 0, capFile.pkgId.length,
             applets[0], 0, applets[0].length, /* applet */
             null, 0, 0, /* instance aid */
             OPApplet.NO_PRIVS,  /* no special priviledges */
             null, 0, 0,   /* install data */
             null, 0);   
         System.out.println("Install succeeded!");
         // synchronize state with on-card card manager
         cardManager.update();
         // Print information regarding card manager, applets and packages on-card
         JCInfo info = JCInfo.INFO;
         System.out.println("\nCardManager AID   :  " + JCInfo.dataToString(cardManager.getAID()));
         System.out.println("CardManager state :  " + info.toString("card.status", (byte) cardManager.getState()) + "\n");
         Object[] app = cardManager.getApplets(CardManager.GET_APPLETS, CardManager.CVM_FORMAT_HEX, true);
         if (app == null) {
             System.out.println("No applets installed on-card");
         } else {
             System.out.println("Applets:");
             for (int i = 0; i < app.length; i++) {
              System.out.println(info.toString("applet.status", (byte) ((OPApplet) app).getState()) + " " + JCInfo.dataToString(((OPApplet) app[i]).getAID()));
         // List packages on card
         Object[] lf = cardManager.getLoadFiles(CardManager.CVM_FORMAT_HEX, true);
         if (lf == null) {
         System.out.println("No packages installed on-card");
         } else {
         System.out.println("Packages:");
         for (int i = 0; i < lf.length; i++) {
              System.out.println(info.toString("loadfile.status", (byte)((LoadFile) lf[i]).getState()) + " " + JCInfo.dataToString(((LoadFile) lf[i]).getAID()));
    static String numbers = "0123456789abcdef";
    private byte[] c2b(String s) {
         if (s == null) return null;
         if (s.length() % 2 != 0) throw new RuntimeException("invalid length");
         byte[] result = new byte[s.length() / 2];
         for (int i = 0; i < s.length(); i += 2) {
         int i1 = numbers.indexOf(s.charAt(i));
         if (i1 == -1) throw new RuntimeException("invalid number");
         int i2 = numbers.indexOf(s.charAt(i + 1));
         if (i2 == -1) throw new RuntimeException("invalid number");
         result[i / 2] = (byte) ((i1 << 4) | i2);
         return result;

  • Personalize cjcre/ java card

    Hi,
    I would like to know how to personalize cjcre/ java card. For example, we have developed applets, which needs to study the data like card holder name, date of birth personalised in card. This is needed for debugging purpose. There are straight forward methods in JCOP for personalising the card simulator. Some sample code of what we do in JCOP:
    Following classes are used:
    import com.ibm.jc.JCTerminal;
    import com.ibm.jc.JCard;
    import com.ibm.jc.terminal.TraceJCTerminal;
    Command like this are used:
    "Perso #04","80","E2","00","00","010129702757115413330089010582D1412201029430730F5F2011496E7465726F7065722E20313920383041")
    Is it possible to do this kind of work in cjcre or related tools in Java Card system? We are not sure about the JCOP continuation of support, so we would prefer to have another tool like cjcre to simulate cards.
    Any help is appreciated
    Edited by: mohanvaradharajan on Jul 8, 2010 3:39 AM

    Hi,
    There is an offcard API included in the JCDK. You will need OCF as well for this to work. You can look at the samples in the JCDK for an example of how to use this.
    Here is also a related thread: [http://forums.sun.com/thread.jspa?forumID=23&threadID=5440330]
    Cheers,
    Shane

Maybe you are looking for