Commit Graph

32697 Commits

Author SHA1 Message Date
Ronald Cron
db25da0f32 dtls: Fix log level
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-03-25 14:28:17 +01:00
Ronald Cron
243a28c7fd dtls: parse_client_hello: Adapt mbedtls_ssl_read_record() error code
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-03-25 14:28:17 +01:00
Ronald Cron
4decf92956 dtls: Keep invalid/unexpected record header error code
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-03-25 14:28:17 +01:00
Ronald Cron
82be755414 dtls: Improve comment
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-03-25 14:28:17 +01:00
Ronald Cron
7a50711061 Update buffering when adapting to ClientHello message_seq
Credit to OSS-Fuzz for detecting the problem.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-03-25 14:26:16 +01:00
Ronald Cron
7fabb42524 Introduce ssl_buffering_shift_slots
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-03-23 19:18:26 +01:00
Ronald Cron
072ddb0346 dtls: Error out on invalid/unexpected record header
Error out on invalid/unexpected record header
when reading the DTLS 1.2 ClientHello.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-03-23 19:18:26 +01:00
Ronald Cron
f8dd49e047 dtls: Fix debug log
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-03-23 19:18:26 +01:00
Ronald Cron
36d75df56b Revert "ssl_server2.c: DTLS: Attempt to read the response to the close notification"
This reverts commit 0a8c35d273.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-03-23 19:18:26 +01:00
Gilles Peskine
b7a34b9224 Merge pull request #1522 from ronald-cron-arm/mbedtls-3.6-release-sync-merge
Merge of 'mbedtls-restricted/mbedtls-3.6-release-sync' into 'mbedtls-restricted/mbedtls-3.6-restricted'
2026-03-23 14:29:17 +01:00
Ronald Cron
707c8c34ec Merge remote-tracking branch 'mbedtls-restricted/mbedtls-3.6-release-sync' into 'mbedtls-restricted/mbedtls-3.6-restricted' 2026-03-23 12:08:25 +01:00
Bence Szépkúti
8530b5e708 Merge pull request #1504 from gilles-peskine-arm/psa-rng-fork-3.6
Backport 3.6: PSA RNG fork protection
2026-03-19 17:26:52 +01:00
Gilles Peskine
f6118b40e1 Merge pull request #1492 from minosgalanakis/bugfix/ccm_finish_boundary_check_3.6
Bugfix/ccm finish boundary check 3.6
2026-03-17 21:57:28 +01:00
Ronald Cron
303504fba9 Merge pull request #10645 from minosgalanakis/mbedtls-3.6-release-sync
MbedTLS 3.6.6 release sync
2026-03-17 20:46:43 +00:00
Gilles Peskine
9dfe49a980 Update framework with mbedtls_test_fork_run_child merged
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-17 21:29:58 +01:00
Minos Galanakis
b19eec6495 Updated framework pointer
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-03-17 16:55:40 +00:00
Ronald Cron
c1cd21d854 Merge pull request #1510 from yanesca/1445_fix_signature_algorithm_injection-backport
Fix signature algorithm injection [3.6 Backport]
2026-03-17 17:09:51 +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
Minos Galanakis
73c6d6d3e9 test_suite_ccm: Added error.h
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-03-17 11:42:42 +00:00
Manuel Pégourié-Gonnard
b48ddb3f4e Merge pull request #1485 from gilles-peskine-arm/dev-random-config-3.6
Backport 3.6: Use /dev/random and make it configurable
2026-03-17 10:54:46 +01:00
Janos Follath
562326e491 send_invalid_sig_alg: use driver friendly guards
The compile time guards were too restrictive, excluding builds with
drivers, updating them will allow driver tests to run as well.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-17 09:09:20 +00:00
Gilles Peskine
8cffc5dc9d Update framework with fix for platform requirements
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-16 23:46:56 +01:00
David Horstmann
0501209507 Move TLS 1.3 verify-result setting for PSK
When we are doing PSK, we'd like to set verify_result to
0 to indicate success. Previously this was done in
mbedtls_ssl_set_hs_psk() but this is inadequate since this function may
be called for early data (where certificate verification happens later
in the handshake).

Instead, set this value after writing / processing the encrypted
extensions on the server / client respectively, so that we know whether
we are doing certificate verification or not for sure. This change is
effective only for TLS 1.3 as TLS 1.2 sets verify_result for PSK in
ssl_parse_certificate_coordinate().

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2026-03-16 17:19:30 +00:00
Gilles Peskine
fd0e168fab Extend PSA RNG fork protection to NV-seed-only configurations
In builds with only a nonvolatile seed but no actual entropy source, the
naive protection against fork() by reseeding in the child doesn't work:
every child forked from the same RNG state gets the same RNG state. To make
the child's RNG state unique in that case, use a public but unique
personalization string.

The personalization string includes the time. Use `mbedtls_ms_time()` if
available. Fall back to the classic (but obsolescent) `gettimeofday()`
otherwise.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-16 17:50:06 +01:00
Gilles Peskine
0b93865aed Protect the PSA RNG from duplication on fork
If a process forks with the PSA subsystem active, the PSA RNG state is
duplicated. This led to the parent process and the child process generating
the same sequence of random numbers.

Fix this by forcing a reseed if the value of `getpid()` changes. This is the
same technique used in OpenSSL ≥1.1.1d.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-16 17:50:06 +01:00
Gilles Peskine
ce8a71c071 Test the PSA RNG after fork()
Assert that two forked children have distinct RNG states, and also that the
state is distinct from their parent.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-16 17:50:06 +01:00
Gilles Peskine
0764c9348a Update framework with mbedtls_test_fork_run_child
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-16 17:50:06 +01:00
Gilles Peskine
03fafd2637 Update a statement about the default value (now /dev/random)
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-03-16 14:02:47 +01:00
Bence Szépkúti
c5f0f738ed Merge pull request #1497 from gilles-peskine-arm/psa-rng-reseed-3.6
Backport 3.6: API to reseed the PSA RNG
2026-03-16 13:53:53 +01:00
Janos Follath
52cf5d884e Fix send_invalid_sig_alg() test
This commit fixes two problems:
1. In 3.6 the SSL unit test framework ignores option.cipher, we need to
   enforce it manually
2. In 3.6 we still have RSA key exchange and we need to condition the
   RSA test on the presence of ECDHE_RSA key exchange modes as well

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:39:01 +00:00
Janos Follath
5b5e3ba75b Fix ssl_parse_signature_algorithm guards
In 3.6 we still have RSA key exchange and the existing preprocessor
guards are insufficient. Use the same macro to guard the definition that
guards the call.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:39:01 +00:00
Janos Follath
b353e92c2b Improve ssl_parse_signature_algorithm
Simplify and improve error reporting and remove unnecessary
initialisation (the caller is responsible for initialising those
values).

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:39:01 +00:00
Janos Follath
c07cc0e36b Fix a typo and an oversight
DEBUG_C supposed to have been removed from the test dependencies, still
being there is an oversight. Removing it was the sole purpose of
3e58109fbd.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:39:01 +00:00
Janos Follath
1f938bc20f Fix code style
Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:39:01 +00:00
Janos Follath
28886c543e ssl_parse_signature_algorithm: match error codes
The caller is returning MBEDTLS_ERR_SSL_ILLEGAL_PARAMETER if
ssl_parse_signature_algorithm() fails, but
ssl_parse_signature_algorithm() returns
MBEDTLS_ERR_SSL_HANDSHAKE_FAILURE upon failure. There is no good reason
for this mismatch and better to be aligned.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:39:01 +00:00
Janos Follath
d91902c9d6 send_invalid_sig_alg: reduce debug dependency
Run as much of the test as we can even in the abscence of
MBEDTLS_DEBUG_C.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:39:01 +00:00
Janos Follath
4d70ce2f13 ssl_parse_signature_algorithm: caller to get bytes
After the recent refactoring ssl_parse_signature_algorithm() sends an
alert on failure, but the caller also sends an alert on failure. Sending
two alerts is at least a protocol violation, and might not leave the SSL
context in a good state.

It is simpler to have the caller read the two bytes, and pass them to
this function.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:39:01 +00:00
Janos Follath
51ea7aca6f Fix dependencies
The unit test framework always loads the client key as well, which
requires a different curve and a hash than the server key.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:39:01 +00:00
Janos Follath
e50420a2dd Fix code style
Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:39:01 +00:00
Janos Follath
03a9c87895 send_invalid_sig_alg: add baseline test
Add a test case with a successful handshake for each test case that
causes the desired handshake failure, with minimal differences between
the two.

The reason is to have more assurance that the handshake is failing for
the desired reason (as opposed to not having done something correctly in
the test code).

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:38:59 +00:00
Janos Follath
4d2027b271 Fix test case dependency
Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:38:21 +00:00
Janos Follath
0ab0d7c170 Fix typos
Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:38:21 +00:00
Janos Follath
2b696cd84f Fix some compile time guards
Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:38:21 +00:00
Janos Follath
cd0b3f34b6 send_invalid_sig_alg: check logs
There are other issues that can fail with the same error code. Make sure
that the handshake fails exactly the way we want it to fail by analysing
the client logs.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:38:21 +00:00
Janos Follath
b34279950d Use API function to set sig_alg config in test
Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:38:21 +00:00
Janos Follath
3549b6f4a8 Fix the MBEDTLS_TEST_HAS_ADDITIONAL_HASH macro
It should require a hash that is configured in TLS 1.2 SSL contexts by
default.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:38:20 +00:00
Janos Follath
fcb70427f8 Reintroduce ssl_parse_signature_algorithm
The logic was easier to follow before 693a47a, which removed the
ssl_parse_signature_algorithm function and introduced the bug being
fixed in this PR.

When validating multiple conditions, it's easier to read, easier to
debug and, as we can see, easier to get right if you validate them
separately.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:38:20 +00:00
Janos Follath
238976c73a sig_algs: add ChangeLog
Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:38:20 +00:00
Janos Follath
27c0aa0b3e sig_algs: Add non-regression test
Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:38:17 +00:00
Janos Follath
94116eddb8 Fix mbedtls_test_free_handshake_options
We usually follow the pattern that a zero-initialised struct is safe to
free. This wasn't the case here.

Signed-off-by: Janos Follath <janos.follath@arm.com>
2026-03-16 12:37:49 +00:00