32229 Commits

Author SHA1 Message Date
Gabor Mezei
035d7c8cfa
Move file backup support to config_common.py
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2024-10-21 14:26:52 +02:00
Gabor Mezei
f5408f0909
Enable usage of crypto config in depends.py
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2024-10-21 14:26:52 +02:00
Harry Ramsey
b791a88c33 Fix test case dependency
This commit fixes the error test suite to depend on MBEDTLS_ERROR_C
rather than MBEDTLS_ERRORCOMMON_C.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-21 12:07:27 +01:00
Harry Ramsey
bef54c5003 Remove unnecessary if defined
This commit removes unnecessary if defined for multiple files as they
are already guarded.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-21 12:00:24 +01:00
Gilles Peskine
6707584614
Merge pull request #9593 from gilles-peskine-arm/test-cases-not-executed-enforce-development
Test cases not executed: switch to enforcement mode
2024-10-18 18:19:34 +00:00
Harry Ramsey
924dca9d39 Move mbedtls_test_hook_error_add from error.c to helpers.c
This commit moves mbedtls_test_hook_error_add from error.c to helpers.c.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-18 15:16:05 +01:00
Harry Ramsey
c44f67b581 Fix error.c generation issue with headers
This commit fixes include issues with error.c. Since error_common.h now
defines error codes, this is a mandatory include. The macro
MBEDTLS_ERROR_C guards functions for strerror which is now found in
error.h.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-18 11:17:50 +01:00
Harry Ramsey
9c66405098 Disable strerror in test programs
This commit disables printing strerror messages in test programs. This
is due to moving the functions back to Mbed TLS and wanting to keep
dependencies of programs small. The code has not been removed but simply
commented out for when these functions are reimplemented.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-18 11:17:50 +01:00
Ronald Cron
d916cc9755 tf-psa-crypto: cmake: Add lcov target
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-18 11:45:37 +02:00
Ronald Cron
4802aaab56 Adapt lcov.sh to multiple source directories
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-18 11:45:37 +02:00
Ronald Cron
4cd797e7fb tf-psa-crypto: Add cmake_package test program
We cannot add the equivalent of
cmake_package_install yet as the build in
tf-psa-crypto still references some headers
in ./include/mbedtls like mbedtls_config.h.

We cannot add the equivalent of
cmake_subproject yet as currently only
the case of the Mbed TLS parent project is
supported.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-18 11:42:17 +02:00
Ronald Cron
4870e613f8 Refactor pkgconfig.sh
Refactor pkgconfig.sh to be able to use it
for Mbed TLS and TF-PSA-Crypto packages.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-18 10:23:15 +02:00
Ronald Cron
f85882de57 tf-psa-crypto: cmake: Add package config and install support
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-18 10:23:15 +02:00
Ronald Cron
2d453c9b07 cmake: Remove custom LIB_INSTALL_DIR variable to set install dir
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-18 10:23:15 +02:00
Ronald Cron
b58c2254d6 tf-psa-crypto: cmake: Add build of documentation
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-18 10:23:09 +02:00
Ronald Cron
f584e97aed cmake: Use MBEDTLS/TF_PSA_CRYTPO_AS_SUBPROJECT
Use MBEDTLS/TF_PSA_CRYTPO_AS_SUBPROJECT
instead of using the test employed to set
MBEDTLS/TF_PSA_CRYTPO_AS_SUBPROJECT value.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-18 10:16:35 +02:00
Ronald Cron
7b2fae2be9 cmake: Remove partial support for partial use CMake build system
Let the projects using some CMakeLists.txt files
without the top CMakeLists.txt define the variables
that the top CMakeLists.txt set for all.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-18 10:16:35 +02:00
Ronald Cron
493595665e tf-psa-crypto: cmake: Fix p-256 installation
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-18 10:16:35 +02:00
Manuel Pégourié-Gonnard
fd4f2831d7 Fix a typo in a comment
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-10-18 09:58:11 +02:00
Harry Ramsey
e05cf2e11e Improve submodule error messages for Github archives
This commit improves the error messages informing users that have
downloaded Github archives to instead download a release archive. This
is due to Github not supporting submodules within archives and no
trivial way for users to use git to download them.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-18 08:20:57 +01:00
Harry Ramsey
8b4b15269a Fix test scripts for split error files
This commit fixes failing tests to do with generated files and code
styles.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-18 08:19:50 +01:00
Harry Ramsey
3901af52b8 Add x509 library to utility programs
This commit adds Mbed TLS x509 as a library dependency for utility
programs. This is necessary for strerror.c to work correctly.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-18 08:19:50 +01:00
Harry Ramsey
bd77a35b95 Move tests for error.c from tf-psa-crypto to Mbed TLS
This commit moves the test functions and test data from tf-psa-crypto to
Mbed TLS.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-18 08:19:50 +01:00
Harry Ramsey
a05bfeed1e Refactor tf-psa-crypto to use error_common.h instead of error.h
This commit refactors tf-psa-crypto to include error_common.h instead of
error.h as these files have been split and the relevant error codes are
now inside error_common.h.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-18 08:19:50 +01:00
Harry Ramsey
798d8b6533 Update build scripts for error.c generation
This commit updates the build scripts for error.c generation to be
generated in the Mbed TLS library directory.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-18 08:19:50 +01:00
Harry Ramsey
d2bcdba9ca Update generate_errors.pl for error header split
This commit updates generated_errors.pl to create the error.c file and
correctly include the error_common.h header file, which contains error
code definitions.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-18 08:19:50 +01:00
Harry Ramsey
90724f7f54 Move error.h from tf-psa-crypto to Mbed TLS
This commit moves error.h from tf-psa-crypto to Mbed TLS for 4.0
release.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-18 08:19:50 +01:00
Harry Ramsey
69b67c8626 Split error.h into error_common.h and error.h
This commit splits error.h into error_common.h containing error code
definitions and error.h which contains functions to convert error codes
to error messages.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2024-10-18 08:19:50 +01:00
Gilles Peskine
f5025e2680 Merge remote-tracking branch 'development' into test-cases-not-executed-enforce-development
Conflicts:
* framework: update to the head of 'main'.
2024-10-17 21:20:01 +02:00
David Horstmann
13d2939563
Merge pull request #9673 from eleuzi01/issue-54-fw
Move TLS auxiliary test scripts to the framework
2024-10-17 17:15:46 +00:00
Manuel Pégourié-Gonnard
dea880f035 all.sh: fix missing quotes
Without quotes, when the variable is empty, the shell will see three
tokens: [, -n, ]. After skipping ] as usual, it will see a single token,
so it will consider it not as command, but a string to be tested for "is
it empty", and since "-n" is not empty, the command will return true.

With quotes it see 4 tokens: [, -n, <empty string>, ] and interprets -n
as desired.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-10-17 09:21:19 +02:00
Gilles Peskine
86421f3e87 Update framework to main
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-16 19:34:30 +02:00
Gilles Peskine
e1f37c58a2
Merge pull request #9566 from gilles-peskine-arm/error-codes-4.0-enforce-add-macro
Error codes: enforce add macro
2024-10-16 17:28:04 +00:00
Valerio Setti
8b675b8c2c CMakeLists: use -O2 as ASAN_FLAG only in GCC versions before 7.0
Since the bug affecting the performance only affects GCC versions
before 7.0, use -O2 flag instead of -O3 for them and keep the
better optimization for newer compilers.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-10-16 16:22:24 +02:00
Valerio Setti
401c917226 Revert "Temporarily comment out tests that are clogging the CI"
This reverts commit 50d7579dd1230e4e77c2a6e14ea8c75110cd4bcb.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2024-10-16 16:22:12 +02:00
Elena Uziunaite
8b6ee19890 Update submodule after the merge
Signed-off-by: Elena Uziunaite <elena.uziunaite@arm.com>
2024-10-16 14:59:32 +01:00
Gilles Peskine
4e4647a4e7
Merge pull request #9690 from valeriosetti/fix-pk-write-buffer-overrun
pkwrite: fix buffer overrun
2024-10-16 12:00:52 +00:00
Ronald Cron
51287b3be5
Merge pull request #9700 from ronald-cron-arm/test-psa-crypto-drivers
Enable PSA_CRYPTO_CONFIG in test_psa_crypto_drivers
2024-10-16 11:29:20 +00:00
Gilles Peskine
5255a9e805 Include "error.h" for MBEDTLS_ERROR_ADD
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-16 11:52:47 +02:00
Gilles Peskine
8085f51108 Use MBEDTLS_ERROR_ADD instead of explicit addition: enforcement
Reject direct additions of error constants (regex-based approximation).

Fix the lone straggler.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-16 11:52:27 +02:00
Gilles Peskine
ed6feae513 Use MBEDTLS_ERROR_ADD instead of explicit addition: simple cases
Replace obvious additions of an `MBEDTLS_ERR_xxx` constant by a call to
`MBEDTLS_ERROR_ADD`.

Skip `case` statements since `MBEDTLS_ERROR_ADD(pp_constant)` is not a
preprocessor constant.

This commit does not replace additions split over lines. Those will be
handled in a subsequent commit.

```
git ls-files '*.h' '*.c' '*.function' '*.data' |
xargs perl -i -pe '
    next if /\bcase\b/;
    s/\b(MBEDTLS_ERR_\w+)\s*\+\s*(\w+)\b/MBEDTLS_ERROR_ADD($1, $2)/g;
    s/\b(\w+)\s*\+\s*(MBEDTLS_ERR_\w+)\b/MBEDTLS_ERROR_ADD($1, $2)/g'
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-16 11:52:24 +02:00
Manuel Pégourié-Gonnard
6c0b4e73c0 all.sh: adjust for when tf-psa-crypto is absent
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-10-16 10:50:43 +02:00
Manuel Pégourié-Gonnard
f48d4edd0c all.sh: re-instate 3.6-specific code
This aligns development and 3.6 in preparation for moving to the
framework repo.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-10-16 10:50:15 +02:00
Gilles Peskine
50d7579dd1 Temporarily comment out tests that are clogging the CI
The pk_write_pubkey_check sometimes take ~3 hours to run with
GCC+Asan on the CI in the full config. Comment out the slowest
ones while we investigate and release 3.6.2.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-16 10:48:56 +02:00
Ronald Cron
ede04b34d1 Remove unnecessary -O2 compilation flag
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-16 10:47:15 +02:00
Ronald Cron
6197cdf869 Fix comment
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-10-16 10:45:38 +02:00
Gilles Peskine
c76f82db27 Work around GCC 5 performance problem with Asan+UBSan and -O3
Old GCC versions hit a performance problem with test_suite_pkwrite
"Private keey write check EC" tests when building with Asan+UBSan
and -O3: those tests take more than 100x time than normal, with
test_suite_pkwrite taking >3h on the CI. Observed with GCC 5.4 on
Ubuntu 16.04 x86_64 and GCC 6.5 on Ubuntu 18.04 x86_64.
GCC 7.5 and above on Ubuntu 18.04 appear fine.

To avoid the performance problem, use -O2 instead of -O3 in then "Asan"
build type with GCC. It doesn't slow down much even with modern compiler
versions.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-16 10:31:29 +02:00
Gilles Peskine
604e4d99dd Fix completion mistake in changelog entry
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-16 10:31:28 +02:00
David Horstmann
a4415d992a Defer static keystore to 3.6.3
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-10-16 10:30:33 +02:00
Gilles Peskine
e298eeb739 Changelog entry for security fix
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-16 10:30:30 +02:00