1
0
mirror of https://github.com/ARMmbed/mbedtls.git synced 2025-06-05 14:26:42 +08:00

31838 Commits

Author SHA1 Message Date
Minos Galanakis
12cf388856 Added Mock Renegotiation negative test for testing.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-03-14 00:10:10 +00:00
Minos Galanakis
a37a936beb ssl-opt: Added fragmented HS tests for server-initiated renegotiation.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-03-14 00:10:10 +00:00
Minos Galanakis
c4595a4c6a ssl-opt: Added fragmented HS tests for client-initiated renegotiation.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-03-14 00:10:10 +00:00
Minos Galanakis
1e6438d8b9 ssl-opt: Added fragmented HS tests for SSL_VARIABLE_BUFFER_LENGTH.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-03-14 00:10:09 +00:00
Gilles Peskine
ba4f16691c
Merge pull request #10058 from gilles-peskine-arm/mbedtls_net_send-api-desc-tweak-3.6
Backport 3.6: mbedtls_net_send API description typo fix
2025-03-13 16:29:57 +00:00
Bence Szépkúti
b22247b85b
Merge pull request #10043 from Mbed-TLS/msvc-format-size-macros-3.6
[Backport 3.6] Fix preprocessor guards for C99 format size specifiers
2025-03-13 10:09:13 +00:00
Noah Pendleton
b05b3b19d7 mbedtls_net_send API description typo fix
Signed-off-by: Noah Pendleton <noah.pendleton@gmail.com>
2025-03-13 10:32:27 +01:00
Gilles Peskine
3dbe333ab0
Merge pull request #10051 from Vge0rge/key_id_range_backport
PSA core: Allow enabling one volatile/builtin key
2025-03-13 09:27:12 +00:00
Manuel Pégourié-Gonnard
5b114163e4
Merge pull request #10056 from minosgalanakis/feature_merge_defragmentation_36
Merge defragmentation feature branch onto 3.6
2025-03-13 08:36:11 +00:00
Bence Szépkúti
c64b7bc664 Use an array of strings instead of pointer smuggling
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-03-12 19:12:44 +01:00
Bence Szépkúti
a029387d1b 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:28:30 +01:00
Bence Szépkúti
f525505886 Clarify changelog
Remove mention of the shipped .sln files, as those are planned to be
removed from Mbed TLS.

Clarify the affected CRT headers.

Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-03-12 17:28:30 +01:00
Minos Galanakis
51668e5249 Updated framework pointer.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-03-12 15:22:27 +00:00
Minos Galanakis
104bd06826 Merge remote-tracking branch 'origin/features/tls-defragmentation/3.6' into feature_merge_defragmentation_36
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-03-12 15:21:56 +00:00
Manuel Pégourié-Gonnard
26932b811b
Merge pull request #10055 from gilles-peskine-arm/tls-defragment-doc-3.6
Backport 3.6: Document the limitations of TLS handshake message defragmentation
2025-03-12 13:00:23 +01:00
Gilles Peskine
a7c020d6cb Update the location of defragmentation limitations
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-12 10:55:48 +01:00
Gilles Peskine
858900656e State globally that the limitations don't apply to DTLS
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-12 10:55:47 +01:00
Gilles Peskine
bc0255592f Clarify DTLS
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-12 10:55:11 +01:00
Gilles Peskine
c3af2f48c4 ClientHello may be fragmented in renegotiation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-12 10:55:11 +01:00
Gilles Peskine
494e4943b5 Move the defragmentation documentation to mbedtls_ssl_handshake
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-12 10:55:10 +01:00
Gilles Peskine
1933932e55 Refer to the API documentation for details
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-12 10:53:11 +01:00
Gilles Peskine
b5ccd32390 Document the limitations of TLS handshake message defragmentation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-12 10:53:11 +01:00
Manuel Pégourié-Gonnard
579f91ad44
Merge pull request #10046 from mpg/fix-defrag-interleave-3.6
Fix defrag interleave 3.6
2025-03-11 12:38:21 +01:00
Georgios Vasilakis
d5e64f71db PSA core: Allow enabling one volatile/builtin key
The current impelementation asserts if the user
sets MBEDTLS_PSA_KEY_SLOT_COUNT to one or if they
limit their builtin range to one key.

This removes the requirement and allows for only
one key volatile/builtin to be enabled.

Signed-off-by: Georgios Vasilakis <georgios.vasilakis@nordicsemi.no>
2025-03-11 09:37:29 +01:00
Manuel Pégourié-Gonnard
8a4ec49671 Cleanly reject non-HS in-between HS fragments
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-03-10 21:38:48 +01:00
Bence Szépkúti
db475821f9 Fix comments
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-03-08 01:02:57 +01:00
Bence Szépkúti
23e941a2e7 Update changelog to call out MinGW
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-03-08 00:42:44 +01:00
Bence Szépkúti
c6934ff670 Never use %zu on MinGW
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-03-07 17:54:20 +01:00
Bence Szépkúti
8154c5823e Remove Everest VS2010 compatibility headers
These headers were necessary for compatibility with Visual Studio 2010,
and interfere with the system headers on Visual Studio 2013+, eg. when
building Mbed TLS using the .sln file shipped with the project.

Move the still-required definition of "inline" to callconv.h, where the
definition for GCC also lives.

Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-03-07 17:54:19 +01:00
Bence Szépkúti
f65983d670 Fix MSVC version guard for C99 format size specifiers
Visual Studio 2013 (_MSC_VER == 1800) doesn't support %zu - only use it
on 2015 and above (_MSC_VER >= 1900).

%ldd works on Visual Studio 2013, but this patch keeps the two macro
definitions together, for simplicity's sake.

Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-03-07 17:45:27 +01:00
Bence Szépkúti
1e62c95148 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-07 17:45:27 +01:00
Bence Szépkúti
9cde9d4b2c Add testcase for MBEDTLS_PRINTF_MS_TIME
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-03-07 17:45:26 +01:00
Bence Szépkúti
85d92ec1ce Test handling of format macros defined in debug.h
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-03-07 17:45:26 +01:00
Bence Szépkúti
d5102c9d7c 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-07 17:45:26 +01:00
Gilles Peskine
26c378cb73
Merge pull request #10030 from gilles-peskine-arm/tls-defragment-incremental-3.6
Backport 3.6: Incremental TLS handshake defragmentation
2025-03-07 13:17:39 +01:00
Gilles Peskine
c22e315086 Fix a log message
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-07 10:44:57 +01:00
Gilles Peskine
229e200cb4 Note unused variables when debugging is disabled
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-06 21:33:32 +01:00
Gilles Peskine
dee926359c Pacify uncrustify
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-06 21:33:29 +01:00
Gilles Peskine
0a467ccd24 Unify handshake fragment log messages
There is no longer any different processing at this point, just
near-identical log messages.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-06 19:22:52 +01:00
Gilles Peskine
b888cca5b6 Fix handshake defragmentation when the record has multiple messages
A handshake record may contain multiple handshake messages, or multiple
fragments (there can be the final fragment of a pending message, then zero
or more whole messages, and an initial fragment of an incomplete message).
This was previously untested, but supported, so don't break it.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-06 19:22:40 +01:00
Gilles Peskine
3175fc3be2 Fix end check before memmove
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-06 19:10:41 +01:00
Gilles Peskine
7719169ef4 Update framework
Changed log messages and added more tests in
`tests/opt-testcases/handshake-generated.sh`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-06 09:35:55 +01:00
Gilles Peskine
58c3301f65 Make conversion explicit to silence MSVC warning
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-05 17:03:20 +01:00
Gilles Peskine
302f37b05d Fix dodgy printf calls
Pacify `clang -Wformat-pedantic`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-05 17:03:20 +01:00
Gilles Peskine
cc856a2c0e Handshake defragmentation: reassemble incrementally
Reassemble handshake fragments incrementally instead of all at the end. That
is, every time we receive a non-initial handshake fragment, append it to the
initial fragment. Since we only have to deal with at most two handshake
fragments at the same time, this simplifies the code (no re-parsing of a
record) and is a little more memory-efficient (no need to store one record
header per record).

This commit also fixes a bug. The previous code did not calculate offsets
correctly when records use an explicit IV, which is the case in TLS 1.2 with
CBC (encrypt-then-MAC or not), GCM and CCM encryption (i.e. all but null and
ChachaPoly). This led to the wrong data when an encrypted handshake message
was fragmented (Finished or renegotiation). The new code handles this
correctly.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-05 17:03:20 +01:00
Gilles Peskine
22c51b9a0b mbedtls_ssl_prepare_handshake_record(): log offsets after decryption
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-05 17:03:20 +01:00
Gilles Peskine
af0c461f39 mbedtls_ssl_prepare_handshake_record(): refactor first fragment prep
Minor refactoring of the initial checks and preparation when receiving the
first fragment. Use `ssl->in_hsfraglen` to determine whether there is a
pending handshake fragment, for consistency, and possibly for more
robustness in case handshake fragments are mixed with non-handshake
records (although this is not currently supported anyway).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-05 17:03:20 +01:00
Gilles Peskine
1e81d349b8 Tweak handshake fragment log message
In preparation for reworking mbedtls_ssl_prepare_handshake_record(),
tweak the "handshake fragment:" log message.

This changes what information is displayed when a record contains data
beyond the expected end of the handshake message. This case is currently
untested and its handling will change in a subsequent commit.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-05 17:03:20 +01:00
Gilles Peskine
3d490a91ad Tweak "waiting for more handshake fragments" log message
In preparation for reworking mbedtls_ssl_prepare_handshake_record(), tweak
the "waiting for more handshake fragments" log message in
ssl_consume_current_message(), and add a similar one in
mbedtls_ssl_prepare_handshake_record(). Assert both.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-05 17:03:20 +01:00
Gilles Peskine
b6102b6ccf Fix Doxygen markup
Pacify `clang -Wdocumentation`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-05 17:03:20 +01:00