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

13560 Commits

Author SHA1 Message Date
Max Fillinger
1b0e2e903b Add missing ifdef for mbedtls_ssl_tls13_exporter
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 14:35:24 +02:00
Max Fillinger
40c202461f Add label_len argument to non-PSA tls_prf_generic
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:24:50 +02:00
Max Fillinger
5122dc6219 Fix mistake in previous comment change
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:24:50 +02:00
Max Fillinger
7833b18008 Fix HkdfLabel comment
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:24:50 +02:00
Max Fillinger
529931a34a Allow maximum label length in Hkdf-Expand-Label
Previously, the length of the label was limited to the maximal length
that would be used in the TLS 1.3 key schedule. With the keying material
exporter, labels of up to 249 bytes may be used.

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
97a287953f Document BAD_INPUT_DATA error in key material exporter
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:24:50 +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
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
8fa72523be Fix #endif comment
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:20:50 +02:00
Max Fillinger
951b886801 Create MBEDTLS_SSL_KEYING_MATERIAL_EXPORT option
Add the option MBEDTLS_SSL_KEYING_MATERIAL_EXPORT to mbedtls_config.h
to control if the function mbedtls_ssl_export_keying_material() should
be available. By default, the option is disabled.

This is because the exporter for TLS 1.2 requires client_random and
server_random need to be stored after the handshake is complete.

Signed-off-by: Max Fillinger <max@max-fillinger.net>
2025-04-16 11:20:50 +02:00
Max Fillinger
7b52328f6c Remove TLS 1.2 Exporter if we don't have randbytes
The TLS-Exporter in TLS 1.2 requires client_random and server_random.
Unless MBEDTLS_SSL_CONTEXT_SERIALIZATION is defined, these aren't stored
after the handshake is completed.

Therefore, mbedtls_ssl_export_keying_material() exists only if either
MBEDTLS_SSL_CONTEXT_SERIALIZATION is defined or MBEDTLS_SSL_PROTO_TLS1_2
is *not* defined.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:20:50 +02:00
Max Fillinger
92d29301bc Revert "Store randbytes for TLS 1.2 TLS-Exporter"
This reverts commit cb01dd1333f8083af469e9a0c59f316f1eb0cfe3.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:20:50 +02:00
Max Fillinger
6c02ea86aa Use fewer magic numbers in TLS-Exporter functions
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:20:50 +02:00
Max Fillinger
76077e2e31 Add label length argument to tls_prf_generic()
This way, it's not required that the label is null-terminated. This
allows us to avoid an allocation in
mbedtls_ssl_tls12_export_keying_material().

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:20:50 +02:00
Max Fillinger
85b33ee42e Store randbytes for TLS 1.2 TLS-Exporter
Previously, if MBEDTLS_SSL_CONTEXT_SERIALIZATION is not defined,
randbytes are not stored after the handshake is done, but they are
needed for TLS-Exporter in TLS 1.2.

This commit also saves randbytes if MBEDTLS_SSL_PROTO_TLS1_2 is defined.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-04-16 11:20:50 +02:00
Max Fillinger
0118293e23 Fix build when one of TLS 1.2 or 1.3 is disabled
Signed-off-by: Max Fillinger <max@max-fillinger.net>
2025-04-16 11:20:49 +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
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
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
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
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
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
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
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
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
Manuel Pégourié-Gonnard
b6ad19b2b8
Merge pull request #9976 from mpg/defragment-ext-test-3.6
Defragment ext test 3.6
2025-03-17 11:44:28 +00:00
Minos Galanakis
dfc8e43614 Merge remote-tracking branch 'upstream/mbedtls-3.6' into pre-3.6.3-upstream-merge 2025-03-14 14:23:23 +00:00
Gilles Peskine
c03cd1124c
Merge pull request #10025 from waleed-elmelegy-arm/mbedtls-3.6-fix-key-deriv-bad-state-error
Backport 3.6: Fix psa_key_derivation_input_integer() not detecting bad state
2025-03-14 10:11:40 +00:00
Manuel Pégourié-Gonnard
051b1e21d6 Reduce the level of logging used in tests
This should avoid running into a bug with printf format specifiers one
windows.

It's also a logical move for actual tests: I used the highest debug
level for discovery, but we don't need that all the time.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-03-14 09:21:59 +01:00
Manuel Pégourié-Gonnard
00ad6f6b03 New test function inject_client_content_on_the_wire()
Not used for real stuff so far, just getting the tooling in place.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-03-14 09:21:59 +01:00
Gilles Peskine
3dbe333ab0
Merge pull request #10051 from Vge0rge/key_id_range_backport
PSA core: Allow enabling one volatile/builtin key
2025-03-13 09:27:12 +00:00
David Horstmann
26f0044ad0
Merge pull request #1319 from davidhorstmann-arm/calc-finished-check-return-3.6
[Backport 3.6] TLS1.2: Check for failures in Finished calculation
2025-03-12 17:35:40 +00:00
Minos Galanakis
104bd06826 Merge remote-tracking branch 'origin/features/tls-defragmentation/3.6' into feature_merge_defragmentation_36
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-03-12 15:21:56 +00:00
Gilles Peskine
43f636ff4d
Merge pull request #1316 from gilles-peskine-arm/zeroize-psa-202503-3.6
Backport 3.6: Zeroize PSA temporary heap buffers
2025-03-11 17:38:28 +01:00
Georgios Vasilakis
d5e64f71db PSA core: Allow enabling one volatile/builtin key
The current impelementation asserts if the user
sets MBEDTLS_PSA_KEY_SLOT_COUNT to one or if they
limit their builtin range to one key.

This removes the requirement and allows for only
one key volatile/builtin to be enabled.

Signed-off-by: Georgios Vasilakis <georgios.vasilakis@nordicsemi.no>
2025-03-11 09:37:29 +01:00
Manuel Pégourié-Gonnard
8a4ec49671 Cleanly reject non-HS in-between HS fragments
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-03-10 21:38:48 +01:00
Waleed Elmelegy
443908bc5d Replace zero by PSA_ALG_NONE in key derivation input functions
Signed-off-by: Waleed Elmelegy <waleed.elmelegy@arm.com>
2025-03-10 14:20:09 +00:00
David Horstmann
b5ef7da7cb TLS1.2: Check for failures in Finished calculation
If the calc_finished function returns an error code, don't ignore it but
instead return the error code to stop the handshake as the Finished
message may be incorrect.

Signed-off-by: David Horstmann <david.horstmann@arm.com>
2025-03-07 17:25:54 +00:00
Gilles Peskine
c22e315086 Fix a log message
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-07 10:44:57 +01:00
Gilles Peskine
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
Gilles Peskine
dee926359c Pacify uncrustify
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-06 21:33:29 +01:00
Gilles Peskine
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
Gilles Peskine
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