-
Notifications
You must be signed in to change notification settings - Fork 8k
modules: mbedtls: deprecate legacy hash algorithms #96283
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
Closed
valeriosetti
wants to merge
10
commits into
zephyrproject-rtos:main
from
valeriosetti:remove-legacy-hash
Closed
modules: mbedtls: deprecate legacy hash algorithms #96283
valeriosetti
wants to merge
10
commits into
zephyrproject-rtos:main
from
valeriosetti:remove-legacy-hash
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99f36a7
to
3bc96bf
Compare
032c040
to
65f1716
Compare
65f1716
to
4dcc95f
Compare
- create an ad-hoc Kconfig file to hold all the Mbed TLS Kconfigs that are going to be deprecated; - add Kconfig MBEDTLS_MD5 to the new Kconfig.deprecated file; - remove usages of mbedtls_md5_xxx() form tests; - replace CONFIG_MBEDTLS_MD5 with CONFIG_PSA_WANT_ALG_MD5 in the codebase; - add migration-guide note about this deprecation. Signed-off-by: Valerio Setti <[email protected]>
- add Kconfig MBEDTLS_SHA1 to Kconfig.deprecated; - remove usages of mbedtls_sha1_xxx() form Zephyr codebase; - replace CONFIG_MBEDTLS_SHA1 with CONFIG_PSA_WANT_ALG_SHA_1; - add migration-guide note about this deprecation. Signed-off-by: Valerio Setti <[email protected]>
- add Kconfig MBEDTLS_SHA224 to Kconfig.deprecated; - add migration-guide note about this deprecation. Signed-off-by: Valerio Setti <[email protected]>
- add Kconfig MBEDTLS_SHA256 to Kconfig.deprecated; - remove usages of mbedtls_sha256_xxx() form Zephyr codebase; - replace CONFIG_MBEDTLS_SHA256 with CONFIG_PSA_WANT_ALG_SHA_256; - add migration-guide note about this deprecation. Signed-off-by: Valerio Setti <[email protected]>
- add Kconfig MBEDTLS_SHA384 to Kconfig.deprecated; - replace CONFIG_MBEDTLS_SHA348 with CONFIG_PSA_WANT_ALG_SHA_384; - add migration-guide note about this deprecation. Signed-off-by: Valerio Setti <[email protected]>
- add Kconfig MBEDTLS_SHA512 to Kconfig.deprecated; - replace CONFIG_MBEDTLS_SHA512 with CONFIG_PSA_WANT_ALG_SHA_512; - add migration-guide note about this deprecation. Signed-off-by: Valerio Setti <[email protected]>
MD remains a public interface in the upcoming TF-PSA-Crypto 1.0 release, but it still bring connections to legacy crypto and extra footprint related to its wrapping functionalities. Since in most of the cases the required hash algorithm is known, it's better to use the proper PSA solution instead. Unfortunately MBEDTLS_MD Kconfig cannot be deprecated as the other hash related Kconfigs because it's still used in TLS. This commit also adds a test for HMAC_SHA_256 (one of the functions that is replaced in this commit) in "tests/crypto/mbedtls_psa". Signed-off-by: Valerio Setti <[email protected]>
This is the last step in order to fully deprecate all Kcofnigs that are related to legacy Mbed TLS hash support. A new Kconfig is added (CONFIG_PSA_WANT_ALG_HASH_ALL) to replace the deprecated symbol in a PSA fashion. Signed-off-by: Valerio Setti <[email protected]>
The file "mbedtls.c" was copied from upstream Mbed TLS several years ago and since then only minor fixes has been added when failing, no real upgrade was made since then. Reasons for removal include: - some of the symbols were already removed (ex: MD2, MD4, RIPEMD160, ARC4, etc) but their testing was not removed; - most of the code is guarded but "prj.conf" doesn't set any Kconfig related to the crypto features in Mbed TLS, so likely only the default ones are really tested; - last but not least all of these "mbedtls_xxx_self_test()" function will disappear in the next TF-PSA-Crypto release so they cannot be maintained here. This suite is replaced with tests in "zephyr/tests/crypto/mbedtls_psa". "MAINTAINERS.yml" was also updated in this commit in order to reflect this removal and add path for existing tests. Signed-off-by: Valerio Setti <[email protected]>
The previous source file was copied from Mbed TLS several years ago and since then not many updates were made. For example: - testing stopped at CTR-DRBG exiting with failure; - emulation wasn't really catching any output so a timeout of 60 seconds was required in order to fully complete the testing; - the "harness: crypto" was preventing the code from being really tested with twister. Last but not least, all of the functions used here belong to the legacy Mbed TLS crypto support that is going to be removed from the next TF-PSA-Crypto release. The goal of this commit is to renew the test code making it really usable and testable. For the time being hash and ciphers are tested, but asymmetric key testing can be added in the future if desired. Signed-off-by: Valerio Setti <[email protected]>
4dcc95f
to
e8826e8
Compare
|
I realized that this PR is touching a bit too many files and it's not easy to review. I will close it and split into sub-PRs. Sorry for the noise. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This work tries to anticipate the changes required for the next Mbed TLS/TF-PSA-Crypto release (4.0/1.0) by removing usages of legacy crypto in favor of PSA API. Since there are several crypto algorithms that need to be replaced, this PR only focuses on hash algorithms, i.e. MD5, SHA1/224/256/384/512, and HMAC.