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

API client status word checking improvements #236

Open
kingofpayne opened this issue Jul 30, 2021 · 0 comments
Open

API client status word checking improvements #236

kingofpayne opened this issue Jul 30, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@kingofpayne
Copy link
Contributor

Current apdu_exchange and apdu_exchange_nowait methods of SpeculosClient strips off and check automatically the status word from the device response.

def receive(self) -> bytes:
check_status_code(self.response, "/apdu")
data, status = split_apdu(bytes.fromhex(self.response.json()["data"]))
if status != 0x9000:
raise ApduException(status, data)
return data

In particular, it only checks that the status word is 0x9000, and there are other status words which should not be considered as errors, such as: 0x61XX, 0x9100, 0x9200 (as described in https://www.eftlab.com/knowledge-base/complete-list-of-apdu-responses/).

In a corner case example, a test may want to check that the returned status word is 0x61XX (and verify XX has the correct value) and consider 0x9000 as invalid, which I is not possible currently. This status word also conveys information that must be retrieved by the caller.

Delegating the status word check to the client is very convenient in most cases, but this shall not be mandatory.

Side note: Tests using speculos may want to verify that error status words are correctly returned in defined cases. This can be done currently by catching the exception and inspecting it.

@kingofpayne kingofpayne added the enhancement New feature or request label Jul 30, 2021
kingofpayne added a commit that referenced this issue Jul 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant