Skip to content

Commit a78176c

Browse files
authored
Merge pull request #63 from tomi-font/bump_to_3.6.2
update to 3.6.2
2 parents eb55f47 + 5718090 commit a78176c

File tree

12 files changed

+60
-22
lines changed

12 files changed

+60
-22
lines changed

BRANCHES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ The following branches are currently maintained:
107107
- [`development`](https://github.com/Mbed-TLS/mbedtls/)
108108
- [`mbedtls-3.6`](https://github.com/Mbed-TLS/mbedtls/tree/mbedtls-3.6)
109109
maintained until March 2027, see
110-
<https://github.com/Mbed-TLS/mbedtls/releases/tag/v3.6.1>.
110+
<https://github.com/Mbed-TLS/mbedtls/releases/tag/v3.6.2>.
111111
- [`mbedtls-2.28`](https://github.com/Mbed-TLS/mbedtls/tree/mbedtls-2.28)
112112
maintained until the end of 2024, see
113113
<https://github.com/Mbed-TLS/mbedtls/releases/tag/v2.28.9>.

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ cmake_policy(SET CMP0012 NEW)
4040
if(TEST_CPP)
4141
project("Mbed TLS"
4242
LANGUAGES C CXX
43-
VERSION 3.6.1
43+
VERSION 3.6.2
4444
)
4545
else()
4646
project("Mbed TLS"
4747
LANGUAGES C
48-
VERSION 3.6.1
48+
VERSION 3.6.2
4949
)
5050
endif()
5151

@@ -444,7 +444,7 @@ if(NOT DISABLE_PACKAGE_CONFIG_AND_INSTALL)
444444
write_basic_package_version_file(
445445
"cmake/MbedTLSConfigVersion.cmake"
446446
COMPATIBILITY SameMajorVersion
447-
VERSION 3.6.1)
447+
VERSION 3.6.2)
448448

449449
install(
450450
FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/MbedTLSConfig.cmake"

ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
Mbed TLS ChangeLog (Sorted per branch, date)
22

3+
= Mbed TLS 3.6.2 branch released 2024-10-14
4+
5+
Security
6+
* Fix a buffer underrun in mbedtls_pk_write_key_der() when
7+
called on an opaque key, MBEDTLS_USE_PSA_CRYPTO is enabled,
8+
and the output buffer is smaller than the actual output.
9+
Fix a related buffer underrun in mbedtls_pk_write_key_pem()
10+
when called on an opaque RSA key, MBEDTLS_USE_PSA_CRYPTO is enabled
11+
and MBEDTLS_MPI_MAX_SIZE is smaller than needed for a 4096-bit RSA key.
12+
CVE-2024-49195
13+
314
= Mbed TLS 3.6.1 branch released 2024-08-30
415

516
API changes

docs/architecture/psa-keystore-design.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Note that a slot must not be moved in memory while it is being read or written.
6767
There are three variants of the key store implementation, responding to different needs.
6868

6969
* Hybrid key store ([static key slots](#static-key-store) with dynamic key data): the key store is a statically allocated array of slots, of size `MBEDTLS_PSA_KEY_SLOT_COUNT`. Key material is allocated on the heap. This is the historical implementation. It remains the default in the Mbed TLS 3.6 long-time support (LTS) branch when using a handwritten `mbedtls_config.h`, as is common on resource-constrained platforms, because the alternatives have tradeoffs (key size limit and larger RAM usage at rest for the static key store, larger code size and more risk due to code complexity for the dynamic key store).
70-
* Fully [static key store](#static-key-store) (since Mbed TLS 3.6.2): the key store is a statically allocated array of slots, of size `MBEDTLS_PSA_KEY_SLOT_COUNT`. Each key slot contains the key representation directly, and the key representation must be no more than `MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE` bytes. This is intended for very constrained devices that do not have a heap.
70+
* Fully [static key store](#static-key-store) (since Mbed TLS 3.6.3): the key store is a statically allocated array of slots, of size `MBEDTLS_PSA_KEY_SLOT_COUNT`. Each key slot contains the key representation directly, and the key representation must be no more than `MBEDTLS_PSA_STATIC_KEY_SLOT_BUFFER_SIZE` bytes. This is intended for very constrained devices that do not have a heap.
7171
* [Dynamic key store](#dynamic-key-store) (since Mbed TLS 3.6.1): the key store is dynamically allocated as multiple slices on the heap, with a size that adjusts to the application's usage. Key material is allocated on the heap. Compared to the hybrid key store, the code size and RAM consumption are larger. This is intended for higher-end devices where applications are not expected to have a highly predicatable resource usage. This is the default implementation when using the default `mbedtls_config.h` file, as is common on platforms such as Linux, starting with Mbed TLS 3.6.1.
7272

7373
#### Future improvement: merging the key store variants
@@ -95,7 +95,7 @@ When creating a volatile key, the slice containing the slot and index of the slo
9595

9696
The static key store is the historical implementation. The key store is a statically allocated array of slots, of size `MBEDTLS_PSA_KEY_SLOT_COUNT`. This value is an upper bound for the total number of volatile keys plus loaded keys.
9797

98-
Since Mbed TLS 3.6.2, there are two variants for the static key store: a hybrid variant (default), and a fully-static variant enabled by the configuration option `MBEDTLS_PSA_STATIC_KEY_SLOTS`. The two variants have the same key store management: the only difference is in how the memory for key data is managed. With fully static key slots, the key data is directly inside the slot, and limited to `MBEDTLS_PSA_KEY_SLOT_BUFFER_SIZE` bytes. With the hybrid key store, the slot contains a pointer to the key data, which is allocated on the heap.
98+
Since Mbed TLS 3.6.3, there are two variants for the static key store: a hybrid variant (default), and a fully-static variant enabled by the configuration option `MBEDTLS_PSA_STATIC_KEY_SLOTS`. The two variants have the same key store management: the only difference is in how the memory for key data is managed. With fully static key slots, the key data is directly inside the slot, and limited to `MBEDTLS_PSA_KEY_SLOT_BUFFER_SIZE` bytes. With the hybrid key store, the slot contains a pointer to the key data, which is allocated on the heap.
9999

100100
#### Volatile key identifiers in the static key store
101101

doxygen/input/doc_mainpage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111

1212
/**
13-
* @mainpage Mbed TLS v3.6.1 API Documentation
13+
* @mainpage Mbed TLS v3.6.2 API Documentation
1414
*
1515
* This documentation describes the internal structure of Mbed TLS. It was
1616
* automatically generated from specially formatted comment blocks in

doxygen/mbedtls.doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PROJECT_NAME = "Mbed TLS v3.6.1"
1+
PROJECT_NAME = "Mbed TLS v3.6.2"
22
OUTPUT_DIRECTORY = ../apidoc/
33
FULL_PATH_NAMES = NO
44
OPTIMIZE_OUTPUT_FOR_C = YES

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 1
29+
#define MBEDTLS_VERSION_PATCH 2
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 0x03060100
37-
#define MBEDTLS_VERSION_STRING "3.6.1"
38-
#define MBEDTLS_VERSION_STRING_FULL "Mbed TLS 3.6.1"
36+
#define MBEDTLS_VERSION_NUMBER 0x03060200
37+
#define MBEDTLS_VERSION_STRING "3.6.2"
38+
#define MBEDTLS_VERSION_STRING_FULL "Mbed TLS 3.6.2"
3939

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

library/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ endif(USE_STATIC_MBEDTLS_LIBRARY)
300300
if(USE_SHARED_MBEDTLS_LIBRARY)
301301
set(CMAKE_LIBRARY_PATH ${CMAKE_CURRENT_BINARY_DIR})
302302
add_library(${mbedcrypto_target} SHARED ${src_crypto})
303-
set_target_properties(${mbedcrypto_target} PROPERTIES VERSION 3.6.1 SOVERSION 16)
303+
set_target_properties(${mbedcrypto_target} PROPERTIES VERSION 3.6.2 SOVERSION 16)
304304
target_link_libraries(${mbedcrypto_target} PUBLIC ${libs})
305305

306306
if(TARGET ${everest_target})
@@ -312,11 +312,11 @@ if(USE_SHARED_MBEDTLS_LIBRARY)
312312
endif()
313313

314314
add_library(${mbedx509_target} SHARED ${src_x509})
315-
set_target_properties(${mbedx509_target} PROPERTIES VERSION 3.6.1 SOVERSION 7)
315+
set_target_properties(${mbedx509_target} PROPERTIES VERSION 3.6.2 SOVERSION 7)
316316
target_link_libraries(${mbedx509_target} PUBLIC ${libs} ${mbedcrypto_target})
317317

318318
add_library(${mbedtls_target} SHARED ${src_tls})
319-
set_target_properties(${mbedtls_target} PROPERTIES VERSION 3.6.1 SOVERSION 21)
319+
set_target_properties(${mbedtls_target} PROPERTIES VERSION 3.6.2 SOVERSION 21)
320320
target_link_libraries(${mbedtls_target} PUBLIC ${libs} ${mbedx509_target})
321321
endif(USE_SHARED_MBEDTLS_LIBRARY)
322322

library/pkwrite.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,21 @@ static int pk_write_rsa_der(unsigned char **p, unsigned char *buf,
6565
#if defined(MBEDTLS_USE_PSA_CRYPTO)
6666
if (mbedtls_pk_get_type(pk) == MBEDTLS_PK_OPAQUE) {
6767
uint8_t tmp[PSA_EXPORT_KEY_PAIR_MAX_SIZE];
68-
size_t len = 0, tmp_len = 0;
68+
size_t tmp_len = 0;
6969

7070
if (psa_export_key(pk->priv_id, tmp, sizeof(tmp), &tmp_len) != PSA_SUCCESS) {
7171
return MBEDTLS_ERR_PK_BAD_INPUT_DATA;
7272
}
73+
/* Ensure there's enough space in the provided buffer before copying data into it. */
74+
if (tmp_len > (size_t) (*p - buf)) {
75+
mbedtls_platform_zeroize(tmp, sizeof(tmp));
76+
return MBEDTLS_ERR_ASN1_BUF_TOO_SMALL;
77+
}
7378
*p -= tmp_len;
7479
memcpy(*p, tmp, tmp_len);
75-
len += tmp_len;
7680
mbedtls_platform_zeroize(tmp, sizeof(tmp));
7781

78-
return (int) len;
82+
return (int) tmp_len;
7983
}
8084
#endif /* MBEDTLS_USE_PSA_CRYPTO */
8185
return mbedtls_rsa_write_key(mbedtls_pk_rsa(*pk), buf, p);
@@ -125,6 +129,10 @@ static int pk_write_ec_pubkey(unsigned char **p, unsigned char *start,
125129
if (psa_export_public_key(pk->priv_id, buf, sizeof(buf), &len) != PSA_SUCCESS) {
126130
return MBEDTLS_ERR_PK_BAD_INPUT_DATA;
127131
}
132+
/* Ensure there's enough space in the provided buffer before copying data into it. */
133+
if (len > (size_t) (*p - start)) {
134+
return MBEDTLS_ERR_ASN1_BUF_TOO_SMALL;
135+
}
128136
*p -= len;
129137
memcpy(*p, buf, len);
130138
return (int) len;

tests/suites/test_suite_pkwrite.function

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "pk_internal.h"
33
#include "mbedtls/pem.h"
44
#include "mbedtls/oid.h"
5+
#include "mbedtls/base64.h"
56
#include "psa/crypto_sizes.h"
67

78
typedef enum {
@@ -73,6 +74,7 @@ static void pk_write_check_common(char *key_file, int is_public_key, int is_der)
7374
unsigned char *check_buf = NULL;
7475
unsigned char *start_buf;
7576
size_t buf_len, check_buf_len;
77+
int expected_result;
7678
#if defined(MBEDTLS_USE_PSA_CRYPTO)
7779
mbedtls_svc_key_id_t opaque_id = MBEDTLS_SVC_KEY_ID_INIT;
7880
psa_key_attributes_t key_attr = PSA_KEY_ATTRIBUTES_INIT;
@@ -109,6 +111,17 @@ static void pk_write_check_common(char *key_file, int is_public_key, int is_der)
109111

110112
start_buf = buf;
111113
buf_len = check_buf_len;
114+
if (is_der) {
115+
expected_result = MBEDTLS_ERR_ASN1_BUF_TOO_SMALL;
116+
} else {
117+
expected_result = MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL;
118+
}
119+
/* Intentionally pass a wrong size for the provided output buffer and check
120+
* that the writing functions fails as expected. */
121+
for (size_t i = 1; i < buf_len; i++) {
122+
TEST_EQUAL(pk_write_any_key(&key, &start_buf, &i, is_public_key,
123+
is_der), expected_result);
124+
}
112125
TEST_EQUAL(pk_write_any_key(&key, &start_buf, &buf_len, is_public_key,
113126
is_der), 0);
114127

@@ -127,6 +140,12 @@ static void pk_write_check_common(char *key_file, int is_public_key, int is_der)
127140
TEST_EQUAL(mbedtls_pk_setup_opaque(&key, opaque_id), 0);
128141
start_buf = buf;
129142
buf_len = check_buf_len;
143+
/* Intentionally pass a wrong size for the provided output buffer and check
144+
* that the writing functions fails as expected. */
145+
for (size_t i = 1; i < buf_len; i++) {
146+
TEST_EQUAL(pk_write_any_key(&key, &start_buf, &i, is_public_key,
147+
is_der), expected_result);
148+
}
130149
TEST_EQUAL(pk_write_any_key(&key, &start_buf, &buf_len, is_public_key,
131150
is_der), 0);
132151

tests/suites/test_suite_version.data

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Check compile time library version
2-
check_compiletime_version:"3.6.1"
2+
check_compiletime_version:"3.6.2"
33

44
Check runtime library version
5-
check_runtime_version:"3.6.1"
5+
check_runtime_version:"3.6.2"
66

77
Check for MBEDTLS_VERSION_C
88
check_feature:"MBEDTLS_VERSION_C":0

zephyr/module.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ build:
33
kconfig-ext: True
44
security:
55
external-references:
6-
- cpe:2.3:a:arm:mbed_tls:3.6.1:*:*:*:*:*:*:*
7-
- pkg:github/Mbed-TLS/mbedtls@V3.6.1
6+
- cpe:2.3:a:arm:mbed_tls:3.6.2:*:*:*:*:*:*:*
7+
- pkg:github/Mbed-TLS/mbedtls@V3.6.2

0 commit comments

Comments
 (0)