-
Notifications
You must be signed in to change notification settings - Fork 67
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
Relax p1 to use it as an optional feature bitmap #133
Conversation
src/boilerplate/dispatcher.c
Outdated
@@ -127,7 +127,7 @@ void apdu_dispatcher(command_descriptor_t const cmd_descriptors[], | |||
|
|||
G_dispatcher_context.read_buffer = buffer_create(cmd->data, cmd->lc); | |||
|
|||
if (cmd->p1 != 0 || cmd->p2 > 1) { | |||
if (cmd->p2 > 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit : If this 1 value corresponds to the protocol version maybe a comment or a define could be nice ? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, added a constant in 4b199ce (and rebase to the current develop
).
SonarCloud Quality Gate failed. |
Codecov ReportPatch and project coverage have no change.
Additional details and impacted files@@ Coverage Diff @@
## develop #133 +/- ##
========================================
Coverage 83.96% 83.96%
========================================
Files 17 17
Lines 2189 2189
========================================
Hits 1838 1838
Misses 351 351
Flags with carried forward coverage won't be shown. Click here to find out more. Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
For some future use cases, it might be useful to have some additional optional features that can be activated by a client that supports them, but do not otherwise disrupt the normal flow of operations.
The
p1
APDU field is currently unused and forced to be 0.By relaxing the requirement and ignoring the value of
p1
we guarantee that such optional features can be added without breaking forward-compatibility or forcing a protocol version upgrade (which instead uses thep2
field).I also added a test to make sure that a
p2
value higher than the current protocol version is rejected; for the protocol version we prefer explicit opt-in, instead − it would generally be used for more drastic breaking changes to the protocol.