Skip to content

Commit 4ac1f9c

Browse files
committed
[mbedTLS] Update to 3.6.1
1 parent 40b378e commit 4ac1f9c

Some content is hidden

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

68 files changed

+1786
-970
lines changed

thirdparty/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ in the MSVC debugger.
543543
## mbedtls
544544

545545
- Upstream: https://github.com/Mbed-TLS/mbedtls
546-
- Version: 3.6.0 (2ca6c285a0dd3f33982dd57299012dacab1ff206, 2024)
546+
- Version: 3.6.1 (71c569d44bf3a8bd53d874c81ee8ac644dd6e9e3, 2024)
547547
- License: Apache 2.0
548548

549549
File extracted from upstream release tarball:
@@ -553,8 +553,6 @@ File extracted from upstream release tarball:
553553
- All `.c` and `.h` from `library/` to `thirdparty/mbedtls/library/` except
554554
for the `psa_*.c` source files
555555
- The `LICENSE` file (edited to keep only the Apache 2.0 variant)
556-
- Applied the patch `no-flexible-arrays.diff` to fix Windows build (see
557-
upstream GH-9020)
558556
- Applied the patch `msvc-redeclaration-bug.diff` to fix a compilation error
559557
with some MSVC versions
560558
- Added 2 files `godot_core_mbedtls_platform.c` and `godot_core_mbedtls_config.h`

thirdparty/mbedtls/include/mbedtls/bignum.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ int mbedtls_mpi_mod_int(mbedtls_mpi_uint *r, const mbedtls_mpi *A,
880880
mbedtls_mpi_sint b);
881881

882882
/**
883-
* \brief Perform a sliding-window exponentiation: X = A^E mod N
883+
* \brief Perform a modular exponentiation: X = A^E mod N
884884
*
885885
* \param X The destination MPI. This must point to an initialized MPI.
886886
* This must not alias E or N.

thirdparty/mbedtls/include/mbedtls/build_info.h

Lines changed: 24 additions & 6 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 0
29+
#define MBEDTLS_VERSION_PATCH 1
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 0x03060000
37-
#define MBEDTLS_VERSION_STRING "3.6.0"
38-
#define MBEDTLS_VERSION_STRING_FULL "Mbed TLS 3.6.0"
36+
#define MBEDTLS_VERSION_NUMBER 0x03060100
37+
#define MBEDTLS_VERSION_STRING "3.6.1"
38+
#define MBEDTLS_VERSION_STRING_FULL "Mbed TLS 3.6.1"
3939

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

@@ -101,6 +101,13 @@
101101
#define inline __inline
102102
#endif
103103

104+
#if defined(MBEDTLS_CONFIG_FILES_READ)
105+
#error "Something went wrong: MBEDTLS_CONFIG_FILES_READ defined before reading the config files!"
106+
#endif
107+
#if defined(MBEDTLS_CONFIG_IS_FINALIZED)
108+
#error "Something went wrong: MBEDTLS_CONFIG_IS_FINALIZED defined before reading the config files!"
109+
#endif
110+
104111
/* X.509, TLS and non-PSA crypto configuration */
105112
#if !defined(MBEDTLS_CONFIG_FILE)
106113
#include "mbedtls/mbedtls_config.h"
@@ -135,6 +142,12 @@
135142
#endif
136143
#endif /* defined(MBEDTLS_PSA_CRYPTO_CONFIG) */
137144

145+
/* Indicate that all configuration files have been read.
146+
* It is now time to adjust the configuration (follow through on dependencies,
147+
* make PSA and legacy crypto consistent, etc.).
148+
*/
149+
#define MBEDTLS_CONFIG_FILES_READ
150+
138151
/* Auto-enable MBEDTLS_CTR_DRBG_USE_128_BIT_KEY if
139152
* MBEDTLS_AES_ONLY_128_BIT_KEY_LENGTH and MBEDTLS_CTR_DRBG_C defined
140153
* to ensure a 128-bit key size in CTR_DRBG.
@@ -169,8 +182,13 @@
169182

170183
#include "mbedtls/config_adjust_ssl.h"
171184

172-
/* Make sure all configuration symbols are set before including check_config.h,
173-
* even the ones that are calculated programmatically. */
185+
/* Indicate that all configuration symbols are set,
186+
* even the ones that are calculated programmatically.
187+
* It is now safe to query the configuration (to check it, to size buffers,
188+
* etc.).
189+
*/
190+
#define MBEDTLS_CONFIG_IS_FINALIZED
191+
174192
#include "mbedtls/check_config.h"
175193

176194
#endif /* MBEDTLS_BUILD_INFO_H */

thirdparty/mbedtls/include/mbedtls/check_config.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
* \file check_config.h
33
*
44
* \brief Consistency checks for configuration options
5+
*
6+
* This is an internal header. Do not include it directly.
7+
*
8+
* This header is included automatically by all public Mbed TLS headers
9+
* (via mbedtls/build_info.h). Do not include it directly in a configuration
10+
* file such as mbedtls/mbedtls_config.h or #MBEDTLS_USER_CONFIG_FILE!
11+
* It would run at the wrong time due to missing derived symbols.
512
*/
613
/*
714
* Copyright The Mbed TLS Contributors
@@ -12,6 +19,13 @@
1219
#define MBEDTLS_CHECK_CONFIG_H
1320

1421
/* *INDENT-OFF* */
22+
23+
#if !defined(MBEDTLS_CONFIG_IS_FINALIZED)
24+
#warning "Do not include mbedtls/check_config.h manually! " \
25+
"This may cause spurious errors. " \
26+
"It is included automatically at the right point since Mbed TLS 3.0."
27+
#endif /* !MBEDTLS_CONFIG_IS_FINALIZED */
28+
1529
/*
1630
* We assume CHAR_BIT is 8 in many places. In practice, this is true on our
1731
* target platforms, so not an issue, but let's just be extra sure.

thirdparty/mbedtls/include/mbedtls/config_adjust_legacy_crypto.h

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
* \file mbedtls/config_adjust_legacy_crypto.h
33
* \brief Adjust legacy configuration configuration
44
*
5-
* Automatically enable certain dependencies. Generally, MBEDLTS_xxx
5+
* This is an internal header. Do not include it directly.
6+
*
7+
* Automatically enable certain dependencies. Generally, MBEDTLS_xxx
68
* configurations need to be explicitly enabled by the user: enabling
79
* MBEDTLS_xxx_A but not MBEDTLS_xxx_B when A requires B results in a
810
* compilation error. However, we do automatically enable certain options
@@ -22,6 +24,14 @@
2224
#ifndef MBEDTLS_CONFIG_ADJUST_LEGACY_CRYPTO_H
2325
#define MBEDTLS_CONFIG_ADJUST_LEGACY_CRYPTO_H
2426

27+
#if !defined(MBEDTLS_CONFIG_FILES_READ)
28+
#error "Do not include mbedtls/config_adjust_*.h manually! This can lead to problems, " \
29+
"up to and including runtime errors such as buffer overflows. " \
30+
"If you're trying to fix a complaint from check_config.h, just remove " \
31+
"it from your configuration file: since Mbed TLS 3.0, it is included " \
32+
"automatically at the right point."
33+
#endif /* */
34+
2535
/* Ideally, we'd set those as defaults in mbedtls_config.h, but
2636
* putting an #ifdef _WIN32 in mbedtls_config.h would confuse config.py.
2737
*
@@ -48,7 +58,8 @@
4858
defined(MBEDTLS_PSA_BUILTIN_ALG_ECB_NO_PADDING) || \
4959
defined(MBEDTLS_PSA_BUILTIN_ALG_CBC_NO_PADDING) || \
5060
defined(MBEDTLS_PSA_BUILTIN_ALG_CBC_PKCS7) || \
51-
defined(MBEDTLS_PSA_BUILTIN_ALG_CCM_STAR_NO_TAG))
61+
defined(MBEDTLS_PSA_BUILTIN_ALG_CCM_STAR_NO_TAG) || \
62+
defined(MBEDTLS_PSA_BUILTIN_ALG_CMAC))
5263
#define MBEDTLS_CIPHER_C
5364
#endif
5465

@@ -293,6 +304,14 @@
293304
#define MBEDTLS_ECP_LIGHT
294305
#endif
295306

307+
/* Backward compatibility: after #8740 the RSA module offers functions to parse
308+
* and write RSA private/public keys without relying on the PK one. Of course
309+
* this needs ASN1 support to do so, so we enable it here. */
310+
#if defined(MBEDTLS_RSA_C)
311+
#define MBEDTLS_ASN1_PARSE_C
312+
#define MBEDTLS_ASN1_WRITE_C
313+
#endif
314+
296315
/* MBEDTLS_PK_PARSE_EC_COMPRESSED is introduced in Mbed TLS version 3.5, while
297316
* in previous version compressed points were automatically supported as long
298317
* as PK_PARSE_C and ECP_C were enabled. As a consequence, for backward
@@ -409,12 +428,12 @@
409428

410429
/* psa_util file features some ECDSA conversion functions, to convert between
411430
* legacy's ASN.1 DER format and PSA's raw one. */
412-
#if defined(MBEDTLS_ECDSA_C) || (defined(MBEDTLS_PSA_CRYPTO_C) && \
431+
#if (defined(MBEDTLS_PSA_CRYPTO_CLIENT) && \
413432
(defined(PSA_WANT_ALG_ECDSA) || defined(PSA_WANT_ALG_DETERMINISTIC_ECDSA)))
414433
#define MBEDTLS_PSA_UTIL_HAVE_ECDSA
415434
#endif
416435

417-
/* Some internal helpers to determine which keys are availble. */
436+
/* Some internal helpers to determine which keys are available. */
418437
#if (!defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_AES_C)) || \
419438
(defined(MBEDTLS_USE_PSA_CRYPTO) && defined(PSA_WANT_KEY_TYPE_AES))
420439
#define MBEDTLS_SSL_HAVE_AES
@@ -428,7 +447,7 @@
428447
#define MBEDTLS_SSL_HAVE_CAMELLIA
429448
#endif
430449

431-
/* Some internal helpers to determine which operation modes are availble. */
450+
/* Some internal helpers to determine which operation modes are available. */
432451
#if (!defined(MBEDTLS_USE_PSA_CRYPTO) && defined(MBEDTLS_CIPHER_MODE_CBC)) || \
433452
(defined(MBEDTLS_USE_PSA_CRYPTO) && defined(PSA_WANT_ALG_CBC_NO_PADDING))
434453
#define MBEDTLS_SSL_HAVE_CBC

thirdparty/mbedtls/include/mbedtls/config_adjust_legacy_from_psa.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
* \file mbedtls/config_adjust_legacy_from_psa.h
33
* \brief Adjust PSA configuration: activate legacy implementations
44
*
5+
* This is an internal header. Do not include it directly.
6+
*
57
* When MBEDTLS_PSA_CRYPTO_CONFIG is enabled, activate legacy implementations
68
* of cryptographic mechanisms as needed to fulfill the needs of the PSA
79
* configuration. Generally speaking, we activate a legacy mechanism if
@@ -16,6 +18,14 @@
1618
#ifndef MBEDTLS_CONFIG_ADJUST_LEGACY_FROM_PSA_H
1719
#define MBEDTLS_CONFIG_ADJUST_LEGACY_FROM_PSA_H
1820

21+
#if !defined(MBEDTLS_CONFIG_FILES_READ)
22+
#error "Do not include mbedtls/config_adjust_*.h manually! This can lead to problems, " \
23+
"up to and including runtime errors such as buffer overflows. " \
24+
"If you're trying to fix a complaint from check_config.h, just remove " \
25+
"it from your configuration file: since Mbed TLS 3.0, it is included " \
26+
"automatically at the right point."
27+
#endif /* */
28+
1929
/* Define appropriate ACCEL macros for the p256-m driver.
2030
* In the future, those should be generated from the drivers JSON description.
2131
*/
@@ -498,7 +508,6 @@
498508
* The PSA implementation has its own implementation of HKDF, separate from
499509
* hkdf.c. No need to enable MBEDTLS_HKDF_C here.
500510
*/
501-
#define MBEDTLS_PSA_BUILTIN_ALG_HMAC 1
502511
#define MBEDTLS_PSA_BUILTIN_ALG_HKDF 1
503512
#endif /* !MBEDTLS_PSA_ACCEL_ALG_HKDF */
504513
#endif /* PSA_WANT_ALG_HKDF */
@@ -509,7 +518,6 @@
509518
* The PSA implementation has its own implementation of HKDF, separate from
510519
* hkdf.c. No need to enable MBEDTLS_HKDF_C here.
511520
*/
512-
#define MBEDTLS_PSA_BUILTIN_ALG_HMAC 1
513521
#define MBEDTLS_PSA_BUILTIN_ALG_HKDF_EXTRACT 1
514522
#endif /* !MBEDTLS_PSA_ACCEL_ALG_HKDF_EXTRACT */
515523
#endif /* PSA_WANT_ALG_HKDF_EXTRACT */
@@ -520,7 +528,6 @@
520528
* The PSA implementation has its own implementation of HKDF, separate from
521529
* hkdf.c. No need to enable MBEDTLS_HKDF_C here.
522530
*/
523-
#define MBEDTLS_PSA_BUILTIN_ALG_HMAC 1
524531
#define MBEDTLS_PSA_BUILTIN_ALG_HKDF_EXPAND 1
525532
#endif /* !MBEDTLS_PSA_ACCEL_ALG_HKDF_EXPAND */
526533
#endif /* PSA_WANT_ALG_HKDF_EXPAND */
@@ -630,9 +637,6 @@
630637
#if !defined(MBEDTLS_PSA_ACCEL_ALG_PBKDF2_HMAC)
631638
#define MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_HMAC 1
632639
#define PSA_HAVE_SOFT_PBKDF2_HMAC 1
633-
#if !defined(MBEDTLS_PSA_ACCEL_ALG_HMAC)
634-
#define MBEDTLS_PSA_BUILTIN_ALG_HMAC 1
635-
#endif /* !MBEDTLS_PSA_ACCEL_ALG_HMAC */
636640
#endif /* !MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_HMAC */
637641
#endif /* PSA_WANT_ALG_PBKDF2_HMAC */
638642

thirdparty/mbedtls/include/mbedtls/config_adjust_psa_from_legacy.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
* \file mbedtls/config_adjust_psa_from_legacy.h
33
* \brief Adjust PSA configuration: construct PSA configuration from legacy
44
*
5+
* This is an internal header. Do not include it directly.
6+
*
57
* When MBEDTLS_PSA_CRYPTO_CONFIG is disabled, we automatically enable
68
* cryptographic mechanisms through the PSA interface when the corresponding
79
* legacy mechanism is enabled. In many cases, this just enables the PSA
@@ -18,6 +20,14 @@
1820
#ifndef MBEDTLS_CONFIG_ADJUST_PSA_FROM_LEGACY_H
1921
#define MBEDTLS_CONFIG_ADJUST_PSA_FROM_LEGACY_H
2022

23+
#if !defined(MBEDTLS_CONFIG_FILES_READ)
24+
#error "Do not include mbedtls/config_adjust_*.h manually! This can lead to problems, " \
25+
"up to and including runtime errors such as buffer overflows. " \
26+
"If you're trying to fix a complaint from check_config.h, just remove " \
27+
"it from your configuration file: since Mbed TLS 3.0, it is included " \
28+
"automatically at the right point."
29+
#endif /* */
30+
2131
/*
2232
* Ensure PSA_WANT_* defines are setup properly if MBEDTLS_PSA_CRYPTO_CONFIG
2333
* is not defined

thirdparty/mbedtls/include/mbedtls/config_adjust_psa_superset_legacy.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
* \file mbedtls/config_adjust_psa_superset_legacy.h
33
* \brief Adjust PSA configuration: automatic enablement from legacy
44
*
5+
* This is an internal header. Do not include it directly.
6+
*
57
* To simplify some edge cases, we automatically enable certain cryptographic
68
* mechanisms in the PSA API if they are enabled in the legacy API. The general
79
* idea is that if legacy module M uses mechanism A internally, and A has
@@ -17,6 +19,14 @@
1719
#ifndef MBEDTLS_CONFIG_ADJUST_PSA_SUPERSET_LEGACY_H
1820
#define MBEDTLS_CONFIG_ADJUST_PSA_SUPERSET_LEGACY_H
1921

22+
#if !defined(MBEDTLS_CONFIG_FILES_READ)
23+
#error "Do not include mbedtls/config_adjust_*.h manually! This can lead to problems, " \
24+
"up to and including runtime errors such as buffer overflows. " \
25+
"If you're trying to fix a complaint from check_config.h, just remove " \
26+
"it from your configuration file: since Mbed TLS 3.0, it is included " \
27+
"automatically at the right point."
28+
#endif /* */
29+
2030
/****************************************************************/
2131
/* Hashes that are built in are also enabled in PSA.
2232
* This simplifies dependency declarations especially

thirdparty/mbedtls/include/mbedtls/config_adjust_ssl.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
* \file mbedtls/config_adjust_ssl.h
33
* \brief Adjust TLS configuration
44
*
5-
* Automatically enable certain dependencies. Generally, MBEDLTS_xxx
5+
* This is an internal header. Do not include it directly.
6+
*
7+
* Automatically enable certain dependencies. Generally, MBEDTLS_xxx
68
* configurations need to be explicitly enabled by the user: enabling
79
* MBEDTLS_xxx_A but not MBEDTLS_xxx_B when A requires B results in a
810
* compilation error. However, we do automatically enable certain options
@@ -22,6 +24,14 @@
2224
#ifndef MBEDTLS_CONFIG_ADJUST_SSL_H
2325
#define MBEDTLS_CONFIG_ADJUST_SSL_H
2426

27+
#if !defined(MBEDTLS_CONFIG_FILES_READ)
28+
#error "Do not include mbedtls/config_adjust_*.h manually! This can lead to problems, " \
29+
"up to and including runtime errors such as buffer overflows. " \
30+
"If you're trying to fix a complaint from check_config.h, just remove " \
31+
"it from your configuration file: since Mbed TLS 3.0, it is included " \
32+
"automatically at the right point."
33+
#endif /* */
34+
2535
/* The following blocks make it easier to disable all of TLS,
2636
* or of TLS 1.2 or 1.3 or DTLS, without having to manually disable all
2737
* key exchanges, options and extensions related to them. */

thirdparty/mbedtls/include/mbedtls/config_adjust_x509.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
* \file mbedtls/config_adjust_x509.h
33
* \brief Adjust X.509 configuration
44
*
5-
* Automatically enable certain dependencies. Generally, MBEDLTS_xxx
5+
* This is an internal header. Do not include it directly.
6+
*
7+
* Automatically enable certain dependencies. Generally, MBEDTLS_xxx
68
* configurations need to be explicitly enabled by the user: enabling
79
* MBEDTLS_xxx_A but not MBEDTLS_xxx_B when A requires B results in a
810
* compilation error. However, we do automatically enable certain options
@@ -22,4 +24,12 @@
2224
#ifndef MBEDTLS_CONFIG_ADJUST_X509_H
2325
#define MBEDTLS_CONFIG_ADJUST_X509_H
2426

27+
#if !defined(MBEDTLS_CONFIG_FILES_READ)
28+
#error "Do not include mbedtls/config_adjust_*.h manually! This can lead to problems, " \
29+
"up to and including runtime errors such as buffer overflows. " \
30+
"If you're trying to fix a complaint from check_config.h, just remove " \
31+
"it from your configuration file: since Mbed TLS 3.0, it is included " \
32+
"automatically at the right point."
33+
#endif /* */
34+
2535
#endif /* MBEDTLS_CONFIG_ADJUST_X509_H */

0 commit comments

Comments
 (0)