1
0
mirror of https://github.com/ARMmbed/mbedtls.git synced 2025-05-10 17:01:41 +08:00

11872 Commits

Author SHA1 Message Date
Gilles Peskine
15bb8e04bf Improve comments
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-04-30 16:58:00 +02:00
Gilles Peskine
df065720da Allow gcc-15 to be in $PATH
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-04-25 18:59:45 +02:00
Gilles Peskine
2eab9fd92a Enable drivers when testing with GCC 15
The goal of testing with GCC 15 is to validate fixes for
https://github.com/Mbed-TLS/mbedtls/issues/9814 . The bug is present in
multiple places, and some of them affect third-party drivers but not our
built-in implementation. (The bug is that driver contexts might not be
zero-initialized, but some of our built-in implementations happen not to
care about this.) Thus, enable the test drivers in the test component that
uses GCC 15, to gain the extra checks performed in the driver wrappers.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-04-25 18:59:42 +02:00
Gilles Peskine
bf90dc9c71 GCC 15: Silence -Wunterminated-string-initialization
This is a new warning in GCC 15 that our code base triggers in many places.
Silence it for the time being.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-04-25 18:58:33 +02:00
Gilles Peskine
94c1b9a4c3 Test with GCC 15
Non-regression for https://github.com/Mbed-TLS/mbedtls/issues/9814

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-04-25 18:57:33 +02:00
Gilles Peskine
ebd0888cf0 Move persistent key tests to a separate .data file
They can cause specific challenges when debugging, so move them out for
maintainers' convenience.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-04-25 18:48:59 +02:00
Gilles Peskine
f5f15aa9e2 Move concurrent tests to a separate .data file
They can cause specific challenges when debugging, so move them out for
maintainers' convenience.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-04-25 18:48:52 +02:00
Gilles Peskine
84442115ff
Merge pull request #10137 from gilles-peskine-arm/test_suite_ssl-fix-ret-20250408-3.6
Backport 3.6: Fix uncaught failure conditions in test_suite_ssl
2025-04-23 16:42:17 +00:00
Gilles Peskine
0e6032dd94 Fix some test helper functions returning 0 on some failures
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-04-17 10:35:04 +02:00
Gilles Peskine
1ff12810e5 Check the status of mbedtls_ssl_set_hostname()
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-04-17 10:35:03 +02:00
Max Fillinger
820e5cc29b Fix dependencies for TLS-Exporter tests
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:24:50 +02:00
Max Fillinger
6a64f0f171 Exporter: Add min. and max. label tests
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:24:50 +02:00
Max Fillinger
76bb753054 Fix max. label length in key material exporter
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:24:50 +02:00
Max Fillinger
c361064dee Fix requirements for TLS 1.3 Exporter compat test
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:24:50 +02:00
Max Fillinger
2310c1970b Add fixed compatibility test for TLS 1.3 Exporter
When testing TLS 1.3, use O_NEXT_CLI.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:24:50 +02:00
Max Fillinger
e009158d71 Remove exporter compatibility test for TLS 1.3
The openssl version in the docker image doesn't support TLS 1.3, so we
can't run the test.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:24:50 +02:00
Max Fillinger
0faf5d19a7 Fix openssl s_client invocation
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:24:49 +02:00
Max Fillinger
d22493f86b Print names of new tests properly
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:24:49 +02:00
Max Fillinger
9c3a7ba6da ssl-opt.sh: Add tests for keying material export
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:24:49 +02:00
Max Fillinger
c8f936e746 mbedtls_test_ssl_do_handshake_with_endpoints: Zeroize endpoints
Signed-off-by: Max Fillinger <max@max-fillinger.net>
2025-04-16 11:24:49 +02:00
Max Fillinger
ede294ea42 Exporter tests: Don't use unavailbable constant
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:24:49 +02:00
Max Fillinger
2c2a6ac64c Exporter tests: Add missing depends-ons
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:24:47 +02:00
Max Fillinger
8ee21410f1 Use one maximum key_len for all exported keys
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:23:42 +02:00
Max Fillinger
fb7e578689 Exporter tests: Reduce key size in long key tests
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:23:42 +02:00
Max Fillinger
20e4ac8b3e Exporter tests: Free endpoints before PSA_DONE()
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:23:42 +02:00
Max Fillinger
81b41d40dc Exporter tests: Fix possible uninitialized variable use
Signed-off-by: Max Fillinger <max@max-fillinger.net>
2025-04-16 11:23:42 +02:00
Max Fillinger
538ed71ecb Coding style cleanup
Signed-off-by: Max Fillinger <max@max-fillinger.net>
2025-04-16 11:23:42 +02:00
Max Fillinger
e825110391 Exporter tests: Initialize allocated memory
Signed-off-by: Max Fillinger <max@max-fillinger.net>
2025-04-16 11:23:42 +02:00
Max Fillinger
436cc20378 Exportert tests: Free endpoints and options
Signed-off-by: Max Fillinger <max@max-fillinger.net>
2025-04-16 11:23:41 +02:00
Max Fillinger
e95edbf6c5 Fix output size check for key material exporter
HKDF-Expand can produce at most 255 * hash_size bytes of key material,
so this limit applies to the TLS 1.3 key material exporter.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:23:41 +02:00
Max Fillinger
ffc47e6e2b Increase allowed output size of HKDF-Expand-Label
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:23:41 +02:00
Max Fillinger
9e23339ae9 Add more tests for keying material export
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:23:40 +02:00
Max Fillinger
9359f4d703 Fix coding style
Signed-off-by: Max Fillinger <max@max-fillinger.net>
2025-04-16 11:20:49 +02:00
Max Fillinger
d3d7ff4c6b Add test for TLS-Exporter in TLS 1.3
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:20:49 +02:00
Manuel Pégourié-Gonnard
881ebc7ce8 Fix record insertion
We were not making enough room. We want to move everything from the
place where we are going to insert the new record.

This was not causing failures because the code does not look at the
content after the inserted record, because it correctly returns an error
when seeing the inserted record. But as a matter on principle, the test
code should be doing what it says: just insert a new record but leave
a valid fragment after it.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-04-11 10:16:47 +02:00
Manuel Pégourié-Gonnard
6c5af6c7ae Update feature macro for 3.6
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-04-10 10:34:07 +02:00
Manuel Pégourié-Gonnard
f1335bcdcd Use HANDSHAKE_OVER in nominal test cases
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-04-10 10:29:19 +02:00
Manuel Pégourié-Gonnard
e38bc4c445 Improve comments
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-04-10 10:29:08 +02:00
Manuel Pégourié-Gonnard
784041a28d Adapt dependencies to the 3.6 branch
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-04-01 10:46:37 +02:00
Manuel Pégourié-Gonnard
fa547780f2 Use same dependencies for helper functions
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-04-01 10:39:48 +02:00
Manuel Pégourié-Gonnard
066ac1365b Tighten dependencies again
This one is overly tight: TLS 1.3 actually only depends on

    ChachaPoly || (AES && (GCM || CCM))

Furthermore, this should really be reflected in check_config.h.
Individual test cases should be able to just request PROTO_TLS1_3 and
know that there is ciphersuite that works.

However, resolving that seems out of scope for this PR. (It would also
involve updating depends.py for example.)

So, use a dependency that's stricted than necessary. IMO it's still good
enough as most configs we test will have ChachaPoly. However it would be
good to revisit this when a cleaner solution is implemented.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-04-01 10:39:48 +02:00
Manuel Pégourié-Gonnard
063c1ced17 Improve dependency declarations
The function depends on MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED which is
basically

    MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED ||
    MBEDTLS_KEY_EXCHANGE_WITH_CERT_ENABLED

The individual test cases depend on the specific TLS version.

This is not precise enough. In a build with both TLS versions enabled,
we could have cert-based key exchange in one version but not in the
other. So, we need the 1.3 tests to depend on the 1.3 cert-based key
exchange and similarly for 1.2.

For 1.2, cert-based key exchange means ECDHE-{RSA,ECDSA} or
ECDH-{RSA,ECDSA}. Since the test function sets an ECC cert for the
server, we want one of the ECDSA ones. So, the minimal dependency would
be ECDH_ECDSA || ECDHE_ECDSA. Since dependencies with || are
inconvenient to express, and anyway ECDH_ECDSA (static ECDH) is
something we'd like to remove in 4.0 if we can find the time, I chose to
just depend on ECDHE_ECDSA.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-04-01 10:39:48 +02:00
Manuel Pégourié-Gonnard
05ff37fbf2 Tighten dependency declarations
These are not optimal. For example, the tests should in principle be
able to run in builds without ECDSA, by using RSA certs instead. Ideally
PSK should work too.

However, getting optimal dependencies would be a lot of work that's
largely orthogonal to the purpose of this PR, so we'll settle for good
enough.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-04-01 10:39:48 +02:00
Gilles Peskine
f267020565 Improve documentation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-04-01 10:39:48 +02:00
Gilles Peskine
cb3cabd568 Remove redundant setup
mbedtls_test_ssl_endpoint_init() already takes care of setting up debugging.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-04-01 10:39:48 +02:00
Gilles Peskine
7fe3638b54 Fix copypasta
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-04-01 10:39:48 +02:00
Gilles Peskine
f9333a3ac4 Simulate closing the connection mid-message
Simulate the server closing the connection after a partial handshake
message.

These test cases don't send a close_notify alert. The test cases
"insert alert record" exercise what happens if the server sends an alert.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-04-01 10:39:48 +02:00
Gilles Peskine
4f57212da2 Also test inserting non-empty, non-handshake records
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-04-01 10:39:48 +02:00
Gilles Peskine
d973387666 Fix the build without MBEDTLS_DEBUG_C
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-04-01 10:39:48 +02:00
Gilles Peskine
7cdf563a7d Fix the build in PSK-only configurations
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-04-01 10:39:48 +02:00