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

Add SM3 to mbedtls and PSA Crypto #4492

Draft
wants to merge 14 commits into
base: development
Choose a base branch
from
Draft

Conversation

th0ma5b
Copy link

@th0ma5b th0ma5b commented May 12, 2021

GB/T 32905-2016 compliant SM3 implementation.
The SM3 algorithm was designed by Xiaoyun Wang et al in 2010.

http://www.gmbz.org.cn/upload/2018-07-24/1532401392982079739.pdf

Signed-off-by: Thomas Bourlard [email protected]

@paul-elliott-arm paul-elliott-arm added Community component-crypto Crypto primitives and low-level interfaces component-psa PSA keystore/dispatch layer (storage, drivers, …) enhancement 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 needs-work size-m Estimated task size: medium (~1w) labels May 12, 2021
@paul-elliott-arm
Copy link
Member

Hi @th0ma5b - Thankyou for your contribution, this looks very useful.

A couple of points, could you sign off your commits (DCO check failed) and possibly add a changelog entry (https://github.com/ARMmbed/mbedtls/blob/development/ChangeLog.d/00README.md)

Unfortunately this also already requires rebase, but this could be done before or after review.

@th0ma5b
Copy link
Author

th0ma5b commented May 13, 2021

Update:

  • DCO fixed.
  • conflicts resolved, rebased and re-tested.
  • Added a changelog entry.

Can you provide access to error log from CI? (not accessible)

@yuhaoth
Copy link
Contributor

yuhaoth commented May 18, 2021

Update:

* DCO fixed.

* conflicts resolved, rebased and re-tested.

* Added a changelog entry.

Can you provide access to error log from CI? (not accessible)

I put travis CI link in my comment. Please take a look

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.

Thank you for your contribution! I have done a first round of review, focusing on the project conventions and structure. I have not looked at the cryptographic code at all.

@gilles-peskine-arm gilles-peskine-arm removed component-psa PSA keystore/dispatch layer (storage, drivers, …) needs: changelog 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 labels May 18, 2021
Thomas Bourlard and others added 10 commits April 5, 2022 12:34
Add psa dispatch code

Signed-off-by: Thomas Bourlard <[email protected]>
Signed-off-by: Thomas Bourlard <[email protected]>
Signed-off-by: Thomas Bourlard <[email protected]>
Add SM3 tests to test_suite_psa_crypto_metadata.data
Add SM3 tests to test_suite_md.data to test dispatch via mbedtls_md_xxx()
Create test_suite_sm3 to test low-level mbedtls_sm3_xxx()
Remove SM3 test from test_suite_mdx.data
Change SM3 test vectors to lower case in test_suite_psa_crypto_hash.data

Signed-off-by: Thomas Bourlard <[email protected]>
Remove unused MBEDTLS_ERR_SM3_HW_ACCEL_FAILED
Fix Travis CI error reported by -fsanitize=undefined option
Reorder MBEDTLS_XXX_ALT in alphabetical order
Add reference to SM3 specification in sm3.h
Remove MBEDTLS_INTERNAL_VALIDATE_XXX() parameter checks
Fix Travis CI error
[PSA] Update SM3 #define flags to fix no driver config:
 (full config + set MBEDTLS_PSA_CRYPTO_CONFIG
              + unset MBEDTLS_PSA_CRYPTO_DRIVERS
              + unset MBEDTLS_USE_PSA_CRYPTO)
Add SM3 to tests/scripts/all.sh
Remove NULL pointer parameter check test
Update comment about number of SM3 error
Add missing SM3 case in is_hash_accelerated
Extend mbedtls SM3 tests
Update tests/scripts/depends-hashes.pl with SM3

Signed-off-by: Thomas Bourlard <[email protected]>
Add SM3 to the "good standing" group of hash algos.

Signed-off-by: Thomas Bourlard <[email protected]>
Co-authored-by: Jerry Yu <[email protected]>
Signed-off-by: Thomas Bourlard <[email protected]>
@gilles-peskine-arm gilles-peskine-arm added needs-review Every commit must be reviewed by at least two team members, and removed needs-work needs-ci Needs to pass CI tests labels Apr 5, 2022
@gilles-peskine-arm
Copy link
Contributor

This PR will need a rebase and a small additional patch once #5644 is merged, to add the new algorithm to crypto_knowledge.py.

@gaoqingshui
Copy link

Hi, what is the status of this MR? I want to use SM3/SM4 in my private project, what can I do to make this MR merged ASAP?

@gilles-peskine-arm
Copy link
Contributor

@gaoqingshui This pull request is waiting for review. Review bandwidth is the main bottleneck of the Mbed TLS team, and I'm afraid I can't give a date for when we'll be able to.

If you're willing, you can help the project by becoming a reviewer! Meaning reading the review guidelines, start reviewing other people's pull requests, and reach the point where you're considered a trusted reviewer and so reduce the workload of other reviewers.

@daverodgman daverodgman added priority-scheduled This PR is big - it will require time to be scheduled for review and removed Community labels May 13, 2022
@daverodgman daverodgman added the historical-reviewing Currently reviewing (for legacy PR/issues) label Jun 17, 2022
@daverodgman daverodgman added historical-reviewed Reviewed & agreed to keep legacy PR/issue and removed historical-reviewing Currently reviewing (for legacy PR/issues) labels Jul 1, 2022
Comment on lines +36 to +41
#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#else
#include <stdio.h>
#define mbedtls_printf printf
#endif /* MBEDTLS_PLATFORM_C */
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm Oct 12, 2022

Choose a reason for hiding this comment

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

We've realized that the conditional inclusion of platform.h on MBEDTLS_PLATFORM_C was not a good idea, and we're moving to unconditional inclusion. Please use the new style in this new file.

Suggested change
#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#else
#include <stdio.h>
#define mbedtls_printf printf
#endif /* MBEDTLS_PLATFORM_C */
#include "mbedtls/platform.h"

Or even include mbedtls/platform.h regardless of MBEDTLS_SELF_TEST.

@tom-daubney-arm tom-daubney-arm added needs-work and removed needs-review Every commit must be reviewed by at least two team members, labels Jul 7, 2023
@tom-daubney-arm
Copy link
Contributor

We are now converting older PRs to draft PRs where the following conditions are met: They have not been updated in the last 3 months, and they need more than non-trivial work to complete.

I've added "needs-work" since conflicts have now appeared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component-crypto Crypto primitives and low-level interfaces enhancement historical-reviewed Reviewed & agreed to keep legacy PR/issue needs-work priority-scheduled This PR is big - it will require time to be scheduled for review size-m Estimated task size: medium (~1w)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants