Our Online Store have the new products: RFID antenna board. Currently it can work with JC10M24R and JCOP4 card chips.
Compared with normal cards, the antenna board module has a smaller size and fixed holes, which is easy to integrate in the IOT(Internet Of Things) project.

proccess() function isn't receive full apdu command from host?

JavaCard Applet Development Related Questions and Answers.
leonard
Posts: 25
Joined: Wed Nov 18, 2015 12:13 am
Points :176
Contact:

proccess() function isn't receive full apdu command from host?

Post by leonard » Tue Dec 08, 2015 3:03 am

The host send the command bellow to applet to select EF file:
apdu : "00 A4 02 00 02 40 01".
The purpose is select EF file with ID = "40 01" which specify in data field of the command. But when I debug at process() function, the buffer of apdu only consist 5 first- bytes "00 A4 02 00 02", data field set to "00 00". So my applet can not select the EF using EF ID.
Could you tell me what is wrong in apdu command above? Many thanks
You do not have the required permissions to view the files attached to this post. Please login first.

predators
Posts: 21
Joined: Wed Aug 19, 2015 7:18 am
Points :12
Contact:

Re: proccess() function isn't receive full apdu command from host?

Post by predators » Tue Dec 08, 2015 3:34 am

Perhaps the protocol you are using is T0.

Generally, you need to call setIncomingAndReceive () function. It will help you get as many bytes as will fit without buffer overflow in the APDU buffer following the header. It gets all the incoming bytes if they fit.

You can check your source code and the using protocol.

leonard
Posts: 25
Joined: Wed Nov 18, 2015 12:13 am
Points :176
Contact:

Re: proccess() function isn't receive full apdu command from host?

Post by leonard » Tue Dec 08, 2015 4:49 am

predators wrote:Perhaps the protocol you are using is T0.

Generally, you need to call setIncomingAndReceive () function. It will help you get as many bytes as will fit without buffer overflow in the APDU buffer following the header. It gets all the incoming bytes if they fit.

You can check your source code and the using protocol.


Thanks for your help!
In process() function, I call apdu.setIncomingAndReceive(). It get as many bytes as fit without buffer as you said. My applet successful select EF.

But could you help me solve one more problem?
After select EF, host send command bellow to read record "0x10" with "0x05" byte length of current EF.
command: 00 B2 10 04 05

Applet suppose to call readRecord() function when receive this command.
But in process() function, applet just run to setIncomingAndReceive() then don't run any more, don't return any SW bytes and also don't call readRecord() function.
When I comment out setIncomingAndReceive() function, it work and execute the readRecord() function.

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

Re: proccess() function isn't receive full apdu command from host?

Post by UNKNwYSHSA » Tue Dec 08, 2015 5:07 am

This method APDU.setIncomingAndReceive() should only be called on a case 3 or case 4 command.
The command "00 B2 10 04 05" is case 2.
So you need not invoke this method in this command processing.
sense and simplicity

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

Re: proccess() function isn't receive full apdu command from host?

Post by UNKNwYSHSA » Tue Dec 08, 2015 5:13 am

The code is as following:

Code: Select all

byte ins = buf[ISO7816.OFFSET_INS];
switch (ins)
{
    case (byte)0xA4:
    {
        short lc = apdu.setIncomingAndReceive(...);
        // Command processing;
        // ...;
    } break;
    case (byte)0xB2:
    {
        // Command processing;
        // ...;
    } break;

}

Notice: When you coding, you must understand CASE of the APDU command which you are coding for.
sense and simplicity

Post Reply Previous topicNext topic

Who is online

Users browsing this forum: No registered users and 47 guests

JavaCard OS : Disclaimer