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

ecp.c: Refactored a minor check in ecp check privkey #9494

Conversation

minosgalanakis
Copy link
Contributor

@minosgalanakis minosgalanakis commented Aug 21, 2024

Description

Added a comment based on an investigation we did at the functional behaviour of a check.

PR checklist

Please remove the segment/s on either side of the | symbol as appropriate, and add any relevant link/s to the end of the line.
If the provided content is part of the present PR remove the # symbol.

Notes for the submitter

Please refer to the contributing guidelines, especially the
checklist for PR contributors.

Help make review efficient:

  • Multiple simple commits
    • please structure your PR into a series of small commits, each of which does one thing
  • Avoid force-push
    • please do not force-push to update your PR - just add new commit(s)
  • See our Guidelines for Contributors for more details about the review process.

@minosgalanakis minosgalanakis added needs-review Every commit must be reviewed by at least two team members, needs-backports Backports are missing or are pending review and approval. needs-reviewer This PR needs someone to pick it up for review priority-low Low priority - this may not receive review soon size-xs Estimated task size: extra small (a few hours at most) labels Aug 21, 2024
Copy link
Contributor

@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.

The comment isn't right.

Comment on lines 2917 to 2919
/* Zero limb mpis are invalid, but even if
one is provided for d, the grp->nbits
can not be equal to UINT64_MAX. */
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, this comment is wrong.

Zero limb mpis are invalid

  1. Zero-limb mbedtls_mpi are perfectly valid to represent the value 0.
  2. Zero-limb MPIs are not relevant here. mbedtls_mpi_bitlen(d) is 0 when the value of d is 0, regardless of how many limbs are used to represent it.

can not be equal to UINT64_MAX

UINT64_MAX is irrelevant here, you meant SIZE_MAX. This computation doesn't involve uint64_t values. Both mbedtls_mpi_bitlen(d) and grp->nbits are size_t values.

tf-psa-crypto/drivers/builtin/src/ecp.c Outdated Show resolved Hide resolved
@gilles-peskine-arm gilles-peskine-arm added needs-work priority-medium Medium priority - this can be reviewed as time permits and removed needs-review Every commit must be reviewed by at least two team members, needs-backports Backports are missing or are pending review and approval. needs-reviewer This PR needs someone to pick it up for review priority-low Low priority - this may not receive review soon labels Aug 22, 2024
Co-authored-by: Gilles Peskine <[email protected]>
Signed-off-by: minosgalanakis <[email protected]>
@minosgalanakis minosgalanakis force-pushed the doc/add_mbedtls_ecp_check_privkey_comment branch from 0708460 to 991c658 Compare August 22, 2024 12:37
@minosgalanakis minosgalanakis changed the title ecp.c: Added minor comment ecp.c: Refactored a minor check Aug 22, 2024
@minosgalanakis minosgalanakis changed the title ecp.c: Refactored a minor check ecp.c: Refactored a minor check in ecp check privkey Aug 22, 2024
@minosgalanakis minosgalanakis added needs-review Every commit must be reviewed by at least two team members, needs-ci Needs to pass CI tests needs-reviewer This PR needs someone to pick it up for review and removed needs-work labels Aug 22, 2024
Copy link
Contributor

@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.

LGTM

@minosgalanakis
Copy link
Contributor Author

This PR has been migrated to the TF-PSA-Framework PR166

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-ci Needs to pass CI tests needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review priority-medium Medium priority - this can be reviewed as time permits size-xs Estimated task size: extra small (a few hours at most)
Projects
Development

Successfully merging this pull request may close these issues.

2 participants