Skip to content

Update Mbed TLS to 2.24.0 and Mbed PSA service #14160

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

Conversation

LDong-Arm
Copy link
Contributor

@LDong-Arm LDong-Arm commented Jan 15, 2021

Summary of changes

As a prerequisite of TF-M 1.2 update, this PR updates Mbed TLS to 2.24.0 and Mbed PSA service (used by PSA-enabled single-core v7m targets such as K64F) that comes with Mbed TLS.

Notes:

  • hash_wrappers.c has been moved from connectivity/mbedtls/source/ (intended for imported Mbed TLS code only) to connectivity/mbedtls/platform/src/ as it's specific to Mbed OS.
  • common.h has been moved from connectivity/mbedtls/source/ to connectivity/mbedtls/include/mbedtls/, because this header is also used by PSA (since Mbed TLS 2.24.0) and thus needs to be in the exported include path.

Impact of changes

This updates works with all non-PSA targets and those PSA targets with TF-M 1.2 support. This means:

  • No impact on non-PSA targets
  • Single-core v7m targets (e.g. K64F) will work following the update
  • Musca B1 and S1 are out of scope and to be covered in TF-M v1.2 integration #14187
  • CYTFM_064B0S2_4343W will not work. Update to TF-M 1.2 to be discuss with Cypress
  • All Cypress targets will not compile, because Mbed TLS 2.24.0 introduced a new API mbedtls_ecp_write_key() which is missing from Cypress's ecp_alt.c. Until this function is imported, applications and tests will fail to compile with the Arm toolchain for all Cypress targets, due to missing symbols.

So some tests in CI will not pass, until the entire TF-M 1.2 integration work is complete. Since this is incremental work on a feature branch, we may merge it and implement the rest subsequently.

Migration actions required

None.

Documentation

None.


Pull request type

[] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[*] Major update (Breaking change E.g. Return code change / API behaviour change)

(Changes in PSA API)


Test results

[] No Tests required for this change (E.g docs only update)
[x] Covered by existing mbed-os tests (Greentea or Unittest)
[] Tests / results supplied as part of this PR

Reviewers

@jainvikas8 @evedon


@ciarmcom
Copy link
Member

@LDong-Arm, thank you for your changes.
@jainvikas8 @evedon @ARMmbed/mbed-os-maintainers please review.

@LDong-Arm
Copy link
Contributor Author

Hi @0xc0170, is it possible to run our CI on this PR? We'd like a one-off run to see how it impacts existing Mbed targets, thanks in advance.

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 18, 2021

CI started

@LDong-Arm
Copy link
Contributor Author

Looks like CI is stuck at fetching mbed-os

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 18, 2021

Restarted, Ci is having some network instability today.

evedon
evedon previously approved these changes Jan 19, 2021
Copy link
Contributor

@evedon evedon left a comment

Choose a reason for hiding this comment

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

Change looks good, pending green CI result for targets (except Musca B1, S1 and
CYTFM_064B0S2_4343W).

This is an integration branch so the work will be done incrementally.

@mergify mergify bot added needs: CI and removed needs: review labels Jan 19, 2021
@LDong-Arm
Copy link
Contributor Author

Fetching of mbed-os failed in CI

@LDong-Arm
Copy link
Contributor Author

@0xc0170 Shall we rerun CI on this, thanks!

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 20, 2021

Restarted

@mergify mergify bot added needs: work and removed needs: CI labels Jan 20, 2021
@mbed-ci
Copy link

mbed-ci commented Jan 20, 2021

Jenkins CI Test : ❌ FAILED

Build Number: 3 | 🔒 Jenkins CI Job | 🌐 Logs & Artifacts

CLICK for Detailed Summary

jobs Status
jenkins-ci/mbed-os-ci_unittests ✔️
jenkins-ci/mbed-os-ci_cmake-example-GCC_ARM
jenkins-ci/mbed-os-ci_cmake-example-ARM
jenkins-ci/mbed-os-ci_build-greentea-ARM
jenkins-ci/mbed-os-ci_build-greentea-GCC_ARM
jenkins-ci/mbed-os-ci_build-example-GCC_ARM
jenkins-ci/mbed-os-ci_build-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-example-ARM
jenkins-ci/mbed-os-ci_build-cloud-example-ARM ✔️

@LDong-Arm
Copy link
Contributor Author

From the CI run,

  • The CMake examples tests have caught a real error in this PR (missing hash_wrappers.c in Mbed TLS) - I'll push a fix
  • All other failures (TF-M targets) are completely expected

@LDong-Arm LDong-Arm force-pushed the mbedtls-2.24-import branch from 9fb9f6a to 6623c5b Compare January 20, 2021 16:25
@mergify mergify bot dismissed evedon’s stale review January 20, 2021 16:25

Pull request has been modified.

@LDong-Arm
Copy link
Contributor Author

hash_wrappers.c was accidentally deleted by the import script. To avoid this happening again, I've moved it from connectivity/mbedtls/source/ (intended for imported Mbed TLS code only) to connectivity/mbedtls/platform/src/ (Mbed OS specific code), and updated CMakeLists.txt accordingly.

@evedon @jainvikas8 Are you happy with this? A re-approval is needed, then we can rerun CI (I'm sure it'll be good this time) and merge it.

@LDong-Arm LDong-Arm requested a review from evedon January 20, 2021 16:38
@LDong-Arm LDong-Arm force-pushed the mbedtls-2.24-import branch 2 times, most recently from 405b5fb to 1e485af Compare January 21, 2021 15:03
hash_wrappers.c is specific to Mbed OS, moving it into platform
as its original directory is for imported Mbed TLS source only.
@LDong-Arm LDong-Arm force-pushed the mbedtls-2.24-import branch from 1e485af to 47abbf3 Compare January 21, 2021 15:04
Copy link
Contributor Author

@LDong-Arm LDong-Arm left a comment

Choose a reason for hiding this comment

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

@0xc0170 Can we run CI on this again? @jainvikas8 (the reviewer) has gone through this PR with me, so it's almost ready.

@@ -20,7 +20,8 @@
* <https://ieeexplore.ieee.org/servlet/opac?punumber=4375278>.
*/

/* Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved.
/*
* Copyright The Mbed TLS Contributors
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@0xc0170 This copyright change was recently made in all files in Mbed TLS. Since the code is imported, are we okay with this?

@mergify mergify bot added needs: CI and removed needs: work labels Jan 22, 2021
@0xc0170
Copy link
Contributor

0xc0170 commented Jan 22, 2021

CI started

@mergify mergify bot added needs: work and removed needs: CI labels Jan 22, 2021
@mbed-ci
Copy link

mbed-ci commented Jan 22, 2021

Jenkins CI Test : ❌ FAILED

Build Number: 4 | 🔒 Jenkins CI Job | 🌐 Logs & Artifacts

CLICK for Detailed Summary

jobs Status
jenkins-ci/mbed-os-ci_unittests ✔️
jenkins-ci/mbed-os-ci_cmake-example-GCC_ARM
jenkins-ci/mbed-os-ci_cmake-example-ARM
jenkins-ci/mbed-os-ci_build-greentea-GCC_ARM
jenkins-ci/mbed-os-ci_build-greentea-ARM
jenkins-ci/mbed-os-ci_build-cloud-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-example-ARM
jenkins-ci/mbed-os-ci_build-example-GCC_ARM

Note: Now we need to export common.h to the include path, because
this header is now also needed by PSA Crypto service.
Files have been automatically imported by setting MBED_TLS_RELEASE to
mbedtls-2.24.0 in connectivity/mbedtls/tools/importer/Makefile and
running `make` in that directory.
evedon
evedon previously approved these changes Jan 25, 2021
@evedon
Copy link
Contributor

evedon commented Jan 25, 2021

hash_wrappers.c was accidentally deleted by the import script. To avoid this happening again, I've moved it from connectivity/mbedtls/source/ (intended for imported Mbed TLS code only) to connectivity/mbedtls/platform/src/ (Mbed OS specific code), and updated CMakeLists.txt accordingly.

@evedon @jainvikas8 Are you happy with this? A re-approval is needed, then we can rerun CI (I'm sure it'll be good this time) and merge it.

That is the correct thing to do.

@LDong-Arm LDong-Arm force-pushed the mbedtls-2.24-import branch from 47abbf3 to 115304c Compare January 25, 2021 10:12
@mergify mergify bot dismissed stale reviews from evedon and jainvikas8 January 25, 2021 10:13

Pull request has been modified.

@LDong-Arm
Copy link
Contributor Author

LDong-Arm commented Jan 25, 2021

I've made a fix since the last CI run: common.h has been moved from connectivity/mbedtls/source/ to connectivity/mbedtls/include/mbedtls/, because this header is also used by PSA (which sits in a different location in Mbed OS) thus it needs to be in the exported include path. Now I believe all non-TF-M and non-Cypress targets should pass next time.

Note: All Cypress targets will not compile, because Mbed TLS 2.24.0 introduced a new API mbedtls_ecp_write_key() which is missing from Cypress's ecp_alt.c. Until this function is imported, applications and tests will fail to compile with the Arm toolchain for all Cypress targets, due to missing symbols.

@mergify mergify bot added needs: CI and removed needs: work labels Jan 26, 2021
@LDong-Arm
Copy link
Contributor Author

@evedon Thanks for the review.
@0xc0170 Would you please start CI on this?

@0xc0170
Copy link
Contributor

0xc0170 commented Jan 26, 2021

CI started

@mergify mergify bot added needs: work and removed needs: CI labels Jan 26, 2021
@mbed-ci
Copy link

mbed-ci commented Jan 26, 2021

Jenkins CI Test : ❌ FAILED

Build Number: 5 | 🔒 Jenkins CI Job | 🌐 Logs & Artifacts

CLICK for Detailed Summary

jobs Status
jenkins-ci/mbed-os-ci_unittests ✔️
jenkins-ci/mbed-os-ci_cmake-example-ARM
jenkins-ci/mbed-os-ci_cmake-example-GCC_ARM
jenkins-ci/mbed-os-ci_build-greentea-GCC_ARM
jenkins-ci/mbed-os-ci_build-greentea-ARM
jenkins-ci/mbed-os-ci_build-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-example-ARM
jenkins-ci/mbed-os-ci_build-example-GCC_ARM
jenkins-ci/mbed-os-ci_build-cloud-example-ARM ✔️

@LDong-Arm
Copy link
Contributor Author

LDong-Arm commented Jan 26, 2021

All failures are expected:

  • mbed-os-example-lorawan CMake build for K64F: recently fixed by 5616537 on master branch, but our feature branch lags behind. This should be automatically resolved once we merge back to master
  • Examples and Greentea fail to build for TF-M targets due to ongoing integration work: ARM_MUSCA_B1, ARM_MUSCA_S1 (TF-M v1.2 integration #14187) and CYTFM_064B0S2_4343W (maintained by Cypress)
  • Examples and Greentea fail to build for Cypress targets, due to a new Mbed TLS API mbedtls_ecp_write_key() missing from Cypress's driver

@evedon This PR should be ready for merge.

@evedon evedon merged commit d6826f8 into ARMmbed:feature-tf-m-1.2-integration Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants