This discussion is archived
11 Replies Latest reply: Oct 24, 2013 6:27 AM by 966575 RSS

Chaining in T=1 protocol in javacard for data_size>256

966575 Newbie
Currently Being Moderated

Dear Friends

I have a problem that confused me a couple of days. I want to send out data which has size bigger than 256. I found some sample codes in web. these codes like this:

private void sendData(APDU apdu) {

        // work out how many bytes to send this time and how many will be left

        BUF_IN_OFFSET[0] = 0;

     

       

        short remain = (short) ((short)372 - BUF_IN_OFFSET[0]);

        boolean chain = remain > MAX_APDU;

        short sendLen = chain ? MAX_APDU : remain;

       

        // Get ready to send

        apdu.setOutgoing();

        apdu.setOutgoingLength((short)sendLen);

        apdu.sendBytesLong(data, BUF_IN_OFFSET[0], sendLen);

       

         // Check to see if there are more APDU's to send

        if (chain) {

            BUF_IN_OFFSET[0] += sendLen; // count the bytes sent

            remain -=sendLen;

            ISOException.throwIt((short)(ISO7816.SW_BYTES_REMAINING_00 + remain));

           

        } else {

            BUF_IN_OFFSET[0] = 0; // no more bytes to send

        }

 

    }

 

When i execute this code on netbeans simulator it works currectly and response 61xx status word. but when i execute on real card (smartcafe 3.2 expert) it response 9000 and doesn't return remained data length. My card support both T=0/1 protocol and and i guess the used protocol related to this problem, or it may have another problem.

does this code executed for T=1 protocol correctly?

anyone can help me?

Thanks in advance.

Mohsen Mgh

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points