2349 Commits

Author SHA1 Message Date
Gilles Peskine 8e44a94d39 Automatically generate checkers for removed options
Read the list of historical config options in 3.6, compare that to 1.0/4.0
and emit the appropriate checkers.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-24 17:20:35 +02:00
Gilles Peskine 24273c06db Checks for crypto options or internal macros set in mbedtls
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-24 17:20:35 +02:00
Ronald Cron 3a252dda0c Adapt code_size_compare.py to make deprecation and submodules
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2025-09-24 16:31:12 +02:00
Ronald Cron 37148d0fe3 Adapt memory.sh to make deprecation
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2025-09-24 12:39:29 +02:00
Ronald Cron 15cd8b0a63 Adapt footprint.sh to make deprecation
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2025-09-24 12:38:35 +02:00
Gilles Peskine 0acab5c3c6 Improve documentation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-23 16:26:04 +02:00
Gilles Peskine 48a1cbc930 Use -C as the option to convey a directory to run git in
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-23 16:24:27 +02:00
Gilles Peskine 00dddd271f Fix save_config_history.sh when options are passed
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-23 16:24:05 +02:00
Gilles Peskine 4402172a0f Remove redundant assignment
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-23 16:18:17 +02:00
Gilles Peskine fcfe1920c4 Remove subproject as a constructor argument
There's only one subproject and that's unlikely to change, so being able to
specify a subproject at runtime is overkill.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-23 16:14:57 +02:00
Gilles Peskine caaf52d6d0 Merge pull request #10391 from bjwtaylor/remove-deprecated-compilation-options-2
Remove deprecated compilation options 2
2025-09-23 08:40:11 +00:00
Ronald Cron e7bac84a22 Remove the generation of MS visual studio files
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2025-09-22 18:00:26 +02:00
Ronald Cron 31f63210ec Deprecate Make
Move and rename the root Makefile to
scripts/legacy.make. That way running
make from the root fails.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2025-09-22 18:00:26 +02:00
Ronald Cron bb02ec121e Prepare abi_check.py to scripts/legacy.make
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2025-09-22 18:00:26 +02:00
Ronald Cron 879cba1a67 cmake: Introduce version and soversion variables
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2025-09-22 14:34:55 +02:00
Ben Taylor 62491a9327 Revert changes to config.py after dependencies have been merged
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-09-22 09:07:12 +01:00
Gilles Peskine 83e8568dcf New script to save historical config options information
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-19 21:12:22 +02:00
Gilles Peskine 2a68ccf3d1 New module to load historical config options information
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-19 21:12:22 +02:00
Gilles Peskine 08b8ce3a4b Add function to get the framework root
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-19 21:12:22 +02:00
Gilles Peskine 172e29bd7c Run cc instead of cpp
Run a C compiler, not just the preprocessor. This allows capturing static
assertions (`MBEDTLS_STATIC_ASSERT`).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-19 21:12:22 +02:00
Gilles Peskine 103cdbc45c Support non-ASCII compiler messages (assume UTF-8)
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-19 21:12:22 +02:00
Gilles Peskine f7efa1436d Add checker classes for options used in the wrong project
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-19 21:12:20 +02:00
Gilles Peskine 3374f6e90b Generate checks for bad options in the config file
Just a proof-of-concept for now. Interesting checks will come later.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-19 13:36:24 +02:00
Ronald Cron b74b7c7f1e Merge pull request #210 from ronald-cron-arm/prepare-for-visualc-removal
Prepare make_generated_files.py to the removal of generate_visualc_files.pl
2025-09-17 23:10:24 +02:00
Gilles Peskine 37f6573319 Allow some generated files not to exist is bak
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-17 13:09:00 +02:00
Gilles Peskine 302015e0d4 Silence pylint
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-17 12:30:09 +02:00
Gilles Peskine e2c15fbd66 Allow some generated files not to exist
When we add a new generation script in crypto, there is a transition period
when mbedtls does not yet know that it has to run this script. For this
transition period, we can declare the script as optional, and
`make_generated_files.py --check` will not complain if the files are
missing.

Apply this, right now, to `scripts/generate_config_checks.py`, which is
being introduced in TF-PSA-Crypto.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-17 11:36:13 +02:00
Gilles Peskine 06f9c84203 Friendlier error if a file doesn't exist
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-17 11:36:11 +02:00
Gilles Peskine b03e60a836 Have --list print a relative path in the common case
When the current directory is the project root, have `--list` print relative
paths, rather than absolute paths that start with
`build_treeguess_project_root()`.

This is not only nice to humans, but also necessary for
`make_generated_files.py --root DIR --check`: it calls
this script with `--list` and expects a path that is relative
to DIR, not an absolute path that is under the project root.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-16 22:07:19 +02:00
Ronald Cron fa6b187a43 Adjust MBEDTLS_GENERATION_SCRIPTS outside of main
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2025-09-16 18:16:52 +02:00
Gilles Peskine 82a7962c5f Merge remote-tracking branch 'main' into restricted-framework-merge-public-20250916 2025-09-16 16:16:24 +02:00
Ronald Cron 919a1e4e22 Cleanup following the removal of RSA legacy options
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2025-09-16 15:53:43 +02:00
Ronald Cron 2b7f59535f Remove completely MBEDTLS_PLATFORM_GET_ENTROPY_ALT
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2025-09-16 15:53:43 +02:00
Gilles Peskine b7333145d3 Fix generate_config_checks.py not actually generating the files
`output_files` was accidentally an iterator that was not iterated over
unless one of the list-only options was enabled.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-16 12:42:35 +02:00
Gilles Peskine 7ca97be4eb Add option --list-for-cmake
Similar to `generate_*_tests.py`, let Python rather than Cmake worry about
constructing a CMake list.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-15 19:59:18 +02:00
Gilles Peskine 6235dbb314 Improve comments
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-15 19:58:34 +02:00
Gilles Peskine 5b6c405e6f Make *_config_checks_*.h automatically generated files
For the time being, only do this if the generation script
`scripts/generate_config_checks.py` exists in the consuming repository. This
way we can use this framework revision before the scripts are added to the
consuming repositories.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-15 19:58:34 +02:00
Gilles Peskine 110e61a641 Pacify check_names.py
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-15 19:58:34 +02:00
Gilles Peskine 049ff1b90b Generate config check headers
Infrastructure to generate config check headers, to be included in
`${PROJECT}_config.c`.

This commit creates a module with the core logic, and support for three
generated files, to be included before the user config, just after the user
config, and after finalizing the user config.

This commit provides a basic `Checker` class. Future commits will add
derived classes for common cases such as options set in the wrong project.

This module is meant to be used in an executable script in each project,
containing the project-specific names to use and the list of options.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-15 19:58:34 +02:00
Ronald Cron 721e0c9cb4 Prepare make_generated_files.py to the removal of generate_visualc_files.pl
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2025-09-15 10:00:59 +02:00
Gilles Peskine 44ea7135d6 Simplify passing a file to subprocess stdin
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-12 22:04:07 +02:00
Gilles Peskine aebb1faf3b Sort patch files for reproducibility
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-12 22:01:38 +02:00
Gilles Peskine 581da21d7b Allow patch files to have trailing whitespace
An unchanged blank line results in a line containing a single space in the
diff.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-12 21:59:31 +02:00
Gilles Peskine 088a99ee20 Allow framework and consuming branch to have Python scripts with the same name
mypy can't deal with two modules with the same basename on its command line.

We don't normally want modules with the same name in different directories,
to avoid confusion, but it can happen occasionally while moving files across
repositories.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-12 18:36:18 +02:00
Gilles Peskine 1295140bca Read patch files instead of taking a single patch as input
Having separate patch files has several benefits:

* They're available for integrators who wouldn't use our script to
  test compliance.
* We keep them separate so they're easier for us to keep track of,
  and apply separately if needed.
* No need to cheat with unchanged empty lines (normally represented by
  a line containing a single space in a patch file) to keep `check_files.py`
  happy.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-12 17:46:42 +02:00
Gilles Peskine ca98305f7f Treat xxx_HAS_xxx as not a constructor, like xxx_IS_xxx etc.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-12 17:02:30 +02:00
Gilles Peskine 954783cb01 macro_collector: be stricter about unusual macros
When looking for constructors, do complain if we see an unusual macro with a
parameter: there's a significant chance that it's something new that will
require specific handling. As a consequence, we need to explicitly skip more
things that are known not to be constructors.

Keep ignoring macros without parameters that don't look like constructors
for the types we care about. Those probably don't matter.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-12 17:02:30 +02:00
Gilles Peskine b4035db7a1 Fix [] used as a default argument value (mutable default values are dodgy)
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-12 10:44:41 +02:00
Gilles Peskine 565b4c35bf Skip all knowledge of SPAKE2+ keys for now
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-11 21:52:53 +02:00
Gilles Peskine af6b1894b0 Teach crypto_knowledge the categories of SP800_100 and SPAKE2P algorithms
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-11 21:51:53 +02:00