4 Replies Latest reply on Aug 1, 2012 10:59 AM by 953218

    GPShell: How to use the -instParam correctly?

      Good day,
      I want (actually have to for Bachelor's Thesis) to pass some arguments in the install command. (Later it should be the AES-Key and the ID of the card).
      For testing purposes, I wrote the following short applet :
      package challengeresponse;
      import javacard.framework.Applet;
      import javacard.framework.ISO7816;
      import javacard.framework.ISOException;
      import javacard.framework.Util;
      import javacard.framework.APDU;
      public class ChallengeResponse extends Applet {
           // Instruction- and class-bytes
           final static byte CLASS = (byte) 0x80;
           final static byte INS_START = (byte) 0x01;
              static byte[] testdata;
           private ChallengeResponse(byte bArray[], short bOffset, byte bLength) {
                testdata = new byte[2];
                Util.arrayCopy(bArray, (short)0, testdata, (short)bOffset, (short)bLength);
           public static void install(byte bArray[], short bOffset, byte bLength)
                     throws ISOException {
                new ChallengeResponse(bArray,bOffset,bLength);
           public void process(APDU apdu) throws ISOException {
                byte[] apdu_buffer = apdu.getBuffer();
                switch(apdu_buffer[ISO7816.OFFSET_INS]) {
                case INS_START:
                     // When start-command is received do:
                     Util.arrayCopy(testdata, (short)0, apdu_buffer, (short)ISO7816.OFFSET_CDATA, (short)2);
                     apdu.setOutgoingAndSend(ISO7816.OFFSET_CDATA, (short)2);
      This should just send what I give the applet as install parameter, doesn't it?
      And I install it using gpshell with the following file:
      select -AID a000000003000000
      open_sc -security 1 -keyind 0 -keyver 0 -mac_key 404142434445464748494a4b4c4d4e4f -enc_key 404142434445464748494a4b4c4d4e4f // Open secure channel
      delete -AID D0D1D2D3D4D50101
      delete -AID D0D1D2D3D4D501
      delete -AID 0202030405060708090303
      delete -AID 02020304050607080900
      install -file C:\Users\Mark\workspace\ChallengeResponse\bin\challengeresponse\javacard\challengeresponse.cap -nvDataLimit 2000 -instParam C9021234 -priv 2
      The instParam should mean:
      C9: instructions for applet
      02: length of data (2 Bytes)
      12 34: Data

      However, I get the following response:
      install_for_install_and_make_selectable() returns 0x80206A80 (6A80: Wrong data /
       Incorrect values in command data.)
      What do I do wrong? Please help!