Commit Graph

12041 Commits

Author SHA1 Message Date
Gilles Peskine
f3c1f8dd70 Update paths after moving some scripts to the framework
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-19 13:20:36 +01:00
Gilles Peskine
c7d600f21f Align some scripts with development
The changes made between 3.6 and 4.0+ are useless but harmless in 3.6.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-19 13:19:31 +01:00
Bence Szépkúti
444d0ac2c1 Merge pull request #10443 from davidhorstmann-arm/verify-result-default-failure-3.6
[Backport 3.6] Hardening: Make `mbedtls_ssl_get_verify_result()` default to failure
2026-03-17 12:14:48 +00:00
David Horstmann
611f3fb072 Configure the RNG in 3.6 testcase
In Mbed TLS 3.6 we still need to manually configure the RNG for TLS. Add
this to the testcase for default verify_result.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-03-16 11:15:01 +00:00
Manuel Pégourié-Gonnard
e24f1e5c2c Merge pull request #10609 from mpg/pk-psa-large-stack-buffers
[3.6] PK: avoid large stack buffers in "to/from PSA" functions
2026-03-13 08:53:48 +00:00
Ronald Cron
828e3817ac Merge pull request #10623 from ronald-cron-arm/dtls-client-hello-defragmentation-3.6
Backport 3.6: Add support for (D)TLS 1.2 client hello defragmentation
2026-03-10 14:46:41 +00:00
Gilles Peskine
2393fddd60 clock_gettime: don't assume more than 1 second since the origin of time
With e.g. `CLOCK_BOOTTIME`, it's plausible that less than 1 second has
passed since the boot reference time.

Only assert that the returned time is nonzero (because all-bits-zero is
highly implausible as an actual clock value, but likely indicates that the
intended value was not copied out correctly).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
b17d0f3028 Let test suites see strtoull() on FreeBSD if building with -std=c99
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
fa62af0a47 Let test suites see gettimeofday() on FreeBSD
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
08614e1e96 Skip printf("%zu") tests with MinGW
MinGW uses a legacy printf by default which doesn't support the `z` modifier
for `size_t`. Skip these test cases on MinGW.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
5c6ec6bcc0 Add smoke test for gettimeofday()
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
60cfb78882 Fix the build on non-Unix-like platforms that define CLOCK_REALTIME as a macro
Needed for MinGW builds in our CI.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
dec0d500a8 Test printf integer format modifiers more
In particular, test `"%zu"` for `size_t` and `"%lld"` for `long long`, which
older Windows runtimes do not support, but which Mbed TLS uses.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
f994fe05cd Fix the build on non-UNIXLIKE platforms
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
5ca8894b59 Fix the build with dietlibc
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
df9fdae4c4 Add smoke test for availability of some Unix functions
The goal isn't to do any functional testing, but to have a simple diagnostic
if some Unix platform function isn't available, and to have a record of
success in the outcome file.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
15c041c465 Fix wrong pointer type passed to printf
It works in practice, but clang on FreeBSD rightfully complains about it.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
f2c25e0133 test_suite_debug: test the printf used by debug.c
In `test_suite_debug`, test `mbedtls_debug_snprintf()`, which uses
`mbedtls_vsnprintf()` like `mbedtls_debug_print_msg()`. Do this instead of
testing `mbedtls_snprintf()`, which might be subtly different (older
Windows runtimes had slightly different behavior for vsnprintf() vs
snprintf(); TF-PSA-Crypto might pick up a different function if the
platform configuration is different in TF-PSA-Crypto and Mbed TLS).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Gilles Peskine
a7de32a719 Disable Unix-like integration code in baremetal builds in all.sh
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-03 15:19:58 +01:00
Manuel Pégourié-Gonnard
1fee3da79a PK: require more option combinations in tests
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-27 10:48:48 +01:00
Bence Szépkúti
1937efdd94 Merge pull request #10615 from gilles-peskine-arm/generate-psa_test_wrappers-3.6
Backport 3.6: generate psa test wrappers
2026-02-26 13:44:15 +00:00
Ronald Cron
7d022d3275 ssl-opt.sh: DTLS fragmenting: Do not check for ServerKeyExchange fragmentation
In DTLS fragmenting tests, do not check for
ServerKeyExchange message fragmentation as
depending on the configuration and consequently
the chosen ciphersuite the server may not
send the message.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-25 20:18:19 +01:00
Ronald Cron
6b529ff50d component_test_tls1_2_ccm_psk_dtls_psa: Enable MBEDTLS_HAVE_TIME
As done in component_test_tls1_2_ccm_psk_dtls_legacy
enable MBEDTLS_HAVE_TIME in
component_test_tls1_2_ccm_psk_dtls_psa.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-25 17:49:53 +01:00
Ronald Cron
82d549a297 ssl-opt.sh: Use more diverse MTUs
Do not use only power of 2 MTUs.
Use diverse MTUs in DTLS reassembly/
fragmenting/proxy tests.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:30:00 +01:00
Ronald Cron
404daf5f6d ssl-opt.sh: DTLS reassembly: Improve max_content_len requirements
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:30:00 +01:00
Ronald Cron
50d1a74ad8 ssl-opt.sh: Fix/improve comments
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:30:00 +01:00
Ronald Cron
f44b6545fe ssl-opt.sh: Add tests with CH fragmented with DTLS in default config
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:30:00 +01:00
Ronald Cron
f20d48f719 ssl-opt.sh: Add interop test of DTLS defragmentation on server side
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:30:00 +01:00
Ronald Cron
0a8c35d273 ssl_server2.c: DTLS: Attempt to read the response to the close notification
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:30:00 +01:00
Ronald Cron
faa9d95638 ssl-opt.sh: Relax deps of handshake defrag tests
Relax the dependencies of the tests about handshake
message defragmentation/reassembly on server side.

TLS 1.3 does not need to be enable anymore for this
to work for TLS 1.2 handshake messages.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-24 15:30:00 +01:00
Manuel Pégourié-Gonnard
6b90afb2bb PK: ensure we test with keys on the stack or heap
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-23 09:42:06 +01:00
Gilles Peskine
d841a6a782 Generate psa_test_wrappers.{h,c} automatically
This is not only convenient, but now necessary, because if the content of
the generated files changes due to changes in Python files in the framework,
`all.sh check_generated_files` will fail in the framework CI.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-02-22 20:33:27 +01:00
Ronald Cron
d8b97c6a28 ssl-opt.sh: Revert leftover debug level increase
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 14:41:57 +01:00
Ronald Cron
3b6bd65334 ssl_msg.c: Improve handshake message fragmenting message
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 14:41:57 +01:00
Ronald Cron
8e68a06bdf ssl-opt.sh: Improve DTLS proxy 3d tests
Improve DTLS proxy 3d tests with OpenSSL and
GnuTLS servers. Have a better control of which
message is fragmented and verify it is the
case.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 14:41:57 +01:00
Ronald Cron
98b3ef2e43 ssl-opt.sh: Improve DTLS reassembly tests
Improve DTLS reassembly tests with OpenSSL
and GnuTLS server. Check that some messages
have been reassembled.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 14:41:56 +01:00
Ronald Cron
87871ddf30 ssl-opt.sh: Remove DTLS reassembly redundant test
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 14:41:56 +01:00
Ronald Cron
0b4cb31fb6 ssl-opt.sh: Remove CH reassembly unsupported test
We are about to have full support for TLS 1.2
CH reassembly on server side. The equivalent
positive test would be a duplicate of one of
the tests generated by generate_tls_handshake_tests.py.
Thus just removing the negative test.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 14:41:56 +01:00
Ronald Cron
a02505a7be ssl_msg.c: Improve HS message reassembly completed message
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-18 14:41:56 +01:00
David Horstmann
01ef42d5fe Initialize verify_result in session free
Initialize the verify_result field in mbedtls_ssl_session_free().
Previously we were just zeroising the entire session object, which would
yield a default 'success' value if the same object were reused.

Test that this initialisation is actually happening by setting
verify_result manually to zero and calling mbedtls_ssl_session_free() on
the session before checking its value.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-02-17 14:39:53 +00:00
David Horstmann
c42f73fe34 Switch to a default value of -1u
Since we explicitly document the value 0xFFFFFFFF or -1u as representing
'result not available', we can use it as a sensible default value
without creating an API change. Use this value instead of introducing a
new verification result value.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-02-17 14:39:53 +00:00
David Horstmann
b413935518 Add non-regression test for verify_result init
Write a testcase to get verify_result before we have performed a
handshake and make sure that it is initialised to a failure value.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-02-17 14:39:50 +00:00
Ronald Cron
373e08939f Add branch specific generate_tls_handshake_tests.py file
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-02-17 10:10:34 +01:00
Manuel Pégourié-Gonnard
6617ab467f pkwrite: tests: make helper more robust
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-10 11:34:00 +01:00
Manuel Pégourié-Gonnard
56503ba340 pkwrite: tests: test that DER writes at the end
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-10 11:24:05 +01:00
Manuel Pégourié-Gonnard
533a806405 pkwrite: test: factor common part into helper func
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2026-02-10 11:18:24 +01:00
Valerio Setti
2b2f430fcd tests: scripts: adapt test_tf_psa_crypto_optimized_alignment to 3.6
Move from CMake to Make

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-01-28 00:18:09 +01:00
Valerio Setti
10193b37e3 tests: scripts: add new component to test alignment with GCC O3 optizations
This is meant to test a bug found on:
- Little endian platforms other than x86 or ARM (these have specific
  optimizations available);
- GCC versions from 10 to 14.2 (below and above are fine);
- Optimization level "-O3" (lower levels are fine).

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2026-01-28 00:07:44 +01:00
Gilles Peskine
ccf280d158 Add a few more test cases for printf formats
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-01-26 17:49:05 +01:00
Valerio Setti
8102fe3b0f tests: suite_psa_crypto_persistent_key: fix load_primed_storage
Do not remove keys that belong to the reserved range.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-11-03 11:07:04 +01:00