1
0
mirror of https://github.com/ARMmbed/mbedtls.git synced 2025-05-12 01:42:21 +08:00

7022 Commits

Author SHA1 Message Date
Max Fillinger
0b65a91eea Fix doxygen for MBEDTLS_SSL_KEYING_MATERIAL_EXPORT
Error was introduced while resolving a merge conflict.

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
d97e0e8edc Enable MBEDTLS_SSL_KEYING_MATERIAL_EXPORT by default
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
c48e9e0004 Fix coding style
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
f95bfda1f9 Fix doxygen comment parameter name
Signed-off-by: Max Fillinger <max@max-fillinger.net>
2025-04-16 11:20:49 +02:00
Max Fillinger
5805cc9807 Fix typos in comment
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
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
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
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
0ed5cb8074
Merge pull request #10004 from gilles-peskine-arm/doc-threading-needed-by-psa-3.6
Backport 3.6: Document PSA's need for threading
2025-03-14 03:51:52 +00:00
Gilles Peskine
ba4f16691c
Merge pull request #10058 from gilles-peskine-arm/mbedtls_net_send-api-desc-tweak-3.6
Backport 3.6: mbedtls_net_send API description typo fix
2025-03-13 16:29:57 +00:00
Bence Szépkúti
b22247b85b
Merge pull request #10043 from Mbed-TLS/msvc-format-size-macros-3.6
[Backport 3.6] Fix preprocessor guards for C99 format size specifiers
2025-03-13 10:09:13 +00:00
Noah Pendleton
b05b3b19d7 mbedtls_net_send API description typo fix
Signed-off-by: Noah Pendleton <noah.pendleton@gmail.com>
2025-03-13 10:32:27 +01: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
858900656e State globally that the limitations don't apply to DTLS
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-12 10:55:47 +01:00
Gilles Peskine
bc0255592f Clarify DTLS
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-12 10:55:11 +01:00
Gilles Peskine
c3af2f48c4 ClientHello may be fragmented in renegotiation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-12 10:55:11 +01:00
Gilles Peskine
494e4943b5 Move the defragmentation documentation to mbedtls_ssl_handshake
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-12 10:55:10 +01:00
Gilles Peskine
b5ccd32390 Document the limitations of TLS handshake message defragmentation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-12 10:53:11 +01:00
Gilles Peskine
d3b3c6740f More generally, what needs psa_crypto_init also needs threading
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-11 14:45:54 +01:00
Bence Szépkúti
db475821f9 Fix comments
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-03-08 01:02:57 +01:00
Bence Szépkúti
c6934ff670 Never use %zu on MinGW
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-03-07 17:54:20 +01:00
Bence Szépkúti
f65983d670 Fix MSVC version guard for C99 format size specifiers
Visual Studio 2013 (_MSC_VER == 1800) doesn't support %zu - only use it
on 2015 and above (_MSC_VER >= 1900).

%ldd works on Visual Studio 2013, but this patch keeps the two macro
definitions together, for simplicity's sake.

Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-03-07 17:45:27 +01:00
Gilles Peskine
9dfe548008 Document the need to call mbedtls_ssl_set_hostname
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-25 18:46:17 +01:00
Gilles Peskine
5ee008d15f Improve documentation of mbedtls_ssl_set_hostname
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-25 18:46:17 +01:00
Gilles Peskine
4f563e7d90 Expand and rectify the documentation of mbedtls_ssl_context::hostname
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-25 18:46:17 +01:00
Gilles Peskine
11f74c5751 Add a note about calling mbedtls_ssl_set_hostname to mbedtls_ssl_setup
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-25 18:46:17 +01:00
Valerio Setti
79a98bd7b6 crypto_extra: improve description of psa_can_do_hash()
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-02-21 15:01:04 +01:00
Valerio Setti
05b3835bd6 psa: move definition of psa_can_do_hash() to crypto_extra.h
This allows any implementer of the PSA client interface to easily
include this header and therefore function's prototype.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-02-21 15:01:04 +01:00
Valerio Setti
460d2ee363 adjust_legacy_crypto: improve enablement of MBEDTLS_MD_xxx_VIA_PSA
The previous change that replaced CRYPTO_C with CRYPTO_CLIENT
caused an increase of the mbedtls_md struct in scenarios where
the hash related PSA_WANTs were enabled, but not accelerated.
This caused an ABI-API break which is not allowed for an LTS
branch.
Since the main goal here is to allow PSA dispatch in a "pure
crypto client" scenario, we partially revert the previous change
to config_adjust_legacy_crypto.h and add an extra condition
for "CRYPTO_CLIENT && !CRYPTO_C".

This commit also reverts changes done in analyze_outcomes.py
because they are no more necessary.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-02-21 13:13:24 +01:00
Valerio Setti
c516307ad9 md: allow dispatch to PSA whenever CRYPTO_CLIENT is enabled
Instead of allowing PSA dispatching only when CRYPTO_C is set and
some MBEDTLS_PSA_ACCEL_ALG_xxx is set, we enable dispatching
when CRYPTO_CLIENT and PSA_WANT_ALG_xxx are set. This makes
the feature more useful in cases where the PSA support is
provided externally, like for example TF-M in Zephyr.

This commit also add proper guards for tests trying to use MD+PSA
dispatch.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-02-21 13:13:24 +01:00
Valerio Setti
2c1de04e9d adjust_legacy_crypto: move auto-enabling of CRYPTO_CLIENT when CRYPTO_C
Move the auto-enabling of CRYPTO_CLIENT when CRYPTO_C at the
beginning of the file so that all that becomes later is aware
of this.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-02-21 13:13:24 +01:00
Gilles Peskine
730be78ce5 Document PSA's need for threading
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-20 20:20:19 +01:00
Gilles Peskine
55151d3da6 Fix Doxygen misuse
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-17 23:09:00 +01:00
Gilles Peskine
b710599e4a Merge in_hsfraglen with badmac_seen_or_in_hsfraglen
In the `mbedtls_ssl_context` structure, merge the field `in_hsfraglen` into
`badmac_seen_or_in_hsfraglen`. This restores the ABI of `libmbedtls` as it
was in Mbed TLS 3.6.0 through 3.6.2.

The field `badmac_seen_or_in_hsfraglen` (formerly `badmac_seen`) was only
used for DTLS (despite being present in non-DTLS builds), and the field
`in_hsfraglen` was only used in non-DTLS TLS. Therefore the two values can
be stored in the same field.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-17 16:28:51 +01:00
Gilles Peskine
ebdd405f68 Change the type of in_hsfraglen to unsigned
In the `mbedtls_ssl_context` structure, change the type of `in_hsfraglen`
from `size_t` to `unsigned`. This is in preparation for merging
`in_hsfraglen` into `badmac_seen_or_in_hsfraglen`, which has the type
`unsigned` and cannot change since we do not want to change the ABI.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-17 16:26:27 +01:00
Gilles Peskine
f6a676d93f Rename badmac_seen to badmac_seen_or_in_hsfraglen
Prepare to unify two fields of the `mbedtls_ssl_context` structure:
`badmac_seen` (always present but only used in DTLS) and
`in_hsfraglen` (always present but only used in non-DTLS TLS).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-17 16:10:14 +01:00
Deomid rojer Ryabkov
bbe8745d19 Remove in_hshdr
The first fragment of a fragmented handshake message always starts at the beginning of the buffer so there's no need to store it.

Signed-off-by: Deomid rojer Ryabkov <rojer@rojer.me>
2025-02-17 15:59:55 +01:00
Deomid rojer Ryabkov
3fc5a4dc86 Defragment incoming TLS handshake messages
Signed-off-by: Deomid rojer Ryabkov <rojer@rojer.me>
2025-02-17 15:59:04 +01:00
Gilles Peskine
7656ad7b9f Create configuration option to bypass the mbedtls_ssl_set_hostname check
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-13 21:47:26 +01:00
Gilles Peskine
0178dc9946 Create error code for mbedtls_ssl_set_hostname not called
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-13 21:24:01 +01:00
Gilles Peskine
6b8859467c Keep track of whether mbedtls_ssl_set_hostname() has been called
Use a special marker as ssl->hostname if mbedtls_ssl_set_hostname() has been
called with NULL. If mbedtls_ssl_set_hostname() has never been called, the
field is NULL, as before.

No behavior change apart from now emitting a different log message depending
on whether mbedtls_ssl_set_hostname() has been called with NULL or not at all.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-13 21:24:01 +01:00
Gilles Peskine
ce00ac4a29 Update the documentation of ssl->hostname
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-02-13 21:24:01 +01:00