Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid reading Elementary File beyond the EOF #57

Closed
sfaragnaus opened this issue Apr 14, 2018 · 1 comment
Closed

Avoid reading Elementary File beyond the EOF #57

sfaragnaus opened this issue Apr 14, 2018 · 1 comment
Assignees

Comments

@sfaragnaus
Copy link

Currently the read_file() reads in chunk of 128 bytes till it obtains a 'wrong length' error from the card. The behaviour on the EOF could be vendor-specific and could not work with future manufacturer, so it would be best to read the File Control Block (containing the file size) and then read the exact length, thus avoiding the EOF.

Same as: italia/cie-nis-cpp-sdk#39 (comment)

@fottavi
Copy link
Collaborator

fottavi commented Apr 16, 2018

Actually the end-of-file behavior on IAS application is fixed. See IAS_ECC_v1.0.1 spec, pag 147, Table 34:
'6B00' - Wrong parameters P1-P2 : Offset + length is beyond the end of file
So we can expect it not to change between manifacturers.

Anyway, that's a good point. On ICAO all DGs are ASN.1 structures, so the lenght is encoded at the beginning of the file (the file could be bigger than the data structure inside, so reading ASN.1 lenght is be better that reading FCI). On IAS file system it's not always true, so we could have 2 different functions to read a file, one for ASN.1 structure and one for flat binary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants