1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-01 10:06:53 +03:00

31930 Commits

Author SHA1 Message Date
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
dee926359c Pacify uncrustify
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-06 21:33:29 +01:00
ce726b23fa Fix uninitialized variable
The of m_bytes value isn't actually used when it's uninitialized,
because *data is null, but that's very fragile.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-06 19:27:50 +01:00
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
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
3175fc3be2 Fix end check before memmove
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-06 19:10:41 +01:00
184cac1eb6 Zeroize temporary heap buffers used when deriving an ECC key
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-06 12:42:30 +01:00
e847afd9ef Zeroize temporary heap buffers used in PSA operations
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-06 12:41:59 +01:00
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
9a9f0c77cf Merge pull request #1312 from gilles-peskine-arm/ssl-hostname-unset-magic-pointer-3.6
Backport 3.6: require setting the hostname for verification
2025-03-05 17:59:12 +00:00
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
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
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
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
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
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
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
b6102b6ccf Fix Doxygen markup
Pacify `clang -Wdocumentation`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-05 17:03:20 +01:00
134677d44c Merge pull request #10029 from gilles-peskine-arm/tls-defragment-generate-tests-3.6
Backport 3.6: Generate TLS handshake defragmentation tests
2025-03-05 16:49:21 +01:00
2e7def5748 Update framework
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-05 10:08:29 +01:00
9d54be57b0 Generate handshake defragmentation test cases: update analyze_outcomes
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-05 10:08:21 +01:00
1d25c71ab6 Merge pull request #9562 from valeriosetti/md-psa-dispatch-3.6
Backport 3.6: md: allow dispatch to PSA whenever CRYPTO_CLIENT is enabled
2025-03-04 08:34:11 +00:00
2e7f2a2e48 Switch to generated handshake tests
Replace `tests/opt-testcases/handshake-manual.sh` by
`tests/opt-testcases/handshake-generated.sh`. They are identical except for
comments, and for some extra dependencies on
`MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED` which are needed in `development,
but not in `mbedtls-3.6. Those dependencies don't hurt the useful coverage
of the tests, so we'll live with them.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-03 21:03:22 +01:00
6183a645fc Normalize requirements in defragmentation test cases
Be more uniform in where certificate authentication and ECDSA are explicitly
required. A few test cases now run in PSK-only configurations where they
always could. Add a missing requirement on ECDSA to test cases that are
currently skipped.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-03 21:00:50 +01:00
49e1ed277e Normalize messages in defragmentation test cases
Make some test case descriptions and log patterns follow more systematic
patterns.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-03 21:00:50 +01:00
8321ab574c Normalize whitespace in defragmentation test cases
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-03 21:00:50 +01:00
8ef2e74704 Move most TLS handshake defragmentation tests to a separate file
Prepare for those test cases to be automatically generated by a script.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-03 21:00:48 +01:00
28f953c5ec New generated file: tests/opt-testcases/handshake-generated.sh
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-03 20:58:32 +01:00
82cd324fd4 Fix code style for key derivation input function
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2025-03-03 15:04:17 +00:00
abb08f1088 Merge pull request #10024 from gilles-peskine-arm/tls-defragmentation-merge-3.6-20250303
[tls-defragmentation/3.6] Update main branch
2025-03-03 14:03:37 +00:00
cba05ece2b Replace zero by PSA_ALG_NONE in key derivation test function
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2025-03-03 12:48:40 +00:00
07e5739115 Replace zero by PSA_ALG_NONE in key derivation testing
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2025-03-03 12:48:16 +00:00
b6ed6f72cd Simplify testing psa_key_derivation_input_*() bad state
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2025-03-03 12:45:43 +00:00
72b391fe07 Fix psa_key_derivation_input_integer() not detecting bad state
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2025-03-03 12:37:02 +00:00
e0f1240cd5 Merge remote-tracking branch 'mbedtls-3.6' into tls-defragmentation-merge-3.6-20250303 2025-03-02 21:16:08 +01:00
b55fd70a05 Merge pull request #10016 from minosgalanakis/issue9887_add_basic_defragmentation_tests_36
[3.6 Backport] Add basic handshake defragmentation tests in ssl-opt
2025-02-28 12:55:56 +01:00
bc55af83d3 framework: update reference
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-02-28 12:18:03 +01:00
5764816335 ssl-opt: Re-introduce certificate dependency for HS negative tests.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-27 22:39:56 +00:00
97a24ebdb1 ssl-opt: Removed dependencies for HS defrag negative tests.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-27 18:11:20 +00:00
48348261d4 ssl-opt: Adjusted reference hs defragmentation tests.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-27 15:26:25 +00:00
19d857d74c ssl-opt: Minor typos and documentation fixes.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-27 15:26:24 +00:00
21e4f21df9 analyze_outcomes: Temporary disabled 3 HS Degragmentation tests.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-27 15:25:50 +00:00
618ad79395 ssl-opt: Updated documentation of HS-Defrag tests.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-27 15:25:50 +00:00
bb1bd8bf9e ssl-opt: Removed redundant dependencies: requires_openssl_3_x
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-27 15:25:49 +00:00
065b89c7ad ssl-opt.sh: Disabled HS Defrag Tests for TLS1.2 where len < 16
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-27 15:24:37 +00:00
4335125664 ssl-opt: Replaced max_send_frag with split_send_frag
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-27 15:24:37 +00:00
ee8e7c3fb3 ssl-opt: Added coverage for hs defragmentation TLS 1.2 tests.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-27 15:24:35 +00:00
2622aea537 ChangeLog: Updated the entry for tls-hs-defragmentation
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-27 15:23:38 +00:00
e6dbf495b1 ssl-opt: Updated documentation.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-27 15:23:38 +00:00
79693bf48a ssl-opt: Added negative tests for handshake fragmentation.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-27 15:20:41 +00:00