3 Replies Latest reply on Sep 14, 2013 12:16 PM by johnnybravo

    6985 - Conditions of use not satisfied on HelloWorld?

    johnnybravo

      Hello,

       

      I was quite far in progress with a project until I came across this Response APDU (or CLA not supported) but I just couldn't find why this happened.
      So I just used the same project and just made a simple helloWorld out of it:

       

      package testproject;
      import javacard.framework.APDU;
      import javacard.framework.ISO7816;
      import javacard.framework.Applet;
      import javacard.framework.ISOException;
      import javacard.framework.Util;
      
      public class MyJCProject extends Applet {
      
        private static final byte[] test = {(byte) 'T', (byte) 'e', (byte) 's', (byte) 't'};
        private static final byte HW_CLA = (byte) 0x80;
        private static final byte HW_INS = (byte) 0x00;
      
        public static void install(byte[] bArray, short bOffset, byte bLength) {
        // GP-compliant JavaCard applet registration
        new cipurse.CipurseApplet().register(bArray, (short) (bOffset + 1),
        bArray[bOffset]);
        }
      
      
       public void process(APDU apdu) {
        // Good practice: Return 9000 on SELECT
        if (selectingApplet()) {
        return;
        }
      
        byte[] buffer = apdu.getBuffer();
        byte CLA = (byte) (buffer[ISO7816.OFFSET_CLA] & 0xff);
        byte INS = (byte) (buffer[ISO7816.OFFSET_INS] & 0xff);
      
        if (CLA != HW_CLA)
        ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
      
        switch (buffer[ISO7816.OFFSET_INS]) {
        case HW_INS:
        getTest(apdu);
        break;
        default:
        // good practice: If you don't know the INStruction, say so:
        ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
        }
        }
        private void getTest(APDU apdu) {
        // TODO Auto-generated method stub
        byte[] buffer = apdu.getBuffer();
        short len = (short) test.length;
      
        Util.arrayCopyNonAtomic(test, (short) 0, buffer, (short) 0, len);
        apdu.setOutgoingAndSend((short) 0, len);
        }
      }
      

       

      in JCOP Shell i can select the modul, but I already get a unusual response (not sure why), but it is a 9000:

      => 00 A4 04 00 08 A0 00 00 00 03 00 00 00 00          ..............

      (10791 usec)

      <= 6F 65 84 08 A0 00 00 00 03 00 00 00 A5 59 9F 65    oe...........Y.e

          01 FF 9F 6E 06 47 91 00 78 34 00 73 4A 06 07 2A    ...n.G..x4.sJ..*

          86 48 86 FC 6B 01 60 0C 06 0A 2A 86 48 86 FC 6B    .H..k.`...*.H..k

          02 02 01 01 63 09 06 07 2A 86 48 86 FC 6B 03 64    ....c...*.H..k.d

          0B 06 09 2A 86 48 86 FC 6B 04 02 15 65 0B 06 09    ...*.H..k...e...

          2B 85 10 86 48 64 02 01 03 66 0C 06 0A 2B 06 01    +...Hd...f...+..

          04 01 2A 02 6E 01 02 90 00                         ..*.n....

      Status: No Error

       

      well, according to the programm, it should return "Test" on an APDU with CLA 80 and INS 00, but all I see is

      cm>  /send 80000000

      => 80 00 00 00                                        ....

      (5809 usec)

      <= 69 85                                              i.

      Status: Conditions of use not satisfied

       

      please tell me something is wrong with what I am doing!

        • 1. Re: 6985 - Conditions of use not satisfied on HelloWorld?
          Sebastien_Lorquet

          When you see a SW that you did not write, this SW is emitted by the platform before it reaches your code.

           

          6F00 is sent when the code throws an exception.

           

          1) In your case , INS=00h is invalid. Try something else.

           

          2) and since your apdu return data, you can't send a 4-byte command. You have to append Le, 80 XX 00 00 00.

           

          Your applet will still work, but it's a bad practice.

           

          <joke> And keeping JCOP examples comments is also a bad practice. :) </joke>

           

          BR

          1 person found this helpful
          • 2. Re: 6985 - Conditions of use not satisfied on HelloWorld?
            johnnybravo

            My problem is that this happens on any Java Card Project, also to the ones that actually worked fine before.

            So what I did was just creating a new Project with a new AID and what else is needed and tried it with a simple HelloWorld.

             

            so INS=00 is the only correct INS according to the code. but the same thing happens on any other INS.

            if INS would be the problem it would throw 6d00.

             

            @Le ... I know, and I usually don't do it, but in this case it does not make any difference at all.

            • 3. Re: 6985 - Conditions of use not satisfied on HelloWorld?
              johnnybravo

              Not knowing how this happened, I just made a new copy of my "default" JCOP-Folder with the settings! created the same programm, now it runs, what a relief!

              /select |test

              => 00 A4 04 00 0A 74 75 77 69 65 6E 69 6E 73 6F 00    .....test.

              (5380 usec)

              <= 90 00                                              ..

              Status: No Error

               

              here is the usual respond to selecting applets.