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

Relax p1 to use it as an optional feature bitmap #133

Merged
merged 3 commits into from
Mar 31, 2023
Merged

Relax p1 to use it as an optional feature bitmap #133

merged 3 commits into from
Mar 31, 2023

Conversation

bigspider
Copy link
Collaborator

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 the p2field).

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.

@@ -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) {
Copy link
Contributor

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 ? :)

Copy link
Collaborator Author

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
Copy link

sonarcloud bot commented Mar 31, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@codecov-commenter
Copy link

Codecov Report

Patch and project coverage have no change.

Comparison is base (192031a) 83.96% compared to head (4b199ce) 83.96%.

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           
Flag Coverage Δ
unittests 83.96% <ø> (ø)

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

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

3 participants