JavacardOS will not accept order any more, please contact our partner Feitian online Store:
https://ftsafe.en.alibaba.com/index.html

GET REPONSE command with JCOP card

JavaCard Applet Development Related Questions and Answers.
Heather
Posts: 24
Joined: Mon Nov 30, 2015 5:41 am
Points :121
Contact:

GET REPONSE command with JCOP card

Post by Heather » Thu Dec 17, 2015 3:29 am

I also installed my applet into JCOP card and tested GET REPONSE COMMAND. But it returned as follows:

Send: 00 00 00 00 00
Recv: 6C 02
Time used: 0.000 ms
Send: 00 00 00 00 02
Recv: 03 01 90 00
Time used: 10.000 ms


Why did JCOP card return these?

Here is applet-code:

Code: Select all

package GR_TEST;

import javacard.framework.*;
import javacardx.apdu.ExtendedLength;

public class GR_TEST extends Applet implements ExtendedLength
{
   byte[] a = null;

   public GR_TEST() {
      a = new byte[(short)1000];
      for (short i = 0; i < 1000; ++i) {
         a[i] = (byte)((short)i & 0xFF);
      }
   }
   public static void install(byte[] bArray, short bOffset, byte bLength)
   {
      new GR_TEST().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
   }

   public void process(APDU apdu)
   {
      if (selectingApplet())
      {
         return;
      }

      byte[] buf = apdu.getBuffer();
      switch (buf[ISO7816.OFFSET_INS])
      {
      case (byte)0x00:
         short reason = 0;
         try {
            apdu.setOutgoing();
         } catch (APDUException e) {
            reason = 0x0100;
            reason |= e.getReason(); 
         }
         try {
            apdu.setOutgoingLength((short)1000);
         } catch (APDUException e) {
            reason = 0x0200;
            reason |= e.getReason();
         }
         try {
            apdu.sendBytesLong(a, (short)0, (short)1000);
         } catch (APDUException e) {
            reason = 0x0300;
            reason |= e.getReason();
         }
         if (reason != 0) {
            apdu.setOutgoingLength((short) 2);
            Util.setShort(buf, (short) 0, reason);
            apdu.sendBytes((short) 0, (short) 2);
         }
         break;
      default:
         ISOException.throwIt((short)0x8080);
      }
   }

}

User avatar
UNKNwYSHSA
Posts: 630
Joined: Thu May 21, 2015 4:05 am
Points :3055
Contact:

Re: GET REPONSE command with JCOP card

Post by UNKNwYSHSA » Thu Dec 17, 2015 12:01 pm

Illegal use of method apdu.sendBytesLong()???
sense and simplicity

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 36 guests

JavaCard OS : Disclaimer