Skip to content

Treat an absent Le as up to 256 bytes like a YubiKey - #34

Closed
FlorianFranzen wants to merge 1 commit into
trussed-dev:mainfrom
FlorianFranzen:fix/absent-le
Closed

FlorianFranzen wants to merge 1 commit into
trussed-dev:mainfrom
FlorianFranzen:fix/absent-le

Conversation

@FlorianFranzen

@FlorianFranzen FlorianFranzen commented Oct 6, 2026 •

Copy link
Copy Markdown

Yubico ecosystem clients (ykman, yubico-piv-tool, yubikey.rs) send case 3 APDUs without an Le byte and never issue GET RESPONSE after a plain SELECT. apdu-dispatch currently treats the absent Le as "no response data expected" and answers 61XX with the data held back, which loses those clients entirely. A real YubiKey returns up to 256 bytes directly and chunks only what exceeds that over GET RESPONSE.

Covered by a new echo_without_le dispatch test; also validated end to end against ykman and yubikey.rs through piv-authenticator's vpicc virtual card.

@robin-nitrokey

Copy link
Copy Markdown
Member

Thank you for bringing up this issue. The ISO 7816-4 standard explicitly says (§ 5.1):

Le field: Absent for encoding Ne = 0, present for encoding Ne > 0
Ne denotes the maximum number of bytes expected in the response data field. The Le field encodes Ne.
If the Le field is absent, then Ne is zero.
Therefore in any command-response pair, the absence of Le field is the standard way for receiving no response data field.

For the SELECT command specifically, it says (§ 7.1.1):

If the Le field is absent, i.e., for returning no file control information, then the response data field shall also be absent.

So I think we implement the specified behavior correctly and I’m reluctant to deviate from the spec just because the Yubikey does so. Or do you see a reason why this behavior would also be covered by the standard?

@FlorianFranzen

Copy link
Copy Markdown
Author

Wow, you are completely right. Turns out yubikey.rs just treated 61XX after SELECT as an error (iqlusioninc/yubikey.rs#663). 🤦

I was debugging this to long, I just convinced myself this must be the issue. Looked at the trace logs again and ykman actually never showed that behavior.

Anyhow, sorry for the noise.

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

Successfully merging this pull request may close these issues.

2 participants