Skip to content

Fix useless calls in PSA crypto metadata tests #378

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

Merged

Conversation

ronald-cron-arm
Copy link
Collaborator

In ecc_key_family test, the parity of the elliptic curve identifier
was computed but not tested to be even.

In dh_key_family test, the parity of the PSA Diffie-Hellman group
identifier was computed but not tested to be even.

Signed-off-by: Ronald Cron [email protected]

@ronald-cron-arm ronald-cron-arm added bug Something isn't working needs: review The pull request is ready for review. This generally means that it has no known issues. labels Feb 28, 2020
Copy link
Collaborator

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the small size of the patch and the fact that the commit needs to be split anyway, please force-push a new history.

/* Check the parity of value.
* Return 0 if value has even parity and a nonzero value otherwise. */
int test_parity( uint32_t value )
/* Check if the parity of value is even.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please comment the why in preference to the what. The job of this function is to test whether the parity is whichever parity is expected for numerical values. The fact that it's even parity is a detail.

See the discussion in #330 (comment) . This discussion also highlights that “even parity” is not such good documentation: Jaeden calls it “odd parity”!

My bad for not documenting why we're checking the parity of some values. Here's some proposed documentation.

/* Check the parity of value.
 * Numerical encodings of key types and related values such as EC curves and
 * DH groups should all have the same parity. This guarantees that a
 * single-bit error will be detected.
 * The expected parity is even because this makes all-bits-zero valid.
 */
int test_parity( uint32_t value )

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed the function documentation taking into account your proposal. Please have a look to the new version.

/* Check the parity of value.
* Return 0 if value has even parity and a nonzero value otherwise. */
int test_parity( uint32_t value )
/* Check if the parity of value is even.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't combine unrelated things into the same commit. Here you have a commit that does four things: adding documentation, renaming a function, changing the return value, and adding the missing TEST_ASSERT calls. Adding documentation could go with changing the return value but the other three should be separate.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't rename the function and don't change the return value anymore. Two commits now: the first one fix/improve the documentation of the test_parity() function. The second one fixes the useless calls.

@gilles-peskine-arm gilles-peskine-arm added needs: work The pull request needs rework before it can be merged. and removed needs: review The pull request is ready for review. This generally means that it has no known issues. labels Mar 2, 2020
@ronald-cron-arm ronald-cron-arm force-pushed the psa_crypto_metadata-test_parity branch from 2563f92 to 685764f Compare March 2, 2020 13:57
Fix and improve the documentation of the test_parity() function in PSA
crypto metadata tests:

. Align the short description of the function with the function name:
  "Test ..." instead of "Check ..."
. Fix the description of the returned value: the returned value is
  nonzero, not zero, if the parity is even.
. Add documentation explaining the needs for parity testing and that
  the parity is expected to be even.

Signed-off-by: Ronald Cron <[email protected]>
In ecc_key_family test, the parity of the elliptic curve identifier
was computed but not tested to be even.

In dh_key_family test, the parity of the PSA Diffie-Hellman group
identifier was computed but not tested to be even.

Signed-off-by: Ronald Cron <[email protected]>
@ronald-cron-arm ronald-cron-arm force-pushed the psa_crypto_metadata-test_parity branch from 685764f to 3876f4a Compare March 2, 2020 15:09
@ronald-cron-arm ronald-cron-arm added needs: review The pull request is ready for review. This generally means that it has no known issues. and removed needs: work The pull request needs rework before it can be merged. labels Mar 2, 2020
Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mpg
Copy link
Contributor

mpg commented Mar 26, 2020

Everything passed in the CI except for mbed-os and iar tests which are known issues.

@mpg mpg added ready for merge Design and code approved, CI passed, and likewise for backports. Label added by gatekeepers only. and removed needs: review The pull request is ready for review. This generally means that it has no known issues. labels Mar 26, 2020
@mpg mpg merged commit 3ce31aa into ARMmbed:development Mar 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready for merge Design and code approved, CI passed, and likewise for backports. Label added by gatekeepers only.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants