Skip to content

Commit 888b2c8

Browse files
authored
Merge branch 'espressif:release/v5.3' into release/v5.3
2 parents 6bc9c11 + c50e49d commit 888b2c8

Some content is hidden

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

47 files changed

+470
-236
lines changed

components/bootloader_support/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ if(CONFIG_APP_BUILD_TYPE_APP_2NDBOOT)
3636
)
3737
endif()
3838

39+
if(CONFIG_ESP_ROM_REV0_HAS_NO_ECDSA_INTERFACE)
40+
list(APPEND srcs "src/${IDF_TARGET}/bootloader_ecdsa.c")
41+
endif()
42+
3943
if(BOOTLOADER_BUILD OR CONFIG_APP_BUILD_TYPE_RAM)
4044
set(include_dirs "include" "bootloader_flash/include"
4145
"private_include")
@@ -50,10 +54,6 @@ if(BOOTLOADER_BUILD OR CONFIG_APP_BUILD_TYPE_RAM)
5054
"src/${IDF_TARGET}/bootloader_${IDF_TARGET}.c"
5155
)
5256
list(APPEND priv_requires hal)
53-
if(CONFIG_ESP_ROM_REV0_HAS_NO_ECDSA_INTERFACE)
54-
list(APPEND srcs
55-
"src/${IDF_TARGET}/bootloader_ecdsa.c")
56-
endif()
5757
else()
5858
list(APPEND srcs
5959
"src/idf/bootloader_sha.c")

components/bootloader_support/src/esp_image_format.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -47,7 +47,12 @@ static const char *TAG = "esp_image";
4747

4848
#define HASH_LEN ESP_IMAGE_HASH_LEN
4949

50-
#define SIXTEEN_MB 0x1000000
50+
#if SOC_SPI_MEM_SUPPORT_CACHE_32BIT_ADDR_MAP
51+
#define ESP_IMAGE_MAX_FLASH_ADDR_SIZE UINT32_MAX
52+
#else
53+
#define ESP_IMAGE_MAX_FLASH_ADDR_SIZE 0x1000000
54+
#endif
55+
5156
#define ESP_ROM_CHECKSUM_INITIAL 0xEF
5257

5358
/* Headroom to ensure between stack SP (at time of checking) and data loaded from flash */
@@ -138,7 +143,7 @@ static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_
138143
verify_sha = (part->offset != ESP_BOOTLOADER_OFFSET) && do_verify;
139144
#endif
140145

141-
if (part->size > SIXTEEN_MB) {
146+
if (part->size > ESP_IMAGE_MAX_FLASH_ADDR_SIZE) {
142147
err = ESP_ERR_INVALID_ARG;
143148
FAIL_LOAD("partition size 0x%"PRIx32" invalid, larger than 16MB", part->size);
144149
}
@@ -297,7 +302,7 @@ esp_err_t esp_image_verify(esp_image_load_mode_t mode, const esp_partition_pos_t
297302
esp_err_t esp_image_get_metadata(const esp_partition_pos_t *part, esp_image_metadata_t *metadata)
298303
{
299304
esp_err_t err;
300-
if (metadata == NULL || part == NULL || part->size > SIXTEEN_MB) {
305+
if (metadata == NULL || part == NULL || part->size > ESP_IMAGE_MAX_FLASH_ADDR_SIZE) {
301306
return ESP_ERR_INVALID_ARG;
302307
}
303308

@@ -751,7 +756,7 @@ static esp_err_t process_segment_data(int segment, intptr_t load_addr, uint32_t
751756
static esp_err_t verify_segment_header(int index, const esp_image_segment_header_t *segment, uint32_t segment_data_offs, bool silent)
752757
{
753758
if ((segment->data_len & 3) != 0
754-
|| segment->data_len >= SIXTEEN_MB) {
759+
|| segment->data_len >= ESP_IMAGE_MAX_FLASH_ADDR_SIZE) {
755760
if (!silent) {
756761
ESP_LOGE(TAG, "invalid segment length 0x%"PRIx32, segment->data_len);
757762
}

components/esp-tls/esp-tls-crypto/esp_tls_crypto.c

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
/*
2-
* SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

77
#include "esp_tls_crypto.h"
88
#include "esp_log.h"
99
#include "esp_err.h"
10-
static const char *TAG = "esp_crypto";
10+
#include "sdkconfig.h"
11+
__attribute__((unused)) static const char *TAG = "esp_crypto";
1112
#ifdef CONFIG_ESP_TLS_USING_MBEDTLS
1213
#include "mbedtls/sha1.h"
1314
#include "mbedtls/base64.h"
15+
#include "mbedtls/error.h"
1416
#define _esp_crypto_sha1 esp_crypto_sha1_mbedtls
1517
#define _esp_crypto_base64_encode esp_crypto_bas64_encode_mbedtls
1618
#elif CONFIG_ESP_TLS_USING_WOLFSSL
@@ -25,11 +27,34 @@ static int esp_crypto_sha1_mbedtls( const unsigned char *input,
2527
size_t ilen,
2628
unsigned char output[20])
2729
{
28-
int ret = mbedtls_sha1(input, ilen, output);
30+
#if CONFIG_MBEDTLS_SHA1_C || CONFIG_MBEDTLS_HARDWARE_SHA
31+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
32+
mbedtls_sha1_context ctx;
33+
34+
mbedtls_sha1_init(&ctx);
35+
36+
if ((ret = mbedtls_sha1_starts(&ctx)) != 0) {
37+
goto exit;
38+
}
39+
40+
if ((ret = mbedtls_sha1_update(&ctx, input, ilen)) != 0) {
41+
goto exit;
42+
}
43+
44+
if ((ret = mbedtls_sha1_finish(&ctx, output)) != 0) {
45+
goto exit;
46+
}
47+
48+
exit:
49+
mbedtls_sha1_free(&ctx);
2950
if (ret != 0) {
3051
ESP_LOGE(TAG, "Error in calculating sha1 sum , Returned 0x%02X", ret);
3152
}
3253
return ret;
54+
#else
55+
ESP_LOGE(TAG, "Please enable CONFIG_MBEDTLS_SHA1_C or CONFIG_MBEDTLS_HARDWARE_SHA to support SHA1 operations");
56+
return MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED;
57+
#endif /* CONFIG_MBEDTLS_SHA1_C || CONFIG_MBEDTLS_HARDWARE_SHA*/
3358
}
3459

3560
static int esp_crypto_bas64_encode_mbedtls( unsigned char *dst, size_t dlen,

components/esp_http_server/src/httpd_ws.c

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -13,10 +13,12 @@
1313
#include <esp_err.h>
1414
#include <mbedtls/sha1.h>
1515
#include <mbedtls/base64.h>
16+
#include <mbedtls/error.h>
1617

1718
#include <esp_http_server.h>
1819
#include "esp_httpd_priv.h"
1920
#include "freertos/event_groups.h"
21+
#include "sdkconfig.h"
2022

2123
#ifdef CONFIG_HTTPD_WS_SUPPORT
2224

@@ -51,23 +53,23 @@ static const char *TAG="httpd_ws";
5153
*/
5254
static const char ws_magic_uuid[] = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
5355

54-
/* Checks if any subprotocols from the comma seperated list matches the supported one
56+
/* Checks if any subprotocols from the comma separated list matches the supported one
5557
*
5658
* Returns true if the response should contain a protocol field
5759
*/
5860

5961
/**
60-
* @brief Checks if any subprotocols from the comma seperated list matches the supported one
62+
* @brief Checks if any subprotocols from the comma separated list matches the supported one
6163
*
6264
* @param supported_subprotocol[in] The subprotocol supported by the URI
63-
* @param subprotocol[in], [in]: A comma seperate list of subprotocols requested
65+
* @param subprotocol[in], [in]: A comma separate list of subprotocols requested
6466
* @param buf_len Length of the buffer
6567
* @return true: found a matching subprotocol
6668
* @return false
6769
*/
6870
static bool httpd_ws_get_response_subprotocol(const char *supported_subprotocol, char *subprotocol, size_t buf_len)
6971
{
70-
/* Request didnt contain any subprotocols */
72+
/* Request didn't contain any subprotocols */
7173
if (strnlen(subprotocol, buf_len) == 0) {
7274
return false;
7375
}
@@ -77,7 +79,7 @@ static bool httpd_ws_get_response_subprotocol(const char *supported_subprotocol,
7779
return false;
7880
}
7981

80-
/* Get first subprotocol from comma seperated list */
82+
/* Get first subprotocol from comma separated list */
8183
char *rest = NULL;
8284
char *s = strtok_r(subprotocol, ", ", &rest);
8385
do {
@@ -143,7 +145,34 @@ esp_err_t httpd_ws_respond_server_handshake(httpd_req_t *req, const char *suppor
143145

144146
/* Generate SHA-1 first and then encode to Base64 */
145147
size_t key_len = strlen(server_raw_text);
146-
mbedtls_sha1((uint8_t *)server_raw_text, key_len, server_key_hash);
148+
149+
#if CONFIG_MBEDTLS_SHA1_C || CONFIG_MBEDTLS_HARDWARE_SHA
150+
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
151+
mbedtls_sha1_context ctx;
152+
mbedtls_sha1_init(&ctx);
153+
154+
if ((ret = mbedtls_sha1_starts(&ctx)) != 0) {
155+
goto sha_end;
156+
}
157+
158+
if ((ret = mbedtls_sha1_update(&ctx, (uint8_t *)server_raw_text, key_len)) != 0) {
159+
goto sha_end;
160+
}
161+
162+
if ((ret = mbedtls_sha1_finish(&ctx, server_key_hash)) != 0) {
163+
goto sha_end;
164+
}
165+
166+
sha_end:
167+
mbedtls_sha1_free(&ctx);
168+
if (ret != 0) {
169+
ESP_LOGE(TAG, "Error in calculating SHA1 sum , returned 0x%02X", ret);
170+
return ESP_FAIL;
171+
}
172+
#else
173+
ESP_LOGE(TAG, "Please enable CONFIG_MBEDTLS_SHA1_C or CONFIG_MBEDTLS_HARDWARE_SHA to support SHA1 operations");
174+
return ESP_FAIL;
175+
#endif /* CONFIG_MBEDTLS_SHA1_C || CONFIG_MBEDTLS_HARDWARE_SHA */
147176

148177
size_t encoded_len = 0;
149178
mbedtls_base64_encode((uint8_t *)server_key_encoded, sizeof(server_key_encoded), &encoded_len,
@@ -153,7 +182,7 @@ esp_err_t httpd_ws_respond_server_handshake(httpd_req_t *req, const char *suppor
153182

154183
char subprotocol[50] = { '\0' };
155184
if (httpd_req_get_hdr_value_str(req, "Sec-WebSocket-Protocol", subprotocol, sizeof(subprotocol) - 1) == ESP_ERR_HTTPD_RESULT_TRUNC) {
156-
ESP_LOGW(TAG, "Sec-WebSocket-Protocol length exceeded buffer size of %"NEWLIB_NANO_COMPAT_FORMAT", was trunctated", NEWLIB_NANO_COMPAT_CAST(sizeof(subprotocol)));
185+
ESP_LOGW(TAG, "Sec-WebSocket-Protocol length exceeded buffer size of %"NEWLIB_NANO_COMPAT_FORMAT", was truncated", NEWLIB_NANO_COMPAT_CAST(sizeof(subprotocol)));
157186
}
158187

159188

components/esp_rom/esp32c3/ld/esp32c3.rom.bt_funcs.ld

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,10 +421,10 @@ r_llc_ll_reject_ind_pdu_send = 0x40000f3c;
421421
r_llc_ll_start_enc_rsp_ack_handler = 0x40000f40;
422422
r_llc_ll_terminate_ind_ack = 0x40000f44;
423423
r_llc_ll_unknown_ind_handler = 0x40000f48;
424-
/* r_llc_llcp_send = 0x40000f4c; */
424+
r_llc_llcp_send = 0x40000f4c;
425425
r_llc_llcp_state_set = 0x40000f50;
426426
r_llc_llcp_trans_timer_set = 0x40000f54;
427-
r_llc_llcp_tx_check = 0x40000f58;
427+
/* r_llc_llcp_tx_check = 0x40000f58; */
428428
r_llc_loc_con_upd_proc_err_cb = 0x40000f64;
429429
r_llc_loc_dl_upd_proc_continue = 0x40000f68;
430430
r_llc_loc_encrypt_proc_continue = 0x40000f6c;

components/esp_rom/esp32c3/ld/esp32c3.rom.eco7_bt_funcs.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ r_lld_con_terminate_max_evt_update = 0x40001c5c;
1818
r_llc_pref_param_compute_eco = 0x40001ce8;
1919
r_llc_hci_con_upd_info_send_eco = 0x40001cec;
2020
r_llc_rem_encrypt_proc_continue_eco = 0x40001cf0;
21-
r_llc_start_eco = 0x40001cf8;
2221
r_lld_ext_adv_dynamic_aux_pti_process_eco = 0x40001cfc;
2322
r_lld_adv_start_eco = 0x40001d04;
2423
r_lld_con_evt_canceled_cbk_eco = 0x40001d08;
@@ -127,4 +126,5 @@ r_hci_register_vendor_desc_tab = 0x40000d9c;
127126
r_lld_scan_process_pkt_rx_adv_rep = 0x40001284;
128127
r_register_esp_vendor_cmd_handler = 0x40001400;
129128
r_llc_llcp_pdu_handler_get_overwrite = 0x40001d5c;
129+
r_llc_start_eco = 0x40001cf8;
130130
*/

components/esp_rom/esp32s3/ld/esp32s3.rom.bt_funcs.ld

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,10 +421,10 @@ r_llc_ll_reject_ind_pdu_send = 0x40003d98;
421421
r_llc_ll_start_enc_rsp_ack_handler = 0x40003da4;
422422
r_llc_ll_terminate_ind_ack = 0x40003db0;
423423
r_llc_ll_unknown_ind_handler = 0x40003dbc;
424-
/* r_llc_llcp_send = 0x40003dc8; */
424+
r_llc_llcp_send = 0x40003dc8;
425425
r_llc_llcp_state_set = 0x40003dd4;
426426
r_llc_llcp_trans_timer_set = 0x40003de0;
427-
r_llc_llcp_tx_check = 0x40003dec;
427+
/* r_llc_llcp_tx_check = 0x40003dec; */
428428
/* r_llc_loc_ch_map_proc_continue = 0x40003df8; */
429429
r_llc_loc_con_upd_proc_err_cb = 0x40003e10;
430430
r_llc_loc_dl_upd_proc_continue = 0x40003e1c;

components/mbedtls/Kconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,21 @@ menu "mbedTLS"
698698
Standard ECDSA is "fragile" in the sense that lack of entropy when signing
699699
may result in a compromise of the long-term signing key.
700700

701+
config MBEDTLS_SHA1_C
702+
bool "Enable the SHA-1 cryptographic hash algorithm"
703+
default y
704+
help
705+
Enabling MBEDTLS_SHA1_C adds support for SHA-1.
706+
SHA-1 is considered a weak message digest and its use constitutes
707+
a security risk.
708+
Disabling this configuration option could impact TLS 1.2 / Wi-Fi Enterprise compatibility
709+
with certain older certificates that rely on SHA-1 for digital signatures.
710+
Before proceeding, ensure that all your certificates are using stronger hash algorithms,
711+
such as SHA-256 (part of the SHA-2 family).
712+
If you're using older certificates or if you're unsure about the impact on your product,
713+
please consider testing the changes in a controlled environment for individual features
714+
like OTA updates, cloud connectivity, secure local control, etc.
715+
701716
config MBEDTLS_SHA512_C
702717
bool "Enable the SHA-384 and SHA-512 cryptographic hash algorithms"
703718
default y

components/mbedtls/port/include/mbedtls/esp_config.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2490,8 +2490,11 @@
24902490
* on it, and considering stronger message digests instead.
24912491
*
24922492
*/
2493+
#if CONFIG_MBEDTLS_SHA1_C
24932494
#define MBEDTLS_SHA1_C
2494-
2495+
#else
2496+
#undef MBEDTLS_SHA1_C
2497+
#endif
24952498
/**
24962499
* \def MBEDTLS_SHA224_C
24972500
*

0 commit comments

Comments
 (0)