35109 Commits

Author SHA1 Message Date
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
Ben Taylor 095fe073c3 Update tf-psa-crypto and framework modules to resolve merge conflict and config_macros import error
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-01-12 08:19:07 +00:00
Ben Taylor c23592d7ee Add improvements to code comments and docs
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-01-12 08:19:07 +00:00
Ben Taylor 085aef59ca Change function name from mbedtls_pk_key_type_to_string to mbedtls_x509_pk_type_as_string
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-01-12 08:19:07 +00:00
Ben Taylor f77d749127 Further updates to ssl-opt tests as wrapped keys now expose the underlying type
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-01-12 08:19:07 +00:00
Ben Taylor 98e958c91e Update ssl-opt tests as wrapped keys now expose the underlying type
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-01-12 08:19:07 +00:00
Ben Taylor 81deeb8a5a Update ssl-opt to remove Opaque key types
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-01-12 08:19:07 +00:00
Ben Taylor 837a3cec40 rename function
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-01-12 08:19:07 +00:00
Ben Taylor f9b95cedaa Fix style issues
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-01-12 08:19:07 +00:00
Ben Taylor 2481daa309 Replace mbedtls_pk_get_name with pk_key_type_to_string
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-01-12 08:19:07 +00:00
Valerio Setti 5aba22b3df tests: scripts: configuration-crypto: fix paths for "not grep"
A switch has recently been made from make to cmake to build these tests
but paths for "not grep" were not properly updated.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-01-09 22:52:45 +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
Valerio Setti f7173e4389 Merge pull request #10517 from valeriosetti/issue10460
Remove use of pk_debug()
2026-01-09 15:22:13 +00: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
Minos Galanakis f51cf54fd4 all-core.sh: Allow overriding of the psa-sim location
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-01-08 17:46:11 +00:00
Minos Galanakis 7f6ad7c9b8 psasim: Update location in Makefile and all-core.sh
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-01-08 17:45:54 +00:00
Minos Galanakis fc4689b631 Removed old psasim dir
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-01-08 17:45:19 +00:00
Minos Galanakis daee5e1925 Merge branch 'tmp-branch-move-files-to-framework' into move-files-into-framework
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-01-08 17:43:06 +00:00
Minos Galanakis d9823616cf Moved tests/psa-client-server to framework.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-01-08 17:15:35 +00:00
Minos Galanakis bf381062bf psasim: Moved to psasim_deprecated
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-01-08 17:13:53 +00:00
Valerio Setti fdccbbb91f tests: scripts: configuration-crypto: fix paths after switch to CMake
Switching to CMake build caused some failures due to the fact that:

- binary objects in tf-psa-crypto are not in the same location as before;
- header files from "<mbedtls-root>/include" are no more included when
  building tf-psa-crypto ojects.

This commit fixes both problems.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-01-08 17:53:56 +01:00
Ronald Cron 193401cce1 Merge pull request #10544 from gilles-peskine-arm/move-crypto-makefiles
Let crypto own its part of the makefiles
2026-01-08 16:02:56 +00:00
Gilles Peskine 4ffb299208 Remove local copies of makefile helpers
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-08 14:57:50 +01:00
Gilles Peskine e23b6e4dc8 Use the crypto makefile helpers in tf-psa-crypto
Now that the crypto files have been moved to the crypto repository, consume
them there.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-08 14:57:50 +01:00
Gilles Peskine fca232cb25 Update tf-psa-crypto with makefile helpers
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-08 14:57:50 +01:00
Valerio Setti 059aac8680 tests: scripts: build with cmake in all components using Asan
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-01-08 14:33:30 +01:00
Valerio Setti 0294b11967 Merge pull request #10556 from gilles-peskine-arm/sha3-cleanup-202512-prep2
SHA3 cleanup prep: Adapt to the split of test_suite_shax
2026-01-08 12:18:28 +00: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
Valerio Setti 4d62c59a56 tests: scripts: add new component to test with only pkwrite disabled
This is similar to the already existing "component_full_no_pkparse_pkwrite".
The biggest difference is that this new component starts from "full" config
instead of "crypto_full" because we want to test also some TLS modules,
in particular "test_suite_debug" where the new function
"mbedtls_pk_write_pubkey_psa" has been introduced.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-01-08 10:32:57 +01:00
Valerio Setti ebbaca0a99 library: debug: adjust guards for "mbedtls_debug_print_crt"
Keep MBEDTLS_PK_WRITE_C as guard only for "debug_print_pk" but let
"mbedtls_debug_print_crt" to work also when MBEDTLS_PK_WRITE_C is disabled.
In this case the only public key won't be printed, but the rest of the
certificate will be.

This commit also updates test coverage by duplicating test cases: now there
will be one case for when MBEDTLS_PK_WRITE_C is enabled and another one
for !MBEDTLS_PK_WRITE_C.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-01-08 10:32:57 +01:00
Valerio Setti 2af638a177 library: debug: fix print format in mbedtls_debug_print_buf_ext()
%zu creates problem in MinGW testing. Use MBEDTLS_PRINTF_SIZET intead.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-01-08 10:32:57 +01:00
Valerio Setti d040eb823e include: debug: fix guards for MBEDTLS_SSL_DEBUG_CRT
Guards for "mbedtls_debug_print_crt()" were updated in previous commit,
but those changes were not applied to MBEDTLS_SSL_DEBUG_CRT therefore
causing build failures in the CI. This commit fixes the problem.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-01-08 10:32:57 +01:00
Valerio Setti af62bae5c1 library: debug: add PK_WRITE_C guard to mbedtls_debug_print_crt()
In tf-psa-crypto "mbedtls_pk_write_pubkey_psa()" is only available when
MBEDTLS_PK_WRITE_C is defined. Therefore we need to add this guard also
in mbedtls to "debug_print_pk" (and indirectly to
"mbedtls_debug_print_crt") and the corresponding tests using it.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-01-08 10:32:57 +01:00
Valerio Setti 3c419c1ca3 tests: scripts: adjust CRT dump test data
Adjust dumping format of public keys following recent updates to
mbedtls_debug_print_crt() and debug_print_pk()

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-01-08 10:32:57 +01:00
Valerio Setti f1cb45289b library: debug: improve mbedtls_debug_print_buf()
Move single line printing to a separate function named
mbedtls_debug_print_buf_one_line(). This accepts one extra parameter
'add_text' to tell if the final text chars are to be printed at the end
of the line or not.

Add also mbedtls_debug_print_buf_ext() as a generalized version of
mbedtls_debug_print_buf() by adding the extra 'add_text' param.

debug_print_pk() will now use mbedtls_debug_print_buf_ext() in order not
to print chars while dumping the buffer.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-01-08 10:32:57 +01:00
Valerio Setti c6bf9d8200 library: debug: use mbedtls_pk_write_pubkey_psa() to write public key
Remove usage of mbedtls_pk_debug stuff and related functions
(mbedtls_debug_print_psa_rsa(), mbedtls_debug_print_psa_ec(),
mbedtls_debug_print_integer() and debug_count_valid_bits()) and use
mbedtls_pk_write_pubkey_psa() to get the public key from the PK context.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-01-08 10:32:57 +01:00
Valerio Setti 10eaf68acd library: debug: remove mbedtls_debug_print_mpi()
This function is no more used anywhere and can be safely removed.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-01-08 10:32:57 +01:00
Valerio Setti fa298be91a tests: src: pk_helpers: style fix in code and documentation
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-01-08 09:28:34 +01:00
Valerio Setti e28511869c tests: src: pk_helpers: select predefined keys using PSA key type and bits
A new look-up table is created, "predefined_keys_psa", to list all the
predefined keys together with the corresponding PSA key type and bits.
A new look-up table was created in order not to conflict with the already
existing "predefined_keys" one.

"mbedtls_pk_helpers_get_predefined_key_data" is modified in order to
use the new look-up table.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-01-08 09:16:21 +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
Valerio Setti 88e0eb729e tests: src: pk_helpers: add documentation and proper functions prefix
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-01-07 18:25:07 +01:00
Valerio Setti 6d2ca07e72 scripts: generate_test_keys: minor improvements
- better guard for the "ecp.h" header file;
- use already existing Mbed TLS' macro for unused variables and place it
  at the beginning of the declaration of "predefined_keys".

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-01-07 18:25:06 +01:00
Gilles Peskine 68b0ad1512 Adapt to the split of test_suite_shax
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 16:19:48 +01:00
Ronald Cron 67152f3049 Merge pull request #10543 from gilles-peskine-arm/split-crypto-makefiles
Split crypto part of Mbed TLS makefiles
2026-01-07 15:18:32 +00:00
Ronald Cron a271e934ed Merge pull request #10555 from gilles-peskine-arm/sort-config_check_user-mbedtls
Fix non-determinism when generating mbedtls_config_check_user.h
2026-01-07 11:45:51 +00:00
Valerio Setti 92d56edb31 scripts: generate_test_keys: allow multiple usage of the generated header
- declare all arrays and structures as static
- add guards to the header file

This allows multiple inclusions of the generated header file.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-01-07 12:24:32 +01:00