1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-04-19 01:04:04 +03:00

12188 Commits

Author SHA1 Message Date
Gilles Peskine
e85ece6584 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:02:18 +01:00
Gilles Peskine
e0bd20bd58 Generate handshake defragmentation test cases: update analyze_outcomes
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-04 18:24:52 +01:00
Gilles Peskine
f89bc27603 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.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-03 16:13:19 +01:00
Gilles Peskine
5071a25320 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 16:13:19 +01:00
Gilles Peskine
46cb8a2aa9 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 16:13:19 +01:00
Gilles Peskine
aaab090ad8 Normalize whitespace in defragmentation test cases
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-03 16:13:19 +01:00
Gilles Peskine
b40d33b7c8 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 16:13:19 +01:00
Gilles Peskine
4773333dc6 New generated file: tests/opt-testcases/handshake-generated.sh
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-03 16:13:19 +01:00
Gilles Peskine
5df993dcc9 Merge remote-tracking branch 'development' into tls-defragmentation-merge-development-20250303 2025-03-02 21:15:58 +01:00
Minos Galanakis
4354dc646f ssl-opt: Re-introduce certificate dependency for HS negative tests.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-27 22:40:37 +00:00
Minos Galanakis
0dd57a9913 ssl-opt: Removed dependencies for HS defrag negative tests.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-27 18:05:48 +00:00
Minos Galanakis
d01ac30cfa ssl-opt: Adjusted reference hs defragmentation tests.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-27 15:11:21 +00:00
Minos Galanakis
76957cceab ssl-opt: Minor typos and documentation fixes.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-27 15:11:21 +00:00
Minos Galanakis
19dbbe0958 analyze_outcomes: Temporary disabled 3 HS Degragmentation tests.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-27 11:46:36 +00:00
Minos Galanakis
17170a5ed2 ssl-opt: Updated documentation of HS-Defrag tests.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-27 11:40:33 +00:00
Minos Galanakis
c8709c6a85 ssl-opt: Removed redundant dependencies: requires_openssl_3_x
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-26 17:12:01 +00:00
Minos Galanakis
cd6a24b288 ssl-opt.sh: Disabled HS Defrag Tests for TLS1.2 where len < 16
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-24 09:27:09 +00:00
Minos Galanakis
99ca6680f2 ssl-opt: Replaced max_send_frag with split_send_frag
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-24 09:16:06 +00:00
Minos Galanakis
a5a8c9f5c9 ssl-opt: Added coverage for hs defragmentation TLS 1.2 tests.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-24 09:16:06 +00:00
Minos Galanakis
d708a63857 ssl-opt: Updated documentation.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-24 09:16:06 +00:00
Minos Galanakis
36c81f5f05 ssl-opt: Added DSA-RSA dependency on TLS1.2 defragmentation testing.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-24 09:16:06 +00:00
Minos Galanakis
74ce7498d7 ssl-opt: Added negative tests for handshake fragmentation.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-24 09:16:06 +00:00
Minos Galanakis
1c106afd22 ssl-opt: Added handshake fragmentation tests for 4 byte fragments.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-24 09:16:06 +00:00
Minos Galanakis
41782a9cd0 ssl-opt: Added negative-assertion testing, (HS Fragmentation disabled)
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-24 09:16:06 +00:00
Minos Galanakis
85fe73d55d ssl-opt: Added tls 1.2 tests for HS defragmentation.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-24 09:16:06 +00:00
Minos Galanakis
a4dde77cbe ssl-opt: Dependency resolving set to use to requires_protocol_version HS deframentation tests.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-24 09:16:06 +00:00
Minos Galanakis
a8a298c9d6 ssl-opt: Adjusted the wording on handshake fragmentation tests.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-24 09:16:06 +00:00
Minos Galanakis
a1b9117f17 ssl-opt: Added requires_openssl_3_x to defragmentation tests.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-24 09:16:06 +00:00
Minos Galanakis
270dd7462e ssl-opt: Updated the keywords to look up during handshake fragmentation tests.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-02-24 09:16:06 +00:00
Waleed Elmelegy
4028cfd9ca Add missing client certificate check in handshake defragmentation tests
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2025-02-24 09:16:06 +00:00
Waleed Elmelegy
5f21537c2a Test Handshake defragmentation only for TLS 1.3 only for small values
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2025-02-24 09:16:06 +00:00
Waleed Elmelegy
a75c7e09c8 Add guard to handshake defragmentation tests for client certificate
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2025-02-24 09:16:06 +00:00
Waleed Elmelegy
f162249e87 Add a comment to elaborate using split_send_frag in handshake defragmentation tests
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2025-02-24 09:16:06 +00:00
Waleed Elmelegy
61b8e2d225 Enforce client authentication in handshake fragmentation tests
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2025-02-24 09:16:06 +00:00
Waleed Elmelegy
39d83dd38d Remove unneeded mtu option from handshake fragmentation tests
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2025-02-24 09:16:06 +00:00
Waleed Elmelegy
48874b3aba Add client authentication to handshake defragmentation tests
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2025-02-24 09:16:06 +00:00
Waleed Elmelegy
f9120311e3 Require openssl to support TLS 1.3 in handshake defragmentation tests
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2025-02-24 09:16:06 +00:00
Waleed Elmelegy
fccd014c2d Remove unnecessary string check in handshake defragmentation tests
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2025-02-24 09:16:06 +00:00
Waleed Elmelegy
c0118d87b9 Fix typo in TLS Handshake defrafmentation tests
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2025-02-24 09:16:06 +00:00
Waleed Elmelegy
0e0d5d4dc8 Improve TLS handshake defragmentation tests
* Add tests for the server side.
* Remove restriction for TLS 1.2 so that we can test TLS 1.2 & 1.3.
* Use latest version of openSSL to make sure -max_send_frag &
  -split_send_frag flags are supported.

Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2025-02-24 09:16:06 +00:00
Waleed Elmelegy
79a8ded315 Add TLS Hanshake defragmentation tests
Tests uses openssl s_server with a mix of max_send_frag
and split_send_frag options.

Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2025-02-24 09:16:06 +00:00
Harry Ramsey
21506fd7f1 Update documentation regarding metatest
This commit updates the paths in the documentation for metatest.c as it
has been moved to MbedTLS Framework.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2025-02-19 15:30:25 +00:00
Harry Ramsey
9b4035cc9e Update path for moved test_zeroize.gdb script
This commit updates the path for the moved test_zeroize.gdb script which
has been moved to MbedTLS-Framework.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2025-02-19 15:30:25 +00:00
Harry Ramsey
d096793c3f Update paths for moved program files in components-build-system.sh
This commit updates the paths for dlopen_demo.sh in
components-build-system.sh as the file has been moved to the framework.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2025-02-19 15:30:25 +00:00
Harry Ramsey
b14141dd71 Move programs out of Mbed TLS
This commit moves demo_common.sh, dlopen_demo.sh, metatest.c
query_compile_time_config.c, query_config.h, query_included_headers.c,
zeroize.c and test_zeroize.gdb from MbedTLS into the MbedTLS framework.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2025-02-19 15:17:32 +00:00
Harry Ramsey
2a75a60d34 Update path to user-config-zeroize-memset.h
This commit updates the path to user-config-zeroize-memset.h as it has
been moved to TF-PSA-Crypto.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2025-02-19 08:03:57 +00:00
Harry Ramsey
76e476245a Move zeroize config to TF-PSA-Crypto
This commit moves user-config-zeroize-memset.h to TF-PSA-Crypto where it
more appropriately belongs.

Signed-off-by: Harry Ramsey <harry.ramsey@arm.com>
2025-02-19 08:03:57 +00:00
Valerio Setti
24e6ecb502 tests: move components-compliance.sh to tf-psa-crypto repo
This file is cancelled from the Mbed TLS repo and copied to the
TF-PSA-Crypto one.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-02-17 17:40:08 +01:00
Valerio Setti
1494a09ff7 test_suite_ssl: require GCM or ChaChaPoly in handshake_serialization()
Hanshake serialization requires that the selected ciphersuite uses
an AEAD algorithm. However, following the DHE-RSA removal, trying to
still use RSA signature might select a ciphersuite which is not using
AEAD, but CBC instead (see preference order in "ssl_ciphersuite.c").

This is especially problematic in tests scenarios where both GCM and
ChaChaPoly are disabled, so that CCM remains as the only AEAD algorithm.
Ciphersuites using RSA signature and CCM are very low on the preference
list, so very unlikely to be picked in tests. This cause a CBC one to
be selected in this case and the handshake_serialization() function
to fail.

In order to prevent failures from happening, in this commit we require
that either GCM or ChaChaPoly are enabled, so that ciphersuites using one
of these are likely to be picked.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-02-06 10:12:02 +01:00
Valerio Setti
8438c637ee tests: remove references to DHE-RSA
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-02-06 10:05:58 +01:00