Commit Graph

34597 Commits

Author SHA1 Message Date
Gilles Peskine 93d94f4b42 c_build_helper: don't hide the compiler output
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-20 11:31:45 +01:00
Gilles Peskine 390abf3b39 Fix compatibility with old CMake
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-19 12:36:38 +01:00
Gilles Peskine ab1a43e781 check_names: Use the same Python executable instead of python3
Fix build failure in environments where `python3` doesn't exist or is too
old.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-19 12:34:34 +01:00
Gilles Peskine 18525876aa check_names: allow pqcp driver to configure mldsa-native
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-15 19:31:32 +01:00
Gilles Peskine 0c94e7d164 check_names: Allow mldsa-native symbols to be undeclared
The mldsa-native and mlkem-native headers use preprocessor tricks to
construct identifiers. We can't recognize those. So f a symbol found in the
binary is in the expected sub-namespace for those parts of the library,
allow it to be undeclared.

Make the exception general enough for mldsa-native (needed now) and
mlkem-native (needed soon).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-15 19:31:27 +01:00
Gilles Peskine dd06b4989f check_names: tighten the pattern for internal macros
The pattern for internal macros was weird, in part, because of the unusual
short names we use in bignum code. Make the pattern stricter, but add an
exception mechanism. Declare an exception for those bignum names, but
allow them only in bignum code.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-15 19:23:27 +01:00
Gilles Peskine 21007fc2bc check_names: use set, not list, when only testing membership
It's both clearer and faster.

No semantic change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-15 18:09:14 +01:00
Gilles Peskine 2f01eca203 check_names: add type annotations
I needed that to understand how the data is represented (str vs Match, list
vs set vs tuple, ...).

No semantic change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-15 18:09:08 +01:00
Gilles Peskine 8caa0e42ab check_names: Use dedicated class for parse results
Use a typed namespace instead of a dictionary with heterogenously typed values.

No semantic change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-15 18:08:56 +01:00
Gilles Peskine 8b6217bba8 check_names: don't build what we don't need
We only look at symbols in the library, so don't bother building tests.

No semantic change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-15 18:08:46 +01:00
Gilles Peskine fceee93024 Add drivers/pqcp/include to C include paths
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-12 13:26:25 +01:00
Ronald Cron ebad5b9817 Merge pull request #270 from gilles-peskine-arm/make_generated_files-use_same_python
Use the same Python executable instead of `python`
2026-01-12 12:04:30 +01:00
Gilles Peskine a56534ba79 Use the same Python executable instead of python
`python` might be the wrong version, for example it might be Python 2 on
some systems, or it might be a different version of Python 3. Use
`sys.executable`, so that the same version gets used consistently.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-09 20:44:58 +01:00
Gilles Peskine ee399cc257 Merge pull request #245 from gilles-peskine-arm/make_generated_files-fix-check
Fix make_generated_files --check
2026-01-09 10:46:49 +01:00
Valerio Setti dae1609b58 Merge pull request #253 from gilles-peskine-arm/all.sh-cleanup-cmake-only-in-tree
Only clean CMake artifacts in-tree
2026-01-08 10:49:05 +01:00
Gilles Peskine 898a721b9d Fix missing cleanup of toplevel Makefile
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 19:52:49 +01:00
Gilles Peskine a082c08a1d CMake artifacts cleanup: fix the new code on Ubuntu 16.04
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 19:52:49 +01:00
Gilles Peskine ffeda99865 Only clean CMake artifacts in-tree
Don't recurse into every subdirectory: that also removed files from
out-of-tree builds that the user may have placed into subdirectories. With
make as the build tool, the cleanup is mostly recoverable, but with ninja as
the build tool, you have to manually run `cmake` again after running
`all.sh`.

Instead, look for things to clean only in directories managed by git.

This also has the benefit of not touching `**/Makefile` if there hasn't been
an in-tree CMake build.

Fixes https://github.com/Mbed-TLS/mbedtls-framework/issues/252

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 19:52:49 +01:00
Gilles Peskine feef17dcf3 Actually fail if --check fails
Return a nonzero status if called with `--check` and the check finds some
problems.

Fixes #244.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 19:24:20 +01:00
Gilles Peskine b8d3b81597 Add missing type annotations
mypy only checks types in functions that have a return type annotation.

In `check_generated_files`, change from returning `None` to returning a
boolean, since the function is supposed to check some boolean-valued
assertion. So far, the function always returns `True`.

In `main`, explicitly return an `int` value as expected by the caller. When
calling `check_generated_files`, convert the boolean result into an exit
status.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 19:24:20 +01:00
Gilles Peskine 77f707a557 Merge pull request #260 from gilles-peskine-arm/config-checks-generator-current-framework
framework: generate_config_checks.py: use current data
2026-01-05 11:29:43 +01:00
Gilles Peskine fa64d11a81 Simplify shadow file comparison interface
Provide one method to just give a boolean result, and one to give a
diff-like output as a simple string.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-02 22:20:46 +01:00
Gilles Peskine 58957b982a Add code to update the shadow file
Add code to compare the shadow file containing the list of config options
with the options in the config file. Also add code to update (or just
create) the shadow file.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-12-30 17:13:22 +01:00
Gilles Peskine 530dbad925 Read current options from a shadow file rather than the config file
The list of current options needs to be up-to-date, so we can't just use
historical data.

Users may edit the default config file (`include/tf-psa-crypto/crypto_config.h`
or `include/mbedtls/mbedtls_config.h`). One of the reasons we use the list of
config options is to prevent users from defining internal macros in their
config file (in code generated by `generated_config_checks.py`). An internal
macro is one that isn't listed in the official config file. So we need to
know what macros are listed in the official config file, regardless of edits
to the current config file.

Hence we read a "shadow file" which contains the official list of options,
rather than the "live" config file. This file will need to be kept
up-to-date during development, but is not user-editable.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-12-30 17:13:22 +01:00
Gilles Peskine 7f66782321 New module to load lists of config and adjusted macros
Load the list of C preprocessor macros that are options in the configuration
file (`mbedtls/mbedtls_config.h` or `psa/crypto_config.h`), and the list of
C preprocessor macros that are defined in `*adjust*.h` but are not public
options (derived internal macros).

The new module `config_macros` supports both querying the current tree and
querying historical data saved by `save_config_macros.sh`, with the same
query interface. The part that queries historical data subsumes the
`config_history` module.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-12-23 12:34:02 +01:00
Bence Szépkúti 7e8ddd4d92 Merge pull request #229 from bensze01/abicheck-port
Update abi_check.py to support standalone tf-psa-crypto
2025-12-22 22:22:02 +01:00
Bence Szépkúti 12fe6e31e7 Fix copypasta in check-python-files.sh
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-12-18 20:20:25 +01:00
Bence Szépkúti 5066f2cbf9 Work around code duplication warning in pylint
Use `find` to sort scripts/abi_check.py into a separate invocation of pylint.

Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-12-18 20:20:25 +01:00
Bence Szépkúti f9c2d65909 Preserve the docstring's formatting in the description
The default formatter coalesces all whitespace and reflows the text.

Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-12-18 20:20:25 +01:00
Bence Szépkúti 074abc17d8 Remove unused version parameter
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-12-18 20:20:25 +01:00
Bence Szépkúti 25872c333d Rename abi_check and convert it to a pure-play module
The actual scripts will continue to live in the individual repositories.

Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-12-18 20:20:25 +01:00
Bence Szépkúti 781620871b Do not change the working directory
The only value that depended on us being in the project root was repo_path.

Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-12-18 20:20:25 +01:00
Bence Szépkúti 9f715c0e78 Make the name-clash detection more readable
No functional changes.

Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-12-18 20:20:25 +01:00
Bence Szépkúti feed0606f0 Remove stray debugging bypasses
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-12-18 20:20:25 +01:00
Bence Szépkúti 315dc8af57 Allow calling abi_check.py from tf-psa-crypto
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-12-18 20:20:25 +01:00
Bence Szépkúti 56400d627e Detect soname clashes
The same library may be present in the same build tree, eg.
libtfpsacrypto.so, which gets copied from the tf-psa-crypto/core/ to
library/ during an Mbed TLS build.

Make sure that the duplicated libraries are byte-for-byte identical,
otherwise abort the test.

Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-12-18 20:20:25 +01:00
Bence Szépkúti dad0f26dc2 Build library using CMake
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-12-18 20:20:25 +01:00
Bence Szépkúti 40eb9b1846 Log output of failed subprocesses
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-12-18 20:20:25 +01:00
Bence Szépkúti a154f6326b Remove dead code related to the old crypto submodule
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-12-18 20:20:25 +01:00
Bence Szépkúti fdb9b08cbb Fix reporting invalid arguments
Argparse generally uses a return code of 2 for these situations.

Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-12-18 20:20:25 +01:00
Bence Szépkúti fc6b6426b4 Fix import path
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-12-18 20:20:25 +01:00
Bence Szépkúti ebd2cd5b82 Merge branch mbedtls/development into abicheck-port 2025-12-18 20:20:22 +01:00
Bence Szépkúti 49e9d30bcd Move abi_check.py into the framework
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-12-18 20:12:48 +01:00
Ronald Cron f4dbe69f87 Merge pull request #254 from mpg/config-test-builtin
Adjust macros used in generated config tests
2025-12-18 15:49:37 +01:00
Ronald Cron 14bf96af2b Merge pull request #258 from gilles-peskine-arm/generate_test_cert_macros-fix_list_dependencies
Framework: Split crypto part of Mbed TLS makefiles
2025-12-18 15:04:52 +01:00
Gilles Peskine 0e6a1b6463 generate_test_cert_macros.py: fix --list-dependencies
Fix non-file elements appearing in
`generate_test_cert_macros.py --list-dependencies`. That only worked
because Mbed TLS didn't call it as intended (not done in `CMakeLists.txt`
or `make_generated_files.py`, and buggy in `tests/Makefile`).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-12-17 16:27:24 +01:00
Manuel Pégourié-Gonnard fd7b6f8716 Remove useless entries from modules list
- ECDH_C is not longer needed since the previous commit
- CIPHER_C and ECDSA_C were already useless

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-12-17 10:01:16 +01:00
Manuel Pégourié-Gonnard 45014a8dec Special-case the Everest option in 1.x
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-12-17 10:01:16 +01:00
Ronald Cron 5ef7e74c53 Merge pull request #243 from ronald-cron-arm/test-driver
Add support for TF-PSA-Crypto test driver
2025-12-11 19:29:06 +01:00
Ronald Cron 2bde77939f test_driver.py: Make __write_test_driver_files an instance method
Make __write_test_driver_files an instance method
instead of a static method as it is supposed to
be used only in an instance context.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2025-12-11 15:09:41 +01:00