Skip to content

Mechanism for marking a compilation option as private #10147

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

Open
gilles-peskine-arm opened this issue Apr 24, 2025 · 2 comments · May be fixed by Mbed-TLS/mbedtls-framework#164 or Mbed-TLS/TF-PSA-Crypto#269
Assignees
Labels
api-break This issue/PR breaks the API and must wait for a new major version enhancement size-s Estimated task size: small (~2d)

Comments

@gilles-peskine-arm
Copy link
Contributor

gilles-peskine-arm commented Apr 24, 2025

Create a mechanism for marking a configuration option as private.

  • Private options must not be set by mbedtls_config.h, crypto_config.h or their alternatives and extensions (MBEDTLS_CONFIG_FILE, MBEDTLS_USER_CONFIG_FILE, etc.). Any attempt to test them is rejected with an #error raised whenever build_info.h is enabled.
  • Nice-to-have: also reject private options passed on the compiler command line with -D.
  • Private options may be set by adjust*.h headers.
  • If MBEDTLS_ALLOW_REMOVED_FEATURES or TF_PSA_CRYPTO_ALLOW_REMOVED_FEATURES (as applicable) is enabled, then private options are allowed. These options are enabled in the full config, so it's ok to make an option private and default-off if our test coverage depends on it (e.g. removing an elliptic curve that is still used in test data).
  • This applies to both TF-PSA-Crypto and Mbed TLS.
  • Nice-to-have: complain if users try to define crypto options in mbedtls_config.h or X.509/TLS options in crypto_config.h. However, there must not be any complaints if the same configuration is used for both.
  • Document a simple way to make more options private.
  • Make legacy crypto options that are subsubmed by PSA_WANT_ private. (This may be done in a follow-up, but it's a good way to validate the new mechanism.)

The goal is to reject incomplete migrations of configurations from Mbed TLS 3.x. In particular, if the user attempts to set a legacy crypto option because of an incomplete migration from a configuration without MBEDTLS_PSA_CRYPTO_CONFIG, this should be rejected.

See “Strategy for removing a compilation option” in Mbed-TLS/TF-PSA-Crypto#145 (published soon) for further considerations.

@gilles-peskine-arm gilles-peskine-arm added api-break This issue/PR breaks the API and must wait for a new major version enhancement size-s Estimated task size: small (~2d) labels Apr 24, 2025
@gilles-peskine-arm gilles-peskine-arm self-assigned this Apr 24, 2025
@gilles-peskine-arm gilles-peskine-arm moved this to Implementation in progress in Mbed TLS 4.0 planning Apr 24, 2025
@mpg
Copy link
Contributor

mpg commented Apr 25, 2025

@gilles-peskine-arm
Copy link
Contributor Author

Consider the following user story:

As a developer of some middleware using Mbed TLS (especially for cryptography),
I want to write a single configuration file that works both with Mbed TLS 3.6 and TF-PSA-Crypto 1.x,
so that my middleware can be built indifferently with an LTS branch or the latest release of Mbed TLS and TF-PSA-Crypto.

This is mostly doable through conditionals on MBEDTLS_VERSION_MAJOR, which is set by including the configuration file. Note that we don't have a TF-PSA-Crypto equivalent yet.

Note that it gets a little complicated if the same configuration file is parsed first by tf-psa-crypto/build_info.h, and then again by mbedtls/build_info.h. The first time round, MBEDTLS_VERSION_MAJOR is not defined yet!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-break This issue/PR breaks the API and must wait for a new major version enhancement size-s Estimated task size: small (~2d)
Projects
Status: Implementation in progress
2 participants