Page 1 of 1

how to solve this question?

Posted: Thu Oct 25, 2018 10:25 pm
by happy123654
hello, every boy, who can help me to resolve this question?

Now, I use my tool to test my java cos. there is a test case failure in T0 protocol and success in T1 or TCL.
the command is as followed:
send: 80050000
the right response: 256 bytes data +SW.
the real response: The tool cannot receive anything.

If I modify the commad as followed:
send:80500000
the right response: 255 bytes data +SW
the real response: ==the right response

Re: how to solve this question?

Posted: Thu Oct 25, 2018 10:38 pm
by later123654
hello, you can provide your code here which can help me to parse this question.

Re: how to solve this question?

Posted: Thu Oct 25, 2018 10:52 pm
by happy123654
public void process(APDU apdu)
{
if (selectingApplet())
{
return;
}

byte[] buf = apdu.getBuffer();
switch (buf[ISO7816.OFFSET_INS])
{
case (byte)0x01:
Util.arrayFillNonAtomic(buf, (short)0, (short)256, (byte)0xaa);
apdu.setOutgoingAndSend((short)0, (short)256);
break;
case (byte)0x02:
Util.arrayFillNonAtomic(buf, (short)0, (short)256, (byte)0xbb);
apdu.setOutgoingAndSend((short)0, (short)255);
break;
default:
ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
}
}

Re: how to solve this question?

Posted: Thu Oct 25, 2018 10:55 pm
by later123654
I test the code and the command with JCOP card and the question is still exist.
But the command is ok:
the command( 8005000000) can return 256 bytest data.

so you can modify the command.

Re: how to solve this question?

Posted: Thu Oct 25, 2018 10:57 pm
by happy123654
hello boy. I modify my command to be 8005000000 and I can get the right response.

but why?

Re: how to solve this question?

Posted: Thu Oct 25, 2018 11:32 pm
by later123654
I guess the reason : the reader handle the command as case 1 and refuse the response data from the card.

Re: how to solve this question?

Posted: Thu Oct 25, 2018 11:33 pm
by happy123654
i see and thanks very much!

Re: how to solve this question?

Posted: Wed Oct 31, 2018 2:46 am
by BirdKing
T0 is an imperfect protocol. It claims the applet and host on pc knows how many bytes will be translated. You may add setIncomingAndReceive() and try this apdu again.