Use READ BINARY to read more than 256 bytes

后端 未结 5 2096
小鲜肉
小鲜肉 2020-12-10 15:40

I am trying to read a smartcard(German Gesundheitskarte) using javax.smartcardio

In the definition of the EF \"PD\" its length is specified as 850 bytes. The conten

5条回答
  •  借酒劲吻你
    2020-12-10 16:12

    A small addition to the IMO very helpful answer by Maarten Bodewes about reading larger files, and the suggestion by stajo to use extended Le. I hope this saves others some time and effort.

    Trying to use Le for long reads is tricky:

    • Extended Le requires to use extended Lc as well.
    • Extended Lc must not be 0, according to the standard, so you cannot start at offset 0
    • And if your Lc is not 0, you need to use the "B1" INS.
    • The B1 then makes it a bit more complicated to calculate the correct sizes, as Maarten Bodewes explained.

    In addition to that, you need to find out first whether the card supports extended Lc/Le at all; the information about this is spread over the ATR historical bytes, the EF.ATR, and the current EF info.

    So while it is possible in theory to read large batches of data from a single file, it is a lot of effort in practice, and you cannot do read the entire file with one command either.

    Consider above before you take the effort to use extended Le for reading.

提交回复
热议问题