1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-06-09 10:01:18 +03:00

7124 Commits

Author SHA1 Message Date
Gilles Peskine
b4cbc156ef
Merge pull request #10192 from valeriosetti/fixes-for-ecp-restartable-part2
[development] Some pre-requisites for psa#299
2025-06-05 07:50:53 +00:00
Gilles Peskine
dcd43fcc45 Move oid_xxx_numeric_string back to oid.h
The header `mbedtls/oid.h` now belongs to the X.509 library. Move the
declarations of `mbedtls_oid_get_numeric_string()` and
`mbedtls_oid_from_numeric_string()` back to this header, which is where they
were in all previous releases of Mbed TLS. This avoids gratuitously breaking
backward compatibility.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Gilles Peskine
b828820f7a Declare oid_xxx_numeric_string only when they are defined
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Gilles Peskine
02ec585518 Replace MBEDTLS_OID_C by function-specific dependencies
For each function in `x509_oid.c`, determine where it is used and only
include it in the build if it is needed by the X.509 code. Define the
corresponding internal tables only when they are consumed by a function.

This makes Mbed TLS completely independent of the compilation option
`MBEDTLS_OID_C`. This option remains present only in sample configs for
crypto, where it must stay until TF-PSA-Crypto no longer relies on this
option.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Gilles Peskine
cd4c0d7b00 Move OID string definitions back to mbedtls/oid.h
Some code that parses or writes X.509 needs to know OID values. We provide a
convenient list. Don't remove this list from the public interface of the
library.

For user convenience, expose these values in the same header as before and
with the same name as before: `MBEDTLS_OID_xxx` in `<mbedtls/oid.h>`.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Gilles Peskine
f9ca8ed9dd Create a public header file for OID values
This will be a subset of the former `<mbedtls/oid.h>`, with only macro
definitions, no function declarations.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Gilles Peskine
47f1d7be95 Replace MBEDTLS_ERR_OID_BUF_TOO_SMALL with PSA_ERROR_BUFFER_TOO_SMALL
Remove the definition of `MBEDTLS_ERR_OID_BUF_TOO_SMALL` in `x509_oid.h`,
and use the corresponding PSA error instead.

```
git grep -l MBEDTLS_ERR_OID_BUF_TOO_SMALL | xargs perl -i -pe 's/\bMBEDTLS_ERR_OID_BUF_TOO_SMALL\b/PSA_ERROR_BUFFER_TOO_SMALL/p'
edit library/x509_oid.h
```

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Gilles Peskine
32a1112e88 Remove MBEDTLS_OID_X509_EXT_xxx constants
They're just aliases for the corresponding MBEDTLS_X509_EXT_xxx. We don't
need separate names.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Gilles Peskine
86b9d3f299 documentation of mbedtls_ssl_async_sign_t with RSA: update to PSA
Stop referring to low-level APIs that are becoming private.

Also drop the requirement on supporting what is now
PSA_ALG_RSA_PKCS1V15_SIGN_RAW. That was needed for TLS 1.0/1.1 which signs
MD5||SHA1, but is no longer needed since Mbed TLS 3.0 dropped support for
these protocol versions.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-06-03 15:51:34 +02:00
Valerio Setti
199a15645d library: debug: make mbedtls_debug_print_ecp() internal
Remove the public definition of mbedtls_debug_print_ecp(). The function
is only used internally in debug.c, so we can then make the function
static.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-05-27 09:56:27 +02:00
Ronald Cron
36f424e240
Merge pull request #10190 from valeriosetti/prerequisites-for-ecp-restartable
[development] Some prerequisites for PR #10187
2025-05-26 15:15:23 +00:00
Valerio Setti
153a906a51 library: debug: remove mbedtls_debug_printf_ecdh()
The function is not used anywhere and can be removed.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-05-23 15:08:48 +02:00
Ben Taylor
e23afdd765 remove compat-2.x.h
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-05-08 14:55:44 +01:00
Valerio Setti
68878ccdd0 library: x509: simplify RSA-PSS management
- Do not store RSA-PSS signature options in CRL/CRT/CSR structures;
- During the parsing phase, just ensure that MGF1 hash alg is the same
  as the one used for the message.

Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
2025-05-07 09:06:52 +02:00
David Horstmann
232da48471
Merge pull request #9421 from mfil/feature/implement_tls_exporter
Implement TLS-Exporter
2025-04-17 14:47:13 +00:00
Manuel Pégourié-Gonnard
ed4a2b4f0a Merge branch 'development-restricted' into merge-from-restricted
* development-restricted:
  Add missing credit for set_hostname issue
  Add changelog entry for TLS 1.2 Finished fix
  TLS1.2: Check for failures in Finished calculation
  ssl_session_reset: preserve HOSTNAME_SET flag
  Document the need to call mbedtls_ssl_set_hostname
  Improve documentation of mbedtls_ssl_set_hostname
  Changelog entries for requiring mbedls_ssl_set_hostname() in TLS clients
  Add a note about calling mbedtls_ssl_set_hostname to mbedtls_ssl_setup
  mbedtls_ssl_set_hostname tests: add tests with CA callback
  Call mbedtls_ssl_set_hostname in the generic endpoint setup in unit tests
  Require calling mbedtls_ssl_set_hostname() for security
  Create error code for mbedtls_ssl_set_hostname not called
  Keep track of whether mbedtls_ssl_set_hostname() has been called
  Access ssl->hostname through abstractions in certificate verification
  mbedtls_ssl_set_hostname tests: baseline
  Add a flags field to mbedtls_ssl_context
  Automate MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK dependency
  Make guards more consistent between X.509-has-certs and SSL-has-certs
  Fix Doxygen markup
  Make ticket_alpn field private

 Conflicts:
	programs/ssl/ssl_test_common_source.c
2025-04-01 09:40:47 +02:00
Max Fillinger
7577c9e373 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-03-28 17:08:12 +01:00
Max Fillinger
9c5bae5026 Fix max. label length in key material exporter
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-03-28 17:08:12 +01:00
Max Fillinger
53d9168502 Document BAD_INPUT_DATA error in key material exporter
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-03-28 17:08:12 +01:00
Max Fillinger
c6fd1a24d2 Use one maximum key_len for all exported keys
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-03-28 17:06:48 +01:00
Max Fillinger
3e1291866d 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-03-28 17:06:48 +01:00
Max Fillinger
51bec543bb Enable MBEDTLS_SSL_KEYING_MATERIAL_EXPORT by default
Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
2025-03-28 16:53:58 +01:00
Max Fillinger
2fe35f61bf 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-03-28 16:53:58 +01:00
Max Fillinger
281fb79116 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-03-28 16:53:58 +01:00
Max Fillinger
e10c9849e2 Fix coding style
Signed-off-by: Max Fillinger <max@max-fillinger.net>
2025-03-28 16:53:58 +01:00
Max Fillinger
7b72220d42 Fix coding style
Signed-off-by: Max Fillinger <max@max-fillinger.net>
2025-03-28 16:53:58 +01:00
Max Fillinger
ae7d66a1d5 Fix doxygen comment parameter name
Signed-off-by: Max Fillinger <max@max-fillinger.net>
2025-03-28 16:53:57 +01:00
Max Fillinger
5561994020 Fix typos in comment
Signed-off-by: Max Fillinger <max@max-fillinger.net>
2025-03-28 16:53:57 +01:00
Max Fillinger
9c9989fc6d Fix mismatches in function declarations
Missed some const keywords in function declarations.

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
Ben Taylor
7a84f0f3a9 removed rng parameters from struct mbedtls_ssl_config
Signed-off-by: Ben Taylor <ben.taylor@linaro.org>
2025-03-27 09:34:21 +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
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
1ffdb18cdb Remove mbedtls_low_level_sterr() and mbedtls_high_level_strerr()
Just removed from the API. We can greatly simplify error.c but that will be
for later.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-24 14:26:39 +00: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
Gilles Peskine
c4dd970386
Merge pull request #9096 from noahp/noahp/mbedtls_net_send-api-desc-tweak
mbedtls_net_send API description typo fix
2025-03-13 16:22:55 +00:00
Bence Szépkúti
906d3cdff5
Merge pull request #10020 from bensze01/msvc-format-size-macros
Fix preprocessor guards for C99 format size specifiers
2025-03-13 10:09:06 +00:00
Bence Szépkúti
011b6cb1c5 Fix comments
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-03-12 17:11:42 +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
Bence Szépkúti
cd1ece7846 Never use %zu on MinGW
Signed-off-by: Bence Szépkúti <bence.szepkuti@arm.com>
2025-03-12 16:18:35 +01:00
Bence Szépkúti
becb21e668 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-12 16:16:20 +01:00
Gilles Peskine
2b78a5abfa State globally that the limitations don't apply to DTLS
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-12 10:07:33 +01:00
Gilles Peskine
d9c858039e Clarify DTLS
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-11 13:47:49 +01:00
Gilles Peskine
80facedad9 ClientHello may be fragmented in renegotiation
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-11 13:47:14 +01:00
Gilles Peskine
d8f9e22b5e Move the defragmentation documentation to mbedtls_ssl_handshake
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-03-11 13:45:27 +01: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