11654 Commits

Author SHA1 Message Date
Ronald Cron
78fd9f9d5f
Revert "Move back test configs" 2024-11-21 13:56:53 +01:00
Ronald Cron
83d21cc8f4 Move back *config_test_driver* headers from the framework
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-11-20 13:22:54 +01:00
David Horstmann
b25eaca940 Properly clean instrument_record_status.h
The paths to this header in clean: targets were missed previously when
changing paths to reflect the move of the header to the framework.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-11-14 14:19:50 +00:00
David Horstmann
44a9f2ff5f Add missing dependency to hash testsuite
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-11-14 14:19:49 +00:00
David Horstmann
cbf530dde7 Disable test hooks when checking missing symbols
The function mbedtls_test_hook_error_add() is declared in the library
but supplied by test helpers in framework/tests/src, so it is undefined
in library-only builds. This messes up our checks for missing symbols,
so disable MBEDTLS_TEST_HOOKS when we are building to check missing
symbols.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-11-14 14:19:49 +00:00
David Horstmann
501e9a9fee Update paths to generated PSA test wrappers
These are not moving to the framework, so their paths are fine to stay
as they are, undo the update done through global search-replace.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-11-14 14:19:42 +00:00
David Horstmann
c54f0b3e37 Update generate path to instrument_record_status.h
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-11-14 14:19:42 +00:00
David Horstmann
b19374f548 Update path to PSA crypto alt headers
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-11-14 14:19:42 +00:00
David Horstmann
61b7b1e780 Update make clean target with moved test helpers
Test helpers that are now moved to the framework must be cleaned
properly.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-11-14 14:19:42 +00:00
David Horstmann
4d47ee4146 Update test_keys.h generation in Makefile
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-11-14 14:19:42 +00:00
David Horstmann
685c19447f Update libtestdriver paths in tests/Makefile
Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-11-14 14:19:42 +00:00
David Horstmann
45c83caf59 Add tests/Makefile targets for moved test helpers
Everything that has been moved to tests/src needs a Makefile target in
order to be built.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-11-14 14:19:42 +00:00
David Horstmann
4c4e0864f2 Add the framework/tests/include path to testsuites
These need to include from the framework path as this is where most test
helpers have been moved to.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-11-14 14:19:42 +00:00
David Horstmann
dcf42a0b53 Update references to test helpers
Replace:
* tests/src -> framework/tests/src
* tests/include -> framework/tests/include

Except for occurrences of:
* tests/src/test_helpers (since this only contains ssl_helpers.c)
* tests/src/test_certs.h
* tests/include/alt_dummy

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-11-14 14:19:40 +00:00
David Horstmann
eae12b1a01 Move some test helpers out of Mbed TLS
Everything not TLS-related and not ALT-interface-related has been moved
out of tests/src and tests/include and into the framework.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2024-11-14 14:17:28 +00:00
Manuel Pégourié-Gonnard
38b9f724a8 Update path to all-core.sh
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-11-12 12:11:07 +01:00
Manuel Pégourié-Gonnard
598cc22f9e Move all-{core,helpers}.sh out of Mbed TLS
Signed-off-by: Manuel Pégourié-Gonnard <mpg@elzevir.fr>
2024-11-12 11:40:11 +01:00
Manuel Pégourié-Gonnard
429fcdad85
Merge pull request #9754 from mpg/all.sh-tf-psa-crypto-3.6
[Backport 3.6] All.sh changes to support tf-psa-crypto components
2024-11-07 08:49:38 +00:00
Paul Elliott
346d2f4e58
Merge pull request #9731 from gilles-peskine-arm/coverity-20241004-3.6
Backport 3.6: Fix edge cases of mbedtls_psa_raw_to_der and mbedtls_psa_der_to_raw
2024-11-06 19:02:54 +00:00
Gilles Peskine
8369b4acb5 Fix MD_PSA_INIT called before initializing some data structures
This fixes accesses to uninitialized memory in test code if
`psa_crypto_init()` fails.

A lot of those were pointed out by Coverity. I quickly reviewed all calls to
`MD_PSA_INIT()` manually, rather than follow any particular list.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-11-05 17:04:30 +01:00
Manuel Pégourié-Gonnard
69fe0e8bf4 all.sh: improve check for clean config files
The existing check only took care of CONFIG_H. This was both not enough
and too much:
- not enough because config.py can also modify CRYPTO_CONFIG_H and we
want to know about it just as much as CONFIG_H;
- too much because CONFIG_H does not exist in tf-psa-crypto.

Check a list of files instead of a single one, and adjust that list.

Also update an outdated comment about Makefiles

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-11-05 10:38:02 +01:00
Manuel Pégourié-Gonnard
621c96a71f all.sh: rationalize relative path usage
In preparation for adding tf-psa-crypto/test/scripts/all.sh which will
run from tf-psa-crypto.

Use paths relative to the currently sourced file when including common
files (ie, those that will soon be moved to the framework). Otherwise,
use paths relative to the current directory, aka project's root.

Document that test/script/all.sh must be invoked from the project's root
(that was already the case, but implicit so far).

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-11-05 10:37:36 +01:00
Gilles Peskine
aef3f74e4d
Merge pull request #9739 from gilles-peskine-arm/mbedtls_psa_ecp_generate_key-no_public_key-3.6
Backport 3.6: PSA ECC key generation: don't generate the public key
2024-11-04 16:36:49 +00:00
Gilles Peskine
6bdebfe464 Skip slowest FFDH tests against GnuTLS with MSan or Valgrind
Skip 6144-bit and 8192-bit FFDH tests in MSan or Valgrind test
configurations. These test cases are slow and sometimes trigger GnuTLS's
built-in timeout (which cannot be configured until more recent versions).

Resolves #9742.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-31 21:40:43 +01:00
Gilles Peskine
1f4b63779c Don't use Unicode in .function file
generate_test_code.py doesn't support UTF-8 in .function files (but does
in .data files) when run in a non-UTF-8 locale with Python <=3.6.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-30 17:14:46 +01:00
Gilles Peskine
db226b4eec More explanation of what we do and do not test
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-30 13:44:02 +01:00
Paul Elliott
962eb8572b
Merge pull request #9737 from mpg/drop-armcc5-3.6
[3.6] Drop armcc5 support in all.sh
2024-10-30 12:29:55 +00:00
Gilles Peskine
2576bbc9fa Basic statistical tests for mbedtls_psa_ecp_generate_key()
Run a few iterations and check that there is some diversity in the results.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-30 12:18:16 +01:00
Gilles Peskine
9a09443973 Unit tests for mbedtls_psa_ecp_generate_key()
Run the function on a few different curves with shorter, just-right and
larger buffer sizes. Perform some basic sanity checks on the output (which
is random).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-30 12:18:16 +01:00
Manuel Pégourié-Gonnard
6f35a4dbe0
Merge pull request #9547 from davidhorstmann-arm/align-development-3.6-test-helpers-3.6
Align 3.6 test helpers with development
2024-10-30 09:09:36 +00:00
Manuel Pégourié-Gonnard
62a57e68a5 Rm forgotten armc5
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-10-29 12:42:43 +01:00
Manuel Pégourié-Gonnard
95395738b4 Drop building with armcc5 in all.sh
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2024-10-29 11:39:41 +01:00
Bence Szépkúti
2a45f0b952 Add override arguments for new gcc targets
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-10-28 12:16:14 +01:00
Bence Szépkúti
827c89ba07 Clarify GCC version requirement
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-10-28 12:16:13 +01:00
Bence Szépkúti
dc4b7a8032 Split up the Thumb-1 test component
The Thumb-1 tests are by far the slowest, so split the -O0 and -Os tests
into their own components.

Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-10-28 12:16:13 +01:00
Bence Szépkúti
791cb3507a Remove superfluous invocations of make clean
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-10-28 12:16:13 +01:00
Bence Szépkúti
f31a3438c2 Update component speed estimates
The estimates are based on the most recent CI run.

Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-10-28 12:16:13 +01:00
Bence Szépkúti
adcc27a91e Initialize result caching variables
This prevents interference from identically named environment variables.

Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-10-28 12:16:13 +01:00
Bence Szépkúti
1eb18d443f Use true/false in place of integers
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-10-28 12:16:13 +01:00
Bence Szépkúti
d2bd299082 Ignore missing temporary files during cleanup
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-10-28 12:16:12 +01:00
Bence Szépkúti
e4a42f536d Fix copypasta in gcc_version
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-10-28 12:16:12 +01:00
Bence Szépkúti
864ecda59e Add AArch64 default config test
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-10-28 12:16:12 +01:00
Bence Szépkúti
f38ee6179e Add Arm eabi default config tests
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2024-10-28 12:16:12 +01:00
Gilles Peskine
42919e0821 Assert non-empty data when needed
Pacify Coverity about subtracting from the length, and give a signal to
human readers.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-28 10:09:18 +01:00
Gilles Peskine
efe30760e5 Initialize CCM context before doing anything fallible
Otherwise mbedtls_ccm_free() in cleanup could corrupt memory if a failure
happens.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-28 10:09:18 +01:00
Gilles Peskine
5dea5f355a mbedtls_ecdsa_raw_to_der and mbedtls_ecdsa_der_to_raw: reject bits==0
Cleanly reject bits == 0 when calling mbedtls_ecdsa_raw_to_der() and
mbedtls_ecdsa_der_to_raw(). This can plausibly happen when bits is
user-provided data that the calling application doesn't check.

Before this patch, there was typically-benign undefined behavior, such as
adding 0 to a null pointer or calling memcpy on a null pointer with a size
of 0.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-28 10:09:18 +01:00
Gilles Peskine
ad70136703 mbedtls_mpi_write_binary{,_le}: test 0-size output
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-28 10:09:18 +01:00
Gilles Peskine
4eafc9c47e Modernize mpi_write_binary and mpi_write_binary_le
Use TEST_CALLOC instead of a fixed-size buffer, so that Asan/Valgrind builds
will detect a buffer overflow.

Honor output_size regardless of the value of the number.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-28 10:09:18 +01:00
David Horstmann
d37d70a6de
Merge pull request #9723 from paul-elliott-arm/fix_new_coverity_issues_3.6
[Backport 3.6] Fix new coverity issues
2024-10-25 16:43:50 +00:00
David Horstmann
aea9bae25b
Merge pull request #9728 from valeriosetti/fix-9690-workarounds-backport
[Backport 3.6] Revert & fix #9690 workarounds
2024-10-25 15:57:25 +00:00