1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-04-21 23:05:55 +03:00

32028 Commits

Author SHA1 Message Date
Max Fillinger
3be83a7696 Fix mismatches in function declarations
Missed some const keywords in function declarations.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:20:49 +02:00
Max Fillinger
1466bf8897 Fix key_len check in TLS-Exporter
The length of the generated key must fit into a uint16_t, so it must not
be larger than 0xffff.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:20:49 +02:00
Max Fillinger
77a447ba97 Actually set exporter defaults in ssl_client2
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:20:49 +02:00
Max Fillinger
404f7a3bfb Simplify mbedtls_ssl_tls13_exporter
RFC 8446 made it look like we can't use Derive-Secret for the second
step, but actually, Transcript-Hash and Hash are the same thing, so we
can.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
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
Max Fillinger
29f79ea7f4 Fix commented out function declaration
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:20:49 +02:00
Max Fillinger
91ad62efc7 Add changelog entry for TLS-Exporter feature
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:20:49 +02:00
Max Fillinger
de3d5fdc83 Add TLS-Exporter options to ssl_client2
Prints out the exported key on the command line for testing purposes.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:20:49 +02:00
Max Fillinger
90ed7f7f5e Add TLS-Exporter options to ssl_server2
The program prints out the derived symmetric key for testing purposes.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:20:49 +02:00
Max Fillinger
44042f0a57 Implement TLS-Exporter feature
The TLS-Exporter is a function to derive shared symmetric keys for the
server and client from the secrets generated during the handshake.
It is defined in RFC 8446, Section 7.5 for TLS 1.3 and in RFC 5705 for
TLS 1.2.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:20:49 +02:00
Valerio Setti
3302dc6510 programs: demo: do not source project_detection.sh directly
Let "demo_common.sh" do all that it's required for these script to
work properly.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-04-11 15:07:02 +02:00
Ronald Cron
5da6b498ac
Merge pull request #10110 from mpg/defragment-test-server-first-flight-3.6
[Backport 3.6] Test coalesced or split handshake messages
2025-04-11 10:32:10 +00: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
Gilles Peskine
2e10e781f3
Merge pull request #10129 from valeriosetti/fix-demo-programs
[3.6] Fix demo programs' bash scripts
2025-04-10 15:35:46 +00:00
Valerio Setti
5533cc8077 programs: demo: source project_detection.sh
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-04-10 14:15:41 +02:00
Valerio Setti
ecd5aa387e framework: update reference
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-04-10 14:15:20 +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
544fdc6118 Fix printf of enum
The enum is promoted to `int`, so `%d` is a correct format,
but `gcc -Wformat` complains.

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
Gilles Peskine
da5f5b23d0 Add a log message on every SSL state transition
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-04-01 10:39:09 +02:00
Gilles Peskine
49f179d9c8 Always call mbedtls_ssl_handshake_set_state
Call a single function for all handshake state changes, for easier tracing.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-04-01 10:39:04 +02:00
David Horstmann
3623414113
Merge pull request #10092 from davidhorstmann-arm/add-missing-credit-3.6
[3.6] Add missing credit for `set_hostname` issue
2025-03-27 09:11:21 +00:00
Ronald Cron
a1dd7fa1f2
Merge pull request #10069 from ronald-cron-arm/check-generated-files-3.6
[Backport 3.6] Adapt test_keys.h and test_cert.h generation
The PR is based on mbedtls-3.6, no PR in the merging queue for mbedtls-3.6, thus merging directly without going through the merge queue.
2025-03-27 08:35:30 +01:00
David Horstmann
70807520ec Add missing credit for set_hostname issue
Correctly credit Daniel Stenberg for reporting the problem with
mbedtls_ssl_set_hostname().

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2025-03-25 16:01:30 +00: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
Ronald Cron
9449eedb81 Update framework pointer
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
2025-03-25 09:49:16 +01:00
minosgalanakis
0c0f5f200f
Merge pull request #1332 from Mbed-TLS/mbedtls-3.6.3_mergeback
Mbedtls 3.6.3 mergeback
2025-03-24 16:49:08 +00:00
Minos Galanakis
3b56d92581 Merge branch 'mbedtls-3.6.3rc' into mbedtls-3.6.3_mergeback 2025-03-23 13:14:46 +00: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
minosgalanakis
a68d1d2caa
Merge pull request #1328 from Mbed-TLS/mbedtls-3.6.3rc0-pr
Mbedtls 3.6.3rc0 pr
2025-03-20 23:14:23 +00:00
Minos Galanakis
8cf5666a17 Restored framework as a submodule
- git submodule add https://github.com/Mbed-TLS/mbedtls-framework framework
- git submodule init
- pushd framework && git checkout cab0c5 && popd
- git add framework

Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-03-20 11:11:05 +00:00
Minos Galanakis
c90c6d8ff7 Deleted flattened framework dir.
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-03-20 11:06:31 +00:00
Minos Galanakis
22098d41c6 Add auto-generated files
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
v3.6.3 mbedtls-3.6.3
2025-03-20 09:33:09 +00:00