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

11862 Commits

Author SHA1 Message Date
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
Gilles Peskine
aa9b45535b Pacify ancient clang -Wmissing-initializer
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-04-01 10:39:48 +02:00
Gilles Peskine
ad84044386 Test split, coalesced-split and empty handshake records
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-04-01 10:39:48 +02:00
Gilles Peskine
39bcbb6036 Create handshake record coalescing tests
Create tests that coalesce the handshake messages in the first flight from
the server. This lets us test the behavior of the library when a handshake
record contains multiple handshake messages.

Only non-protected (non-encrypted, non-authenticated) handshake messages are
supported.

The test code works for all protocol versions, but it is only effective in
TLS 1.2. In TLS 1.3, there is only a single non-encrypted handshake record,
so we can't test records containing more than one handshake message without
a lot more work.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-04-01 10:39:44 +02:00
Gilles Peskine
adefe78939 Document gotcha of move_handshake_to_state
A single call to move_handshake_to_state() can't do a full handshake.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-04-01 10:39:09 +02:00
Ronald Cron
f810d44956 cmake: Generate test_keys.h and test_certs.h in the build tree
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2025-03-25 09:49:22 +01:00
Minos Galanakis
05657d9dee Revert "Add auto-generated files"
This reverts commit 22098d41c6620ce07cf8a0134d37302355e1e5ef.

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-03-23 13:09:30 +00:00
Minos Galanakis
22098d41c6 Add auto-generated files
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-03-20 09:33:09 +00:00
Minos Galanakis
e62ef05344 Version Bump for 3.6.3
./scripts/bump_version.sh --version 3.6.3

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-03-18 17:11:54 +00:00
Minos Galanakis
7a95d16a31 Merge branch 'mbedtls-3.6-restricted' into mbedtls-3.6.3rc0-pr
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-03-18 16:28:26 +00:00
Gilles Peskine
f985bee481
Merge pull request #10065 from minosgalanakis/task9887_extend_defragmentation_tests_36
[Backport 3.6]  Extend ssl-opt testing for TLS HS defragmentation
2025-03-18 12:46:29 +00:00