Implement psa_hash_compute and psa_hash_compare #327
Labels
No labels
api-spec
bug
CLA requested
CLA valid
compliance
DO NOT MERGE
duplicate
enhancement
feature branch
good first issue
HEADER FORMATTING ISSUE
help wanted
Information
invalid
Jira status: AWAITING REVIEW
Jira status: CLOSED
Jira status: DONE
Jira status: IN PROGRESS
Jira status: IN REVIEW
Jira status: OPEN
Jira status: REOPENED
Jira status: RESOLVED
mirrored
mirror internally
needs: backports
needs: ci
needs: design review
needs: preceding PR
needs: review
needs: work
notabug
open for community contribution
Product Backlog
question
ready for merge
security
stale
type: bug
type: enhancement
type: question
web pages
wontfix
writing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-ARMmbed/mbed-crypto!327
Loading…
Reference in a new issue
No description provided.
Delete branch "psa-hash_compute"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.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).
CI succeeded except for
check_generated_files.shin TLS which is expected to fail until the crypto submodule is updated to includecrypto_compat.hin the VS project template.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.shcomponent that builds withoutMD_Can 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 onMD_Cwithout an automated test that confirms the new dependencies are correct.@ -764,3 +764,3 @@depends_on:MBEDTLS_MD_C:MBEDTLS_SHA256_Cdepends_on:MBEDTLS_SHA256_Chash_setup:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_ERROR_INVALID_ARGUMENTDoes this test really depend on SHA-256? Or are you using it as a convenient shortcut for "at least on hash defined"?
(Same for the next test.)
Note: this will interact with https://github.com/ARMmbed/mbed-crypto/pull/179 so whichever PR is merged first will be OK, but the other will need fixing. I don't think there's anything we can do in advance to avoid that, I'm just leaving that note as a reminder.
We seem to be missing a newline before the next test.
Question: shouldn't we test
psa_hash_verify()with invalid algs as well? If not, why not?Also, a conflict has developed and needs to be resolved.
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
@ -764,3 +764,3 @@depends_on:MBEDTLS_MD_C:MBEDTLS_SHA256_Cdepends_on:MBEDTLS_SHA256_Chash_setup:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_ERROR_INVALID_ARGUMENTI somehow committed it in a later commit. Since I was rebasing due to the merge conflict in
check-test-cases.py, I modified the appropriate commit to add the missing newline.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.@ -764,3 +764,3 @@depends_on:MBEDTLS_MD_C:MBEDTLS_SHA256_Cdepends_on:MBEDTLS_SHA256_Chash_setup:PSA_ALG_HMAC(PSA_ALG_SHA_256):PSA_ERROR_INVALID_ARGUMENTThe dependency is wrong. Probably copypasta.
ITYM
psa_hash_compare. Indeed, I added some test cases.I think I meant
psa_hash_verifybecause I was mislead by the title of this PR, the first commit message, and the name of the next test function:hash_compute_verify.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.
@ -2430,6 +2430,109 @@ exit:}This should probably be
hash_compute_compare. Also, the commit message could be amended.@ -2430,6 +2430,109 @@ exit:}Ok. I went and amended the commit that introduced this test function and reworded the commit messages.
@gilles-peskine-arm Just to notify you that #179 was just merged, so this will need a few
!MBEDTLS_SHA512_NO_SHA384in relevant places now. Also, there's a conflict intest_suite_psa_crypto.datawhich is probably related to dependencies being updated on both sides as well.Rebased again (previous iteration in https://github.com/gilles-peskine-arm/mbed-crypto/tree/psa-hash_compute-5):
!MBEDTLS_SHA512_NO_SHA384to the one new SHA-384 test case.It looks good to me in general, I just have two questions.
@ -933,3 +933,3 @@size_t input_length,const uint8_t *hash,const size_t hash_length);size_t hash_length);Does this mean that we need to update the API reference? This is still const in RC2...
@ -20,6 +20,7 @@## This file is part of Mbed TLS (https://tls.mbed.org)import argparseWhy are the changes needed in this file/commit needed in this PR?
@ -20,6 +20,7 @@## This file is part of Mbed TLS (https://tls.mbed.org)import argparseThe new option to
check-test-casesisn't needed to makepsa_hash_computework. But I made it and used it during the development of the PR to make it easier to see errors (they tend to get lost among the warnings).@ -933,3 +933,3 @@size_t input_length,const uint8_t *hash,const size_t hash_length);size_t hash_length);Indeed, thanks for noticing that.
CI passes except for Mbed OS jobs which is a known preexisting issue.
@ -933,3 +933,3 @@size_t input_length,const uint8_t *hash,const size_t hash_length);size_t hash_length);And I also fixed this in the similar function for MAC, because it's easier to fix it now than track it for later.
@ -933,3 +933,3 @@size_t input_length,const uint8_t *hash,const size_t hash_length);size_t hash_length);I'll update the spec - this doesn't actually change the interface, but it is not standard practice to use this in the API declaration.
@ -933,3 +933,3 @@size_t input_length,const uint8_t *hash,const size_t hash_length);size_t hash_length);@athoelke https://github.com/ARMmbed/psa-crypto-api/pull/366
@ -933,3 +933,3 @@size_t input_length,const uint8_t *hash,const size_t hash_length);size_t hash_length);I saw that - and I've patched it with the corrected header file.
LGTM.
After the latest commit, the CI is still passing except for Mbed OS tests which are a known issue independent from this PR.