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

Make the Relay card still parse and log the APDU #103

Closed
wants to merge 3 commits into from

Conversation

yoe
Copy link

@yoe yoe commented Jun 9, 2017

The basic VirtualSmartcard implementation parses and logs the APDU sent
to the card in the execute instance method, and logs the received APDU
after calling that method.

The Relay implementation, however, overrides the execute method, but
does not log it. The result, when running at the info log level, is that
you see the reply from the card, but not the request from the
application. This is confusing.

Additionally, if the relay implementation shows the request APDU, then
it can be used as a method to analyze what an application is trying to
do.

To remedy all that, parse the APDU and log that parsed value, but don't
do anything further with it.

Signed-off-by: Wouter Verhelst [email protected]

The basic VirtualSmartcard implementation parses and logs the APDU sent
to the card in the execute instance method, and logs the received APDU
after calling that method.

The Relay implementation, however, overrides the execute method, but
does not log it. The result, when running at the info log level, is that
you see the reply from the card, but not the request from the
application. This is confusing.

Additionally, if the relay implementation shows the request APDU, then
it can be used as a method to analyze what an application is trying to
do.

To remedy all that, parse the APDU and log that parsed value, but don't
do anything further with it.

Signed-off-by: Wouter Verhelst <[email protected]>
@frankmorgner
Copy link
Owner

The current behavior is odd, indeed. Thanks for the report!

However, logging the APDUs (command/response) should only be done in execute. The APDU format does not apply to all cards. Specifically, the Relay card should not parse or dump an APDU; instead it could dump the buffer as hex.

@yoe
Copy link
Author

yoe commented Jun 10, 2017

Yes, good point. At the same time, often it's helpful to still get a parsed APDU in the log.

I'll add a command-line parameter --log-unparsed or some such so that the user can ask for APDU's to not be parsed if that makes sense, but still default to using the parsed log format.

Does that make sense?

Some unknown cards, which the Relay card may need to deal with, may not
use the APDU format. Trying to parse commands sent to those cards as
though they were in the APDU format is obviously wrong. However, most
cards do support APDU, so default to logging parsed APDUs, still.
@yoe
Copy link
Author

yoe commented Jun 14, 2017

I've done that, and pushed another commit to this pull request . Please review.

@frankmorgner
Copy link
Owner

Sorry for the late feedback.

I still wonder if we could get around the extra option. Would it be possible to try parsing and printing the APDU and only hexdump the buffer when the parsing fails?

@yoe
Copy link
Author

yoe commented Jun 20, 2017

No worries.

I suppose that's a good idea too, and shouldn't be too hard. I'll look into it.

Don't switch to logging unparsed messages upon command line parameters;
instead, switch to doing so if parsing fails.
bowb pushed a commit to bowb/vsmartcard that referenced this pull request Mar 6, 2023
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.

None yet

2 participants