Skip to content

Commit cdb8752

Browse files
committed
mbedTLS: Update to version 2.28.10
1 parent c127655 commit cdb8752

File tree

16 files changed

+391
-125
lines changed

16 files changed

+391
-125
lines changed

thirdparty/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ in the MSVC debugger.
485485
## mbedtls
486486

487487
- Upstream: https://github.com/Mbed-TLS/mbedtls
488-
- Version: 2.28.9 (5e146adef63b326b04282252639bebc2730939c6, 2024)
488+
- Version: 2.28.10 (2fc8413bfcb51354c8e679141b17b3f1a5942561, 2025)
489489
- License: Apache 2.0
490490

491491
File extracted from upstream release tarball:

thirdparty/mbedtls/include/mbedtls/config.h

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,6 +1713,46 @@
17131713
*/
17141714
//#define MBEDTLS_SSL_ASYNC_PRIVATE
17151715

1716+
/** \def MBEDTLS_SSL_CLI_ALLOW_WEAK_CERTIFICATE_VERIFICATION_WITHOUT_HOSTNAME
1717+
*
1718+
* In TLS clients, when a client authenticates a server through its
1719+
* certificate, the client normally checks three things:
1720+
* - the certificate chain must be valid;
1721+
* - the chain must start from a trusted CA;
1722+
* - the certificate must cover the server name that is expected by the client.
1723+
*
1724+
* Omitting any of these checks is generally insecure, and can allow a
1725+
* malicious server to impersonate a legitimate server.
1726+
*
1727+
* The third check may be safely skipped in some unusual scenarios,
1728+
* such as networks where eavesdropping is a risk but not active attacks,
1729+
* or a private PKI where the client equally trusts all servers that are
1730+
* accredited by the root CA.
1731+
*
1732+
* You should call mbedtls_ssl_set_hostname() with the expected server name
1733+
* before starting a TLS handshake on a client (unless the client is
1734+
* set up to only use PSK-based authentication, which does not rely on the
1735+
* host name). This configuration option controls what happens if a TLS client
1736+
* is configured with the authentication mode #MBEDTLS_SSL_VERIFY_REQUIRED
1737+
* (default), certificate authentication is enabled and the client does not
1738+
* call mbedtls_ssl_set_hostname():
1739+
*
1740+
* - If this option is unset (default), the connection attempt is aborted
1741+
* with the error #MBEDTLS_ERR_SSL_CERTIFICATE_VERIFICATION_WITHOUT_HOSTNAME.
1742+
* - If this option is set, the TLS library does not check the server name
1743+
* that the certificate is valid for. This is the historical behavior
1744+
* of Mbed TLS, but may be insecure as explained above.
1745+
*
1746+
* Enable this option for strict backward compatibility if you have
1747+
* determined that it is secure in the scenario where you are using
1748+
* Mbed TLS.
1749+
*
1750+
* \deprecated This option exists only for backward compatibility and will
1751+
* be removed in the next major version of Mbed TLS.
1752+
*
1753+
*/
1754+
//#define MBEDTLS_SSL_CLI_ALLOW_WEAK_CERTIFICATE_VERIFICATION_WITHOUT_HOSTNAME
1755+
17161756
/**
17171757
* \def MBEDTLS_SSL_CONTEXT_SERIALIZATION
17181758
*
@@ -2290,6 +2330,10 @@
22902330
* That is, the APIs enabled by this option are not covered by the usual
22912331
* promises of API stability.
22922332
*
2333+
* \warning In multithreaded applications, you must also enable
2334+
* #MBEDTLS_THREADING_C, unless only one thread ever calls PSA functions
2335+
* (`psa_xxx()`), including indirect calls through SSL/TLS, X.509 or PK.
2336+
*
22932337
* Requires: MBEDTLS_PSA_CRYPTO_C.
22942338
*
22952339
* Uncomment this to enable internal use of PSA Crypto and new associated APIs.
@@ -3389,6 +3433,14 @@
33893433
*
33903434
* Enable the Platform Security Architecture cryptography API.
33913435
*
3436+
* \note In multithreaded applications, you must enable #MBEDTLS_THREADING_C,
3437+
* unless only one thread ever calls `psa_xxx()` functions.
3438+
* That includes indirect calls, such as:
3439+
* - indirect calls from PK, X.509 or SSL functions when
3440+
* #MBEDTLS_USE_PSA_CRYPTO is enabled;
3441+
* - any other call to a function that requires calling psa_crypto_init()
3442+
* beforehand.
3443+
*
33923444
* Module: library/psa_crypto.c
33933445
*
33943446
* Requires: either MBEDTLS_CTR_DRBG_C and MBEDTLS_ENTROPY_C,
@@ -3605,11 +3657,29 @@
36053657
/**
36063658
* \def MBEDTLS_THREADING_C
36073659
*
3608-
* Enable the threading abstraction layer.
3609-
* By default Mbed TLS assumes it is used in a non-threaded environment or that
3610-
* contexts are not shared between threads. If you do intend to use contexts
3660+
* Traditionally, Mbed TLS assumes it is used in a non-threaded environment or
3661+
* that contexts are not shared between threads. If you do intend to use contexts
36113662
* between threads, you will need to enable this layer to prevent race
3612-
* conditions. See also our Knowledge Base article about threading:
3663+
* conditions.
3664+
*
3665+
* The PSA subsystem has an implicit shared context. Therefore, you must
3666+
* enable this option if more than one thread may use any part of
3667+
* Mbed TLS that is implemented on top of the PSA subsystem.
3668+
*
3669+
* You must enable this option in multithreaded applications where more than
3670+
* one thread performs any of the following operations:
3671+
*
3672+
* - Any call to a PSA function (`psa_xxx()`).
3673+
* - Any call to a TLS, X.509 or PK function (`mbedtls_ssl_xxx()`,
3674+
* `mbedtls_x509_xxx()`, `mbedtls_pkcs7_xxx()`, `mbedtls_pk_xxx()`)
3675+
* if `MBEDTLS_USE_PSA_CRYPTO` is enabled (regardless of whether individual
3676+
* TLS, X.509 or PK contexts are shared between threads).
3677+
* - Any use of a cryptographic context if the same context is used in
3678+
* multiple threads.
3679+
* - Any call to a function where the documentation specifies that
3680+
* psa_crypto_init() must be called prior to that function.
3681+
*
3682+
* See also our Knowledge Base article about threading:
36133683
* https://mbed-tls.readthedocs.io/en/latest/kb/development/thread-safety-and-multi-threading
36143684
*
36153685
* Module: library/threading.c

thirdparty/mbedtls/include/mbedtls/debug.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,16 +108,16 @@
108108
*
109109
* This module provides debugging functions.
110110
*/
111-
#if (defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 0) || (defined(_MSC_VER) && _MSC_VER < 1800)
111+
#if defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER < 1900)
112112
#include <inttypes.h>
113113
#define MBEDTLS_PRINTF_SIZET PRIuPTR
114114
#define MBEDTLS_PRINTF_LONGLONG "I64d"
115115
#else \
116-
/* (defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 0) || (defined(_MSC_VER) && _MSC_VER < 1800) */
116+
/* defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER < 1900) */
117117
#define MBEDTLS_PRINTF_SIZET "zu"
118118
#define MBEDTLS_PRINTF_LONGLONG "lld"
119119
#endif \
120-
/* (defined(__MINGW32__) && __USE_MINGW_ANSI_STDIO == 0) || (defined(_MSC_VER) && _MSC_VER < 1800) */
120+
/* defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER < 1900) */
121121

122122
#ifdef __cplusplus
123123
extern "C" {

thirdparty/mbedtls/include/mbedtls/error.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
* ECP 4 10 (Started from top)
9393
* MD 5 5
9494
* HKDF 5 1 (Started from top)
95-
* SSL 5 2 (Started from 0x5F00)
95+
* SSL 5 3 (Started from 0x5F00)
9696
* CIPHER 6 8 (Started from 0x6080)
9797
* SSL 6 24 (Started from top, plus 0x6000)
9898
* SSL 7 32

thirdparty/mbedtls/include/mbedtls/gcm.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,9 @@ int mbedtls_gcm_setkey(mbedtls_gcm_context *ctx,
107107
/**
108108
* \brief This function performs GCM encryption or decryption of a buffer.
109109
*
110-
* \note For encryption, the output buffer can be the same as the
111-
* input buffer. For decryption, the output buffer cannot be
112-
* the same as input buffer. If the buffers overlap, the output
113-
* buffer must trail at least 8 Bytes behind the input buffer.
110+
* \note The output buffer \p output can be the same as the input
111+
* buffer \p input. If \p output is greater than \p input, they
112+
* cannot overlap.
114113
*
115114
* \warning When this function performs a decryption, it outputs the
116115
* authentication tag and does not verify that the data is
@@ -171,9 +170,11 @@ int mbedtls_gcm_crypt_and_tag(mbedtls_gcm_context *ctx,
171170
* \brief This function performs a GCM authenticated decryption of a
172171
* buffer.
173172
*
174-
* \note For decryption, the output buffer cannot be the same as
175-
* input buffer. If the buffers overlap, the output buffer
176-
* must trail at least 8 Bytes behind the input buffer.
173+
* \note The output buffer \p output can be the same as the input
174+
* buffer \p input. If \p output is greater than \p input, they
175+
* cannot overlap. Implementations which require
176+
* MBEDTLS_GCM_ALT to be enabled may not provide support for
177+
* overlapping buffers.
177178
*
178179
* \param ctx The GCM context. This must be initialized.
179180
* \param length The length of the ciphertext to decrypt, which is also
@@ -243,9 +244,11 @@ int mbedtls_gcm_starts(mbedtls_gcm_context *ctx,
243244
* Bytes. Only the last call before calling
244245
* mbedtls_gcm_finish() can be less than 16 Bytes.
245246
*
246-
* \note For decryption, the output buffer cannot be the same as
247-
* input buffer. If the buffers overlap, the output buffer
248-
* must trail at least 8 Bytes behind the input buffer.
247+
* \note The output buffer \p output can be the same as the input
248+
* buffer \p input. If \p output is greater than \p input, they
249+
* cannot overlap. Implementations which require
250+
* MBEDTLS_GCM_ALT to be enabled may not provide support for
251+
* overlapping buffers.
249252
*
250253
* \param ctx The GCM context. This must be initialized.
251254
* \param length The length of the input data. This must be a multiple of

thirdparty/mbedtls/include/mbedtls/net_sockets.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ int mbedtls_net_recv(void *ctx, unsigned char *buf, size_t len);
226226

227227
/**
228228
* \brief Write at most 'len' characters. If no error occurs,
229-
* the actual amount read is returned.
229+
* the actual amount written is returned.
230230
*
231231
* \param ctx Socket
232232
* \param buf The buffer to read from

thirdparty/mbedtls/include/mbedtls/ssl.h

Lines changed: 94 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,41 @@
183183
#define MBEDTLS_ERR_SSL_BAD_CONFIG -0x5E80
184184
/** Cache entry not found */
185185
#define MBEDTLS_ERR_SSL_CACHE_ENTRY_NOT_FOUND -0x5E00
186+
/** Attempt to verify a certificate without an expected hostname.
187+
* This is usually insecure.
188+
*
189+
* In TLS clients, when a client authenticates a server through its
190+
* certificate, the client normally checks three things:
191+
* - the certificate chain must be valid;
192+
* - the chain must start from a trusted CA;
193+
* - the certificate must cover the server name that is expected by the client.
194+
*
195+
* Omitting any of these checks is generally insecure, and can allow a
196+
* malicious server to impersonate a legitimate server.
197+
*
198+
* The third check may be safely skipped in some unusual scenarios,
199+
* such as networks where eavesdropping is a risk but not active attacks,
200+
* or a private PKI where the client equally trusts all servers that are
201+
* accredited by the root CA.
202+
*
203+
* You should call mbedtls_ssl_set_hostname() with the expected server name
204+
* before starting a TLS handshake on a client (unless the client is
205+
* set up to only use PSK-based authentication, which does not rely on the
206+
* host name). If you have determined that server name verification is not
207+
* required for security in your scenario, call mbedtls_ssl_set_hostname()
208+
* with \p NULL as the server name.
209+
*
210+
* This error is raised if all of the following conditions are met:
211+
*
212+
* - A TLS client is configured with the authentication mode
213+
* #MBEDTLS_SSL_VERIFY_REQUIRED (default).
214+
* - Certificate authentication is enabled.
215+
* - The client does not call mbedtls_ssl_set_hostname().
216+
* - The configuration option
217+
* #MBEDTLS_SSL_CLI_ALLOW_WEAK_CERTIFICATE_VERIFICATION_WITHOUT_HOSTNAME
218+
* is not enabled.
219+
*/
220+
#define MBEDTLS_ERR_SSL_CERTIFICATE_VERIFICATION_WITHOUT_HOSTNAME -0x5D80
186221

187222
/*
188223
* Various constants
@@ -1403,8 +1438,36 @@ struct mbedtls_ssl_context {
14031438
* User settings
14041439
*/
14051440
#if defined(MBEDTLS_X509_CRT_PARSE_C)
1406-
char *hostname; /*!< expected peer CN for verification
1407-
(and SNI if available) */
1441+
/** Expected peer CN for verification.
1442+
*
1443+
* Also used on clients for SNI.
1444+
*
1445+
* The value of this field can be:
1446+
* - \p NULL in a newly initialized or reset context.
1447+
* - A heap-allocated copy of the last value passed to
1448+
* mbedtls_ssl_set_hostname(), if the last call had a non-null
1449+
* \p hostname argument.
1450+
* - A special value to indicate that mbedtls_ssl_set_hostname()
1451+
* was called with \p NULL (as opposed to never having been called).
1452+
*
1453+
* If you need to obtain the value passed to
1454+
* mbedtls_ssl_set_hostname() even if it may have been called with
1455+
* \p NULL, call mbedtls_ssl_get_hostname_pointer().
1456+
*
1457+
* If this field contains the value \p NULL and the configuration option
1458+
* #MBEDTLS_SSL_CLI_ALLOW_WEAK_CERTIFICATE_VERIFICATION_WITHOUT_HOSTNAME
1459+
* is unset, on a TLS client, attempting to verify a server certificate
1460+
* results in the error
1461+
* #MBEDTLS_ERR_SSL_CERTIFICATE_VERIFICATION_WITHOUT_HOSTNAME.
1462+
*
1463+
* If this field contains the special value described above, or if
1464+
* the value is \p NULL and the configuration option
1465+
* #MBEDTLS_SSL_CLI_ALLOW_WEAK_CERTIFICATE_VERIFICATION_WITHOUT_HOSTNAME
1466+
* is set, then the peer name verification is skipped, which may be
1467+
* insecure, especially on a client. Furthermore, on a client, the
1468+
* server_name extension is not sent.
1469+
*/
1470+
char *hostname;
14081471
#endif /* MBEDTLS_X509_CRT_PARSE_C */
14091472

14101473
#if defined(MBEDTLS_SSL_ALPN)
@@ -1535,6 +1598,14 @@ void mbedtls_ssl_init(mbedtls_ssl_context *ssl);
15351598
* Calling mbedtls_ssl_setup again is not supported, even
15361599
* if no session is active.
15371600
*
1601+
* \warning After setting up a client context, if certificate-based
1602+
* authentication is enabled, you should call
1603+
* mbedtls_ssl_set_hostname() to specifiy the expected
1604+
* name of the server. Without this, in most scenarios,
1605+
* the TLS connection is insecure. See
1606+
* #MBEDTLS_ERR_SSL_CERTIFICATE_VERIFICATION_WITHOUT_HOSTNAME
1607+
* for more information.
1608+
*
15381609
* \note If #MBEDTLS_USE_PSA_CRYPTO is enabled, the PSA crypto
15391610
* subsystem must have been initialized by calling
15401611
* psa_crypto_init() before calling this function.
@@ -3107,16 +3178,29 @@ void mbedtls_ssl_conf_sig_hashes(mbedtls_ssl_config *conf,
31073178
#if defined(MBEDTLS_X509_CRT_PARSE_C)
31083179
/**
31093180
* \brief Set or reset the hostname to check against the received
3110-
* server certificate. It sets the ServerName TLS extension,
3111-
* too, if that extension is enabled. (client-side only)
3181+
* peer certificate. On a client, this also sets the
3182+
* ServerName TLS extension, if that extension is enabled.
3183+
* On a TLS 1.3 client, this also sets the server name in
3184+
* the session resumption ticket, if that feature is enabled.
31123185
*
31133186
* \param ssl SSL context
3114-
* \param hostname the server hostname, may be NULL to clear hostname
3115-
3116-
* \note Maximum hostname length MBEDTLS_SSL_MAX_HOST_NAME_LEN.
3117-
*
3118-
* \return 0 if successful, MBEDTLS_ERR_SSL_ALLOC_FAILED on
3119-
* allocation failure, MBEDTLS_ERR_SSL_BAD_INPUT_DATA on
3187+
* \param hostname The server hostname. This may be \c NULL to clear
3188+
* the hostname.
3189+
*
3190+
* \note Maximum hostname length #MBEDTLS_SSL_MAX_HOST_NAME_LEN.
3191+
*
3192+
* \note If the hostname is \c NULL on a client, then the server
3193+
* is not authenticated: it only needs to have a valid
3194+
* certificate, not a certificate matching its name.
3195+
* Therefore you should always call this function on a client,
3196+
* unless the connection is set up to only allow
3197+
* pre-shared keys, or in scenarios where server
3198+
* impersonation is not a concern. See the documentation of
3199+
* #MBEDTLS_ERR_SSL_CERTIFICATE_VERIFICATION_WITHOUT_HOSTNAME
3200+
* for more details.
3201+
*
3202+
* \return 0 if successful, #MBEDTLS_ERR_SSL_ALLOC_FAILED on
3203+
* allocation failure, #MBEDTLS_ERR_SSL_BAD_INPUT_DATA on
31203204
* too long input hostname.
31213205
*
31223206
* Hostname set to the one provided on success (cleared

thirdparty/mbedtls/include/mbedtls/ssl_internal.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,8 @@ struct mbedtls_ssl_handshake_params {
467467

468468
void (*update_checksum)(mbedtls_ssl_context *, const unsigned char *, size_t);
469469
void (*calc_verify)(const mbedtls_ssl_context *, unsigned char *, size_t *);
470-
void (*calc_finished)(mbedtls_ssl_context *, unsigned char *, int);
470+
MBEDTLS_CHECK_RETURN_CRITICAL
471+
int (*calc_finished)(mbedtls_ssl_context *, unsigned char *, int);
471472
mbedtls_ssl_tls_prf_cb *tls_prf;
472473

473474
#if defined(MBEDTLS_DHM_C)
@@ -1214,6 +1215,16 @@ static inline size_t mbedtls_ssl_hs_hdr_len(const mbedtls_ssl_context *ssl)
12141215
return 4;
12151216
}
12161217

1218+
/** Get the host name from the SSL context.
1219+
*
1220+
* \param[in] ssl SSL context
1221+
*
1222+
* \return The \p hostname pointer from the SSL context.
1223+
* \c NULL if mbedtls_ssl_set_hostname() has never been called on
1224+
* \p ssl or if it was last called with \p NULL.
1225+
*/
1226+
const char *mbedtls_ssl_get_hostname_pointer(const mbedtls_ssl_context *ssl);
1227+
12171228
#if defined(MBEDTLS_SSL_PROTO_DTLS)
12181229
void mbedtls_ssl_send_flight_completed(mbedtls_ssl_context *ssl);
12191230
void mbedtls_ssl_recv_flight_completed(mbedtls_ssl_context *ssl);

thirdparty/mbedtls/include/mbedtls/version.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@
2626
*/
2727
#define MBEDTLS_VERSION_MAJOR 2
2828
#define MBEDTLS_VERSION_MINOR 28
29-
#define MBEDTLS_VERSION_PATCH 9
29+
#define MBEDTLS_VERSION_PATCH 10
3030

3131
/**
3232
* The single version number has the following structure:
3333
* MMNNPP00
3434
* Major version | Minor version | Patch version
3535
*/
36-
#define MBEDTLS_VERSION_NUMBER 0x021C0900
37-
#define MBEDTLS_VERSION_STRING "2.28.9"
38-
#define MBEDTLS_VERSION_STRING_FULL "Mbed TLS 2.28.9"
36+
#define MBEDTLS_VERSION_NUMBER 0x021C0A00
37+
#define MBEDTLS_VERSION_STRING "2.28.10"
38+
#define MBEDTLS_VERSION_STRING_FULL "Mbed TLS 2.28.10"
3939

4040
#if defined(MBEDTLS_VERSION_C)
4141

0 commit comments

Comments
 (0)