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

Add support for extended length APDUs #4

Closed
mistial-dev opened this issue Dec 29, 2022 · 8 comments
Closed

Add support for extended length APDUs #4

mistial-dev opened this issue Dec 29, 2022 · 8 comments
Assignees

Comments

@mistial-dev
Copy link
Contributor

mistial-dev commented Dec 29, 2022

At present, APDUs greater than a single byte are not supported:

/// Only short C-APDU (Le, Lc coded on 1 byte) are now supported.

I'm going to be adding support here for longer APDUs, and am filing an issue here to reference in commits and pull requests.

@wsct
Copy link
Owner

wsct commented Dec 29, 2022

I should have handled Lc and Le coded on multiple bytes from the beginning of the project, but I didn't for historical reasons.
May I suggest the introduction of Nc and Ne properties along the existing Lc and Le ? (Lc codes Nc, Le codes Ne, as defined by the ISO/IEC 7816).
I'll be happy to study any merge request that tries to fix this without impacting the other existing plugins and projects.

@mistial-dev
Copy link
Contributor Author

I should have handled Lc and Le coded on multiple bytes from the beginning of the project, but I didn't for historical reasons. May I suggest the introduction of Nc and Ne properties along the existing Lc and Le ? (Lc codes Nc, Le codes Ne, as defined by the ISO/IEC 7816). I'll be happy to study any merge request that tries to fix this without impacting the other existing plugins and projects.

Ok.

I'm interested in maintaining compatibility as well. I'm on ARM mac, and there are issues with PCSC.Net on this platform. I'm switching the code I have that uses it over to WSCT-Core, because it "just works". Most of it uses standard length APDUs, but some of it uses extended.

I'll implement Nc and Ne to keep consistency with the standard.

@mistial-dev
Copy link
Contributor Author

mistial-dev commented Dec 31, 2022

@wsct Is this the kind of thing you were thinking of?

https://github.com/mistial-dev/WSCT-Core/commit/d95e9ce5a269e3b4f29622f2acbaedaffab63e0b

There is still some work to do, just wanted to make sure I wasn't going to cause conflicts or problems.

@wsct
Copy link
Owner

wsct commented Dec 31, 2022

It looks good to me, you successfully grabbed what I was thinking.
The introduction of Nc and Ne should allow existing plugins/app working with short CCx to still do their work, while allowing extended CC to be supported by new or updated plugins.

@mistial-dev
Copy link
Contributor Author

Sounds good. I'll add a bit more testing and exceptions out, then get it out as a Pull Request.

@mistial-dev
Copy link
Contributor Author

mistial-dev commented Dec 31, 2022

@wsct XML backwards compatibility requires a minor change. Obviously, if there's a length more than 255, it can be inferred that it must be extended length. When having XML like this, though:

<commandAPDU cla=... ins=... p1=... p2=... (le=...) > udc </commandAPDU>

I can't necessarily tell if it's extended or regular length without doing a multi-byte length encoding. I can do Le=XXXX for example (even for a value < 256), but it gets interesting when Le is missing, and UDC is less than 256 bytes.

There's no way to encode that "I want an extended APDU, no Le, a couple bytes of UDC" with the current XML setup.

@mistial-dev
Copy link
Contributor Author

Spent a bit of time working on the XML serialization, and was able to keep it backwards-compatible and maintain the same XML for non-extended command APDUs.

It was necessary to add an extended attribute, but that will not interfere with existing serialized XML.

https://github.com/mistial-dev/WSCT-Core/commit/1fc2e7a48ac6b7f60f7526741a4f0ceeb68ffdaf

I also implemented equality checking to help with the testing.

@wsct
Copy link
Owner

wsct commented Jan 2, 2023

WSCT.Core package updated to 6.3.0 on nuget and github packages.
Thank you!

@wsct wsct closed this as completed Jan 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants