Page 1 of 1

sendBytesLong()

Posted: Thu Jun 30, 2016 4:20 am
by Heerden
In the introduction of APDU in Java card API document, it shows "For sending large byte arrays as response data, the APDU class provides a special method sendBytesLong() which manages the APDU buffer." But how does it help to send large byte arrays? Why is this method to manage the APDU buffer? I can not see any useful information.

Here is the description of sendBytesLong

public void sendBytesLong(byte[] outData,
short bOff,
short len)
throws APDUException,
SecurityException

Sends len more bytes from outData byte array starting at specified offset bOff.
If the last of the response is being sent by the invocation of this method, the APDU buffer must not be altered. If the data is altered, incorrect output may be sent to the CAD. Requiring that the buffer not be altered allows the implementation to reduce protocol overhead by transmitting the last part of the response along with the status bytes.

The Java Card runtime environment may use the APDU buffer to send data to the CAD.


Re: sendBytesLong()

Posted: Fri Jul 01, 2016 5:01 am
by mabel
If you have a buffer that is larger than the APDU buffer, you can directly send from that buffer. But you still have the same restrictions on data length that can be sent in one APDU response but you do not need to copy into the APDU buffer for each response. You still need to use APDU response chaining to send more data than you card supports.

Re: sendBytesLong()

Posted: Fri Jul 01, 2016 5:55 am
by Tarantino
The method "sendBytesLong(...)" is to send data in working buffer larger than APDU buffer.