Skip to content

Commit 3d9911f

Browse files
authored
thirdparty.mbedtls: upgrade to v3.6.6 (#26803)
1 parent 13b6e48 commit 3d9911f

56 files changed

Lines changed: 1742 additions & 496 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎thirdparty/mbedtls/include/mbedtls/asn1write.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,10 @@ mbedtls_asn1_named_data *mbedtls_asn1_store_named_data(mbedtls_asn1_named_data *
381381
const unsigned char *val,
382382
size_t val_len);
383383

384+
#endif /* MBEDTLS_ASN1_WRITE_C */
385+
384386
#ifdef __cplusplus
385387
}
386388
#endif
387389

388-
#endif /* MBEDTLS_ASN1_WRITE_C */
389-
390390
#endif /* MBEDTLS_ASN1_WRITE_H */

‎thirdparty/mbedtls/include/mbedtls/build_info.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 3
2828
#define MBEDTLS_VERSION_MINOR 6
29-
#define MBEDTLS_VERSION_PATCH 5
29+
#define MBEDTLS_VERSION_PATCH 6
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 0x03060500
37-
#define MBEDTLS_VERSION_STRING "3.6.5"
38-
#define MBEDTLS_VERSION_STRING_FULL "Mbed TLS 3.6.5"
36+
#define MBEDTLS_VERSION_NUMBER 0x03060600
37+
#define MBEDTLS_VERSION_STRING "3.6.6"
38+
#define MBEDTLS_VERSION_STRING_FULL "Mbed TLS 3.6.6"
3939

4040
/* Macros for build-time platform detection */
4141

‎thirdparty/mbedtls/include/mbedtls/config_adjust_legacy_crypto.h‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,49 @@
4848
#endif
4949
#endif /* _MINGW32__ || (_MSC_VER && (_MSC_VER <= 1900)) */
5050

51+
/* The number of "true" entropy sources (excluding NV seed).
52+
* This must be consistent with mbedtls_entropy_init() in entropy.c.
53+
*/
54+
/* Define auxiliary macros, because in standard C, defined(xxx) is only
55+
* allowed directly on an #if or #elif line, not in recursive expansion. */
56+
#if defined(MBEDTLS_NO_PLATFORM_ENTROPY)
57+
#define MBEDTLS_PLATFORM_ENTROPY_ENABLED 0
58+
#else
59+
#define MBEDTLS_PLATFORM_ENTROPY_ENABLED 1
60+
#endif
61+
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
62+
#define MBEDTLS_ENTROPY_HARDWARE_ALT_DEFINED 1
63+
#else
64+
#define MBEDTLS_ENTROPY_HARDWARE_ALT_DEFINED 0
65+
#endif
66+
67+
#define MBEDTLS_ENTROPY_TRUE_SOURCES ( \
68+
MBEDTLS_ENTROPY_HARDWARE_ALT_DEFINED + \
69+
MBEDTLS_PLATFORM_ENTROPY_ENABLED + \
70+
0)
71+
72+
/* Whether there is at least one entropy source for the entropy module.
73+
*
74+
* Note that when MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG is enabled, the entropy
75+
* module is unused and the configuration will typically not include any
76+
* entropy source, so this macro will typically remain undefined.
77+
*/
78+
#if defined(MBEDTLS_ENTROPY_NV_SEED)
79+
#define MBEDTLS_ENTROPY_HAVE_SOURCES (MBEDTLS_ENTROPY_TRUE_SOURCES + 1)
80+
#elif MBEDTLS_ENTROPY_TRUE_SOURCES != 0
81+
#define MBEDTLS_ENTROPY_HAVE_SOURCES MBEDTLS_ENTROPY_TRUE_SOURCES
82+
#else
83+
#undef MBEDTLS_ENTROPY_HAVE_SOURCES
84+
#endif
85+
86+
/* Test function dependencies can only check with defined(),
87+
* not other preprocessor expressions. */
88+
#if MBEDTLS_ENTROPY_TRUE_SOURCES > 0
89+
#define MBEDTLS_ENTROPY_HAVE_TRUE_SOURCES
90+
#else
91+
#undef MBEDTLS_ENTROPY_HAVE_TRUE_SOURCES
92+
#endif
93+
5194
/* If MBEDTLS_PSA_CRYPTO_C is defined, make sure MBEDTLS_PSA_CRYPTO_CLIENT
5295
* is defined as well to include all PSA code.
5396
*/

‎thirdparty/mbedtls/include/mbedtls/ctr_drbg.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ typedef struct mbedtls_ctr_drbg_context {
186186
unsigned char MBEDTLS_PRIVATE(counter)[16]; /*!< The counter (V). */
187187
int MBEDTLS_PRIVATE(reseed_counter); /*!< The reseed counter.
188188
* This is the number of requests that have
189-
* been made since the last (re)seeding,
190-
* minus one.
189+
* been made since the last (re)seeding.
191190
* Before the initial seeding, this field
192191
* contains the amount of entropy in bytes
193192
* to use as a nonce for the initial seeding,

‎thirdparty/mbedtls/include/mbedtls/debug.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
#if defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER < 1900)
112112
#include <inttypes.h>
113113
#define MBEDTLS_PRINTF_SIZET PRIuPTR
114-
#define MBEDTLS_PRINTF_LONGLONG "I64d"
114+
#define MBEDTLS_PRINTF_LONGLONG PRId64
115115
#else \
116116
/* defined(__MINGW32__) || (defined(_MSC_VER) && _MSC_VER < 1900) */
117117
#define MBEDTLS_PRINTF_SIZET "zu"

‎thirdparty/mbedtls/include/mbedtls/ecdh.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* The Elliptic Curve Diffie-Hellman (ECDH) protocol is an anonymous
77
* key agreement protocol allowing two parties to establish a shared
88
* secret over an insecure channel. Each party must have an
9-
* elliptic-curve publicprivate key pair.
9+
* elliptic-curve public private key pair.
1010
*
1111
* For more information, see <em>NIST SP 800-56A Rev. 2: Recommendation for
1212
* Pair-Wise Key Establishment Schemes Using Discrete Logarithm

‎thirdparty/mbedtls/include/mbedtls/mbedtls_config.h‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,20 @@
12041204
* This is useful if your platform does not support
12051205
* standards like the /dev/urandom or Windows CryptoAPI.
12061206
*
1207+
* If you enable this macro, you will probably need to enable
1208+
* #MBEDTLS_ENTROPY_HARDWARE_ALT and provide a function
1209+
* mbedtls_hardware_poll().
1210+
*
1211+
* \note The default platform entropy function supports the following
1212+
* sources:
1213+
* - getrandom() on Linux (if syscall() is available at compile time);
1214+
* - getrandom() on FreeBSD and DragonFlyBSD (if available at compile
1215+
* time);
1216+
* - `sysctl(KERN_ARND)` on FreeBSD and NetBSD;
1217+
* - #MBEDTLS_PLATFORM_DEV_RANDOM on Unix-like platforms
1218+
* (unless one of the above is used);
1219+
* - BCryptGenRandom() on Windows.
1220+
*
12071221
* Uncomment this macro to disable the built-in platform entropy functions.
12081222
*/
12091223
//#define MBEDTLS_NO_PLATFORM_ENTROPY
@@ -4140,6 +4154,37 @@
41404154
//#define MBEDTLS_PLATFORM_MS_TIME_TYPE_MACRO int64_t //#define MBEDTLS_PLATFORM_MS_TIME_TYPE_MACRO int64_t /**< Default milliseconds time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled. It must be signed, and at least 64 bits. If it is changed from the default, MBEDTLS_PRINTF_MS_TIME must be updated to match.*/
41414155
//#define MBEDTLS_PRINTF_MS_TIME PRId64 /**< Default fmt for printf. That's avoid compiler warning if mbedtls_ms_time_t is redefined */
41424156

4157+
/** \def MBEDTLS_PLATFORM_DEV_RANDOM
4158+
*
4159+
* Path to a special file that returns cryptographic-quality random bytes
4160+
* when read. This is used by the default platform entropy source on
4161+
* non-Windows platforms unless a dedicated system call is available
4162+
* (see #MBEDTLS_NO_PLATFORM_ENTROPY).
4163+
*
4164+
* The default value is `/dev/random`, which is suitable on most platforms
4165+
* other than Linux. On Linux, either `/dev/random` or `/dev/urandom`
4166+
* may be the right choice, depending on the circumstances:
4167+
*
4168+
* - If possible, the library will use the getrandom() system call,
4169+
* which is preferable, and #MBEDTLS_PLATFORM_DEV_RANDOM is not used.
4170+
* - If there is a dedicated hardware entropy source (e.g. RDRAND on x86
4171+
* processors), then both `/dev/random` and `/dev/urandom` are fine.
4172+
* - `/dev/random` is always secure. However, with kernels older than 5.6,
4173+
* `/dev/random` often blocks unnecessarily if there is no dedicated
4174+
* hardware entropy source.
4175+
* - `/dev/urandom` never blocks. However, it may return predictable data
4176+
* if it is used early after the kernel boots, especially on embedded
4177+
* devices without an interactive user.
4178+
*
4179+
* Thus you should change the value to `/dev/urandom` if your application
4180+
* definitely won't be used on a device running Linux without a dedicated
4181+
* entropy source early during or after boot.
4182+
*
4183+
* This is the default value of ::mbedtls_platform_dev_random, which
4184+
* can be changed at run time.
4185+
*/
4186+
//#define MBEDTLS_PLATFORM_DEV_RANDOM "/dev/random"
4187+
41434188
/** \def MBEDTLS_CHECK_RETURN
41444189
*
41454190
* This macro is used at the beginning of the declaration of a function

‎thirdparty/mbedtls/include/mbedtls/pk.h‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,11 @@ typedef struct mbedtls_pk_info_t mbedtls_pk_info_t;
218218
* \brief Public key container
219219
*/
220220
typedef struct mbedtls_pk_context {
221-
const mbedtls_pk_info_t *MBEDTLS_PRIVATE(pk_info); /**< Public key information */
222-
void *MBEDTLS_PRIVATE(pk_ctx); /**< Underlying public key context */
221+
/** Method table */
222+
const mbedtls_pk_info_t *MBEDTLS_PRIVATE(pk_info);
223+
/** Underlying type-specific key context */
224+
void *MBEDTLS_PRIVATE(pk_ctx);
225+
223226
/* The following field is used to store the ID of a private key in the
224227
* following cases:
225228
* - opaque key when MBEDTLS_USE_PSA_CRYPTO is defined
@@ -838,7 +841,7 @@ int mbedtls_pk_verify_ext(mbedtls_pk_type_t type, const void *options,
838841
* length up to the hash length), depending on the padding mode
839842
* in the underlying RSA context. For a pk object constructed
840843
* by parsing, this is PKCS#1 v1.5 by default. Use
841-
* mbedtls_pk_verify_ext() to explicitly select a different
844+
* mbedtls_pk_sign_ext() to explicitly select a different
842845
* algorithm.
843846
*
844847
* \return 0 on success, or a specific error code.

‎thirdparty/mbedtls/include/mbedtls/platform.h‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,37 @@ int mbedtls_platform_set_exit(void (*exit_func)(int status));
385385
#define MBEDTLS_EXIT_FAILURE 1
386386
#endif
387387

388+
#if defined(MBEDTLS_ENTROPY_C) && \
389+
!defined(MBEDTLS_NO_PLATFORM_ENTROPY) && \
390+
!(defined(_WIN32) && !defined(EFIX64) && !defined(EFI32))
391+
/* Platforms where MBEDTLS_PLATFORM_DEV_RANDOM is used
392+
* unless a dedicated system call is available both at
393+
* compile time and at run time. */
394+
#define MBEDTLS_PLATFORM_HAVE_DEV_RANDOM
395+
#endif
396+
397+
#if !defined(MBEDTLS_PLATFORM_DEV_RANDOM)
398+
#define MBEDTLS_PLATFORM_DEV_RANDOM "/dev/random"
399+
#endif
400+
401+
/* Arrange for mbedtls_platform_dev_random to always be visible to
402+
* Doxygen, because it's linked from the documentation of
403+
* MBEDTLS_PLATFORM_DEV_RANDOM and that documentation can be visible
404+
* even in configurations where it isn't used. */
405+
#if defined(MBEDTLS_PLATFORM_HAVE_DEV_RANDOM) || defined(__DOXYGEN__)
406+
/**
407+
* Path to a special file that returns cryptographic-quality random bytes
408+
* when read.
409+
*
410+
* This variable is only declared on platforms where it is used.
411+
* It is available when the macro `MBEDTLS_PLATFORM_HAVE_DEV_RANDOM` is defined.
412+
*
413+
* The default value is #MBEDTLS_PLATFORM_DEV_RANDOM.
414+
* See the documentation of this option for guidance.
415+
*/
416+
extern const char *mbedtls_platform_dev_random;
417+
#endif
418+
388419
/*
389420
* The function pointers for reading from and writing a seed file to
390421
* Non-Volatile storage (NV) in a platform-independent way

‎thirdparty/mbedtls/include/mbedtls/ssl.h‎

Lines changed: 68 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3357,6 +3357,27 @@ int mbedtls_ssl_set_session(mbedtls_ssl_context *ssl, const mbedtls_ssl_session
33573357
* On server, this can be used for alternative implementations
33583358
* of session cache or session tickets.
33593359
*
3360+
* \warning The serialized data contains highly sensitive material,
3361+
* including a resumption key (TLS 1.3) or the master secret
3362+
* (TLS 1.2) from which the session's traffic keys are derived.
3363+
*
3364+
* The serialized data is not cryptographically protected.
3365+
* It is the responsibility of the user of the
3366+
* mbedtls_ssl_session_save() and
3367+
* mbedtls_ssl_session_load() APIs to ensure both its
3368+
* confidentiality and integrity while stored or transported.
3369+
*
3370+
* A breach of confidentiality could result in full compromise
3371+
* of the associated TLS session, including loss of
3372+
* confidentiality and integrity of past and future
3373+
* application data protected under that session.
3374+
*
3375+
* A breach of integrity may allow modification of the
3376+
* serialized data prior to restoration. As it represents
3377+
* trusted internal context, tampering could potentially result
3378+
* in arbitrary code execution or other severe compromise of
3379+
* the hosting process.
3380+
*
33603381
* \warning If a peer certificate chain is associated with the session,
33613382
* the serialized state will only contain the peer's
33623383
* end-entity certificate and the result of the chain
@@ -3395,6 +3416,19 @@ int mbedtls_ssl_session_load(mbedtls_ssl_session *session,
33953416
*
33963417
* \see mbedtls_ssl_session_load()
33973418
*
3419+
* \warning The serialized data contains highly sensitive material,
3420+
* including a resumption key (TLS 1.3) or the master secret
3421+
* (TLS 1.2) from which the session's traffic keys are derived.
3422+
*
3423+
* The serialized data is not cryptographically protected.
3424+
* It is the responsibility of the user of the
3425+
* mbedtls_ssl_session_save() and
3426+
* mbedtls_ssl_session_load() APIs to ensure both its
3427+
* confidentiality and integrity while stored or transported.
3428+
*
3429+
* See the mbedtls_ssl_session_load() documentation for
3430+
* additional information.
3431+
*
33983432
* \param session The session structure to be saved.
33993433
* \param buf The buffer to write the serialized data to. It must be a
34003434
* writeable buffer of at least \p buf_len bytes, or may be \c
@@ -5084,13 +5118,6 @@ int mbedtls_ssl_get_session(const mbedtls_ssl_context *ssl,
50845118
* supported with some limitations (those limitations do
50855119
* not apply to DTLS, where defragmentation is fully
50865120
* supported):
5087-
* - On an Mbed TLS server that only accepts TLS 1.2,
5088-
* the initial ClientHello message must not be fragmented.
5089-
* A TLS 1.2 ClientHello may be fragmented if the server
5090-
* also accepts TLS 1.3 connections (meaning
5091-
* that #MBEDTLS_SSL_PROTO_TLS1_3 enabled, and the
5092-
* accepted versions have not been restricted with
5093-
* mbedtls_ssl_conf_max_tls_version() or the like).
50945121
* - The first fragment of a handshake message must be
50955122
* at least 4 bytes long.
50965123
* - Non-handshake records must not be interleaved between
@@ -5577,6 +5604,19 @@ void mbedtls_ssl_free(mbedtls_ssl_context *ssl);
55775604
*
55785605
* \see mbedtls_ssl_context_load()
55795606
*
5607+
* \warning The serialized data contains highly sensitive material,
5608+
* including the master secret from which the session's traffic
5609+
* keys are derived.
5610+
*
5611+
* The serialized data is not cryptographically protected.
5612+
* It is the responsibility of the user of the
5613+
* mbedtls_ssl_context_save() and
5614+
* mbedtls_ssl_context_load() APIs to ensure both its
5615+
* confidentiality and integrity while stored or transported.
5616+
*
5617+
* See the mbedtls_ssl_context_load() documentation for
5618+
* additional information.
5619+
*
55805620
* \note The serialized data only contains the data that is
55815621
* necessary to resume the connection: negotiated protocol
55825622
* options, session identifier, keys, etc.
@@ -5643,6 +5683,27 @@ int mbedtls_ssl_context_save(mbedtls_ssl_context *ssl,
56435683
* more than one context would cause severe security failures
56445684
* including but not limited to loss of confidentiality.
56455685
*
5686+
* \warning The serialized data contains highly sensitive material,
5687+
* including the master secret from which the session's traffic
5688+
* keys are derived.
5689+
*
5690+
* The serialized data is not cryptographically protected.
5691+
* It is the responsibility of the user of the
5692+
* mbedtls_ssl_context_save() and
5693+
* mbedtls_ssl_context_load() APIs to ensure both its
5694+
* confidentiality and integrity while stored or transported.
5695+
*
5696+
* A breach of confidentiality could result in full compromise
5697+
* of the associated TLS session, including loss of
5698+
* confidentiality and integrity of past and future
5699+
* application data protected under that session.
5700+
*
5701+
* A breach of integrity may allow modification of the
5702+
* serialized data prior to restoration. As it represents
5703+
* trusted internal context, tampering could potentially result
5704+
* in arbitrary code execution or other severe compromise of
5705+
* the hosting process.
5706+
*
56465707
* \note Before calling this function, the SSL context must be
56475708
* prepared in one of the two following ways. The first way is
56485709
* to take a context freshly initialised with

0 commit comments

Comments
 (0)