618 Commits

Author SHA1 Message Date
Ben Taylor
23370efdea Add comment explaining the derivation of the number of keys
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
(cherry picked from commit e0766f1b4a2133ea043e10cef86cc1c76f69b49b)
2026-10-21 08:24:45 +01:00
Ben Taylor
86ba516295 Add test for tansform setup resource leak
This is a manual backport, not a direct cherry-pick, because 3.6 can build TLS without PSA-backed transforms. Gate the regression on MBEDTLS_USE_PSA_CRYPTO.

Signed-off-by: Ben Taylor <ben.taylor@linaro.org>

(cherry picked from commit 95e95268a4c26608612f34f2bb76ff1dfa9ded0a)
2026-10-21 08:24:45 +01:00
Naveed
ebcb95c130 Add regression tests for ssl_context_load length checks
Backport the ssl_context_load_rejects_oob_length test function from
development in its final form, with cases for the serialized in_cid,
out_cid and ALPN lengths.

mbedtls_test_ssl_dtls_join_endpoints() and
mbedtls_test_ssl_perform_connection() do not exist on this branch, so
set up the DTLS endpoints and run the handshake with the helpers that
do: mbedtls_test_ssl_endpoint_init() with message queues,
mbedtls_test_mock_socket_connect() and
mbedtls_test_move_handshake_to_state(). Exchange application data
explicitly before saving the context, as
mbedtls_test_ssl_perform_connection() does on development: the server
keeps its handshake structure until then, and
mbedtls_ssl_context_save() refuses to run while it exists.

Signed-off-by: Naveed <naveed@bugqore.com>
2026-10-04 22:53:31 +05:30
Gilles Peskine
70058ce4b6
Merge pull request #10845 from gilles-peskine-arm/issue1585-backport3.6-visualc
[3.6 only] Test mbedtls_ssl_session_reset()
2026-08-20 16:01:14 +00:00
Naveed
61a2877a8e Force sentinel session ID length in serialized-load test
Signed-off-by: Naveed <naveed@bugqore.com>
2026-08-03 13:45:52 +05:30
Naveed
b6d607d310 Reject out-of-bounds session ID length in ssl_tls12_session_load
Signed-off-by: Naveed <naveed@bugqore.com>
2026-08-03 13:45:52 +05:30
Valerio Setti
b4eb39217b tests: ssl: split ssl_helpers between public and internal functions
Move functions in "ssl_helpers.h" that depend on internal headers to
"ssl_helpers_internal.h". This allows to include "ssl_helpers.h" also
in programs (which do not have access to internal headers).

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2026-07-29 11:36:27 +02:00
Minos Galanakis
4476f02593 Merge remote-tracking branch 'restricted/mbedtls-3.6-restricted' into mbedtls-3.6.7.rc 2026-06-26 15:19:55 +01:00
Ronald Cron
b71ec46f4f tls13_fetch_handshake_msg(): Remove require_record_boundary parameter
Deduce it from the handshake message type

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-06-24 16:16:08 +02:00
Ronald Cron
4303dc6136 tls13_record_boundary_alignement: Append empty hs msg
Append an empty handshake message to expand
the record instead of just a zero byte.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-06-24 16:16:08 +02:00
Ronald Cron
13ab16f1ef Various improvements of tls13_(drop_early_data|record_boundary_alignment)()
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-06-24 16:16:08 +02:00
Ronald Cron
1d0ff13c89 test_suite_ssl: Add initialization to all zeroes of test endpoint structs
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-06-24 16:16:07 +02:00
Ronald Cron
70918ab425 test_suite_ssl: Test EndOfEarlyData on record boundary enforcement
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-06-24 16:16:07 +02:00
Ronald Cron
a441e4666b test_suite_ssl: Test client Finished on record boundary enforcement
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-06-24 16:16:07 +02:00
Ronald Cron
d157fa7ae2 test_suite_ssl: Test server Finished on record boundary enforcement
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-06-24 16:16:07 +02:00
Ronald Cron
ee2cb8abce test_suite_ssl: Test ServerHello on record boundary enforcement
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-06-24 16:16:07 +02:00
Ronald Cron
3f55bb6998 test_suite_ssl: Test ClientHello on record boundary check
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-06-24 16:16:07 +02:00
Ronald Cron
27c489be62 tls13: Add record boundary checks
RFC 8446 (TLS 1.3 specification), Section 5.1, states:

Handshake messages MAY be coalesced into a single TLSPlaintext record
or fragmented across several records, provided that:
    ...
    -Handshake messages MUST NOT span key changes. Implementations
    MUST verify that all messages immediately preceding a key change
    align with a record boundary; if not, then they MUST terminate the
    connection with an "unexpected_message" alert. Because the
    ClientHello, EndOfEarlyData, ServerHello, Finished, and KeyUpdate
    messages can immediately precede a key change, implementations
    MUST send these messages in alignment with a record boundary.

Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-06-24 16:16:07 +02:00
Ronald Cron
399a28c76a test_suite_ssl: Add early data drop tests
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-06-24 16:16:06 +02:00
Ben Taylor
7c007f49f7 Correct error handling in mbedtls_ssl_reset_checksum
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>

Backport note: adapted from upstream commit 35da56b4c749cb066bddfd328731fb1c493228dc; not a direct cherry-pick.
2026-06-24 10:48:59 +01:00
Ben Taylor
e100cbcc2d Improve tls_transcript_error_propagation testing to check for error codes
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-06-24 10:48:59 +01:00
Ben Taylor
34338f9aa9 Update regression test
Co-authored-by: Ronald Cron <ronald.cron@arm.com>
Signed-off-by: Ben Taylor <32939606+bjwtaylor@users.noreply.github.com>
2026-06-24 10:48:59 +01:00
Ben Taylor
54d7ac4d3a fix code style
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-06-24 10:48:59 +01:00
Ben Taylor
d550895075 Improve testing
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-06-24 10:48:59 +01:00
Ben Taylor
7d0e7f889e Remove check for NULL pointer
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-06-24 10:48:59 +01:00
Ben Taylor
2c4d8ad682 Add client tests for RMS computation error
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-06-24 10:48:59 +01:00
Ben Taylor
355eae4d9c Add unsupported trigger check
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-06-24 10:48:59 +01:00
Ben Taylor
1aeb46adb9 Add further documentation to tls_abort_transcript_context
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-06-24 10:48:59 +01:00
Ben Taylor
3d6379aa61 Fixed code style
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-06-24 10:48:59 +01:00
Ben Taylor
f0f708eade refactor initialisation in tls_transcript_error_propagation, so that the variables are initialised straight after they are declared
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-06-24 10:48:59 +01:00
Ben Taylor
9c3cd1a5d4 Add additional guard for sha256 in tests
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-06-24 10:48:59 +01:00
Ben Taylor
167a754c0d Improve layout of the code for debugging with breakpoints
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-06-24 10:48:59 +01:00
Ronald Cron
d0e7136ec3 Improve dependencies and error handling
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>

Backport note: adapted from upstream commit 24e67fd9039dcd57d65d1c043baa80697ce05fe8; not a direct cherry-pick.
2026-06-24 10:48:58 +01:00
Ben Taylor
710d5efac9 tests: ssl: add regression tests for EMS/RMS error propagation
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>

Backport note: adapted from upstream commit e1241ef8bb5890dd47753f888cf6b3d18c9df8c4; not a direct cherry-pick.
2026-06-24 10:48:02 +01:00
Ben Taylor
6bf3204e64 Migrate patched symbols to 3.6
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-06-23 13:38:47 +01:00
Ben Taylor
2c550a2958 Correct syntax of MBEDTLS_GET_UINT32_BE in write_new_session_ticket_mem
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-06-23 13:38:46 +01:00
Ben Taylor
aa290176fd Improve test of non-initilisation of lifetime
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-06-23 13:38:46 +01:00
Ben Taylor
02451dcc65 Add test for leak
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2026-06-23 13:38:46 +01:00
Ronald Cron
f6f6492228
Merge pull request #1641 from gilles-peskine-arm/badmac_seen_or_in_hsfraglen-fix
3.6 only: Fix and test badmac_seen_or_in_hsfraglen confusion
2026-06-22 10:30:00 +02:00
Gilles Peskine
a939d850c7 Add DTLS handshake test with badmac_seen=1
Add a test entry point for a handshake with a specially crafted context.
This can be used for defense in depths for scenarios that we think can't
happen, but might actually happen due to a bug, or due to a new feature that
is insufficiently tested. This can also be a proxy for testing aspects of
renegotiation or session resumption in circumstances that are hard to
arrange.

In this commit, use it to test a DTLS handshake with `ssl->badmac_seen`
:(actually `ssl->badmac_seen_or_in_hsfraglen` in the 3.6 branch) set to a
nonzero value. This can't happen, as far as I know (`badmac_seen` can only
be nonzero during renegotiation, not during a nominal handshake or in
session resumption). But it could happen, for example, if
`mbedtls_ssl_session_reset()` failed to reset `badmac_seen`, as was the case
in Mbed TLS 4.0.0 to 4.1.0.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-15 13:08:43 +02:00
Minos Galanakis
8c458b8cca test_suite_ssl: Updated reject_hrr_selecting_unoffered_group dependencies
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-06-08 15:54:41 +01:00
Minos Galanakis
c3f90ec54d test_suite_ssl: use 3.6 endpoint helper signatures in HRR test
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-06-05 15:16:19 +01:00
Gilles Peskine
929ce501bd Test DTLS renegotiation when badmac_seen_or_in_hsfraglen != 0
Non-regression test for a bug introduced with TLS handshake defragmentation
support in Mbed TLS 3.6.2, whereby the confusion between the `badmac_seen`
meaning and the `in_hsfraglen` meaning of `ssl->badmac_seen_or_in_hsfraglen`
causes renegotiation to be processed incorrectly after receiving a message
with a bad MAC.

This bug will be fixed in a subsequent commit.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 15:40:28 +02:00
Gilles Peskine
2aa80688d9 Add a missing dependency
Needed by a test certificate.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2026-06-05 15:40:28 +02:00
Ronald Cron
d774a25bfe Remove unnecessary dependency
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2026-06-05 12:03:16 +02:00
Nadav0077
b0d5c0c80a
Harden serialized data deserialization
Reject malformed TLS 1.3 serialized sessions instead of accepting
unterminated strings or extra trailing data, and reject serialized SSL
contexts whose DTLS Connection ID length exceeds the maximum supported
size instead of overflowing the internal buffer.

Backport of #10715 (development). The dedicated CID-length test from
#10715 relies on test helpers that do not exist on 3.6 (notably
mbedtls_test_ssl_dtls_join_endpoints and mbedtls_test_ssl_perform_connection)
and is therefore omitted from this backport; the production fix and the
TLS 1.3 session-load tests are backported unchanged.

Signed-off-by: Nadav0077 <18245584+Nadav0077@users.noreply.github.com>
2026-05-22 13:16:58 +03:00
Minos Galanakis
89c0c7da25 test_suite_ssl: Added MBEDTLS_DEBUG_C guards to logs
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-05-20 15:13:13 +01:00
Minos Galanakis
b82b797b2c test_suite_ssl: Restructured reject_hrr_selecting_unoffered_group
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-05-20 15:13:06 +01:00
Minos Galanakis
e42c6d7937 test_suite_ssl: Renamed hrr_reject_selecting_unoffered_group
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-05-20 15:12:54 +01:00
Minos Galanakis
1fe3a73163 test_suite_ssl: doc fixes
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2026-05-13 11:45:56 +01:00