Skip to content

Implement psa_hash_compute and psa_hash_compare #327

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
merged 9 commits into from
Jan 31, 2020

Conversation

gilles-peskine-arm
Copy link
Collaborator

@gilles-peskine-arm gilles-peskine-arm commented Nov 28, 2019

A step on the way to IOTCRYPT-933

If #179 is merged first, this PR will need to be modified to add test case dependencies on !MBEDTLS_SHA512_NO_SHA384.

@gilles-peskine-arm gilles-peskine-arm added needs: preceding PR Requires another PR to be merged first needs: ci Needs a passing full CI run needs: work The pull request needs rework before it can be merged. labels Nov 28, 2019
@gilles-peskine-arm
Copy link
Collaborator Author

CI passed except for expected failures (inherited from #325): an ABI change (two external symbols have been renamed) and generated files in TLS (due to the new header).

@gilles-peskine-arm gilles-peskine-arm added needs: review The pull request is ready for review. This generally means that it has no known issues. and removed needs: ci Needs a passing full CI run needs: work The pull request needs rework before it can be merged. labels Dec 2, 2019
@gilles-peskine-arm gilles-peskine-arm added needs: ci Needs a passing full CI run and removed needs: preceding PR Requires another PR to be merged first labels Dec 6, 2019
@gilles-peskine-arm
Copy link
Collaborator Author

CI succeeded except for check_generated_files.sh in TLS which is expected to fail until the crypto submodule is updated to include crypto_compat.h in the VS project template.

@mpg mpg self-requested a review January 28, 2020 11:33
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.

I'm happy with what I see, except a few notes and questions.

I'm a bit more concerned about what I don't see: do we have an all.sh component that builds without MD_C an runs the test suite that way? I'm not seeing one but perhaps I missed something. I'm not very comfortable approving the massing changes in test dependencies on MD_C without an automated test that confirms the new dependencies are correct.

@mpg
Copy link
Contributor

mpg commented Jan 28, 2020

Also, a conflict has developed and needs to be resolved.

@mpg mpg added the needs: work The pull request needs rework before it can be merged. label Jan 28, 2020
@gilles-peskine-arm
Copy link
Collaborator Author

gilles-peskine-arm commented Jan 28, 2020

I rebased to avoid the merge conflict. I kept the same history except for the missing blank line between two test cases. The previous version is in https://github.com/gilles-peskine-arm/mbed-crypto/tree/psa-hash_compute-3

@gilles-peskine-arm
Copy link
Collaborator Author

We don't run any tests without MBEDTLS_MD_C. There isn't much you can do without it! I made the changes because I prefer to be more correct, even if we can't be absolutely correct.

@gilles-peskine-arm gilles-peskine-arm removed the needs: work The pull request needs rework before it can be merged. label Jan 28, 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.

Thanks for making the requested changes and fixing the conflict. I'm mostly happy now, except for a naming issue that I failed to notice the first time round.

mpg
mpg previously approved these changes Jan 29, 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.

Thanks for fixing the naming issue. I'm happy with the result.

@mpg
Copy link
Contributor

mpg commented Jan 30, 2020

@gilles-peskine-arm Just to notify you that #179 was just merged, so this will need a few !MBEDTLS_SHA512_NO_SHA384 in relevant places now. Also, there's a conflict in test_suite_psa_crypto.data which is probably related to dependencies being updated on both sides as well.

The PSA implementation of hash algorithms, HMAC algorithms and KDF
algorithms using HMAC no longer use the MD module.
The PSA implementations of deterministic ECDSA, of all RSA signatures
and of RSA OAEP use the MD module.
Whether a parameter should be const is an implementation detail of the
function, so don't declare a parameter of psa_hash_compare as
const. (This only applies to parameters themselves, not to objects
that pointer parameters points to.)
psa_hash_compare is tested for good cases and invalid-signature cases
in hash_compute_compare. Also test invalid-argument cases. Also run a
few autonomous test cases with valid arguments.
@gilles-peskine-arm
Copy link
Collaborator Author

Rebased again (previous iteration in https://github.com/gilles-peskine-arm/mbed-crypto/tree/psa-hash_compute-5):

  • "Implement and test psa_hash_compute, psa_hash_compare": added !MBEDTLS_SHA512_NO_SHA384 to the one new SHA-384 test case.
  • "Remove obsolete dependencies on MBEDTLS_MD_C", "Add missing dependencies on MBEDTLS_MD_C": do it to the same test cases, from the updated dependencies.

Copy link
Collaborator

@yanesca yanesca left a comment

Choose a reason for hiding this comment

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

It looks good to me in general, I just have two questions.

@gilles-peskine-arm gilles-peskine-arm changed the title Implement psa_hash_compute and psa_hash_verify Implement psa_hash_compute and psa_hash_compare Jan 30, 2020
@gilles-peskine-arm
Copy link
Collaborator Author

CI passes except for Mbed OS jobs which is a known preexisting issue.

yanesca
yanesca previously approved these changes Jan 30, 2020
Copy link
Collaborator

@yanesca yanesca left a comment

Choose a reason for hiding this comment

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

LGTM.

An earlier commit fixed this for psa_hash_compare. psa_mac_verify had
the same flaw.
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 Jan 31, 2020

After the latest commit, the CI is still passing except for Mbed OS tests which are a known issue independent from this PR.

@mpg mpg added ready for merge Design and code approved, CI passed, and likewise for backports. Label added by gatekeepers only. and removed needs: ci Needs a passing full CI run needs: review The pull request is ready for review. This generally means that it has no known issues. labels Jan 31, 2020
@mpg mpg merged commit 350d4c3 into ARMmbed:development Jan 31, 2020
gilles-peskine-arm added a commit to gilles-peskine-arm/mbed-crypto that referenced this pull request Feb 3, 2020
Previously in d875285:
* ARMmbed#333: Streamline PSA key type encodings: prepare
* ARMmbed#323: Initialise return values to an error

Previously in dbcb442:
* ARMmbed#291: Test MBEDTLS_CTR_DRBG_USE_128_BIT_KEY
* ARMmbed#334: Fix some pylint warnings

Previously in ceceedb:
* ARMmbed#348: Bump version to Mbed TLS 2.20.0 and crypto SO version to 4
* ARMmbed#354: Fix incrementing pointer instead of value

In this commit:
* ARMmbed#349: Fix minor defects found by Coverity
* ARMmbed#179: Add option to build SHA-512 without SHA-384
* ARMmbed#327: Implement psa_hash_compute and psa_hash_compare
* ARMmbed#330: Streamline PSA key type and curve encodings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

4 participants