Skip to content

Move public legacy headers to /include/mbedtls #247

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

felixc-arm
Copy link
Contributor

@felixc-arm felixc-arm commented Apr 4, 2025

Moves public headers from /drivers/builtin/include/mbedtls to /include/mbedtls to make it clear that they are public.
Resolves #223, although there may be further work to move these headers somewhere else, e.g. /include/tf-psa-crypto.

List of files moved for reference:

asn1.h
asn1write.h
base64.h
constant_time.h
lms.h
memory_buffer_alloc.h
nist_kw.h
pem.h
pk.h
platform.h
platform_time.h
platform_util.h
psa_util.h
threading.h

PR checklist

@felixc-arm felixc-arm added 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 size-xs Estimated task size: extra small (a few hours at most) needs-ci Needs to pass CI tests needs-work labels Apr 4, 2025
@gilles-peskine-arm gilles-peskine-arm added priority-high High priority - will be reviewed soon and removed 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 Apr 7, 2025
@gilles-peskine-arm
Copy link
Contributor

There are probably build scripts that need to be updated. For example include/CMakeLists.txt has

    file(GLOB tf-psa-crypto_headers "tf-psa-crypto/*.h")
    file(GLOB mbedtls_crypto_headers "../drivers/builtin/include/mbedtls/*.h")

and presumably there needs to be a line for "mbedtls/*.h". I don't know whether it should be one of these variables or yet another one: I don't know what the difference is between those variables.

@felixc-arm
Copy link
Contributor Author

The companion PR Mbed-TLS/mbedtls#10122 has now passed the CI

@felixc-arm felixc-arm added 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 and removed needs-work needs-ci Needs to pass CI tests labels Apr 10, 2025
@bjwtaylor bjwtaylor self-requested a review April 14, 2025 09:49
bjwtaylor
bjwtaylor previously approved these changes Apr 14, 2025
@valeriosetti valeriosetti self-requested a review April 15, 2025 11:35
Copy link
Contributor

@valeriosetti valeriosetti left a comment

Choose a reason for hiding this comment

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

The PR looks mostly OK to me. I only left 1 question

valeriosetti
valeriosetti previously approved these changes Apr 15, 2025
@github-project-automation github-project-automation bot moved this from In Development to Has Approval in Roadmap pull requests (new board) Apr 15, 2025
@felixc-arm felixc-arm added approved Design and code approved - may be waiting for CI or backports and removed 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 Apr 15, 2025
@gilles-peskine-arm
Copy link
Contributor

The CI is unhappy here. Is the companion mbedtls pull request needed to make it happy?

@mpg
Copy link
Contributor

mpg commented May 6, 2025

Sounds like a plan. Indeed those doxygen errors are actual issues that we want to address (as opposed to just silence), so let's do it - but proceed step by step, starting with getting this PR merged without the doxygen change for now.

@felixc-arm
Copy link
Contributor Author

Cool, I've created #281 to track this Doxygen work.

I've also reverted that commit so everything should be good to review again, although it makes sense to wait until after #212 and its mbedtls PR get merged so that I can rebase on top of that to avoid extra reviews/pings.

@felixc-arm felixc-arm force-pushed the move-public-headers branch from 4f78997 to 75e7af5 Compare May 7, 2025 08:23
@felixc-arm
Copy link
Contributor Author

This is all ready for review again (just a rebase) when you've got a moment @bjwtaylor @valeriosetti

n.b. The failure in OpenCI seems to be an intermittent one that is not related to this PR, and I'd replay it but I don't think I have the permissions or am not in a certain group or something as I can't see a replay button even though I'm logged in (but I can see a rerun button for the internal CI)

@gilles-peskine-arm
Copy link
Contributor

The failure in https://mbedtls.trustedfirmware.org/blue/organizations/jenkins/mbed-tls-tf-psa-crypto-multibranch/detail/PR-247-head/9/pipeline/1211 doesn't look like a glitch:

/var/lib/build/core/psa_crypto.c:21:10: fatal error: 'psa_crypto_driver_wrappers.h' file not found
#include "psa_crypto_driver_wrappers.h"
         ^
/var/lib/build/core/psa_crypto.c:21:10: fatal error: 'psa_crypto_driver_wrappers.h' file not found
#include "psa_crypto_driver_wrappers.h"
         ^
1 error generated.
core/CMakeFiles/tfpsacrypto_static.dir/build.make:71: recipe for target 'core/CMakeFiles/tfpsacrypto_static.dir/psa_crypto.c.o' failed
make[2]: *** [core/CMakeFiles/tfpsacrypto_static.dir/psa_crypto.c.o] Error 1
CMakeFiles/Makefile2:329: recipe for target 'core/CMakeFiles/tfpsacrypto_static.dir/all' failed
make[1]: *** [core/CMakeFiles/tfpsacrypto_static.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 31%] Building C object core/CMakeFiles/tfpsacrypto.dir/psa_crypto_client.c.o
1 error generated.
core/CMakeFiles/tfpsacrypto.dir/build.make:71: recipe for target 'core/CMakeFiles/tfpsacrypto.dir/psa_crypto.c.o' failed
make[2]: *** [core/CMakeFiles/tfpsacrypto.dir/psa_crypto.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:290: recipe for target 'core/CMakeFiles/tfpsacrypto.dir/all' failed
make[1]: *** [core/CMakeFiles/tfpsacrypto.dir/all] Error 2
make: *** [all] Error 2
Makefile:138: recipe for target 'all' failed
^^^^test_tf_psa_crypto_shared: build/test: shared libraries: make -> 2^^^^

It is weird that the internal CI passed though. A non-deterministic failure when building could be a missing build dependency. On the CI, we run make -j2 (at least in builds initiated by make, I'm not completely sure this applies to CMake builds). With parallel builds, sometimes, missing build dependencies are only a problem if the build is executed in a particular order, and are not a problem with sequential builds.

This pull request moves files in a way that could affect dependencies — for example maybe somewhere dependencies are calculated in a way that doesn't take /include/mbedtls into account. Can you please check carefully whether that might be the case?

Experimentally, you may want to try doing build locally with various levels of parallelism and see if it breaks. This can be very sensitive to the level of parallelism, the number of CPUs, how fast the builds are and other factors. For example we used to have a missing dependency that would in practice never be a problem for make -j2 if there was an odd number of files to build, but caused problems frequently if there was an even number! (Or vice versa, I don't remember — but the parity of the number of files was what made make -j2 work or not in practice.)

@felixc-arm
Copy link
Contributor Author

I'll have a look, but I do remember seeing this exact failure on another patch (found it!: https://mbedtls.trustedfirmware.org/blue/organizations/jenkins/mbed-tls-framework-multibranch/detail/PR-153-head/16/pipeline/2066 for Mbed-TLS/mbedtls-framework#153) that is unrelated, so I don't think it is this specific patch that is causing it at least.

@gilles-peskine-arm
Copy link
Contributor

Ok, then this is probably a preexisting issue, which may be exacerbated by changes that we make. Can you please file an issue and reference all the places where you've seen it happen?

@felixc-arm
Copy link
Contributor Author

Sure, opened #286 - and I'll rerun the OpenCI now I have permissions to hopefully ensure it's only an intermittent failure... 🙂

@felixc-arm felixc-arm force-pushed the move-public-headers branch from 75e7af5 to 40b150a Compare May 8, 2025 12:55
@felixc-arm
Copy link
Contributor Author

The Windows CI seemed to have issues with rerunning after Mbed-TLS/mbedtls-test#203 was merged as it was trying to rerun Windows 2013 jobs whilst looking for 'v141' which I think is Visual Studio 2017 which wasn't installed.
So I've rebased it (again... 🙂) to hopefully re-trigger with the Windows 2017 jobs instead and get everything green.

@felixc-arm felixc-arm added approved Design and code approved - may be waiting for CI or backports and removed needs-review Every commit must be reviewed by at least two team members labels May 9, 2025
@gilles-peskine-arm gilles-peskine-arm added this pull request to the merge queue May 12, 2025
@gilles-peskine-arm
Copy link
Contributor

The Windows CI seemed to have issues with rerunning after Mbed-TLS/mbedtls-test#203

Ah, FYI this is a subtlety with the rerun/replay button on Jenkins. It replays the same Groovy script as the run that's getting replayed, but it gets its files from a checkout of the main branch of https://github.com/Mbed-TLS/mbedtls-test. If mbedtls-test has moved forward, the Groovy scripts and the rest of mbedtls-test (e.g. windows_testing.py) may be out of synch. To avoid this, run a fresh job instead of using rerun/replay. For example, here, use the “Build Now” button on https://mbedtls.trustedfirmware.org/job/mbed-tls-tf-psa-crypto-multibranch/job/PR-247-head/ rather than replaying a run.

This comes up rarely in normal usage because merges in mbedtls-test are rare, and replays are also rare, but it's something to keep in mind when testing changes in mbedtls-test — always start new jobs after updating your patch to mbedtls-test, because otherwise you won't be testing your latest patch.

@felixc-arm
Copy link
Contributor Author

I see, good to know the 'build now' button will do a fresh job, cheers!

Merged via the queue into Mbed-TLS:development with commit 6cecd31 May 12, 2025
4 of 5 checks passed
@github-project-automation github-project-automation bot moved this from Has Approval to Done in Roadmap pull requests (new board) May 12, 2025
@felixc-arm felixc-arm deleted the move-public-headers branch May 15, 2025 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Design and code approved - may be waiting for CI or backports priority-high High priority - will be reviewed soon size-xs Estimated task size: extra small (a few hours at most)
Development

Successfully merging this pull request may close these issues.

Move public legacy headers to /include
5 participants