6547 Commits

Author SHA1 Message Date
Bence Szépkúti
24f11a366d Use an array of strings instead of pointer smuggling
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-03-12 19:14:50 +01:00
Bence Szépkúti
46e0b1cac9 Use dummy typedef instead of macro
Use a dummy definition of mbedtls_ms_time_t in builds without
MBEDTLS_HAVE_TIME.

Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-03-12 17:11:46 +01:00
Bence Szépkúti
58bb7ecd94 Disable fatal assertions in Windows printf tests
The Windows CRT treats any invalid format specifiers passed to the CRT
as fatal assertion failures. Disable thie behaviour temporarily while
testing if the format specifiers we use are supported.

Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-03-12 16:16:20 +01:00
Bence Szépkúti
154066d118 Add testcase for MBEDTLS_PRINTF_MS_TIME
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-03-12 16:16:20 +01:00
Bence Szépkúti
c6a8bf0f8e Test handling of format macros defined in debug.h
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-03-12 16:16:20 +01:00
Bence Szépkúti
122105269a Run test_suite_debug without MBEDTLS_SSL_TLS_C
Move the suite's global dependency on MBEDTLS_SSL_TLS_C to the
individual test cases.

Add an preprocesor guard around string_debug to prevent warning about unused
functions.

Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-03-12 16:16:20 +01:00
Gabor Mezei
8829aa336c
Fix code style
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-03-07 13:21:37 +01:00
Gabor Mezei
149509362b
TLS context serialization needs an AEAD ciphersuite
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-03-06 16:06:42 +01:00
Gabor Mezei
ea4df49272
Update test dependencies
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-03-05 12:18:47 +01:00
Gabor Mezei
dcbe4ce9db
Update dependencies
Pre-existing but not having TLS 1.3 in the build does not seem to be
necessary actually. These test functions set the dtls flag when
calling `test_resize_buffers` and then `test_resize_buffers` sets the
`options.dtls` flag which eventually forces the TLS 1.2 version of the
protocol (in `mbedtls_test_ssl_endpoint_init()` call of
`mbedtls_ssl_config_defaults()` with `MBEDTLS_SSL_TRANSPORT_DATAGRAM`
as the transport).

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-03-05 12:18:47 +01:00
Gabor Mezei
8adcfc8240
Add ECDSA ciphersuite support for resize_buffer tests
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-03-05 12:18:47 +01:00
Gabor Mezei
ab02cd5e7b
Revert "Delete test cases"
This reverts commit ecc5d31139dc6877f135e8090e805c250e32a31d.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-03-05 12:18:46 +01:00
Gabor Mezei
cdd34742cf
Fix test case name
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-03-05 12:18:46 +01:00
Gabor Mezei
973a712dd8
Migrate to a usable ciphersuite
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-03-05 12:18:46 +01:00
Gabor Mezei
ff9b2e742a
Delete test cases
Only RSA cipgersuits are accepted for these tests and there is no ECDHE-RSA
alternative for AES-128-CCM so delete them.

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-03-05 12:18:46 +01:00
Gabor Mezei
9d7fd3dfe1
Migrate the RSA key exchage tests
Migrate to ECDHE-ECDSA instead of PSK

Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-03-05 12:18:46 +01:00
Gabor Mezei
fc42c22c7b
Migrate RSA key exchange tests
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-03-05 12:18:30 +01:00
Harry Ramsey
21506fd7f1 Update documentation regarding metatest
This commit updates the paths in the documentation for metatest.c as it
has been moved to MbedTLS Framework.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2025-02-19 15:30:25 +00:00
Valerio Setti
1494a09ff7 test_suite_ssl: require GCM or ChaChaPoly in handshake_serialization()
Hanshake serialization requires that the selected ciphersuite uses
an AEAD algorithm. However, following the DHE-RSA removal, trying to
still use RSA signature might select a ciphersuite which is not using
AEAD, but CBC instead (see preference order in "ssl_ciphersuite.c").

This is especially problematic in tests scenarios where both GCM and
ChaChaPoly are disabled, so that CCM remains as the only AEAD algorithm.
Ciphersuites using RSA signature and CCM are very low on the preference
list, so very unlikely to be picked in tests. This cause a CBC one to
be selected in this case and the handshake_serialization() function
to fail.

In order to prevent failures from happening, in this commit we require
that either GCM or ChaChaPoly are enabled, so that ciphersuites using one
of these are likely to be picked.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-02-06 10:12:02 +01:00
Valerio Setti
592f6826dd test_suite_ssl: update description for conf_curve and conf_gruop tests
These tests are about EC curves/groups, not DH ones, so the description
should be updated accordingly.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-01-27 12:46:25 +01:00
Valerio Setti
8638603ba7 test_suite_ssl: remove tests specific for DHE-RSA
These tests were specific for DHE-RSA (which is being removed on
development branch) and also for each of them there was already the
ECDHE-RSA counterpart available.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-01-27 12:38:39 +01:00
Valerio Setti
b8ef2a4455 test_suite_ssl: adapt handshake_fragmentation() to use ECDHE-RSA
Use ECDHE-RSA instead of DHE-RSA.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-01-27 12:38:39 +01:00
Valerio Setti
5b7bfd8d5a test_suite_ssl: adapt DHE-RSA tests to ECDHE-RSA
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-01-27 12:38:39 +01:00
Manuel Pégourié-Gonnard
7e1154c959
Merge pull request #9906 from mpg/rm-conf-curves
[dev] Remove deprecated function mbedtls_ssl_conf_curves()
2025-01-27 08:21:27 +00:00
Manuel Pégourié-Gonnard
c4e768a8a6 Fix incorrect test function
We should not manually set the TLS version, the tests are supposed to
pass in 1.3-only builds as well. Instead do the normal thing of setting
defaults. This doesn't interfere with the rest of the testing, so I'm
not sure why we were not doing it.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-01-22 10:04:43 +01:00
Valerio Setti
6487da15e9 tests: remove usage of mbedtls_x509write_crt_set_serial
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-01-16 15:02:15 +01:00
Manuel Pégourié-Gonnard
4c3134a396 Remove useless dependency from test function
This dependency was never right in the first place.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-01-14 12:25:52 +01:00
Manuel Pégourié-Gonnard
93d4591255 Remove deprecated function mbedtls_ssl_conf_curves()
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-01-14 12:06:31 +01:00
Gilles Peskine
bc7c523420 Remove uses of secp244k1
Remove all code guarded by `PSA_WANT_ECC_SECP_K1_224`, which is not and will
not be implemented. (It would be K1_225 anyway, but we don't intend to
implement it anyway.)

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-01-08 16:51:23 +01:00
Ronald Cron
ce3c2dd30c
Merge pull request #9806 from ronald-cron-arm/finalize-split-preparation-1
Finalize split preparation-1
2024-12-05 13:23:09 +00:00
Ronald Cron
6924564970 Move back timing.c to mbedtls
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2024-12-04 14:25:02 +01:00
Minos Galanakis
4f7f132536 test-data: Adjusted check-feature test to seek MBEDTLS_TIMING_C.
Features are generated by scripts/generate_features.pl which will reside
in the MbedTLS repository, while MBEDTLS_AES_C now resides in tf-psa-crypto.

Picking `MBEDTLS_TIMING_C` feature ensures the original test's requirements
are satisfied.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2024-12-04 09:57:56 +00:00
Gilles Peskine
4c58e89976
Merge pull request #9613 from gilles-peskine-arm/remove-rsa-psk-key-exchange
Remove RSA-PSK key exchange
2024-11-07 15:09:05 +00:00
Gilles Peskine
ae5353bb62 Move new test suite to the tf-psa-crypto directory
It's a crypto test suite, but it was added in the main tree in a careless
forward port from 3.6.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-11-05 17:43:02 +01:00
Gilles Peskine
7dfe7c9e4a Remove RSA-PSK test cases
The test cases removed by this commit are specific to RSA-PSK, not
incidentally using RSA-PSK when testing other features, so there is no loss
of test coverage.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-11-05 15:48:11 +01:00
Gilles Peskine
f1210191e3 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-11-04 14:07:20 +01:00
Gilles Peskine
dc7d7875ac More explanation of what we do and do not test
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-11-04 14:07:20 +01:00
Gilles Peskine
091941e849 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-11-04 14:07:20 +01:00
Gilles Peskine
77587ce12d 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-11-04 14:07:20 +01:00
Gilles Peskine
8ed4d94166
Merge pull request #9614 from gilles-peskine-arm/use_psa_crypto-always_on
Always enable MBEDTLS_USE_PSA_CRYPTO in all.sh
2024-10-29 14:58:55 +00:00
David Horstmann
f8d13d8fad
Merge pull request #9721 from paul-elliott-arm/fix_new_coverity_issues
Fix new coverity issues
2024-10-25 16:43:37 +00:00
Ronald Cron
5f6e69dae5
Merge pull request #9693 from Harry-Ramsey/split-revert-error-development
Split error.h and move back error.c to mbedtls
2024-10-25 13:12:58 +00:00
Paul Elliott
9a209b8251 Pair inits with declarations
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-10-25 12:41:28 +01:00
Paul Elliott
7c6686014b Fix tests where tests were done prior to init
Variables that are in any way destructed on exit should be initialised
prior to any tests that might jump to exit, to save potential
uninitialised memory accesses.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
2024-10-24 14:58:14 +01:00
Gilles Peskine
8fd2117360 Remove !MBEDTLS_USE_PSA_CRYPTO test cases that have a USE_PSA alternate
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-22 22:10:42 +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
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
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
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
Gilles Peskine
e3c64c3f26 Fix typo in dependency
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2024-10-10 17:26:11 +02:00