Commit Graph

34125 Commits

Author SHA1 Message Date
Minos Galanakis
486b6c8252 components-configuration-crypto: Migrated components with custom LDFLAGS to cmake
Certain testing components require building with a specific subset of LDFLAGS,
such as `-O1`. This patch moves them to the default cmake invokation of `cmake .`
which is the equivalent of `cmake -D CMAKE_BUILD_TYPE:String=None .`

Also remove flags such as `-Werror` which are present in all configs.

Improve compilation flag granularity by disabling CMAKE_BUILD_TYPE defaults
and asserting test-specific flags manually.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-01-12 16:30:33 +00:00
Minos Galanakis
1fcca1f255 component-configuration-crypto: Migrated component_test_crypto_full_md_light_only to cmake
Use compilation directory for object discovery in out-of-source CMake builds.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-01-12 16:30:33 +00:00
Minos Galanakis
5e99591870 components-configuration-crypto: Migrated include dir dependant Release components to cmake
Moved the following components to CMAKE_BUILD_TYPE:String=Release
and adjusted  the include paths for cmake:
* component_build_psa_crypto_spm
* component_test_tfm_config_no_p256m

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-01-12 16:30:33 +00:00
Minos Galanakis
6db68f929b components-configuration-crypto: Migrated straightforwad Release components to cmake
- By default all unspecified build-type components should be release
- CMAKE_BUILD_TYPE:String=Release enables the following
  CFLAGS: "-O2 -Werror -Wall -Wextra"

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-01-12 16:30:33 +00:00
Minos Galanakis
279c016d87 components-configuration-crypto: Migrated test_tfm_config_p256m_driver_accel_ec to cmake
Compilation flags, and spe include directories have been adjusted

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-01-12 16:30:33 +00:00
Minos Galanakis
3baeee8647 components-configuration-crypto: Migrated test_full_static_keystore to cmake
Optimization for size (-Os) is required.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-01-12 16:30:33 +00:00
Minos Galanakis
d1307a1d40 components-configuration-crypto: Migrated simple ASAN components.
Migrate all straightfoward components from using $ASAN_CFLAGS
to CMAKE_BUILD_TYPE:String=Asan

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-01-12 16:30:33 +00:00
Valerio Setti
fef622c2d0 Merge pull request #10559 from valeriosetti/fix-not-grep
tests: scripts: configuration-crypto: fix paths for "not grep"
2026-01-12 14:48:35 +00:00
Valerio Setti
c58c20d4fa tests: scripts: fix grep paths in test_tfm_config_p256m_driver_accel_ec
Paths for "not grep" should have been updated when the build system
switched from Makefile to CMake.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-01-12 13:29:14 +01: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
Valerio Setti
f7173e4389 Merge pull request #10517 from valeriosetti/issue10460
Remove use of pk_debug()
2026-01-09 15:22:13 +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
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
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
Gilles Peskine
6250af4c9c Merge pull request #10554 from gilles-peskine-arm/sha3-cleanup-202512-prep
SHA3 cleanup prep
2026-01-07 10:35:10 +00:00
Gilles Peskine
dd255696a5 Make use of some intermediate variables
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 11:17:43 +01:00
Gilles Peskine
b988dd8f35 Remove accidentally duplicated definitions
"Move crypto-specific code from library/Makefile to a new file" accidentally
copied two lines instead of moving them. Remove the copy that's now in
`crypto-library.make`, since the variables are defined earlier in
`crypto-common.make`. The variables aren't actually used in
`crypto-common.make`, but they could be (arguably should be used to
define `TF_PSA_CRYPTO_LIBRARY_PRIVATE_INCLUDE`).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 11:17:43 +01:00
Gilles Peskine
562677945b Use intermediate variable for TF-PSA-Crypto's contribution to LOCAL_LDFLAGS
Fix a bug whereby `crypto-common.make` was appending to `LOCAL_LDFLAGS`
before `common.make` set the initial value. This broke the build with
pthread enabled: `THREADING` was correctly getting autodetected, but the
addition of `-lpthread` to `LOCAL_LDFLAGS` didn't work.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 11:17:43 +01:00
Gilles Peskine
8a528cfed5 Split the rules to generate config tests
Have crypto handle the crypto part and tls handle the tls part.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 11:17:43 +01:00
Gilles Peskine
49d698588b Move crypto-specific code from tests/Makefile to a new file
The new file is in Mbed TLS for now. Once we have finished moving code to
it, it will move to TF-PSA-Crypto.

What got moved:

* List of generated .data files in crypto
* Rules to generate .data files in crypto
* List of test suites in crypto
* List of generated .h files in crypto
* Rules to generate .h in crypto

What didn't get moved:

* Rules to generate the crypto part of `$(GENERATED_CONFIG_DATA_FILES)`,
  because they are currently mixed with the rule for the mbedtls part. This
  will be done in a subsequent commit.
* Rules to generate .c files from .function files, and to compile the
  resulting .c files. At least for now, we let Mbed TLS decide how to do
  that on its own.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 11:17:43 +01:00
Gilles Peskine
cffc11878f Move crypto-specific code from programs/Makefile to a new file
The new file is in Mbed TLS for now. Once we have finished moving code to
it, it will move to TF-PSA-Crypto.

What got moved:

* List of generated .c files in crypto
* Rules to build generated .c files in crypto
* List of apps in crypto
* Rules to build apps in crypto

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 11:17:43 +01:00
Gilles Peskine
8ac7168799 Move crypto-specific code from library/Makefile to a new file
The new file is in Mbed TLS for now. Once we have finished moving code to
it, it will move to TF-PSA-Crypto.

What got moved:

* List of object files from crypto
* List of generated .c files in crypto
* Rules to build generated .c files in crypto

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 11:17:43 +01:00
Gilles Peskine
d9c6a411c6 Introduce intermediate variables for various TF-PSA-Crypto lists
Use separate variables for the crypto part of lists of generated C files,
generated objects, sample programs and test data files.

No behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 11:17:43 +01:00
Gilles Peskine
ef25955786 Move THREADING autodetection to crypto-common.make
Note that `THREADING` detection must be done after
`TF_PSA_CRYPTO_LIBRARY_PUBLIC_INCLUDE` is defined. Otherwise it won't detect
whether pthread is needed, and will never link with `-lpthread`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 11:17:43 +01:00
Gilles Peskine
c00bd2a6fb THREADING autodetection: only check the crypto config
When running the preprocessor to determine whether pthread is enabled, only
use TF-PSA-Crypto include paths. Don't use the rest of `LOCAL_CFLAGS`,
including Mbed TLS include paths, which aren't really useful here.

This will simplify later refactorings, because it simplifies a dependency
chain [crypto paths] → `LOCAL_CFLAGS` → `THREADING` → `LOCAL_LDFLAGS`
into just [crypto paths] → `THREADING` → `LOCAL_LDFLAGS`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 11:17:43 +01:00
Gilles Peskine
2607134998 Move configurable variables to the top
Define variables that are meant to be possibly overridden on the make
command line (or in a parent makefile) at the top. In particular, define
them before including the crypto and framework makefiles, so these makefiles
can use the default values if there's no parent setting.

Also move some internal variables earlier or later, so that a subsequent
refactoring step can have things in the right order in the mbedtls
per-directory makefile:

1. Define variables consumed by the per-directory crypto makefile.
2. Include the per-directory crypto makefile.
3. Use variables defined by the per-directory crypto makefile.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 11:17:43 +01:00
Gilles Peskine
e3e4da61a8 Use intermediate variables for TF-PSA-Crypto's contribution to LOCAL_CFLAGS
Define these intermediate variables in the crypto helper file.

No behavior change except possibly an inconsequential reordering of compiler
options.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 11:17:43 +01:00
Gilles Peskine
46568f3c6e Move some crypto core and drivers variable definitions to crypto-common.make
No behavior change.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 11:17:43 +01:00
Gilles Peskine
7bef731f0b Create a TF-PSA-Crypto make helper for Mbed TLS
Currently, Mbed TLS can be built with make, and we rely on this in many
`all.sh` components. Mbed TLS knows how to build TF-PSA-Crypto, but this
changes from time to time, and it's hard to do the necessary changes in both
repositories at the same time.

Create a file that Mbed TLS can consume to find out some information needed
to build TF-PSA-Crypto, such as the locations of various files.

Create this file in Mbed TLS. Once we have finished moving code to it, the
file will move to TF-PSA-Crypto.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 11:17:43 +01:00
Gilles Peskine
a47cc27657 Fix mixup in dependencies for generated config checks
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 11:17:43 +01:00
Gilles Peskine
d78060bda6 Get a clean run from make --warn-undefined-variables
Except in psasim, which I am not touching at this time.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 11:17:43 +01:00
Gilles Peskine
f79f4014b6 Fix missing dependencies of test_certs.h
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 11:17:43 +01:00
Gilles Peskine
3884bf3d89 Remove a XySSL-era comment that has run its course
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 11:17:43 +01:00
Gilles Peskine
d13d041ed0 Check for the framework submodule before anything else
If we don't have submodules, we can't do anything.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-07 11:17:43 +01:00