1
0
mirror of https://github.com/ARMmbed/mbedtls.git synced 2025-06-03 05:09:39 +08:00

13574 Commits

Author SHA1 Message Date
Max Fillinger
334c367052 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-03-28 16:53:57 +01:00
Max Fillinger
136fe9e4be Fix commented out function declaration
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-03-28 16:53:57 +01:00
Max Fillinger
bd81c9d0f7 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-03-28 16:53:57 +01:00
Manuel Pégourié-Gonnard
e57ea21a1c
Merge pull request #10042 from bjwtaylor/remove-ssl-conf
Remove mbedtls_ssl_conf_rng()
2025-03-27 14:05:42 +00:00
Ben Taylor
cd2660fb0e fixed code style
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-03-26 13:34:03 +00:00
Ben Taylor
8224e71262 remove NULL guard
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-03-26 13:34:03 +00:00
Ben Taylor
c12152e53e corrected style
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-03-26 13:34:03 +00:00
Ben Taylor
03c05c336e Remove additional line
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-03-26 13:34:03 +00:00
Ben Taylor
fb68b8cf57 Remove empty ifdef
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-03-26 13:34:03 +00:00
Ben Taylor
9774e9a176 corrected code style
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-03-26 13:34:03 +00:00
Ben Taylor
1f091466c1 tidy up syntax
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-03-26 13:34:03 +00:00
Ben Taylor
1cd1e01897 Correct code style
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-03-26 13:34:03 +00:00
Ben Taylor
0deda0e34c Update debug
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-03-26 13:33:32 +00:00
Ben Taylor
d5d707842c removed NR psa-init
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-03-26 13:33:32 +00:00
Ben Taylor
6ff2da196a added further debug
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-03-26 13:33:32 +00:00
Ben Taylor
fd52984896 resolved ci failures
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-03-26 13:32:10 +00:00
Ben Taylor
602b2968ca pre-test version of the mbedtls_ssl_conf_rng removal
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-03-26 13:32:10 +00:00
Ben Taylor
47111a1cb1 initial remove of mbedtls_ssl_conf_rng
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-03-26 13:32:10 +00:00
Valerio Setti
ba66794fb4 library: remove psa_crypto_se.c from Makefile
Following the removal of MBEDTLS_PSA_CRYPTO_SE_C the file was removed
from tf-psa-crypto.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-03-26 13:32:54 +01:00
Ben Taylor
440cb2aac2 Remove RNG from x509 and PK
remove the f_rng and p_rng parameter from x509 and PK.

Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-03-26 08:17:38 +00:00
Gilles Peskine
a7e14dc9eb Don't expect added error codes
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-24 14:13:50 +00:00
Gabor Mezei
58535da8d0
Only check for certificates if it is supported
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-03-20 17:53:07 +01:00
Gabor Mezei
e99e591179
Remove key exchange based on encryption/decryption
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-03-20 17:53:07 +01:00
Gabor Mezei
3c7db0e5a8
Remove MBEDTLS_TLS_RSA_* ciphersuite macros
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-03-20 17:53:07 +01:00
Gabor Mezei
5814e3e566
Remove MBEDTLS_KEY_EXCHANGE_RSA key exchange type
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-03-20 17:53:07 +01:00
Gabor Mezei
e1e27300a2
Remove MBEDTLS_KEY_EXCHANGE_RSA_ENABLED config option
Signed-off-by: Gabor Mezei <gabor.mezei@arm.com>
2025-03-20 17:53:01 +01:00
Manuel Pégourié-Gonnard
4515d10163
Merge pull request #10039 from bjwtaylor/remove-rng-from-ssl
Remove RNG parameters from public SSL APIs
2025-03-19 11:27:51 +00:00
Manuel Pégourié-Gonnard
1038b22d74 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:22:09 +01:00
Manuel Pégourié-Gonnard
6637ef798f 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:22:09 +01:00
Minos Galanakis
a2a0c2cbe7 Merge remote-tracking branch 'origin/features/tls-defragmentation/development' into feature_merge_defragmentation_dev
Signed-off-by: Minos Galanakis <minos.galanakis@arm.com>
2025-03-12 15:25:06 +00:00
Manuel Pégourié-Gonnard
e26a060194 Cleanly reject non-HS in-between HS fragments
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
2025-03-11 09:28:55 +01:00
Ben Taylor
857144c9c2 removed psa_crypto_init from library as this is supposed to be called by the application
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-03-10 13:46:14 +00:00
Ben Taylor
0cfe54e4e0 remove RNG parameters from SSL API's
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-03-10 13:24:31 +00:00
Gilles Peskine
e34ec86370 Fix a log message
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-07 10:43:39 +01:00
Gilles Peskine
dab1cb5b45 Note unused variables when debugging is disabled
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-06 21:33:08 +01:00
Gilles Peskine
b8f1e4bae3 Pacify uncrustify
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-06 21:33:08 +01:00
Gilles Peskine
afb254c5fe 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:23:22 +01:00
Gilles Peskine
15c072f0de Fix handshake defragmentation when the record has multiple messages
A handshake record may contain multiple handshake messages, or multiple
fragments (there can be the final fragment of a pending message, then zero
or more whole messages, and an initial fragment of an incomplete message).
This was previously untested, but supported, so don't break it.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-06 19:03:00 +01:00
Gilles Peskine
0851ec9344 Fix end check before memmove
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-06 15:15:20 +01:00
Gilles Peskine
90a9593bbd Fix dodgy printf calls
Pacify `clang -Wformat-pedantic`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-05 17:02:18 +01:00
Gilles Peskine
e85ece6584 Handshake defragmentation: reassemble incrementally
Reassemble handshake fragments incrementally instead of all at the end. That
is, every time we receive a non-initial handshake fragment, append it to the
initial fragment. Since we only have to deal with at most two handshake
fragments at the same time, this simplifies the code (no re-parsing of a
record) and is a little more memory-efficient (no need to store one record
header per record).

This commit also fixes a bug. The previous code did not calculate offsets
correctly when records use an explicit IV, which is the case in TLS 1.2 with
CBC (encrypt-then-MAC or not), GCM and CCM encryption (i.e. all but null and
ChachaPoly). This led to the wrong data when an encrypted handshake message
was fragmented (Finished or renegotiation). The new code handles this
correctly.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-05 17:02:18 +01:00
Gilles Peskine
235eae9e03 mbedtls_ssl_prepare_handshake_record(): log offsets after decryption
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-05 17:02:18 +01:00
Gilles Peskine
7a17696c34 mbedtls_ssl_prepare_handshake_record(): refactor first fragment prep
Minor refactoring of the initial checks and preparation when receiving the
first fragment. Use `ssl->in_hsfraglen` to determine whether there is a
pending handshake fragment, for consistency, and possibly for more
robustness in case handshake fragments are mixed with non-handshake
records (although this is not currently supported anyway).

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-05 17:02:18 +01:00
Gilles Peskine
07027722cb Tweak handshake fragment log message
In preparation for reworking mbedtls_ssl_prepare_handshake_record(),
tweak the "handshake fragment:" log message.

This changes what information is displayed when a record contains data
beyond the expected end of the handshake message. This case is currently
untested and its handling will change in a subsequent commit.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-05 17:02:18 +01:00
Gilles Peskine
9bdc8aa80b Tweak "waiting for more handshake fragments" log message
In preparation for reworking mbedtls_ssl_prepare_handshake_record(), tweak
the "waiting for more handshake fragments" log message in
ssl_consume_current_message(), and add a similar one in
mbedtls_ssl_prepare_handshake_record(). Assert both.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-05 17:02:18 +01:00
Valerio Setti
d7a465431c library: do not include dhm.c in the build
The file was cancelled from the tf-psa-crypto repo following the removal
of MBEDTLS_DHM_C.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-03-05 10:11:23 +01:00
Valerio Setti
15fd5c9925 ssl: remove support for MBEDTLS_DHM_C
Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-03-05 10:11:23 +01:00
Gilles Peskine
5df993dcc9 Merge remote-tracking branch 'development' into tls-defragmentation-merge-development-20250303 2025-03-02 21:15:58 +01:00
Manuel Pégourié-Gonnard
28f8e205eb
Merge pull request #9872 from rojer/tls_hs_defrag_in
Defragment incoming TLS handshake messages
2025-02-24 09:28:11 +01:00
Stefan Gloor
b5c079b13c fix: rename BEFORE_COLON and BC to avoid conflicts
Namespace BEFORE_COLON and BC defines by prepending MBEDTLS_
and expanding BC to BEFORE_COLON_STR. This is to avoid naming
conflicts with third-party code. No functional change.

Signed-off-by: Stefan Gloor <stefan.gloor@siemens.com>
2025-02-21 10:33:51 +01:00