Duplication of mbedtls-framework #227
Labels
No labels
approved
bug
dependencies
DO-NOT-MERGE
enhancement
good-first-issue
help-wanted
historical-reviewed
historical-reviewing
needs-adoption
needs-ci
needs-design-approval
needs-info
needs-preceding-pr
needs-review
needs-reviewer
needs-work
priority-high
priority-low
priority-medium
priority-scheduled
priority-very-high
single-reviewer
size-l
size-m
size-s
size-xs
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-Mbed-TLS/mbedtls-framework#227
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
The current directory structure requires two references and thus two copies of the framework when building mbedTLS library; the same for local git repositories.
Maybe "flat" repository structure could be considered, where each repository is directory at the same level?
Directories for
mbedTLS:[mbedtls]
[tf-psa-crypto]
[mbedtls-framework]
For
TF-PSA-crypto:[tf-psa-crypto]
[mbedtls-framework]
In this case framework might be reused for both
mbedTLSandTF-PSA-crypto.Hi, thanks for the suggestion!
I think there are some good reasons why we have 2 submodules in that way at the moment (although I appreciate that it is a bit annoying to use).
One problem is that the framework submodule is also shared with Mbed TLS 3.6, so that limits what we can do in terms of changing the directory structure (it's an LTS, so users are relying on it to be the same). We made a submodule
/frameworkwhen we released 3.6 and then we were committed to having that same structure for the lifetime of 3.6.However, when 3.6 reaches end-of-life (in March 2027) we will have more freedom. It's possible that we'll be able to do away with the framework entirely, since we can separate it into (things that are used by crypto) and (things that are used only by TLS/X.509).
@ronald-cron-arm made most of the design decisions around the way the framework works. Ronald, do you have anything to add to this?
We have a hard constraint that TF-PSA-Crypto should work without involving Mbed TLS, so it needs direct access to the framework. We also don't want to require users to track down dependencies, so the framework goes under the project, not separately, and likewise
tf-psa-cryptogoes undermbedtls. As a consequence, the nestingmbedtls/tf-psa-crypto/frameworkmust exist.We could avoid the duplication in several ways, but it doesn't come for free.
For background, the goal of the framework repository is to contain files that are shared between the two projects, or shared between maintained branches of one projects, such as parts of build scripts, test scripts and test data. Both projects consume files from the framework. The framework has a single branch, so at any time, Mbed TLS and TF-PSA-Crypto might use the same framework commit, or Mbed TLS might need a more recent commit, or TF-PSA-Crypto might need a more recent commit — at least we won't have the two projects wanting separate branches of the framework.
We could decide that Mbed TLS only ever consumes the framework through TF-PSA-Crypto. But that would require that every time Mbed TLS needs a framework change, we have to update TF-PSA-Crypto's
frameworkpointer, then Mbed TLS'stf-psa-cryptopointer. So far we haven't judged this acceptable.We could decide that when TF-PSA-Crypto is consumed by Mbed TLS, crypto's framework is not checked out and not used. This should be doable because the framework should never become incompatible with either project. But it requires a lot of work in build scripts, to make the framework location configurable. It's also beneficial only if you don't tell git to do a recursive submodule update, which we can do, but might not be applicable when Mbed TLS itself is a submodule of some other project.
There's no solution that's clearly superior to what we have now, so for the foreseeable future, the status quo wins.
You mean "There's NO solution that's clearly superior to what we have now, so for the foreseeable future, the status quo wins" ?
Right now in
mbedtlsrepository:include,libraryandframeworkare at the same level, butframeworkis a link.The idea is to move contents of the current root of two repositories into a subdirectory.
The root of
mbedtlsrepository contains onlymbedtlsreal directory, whiletf-psa-cryptoandframeworkare links.The root of
tf-psa-cryptorepository contains onlytf-psa-cryptoreal directory, andframeworkis a link.Paths in the scripts have to be rearranged, but is this really impossible without nesting?
Oops, yes.
That wouldn't help. You'd still have the Mbed TLS project with a
frameworksubdirectory and atf-psa-cryptosubdirectory, and thetf-psa-cryptosubdirectory would also have aframeworksubdirectory.Having a link has its own problems (does Windows support symlinks well these days?), and doesn't solve anything.
frameworkcan't be a link in TF-PSA-Crypto because it has to work without Mbed TLS. If we decide thatframeworkcan be a link totf-psa-crypto/frameworkin Mbed TLS, then we could just rewrite our scripts to use the pathtf-psa-crypto/frameworkinstead, and we wouldn't need a link, but we'd be in the situation that we don't want, where an Mbed TLS framework update requires a TF-PSA-Crypto framework update.That exactly what we see now; and to make things even more troublesome - nested links.
But these links are in github. Locally there would be no links, it is three ordinary directories (local repositories) at the same level - this is the goal of the suggestion.
I should add that I personally think that having two copies of the framework is bad enough that we should pursue another solution (always use the outer framework, or always use the inner framework), despite the downsides of the other solutions.
During routine maintenance, it's very common that the two copies of the framework are out of synch. Every once in a while, this has a subtle effect that causes mysterious problems.
The latest such problem was https://github.com/Mbed-TLS/mbedtls/issues/10529 — generated files being inconsistent depending on exactly how they were generated, because Mbed TLS had a
frameworksubmodule that was a couple of weeks more recent than itstf-psa-cryptosubmodule and consequently more recent thantf-psa-crypto/framework.Unfortunately, changing this is hard because:
Replacement of
framework/...with../framework/...would do in most cases if flat repository structure was accepted. In any case, this job should be much simpler than recent repository split.Had an interesting problem related to this yesterday. The issue was that the version of the framework in mbedtls was correct, however tf-psa-crypto was wrong. From what I can tell if you build a tf-psa-crypto PR the CI updates the mbedtls framework version to match that of tf-psa-crypto, so this reverted the correct change to the mbedtls version and caused a failure that was initially not initially reproducible locally. I suspect there we other factors that contributed to my fork being in this state, however though it would be useful to add this in for further discussion.