JavaCard Applet Development Related Questions and Answers.
-
Harten
- Posts: 12
- Joined: Tue Nov 17, 2015 7:41 am
- Points :96
-
Contact:
Post
by Harten » Fri Mar 11, 2016 4:02 am
I saw a piece of code from other website. But I don't know what this code does. Please help me to understand this well. Thanks a lot.
Code: Select all
short lc = (short) (a[ISO7816.OFFSET_LC] & 0xff);
short read = apdu.setIncomingAndReceive();
while(read < lc)
{
read += apdu.receiveBytes(read);
}
-
vermont
- Posts: 13
- Joined: Tue May 26, 2015 10:18 pm
- Points :6
-
Contact:
Post
by vermont » Fri Mar 18, 2016 11:29 pm
Here is the comments version.
Code: Select all
// Get the Lc from a standard length APDU. In JC2.2.2 use the Apdu methods for Lc.
short lc = (short) (a[ISO7816.OFFSET_LC] & 0xff);
// Ask the OS to read the incoming APDU.
short read = apdu.setIncomingAndReceive();
// Check how much was read. The OS may not be able to read the entire APDU in one call.
while(read < lc) {
// Keep reading until the OS has read all of the data in the APDU buffer.
read += apdu.receiveBytes(read);
}
-
pitbar
- Posts: 22
- Joined: Wed Dec 02, 2015 5:39 am
- Points :93
-
Contact:
Post
by pitbar » Sat Mar 19, 2016 3:53 am
Code: Select all
short lc = (short) (a[ISO7816.OFFSET_LC] & 0xff);
It's the standard way to compute Lc byte.
Code: Select all
short read = apdu.setIncomingAndReceive();
This line is to get at least the beginning of the incoming data in the APDU buffer.
Code: Select all
while(read < lc)
{
read += apdu.receiveBytes(read);
}
Appends whatever additional bytes
receiveBytes returns, update
read as this process goes.
Users browsing this forum: No registered users and 58 guests
JavaCard OS : Disclaimer
Board Disclaimer
The views and comments posted in these fora are personal and do not necessarily represent the those of the Management of JavaCard OS.
The Management of JavaCard OS does not, under any circumstances whatsoever, accept any responsibility for any advice, or recommentations, made by, or implied by, any member or guest vistor of JavaCard OS that results in any loss whatsoever in any manner to a member of JavaCard OS, or to any other person.
Furthermore, the Management of JavaCard OS is not, and cannot be, responsible for the content of any other Internet site(s) that have been linked to from JavaCard OS.