readBinaryBySFI method

Future<ResponseAPDU> readBinaryBySFI({
  1. required int sfi,
  2. required int offset,
  3. required int ne,
  4. int cla = ISO7816_CLA.NO_SM,
})

Sends READ BINARY command to ICC. It returns file's ne long chunk of data at offset. File is identified by sfi. Max offset can be 255. Can throw ICCError if R-APDU returns no data and error status or ComProviderError.

Implementation

Future<ResponseAPDU> readBinaryBySFI({ required int sfi, required int offset, required int ne, int cla = ISO7816_CLA.NO_SM }) async {
  if(offset >  255) {
    throw ArgumentError.value(offset, null, "readBinaryBySFI: Max offset can be 256 bytes");
  }
  if((sfi & 0x80) == 0) { // bit 8 must be set
    throw ArgumentError.value(offset, null, "readBinaryBySFI: Invalid SFI identifier");
  }

  return await _readBinary(
    CommandAPDU(cla: cla, ins: ISO7816_INS.READ_BINARY, p1: sfi, p2: offset, ne: ne)
  );
}