mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
fix: removes deprecated http_crypto sources
This commit is contained in:
@@ -4,17 +4,10 @@ else()
|
|||||||
set(req linux esp_event)
|
set(req linux esp_event)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CONFIG_ESP_HTTP_CLIENT_PSA_CRYPTO_MIGRATE)
|
|
||||||
set(HTTP_CRYPTO_SRC "lib/http_crypto_psa.c")
|
|
||||||
else()
|
|
||||||
set(HTTP_CRYPTO_SRC "lib/http_crypto_mbedtls.c")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
idf_component_register(SRCS "esp_http_client.c"
|
idf_component_register(SRCS "esp_http_client.c"
|
||||||
"lib/http_auth.c"
|
"lib/http_auth.c"
|
||||||
"lib/http_header.c"
|
"lib/http_header.c"
|
||||||
"lib/http_utils.c"
|
"lib/http_utils.c"
|
||||||
${HTTP_CRYPTO_SRC}
|
|
||||||
INCLUDE_DIRS "include"
|
INCLUDE_DIRS "include"
|
||||||
PRIV_INCLUDE_DIRS "lib/include"
|
PRIV_INCLUDE_DIRS "lib/include"
|
||||||
# lwip is a public requirement because esp_http_client.h includes sys/socket.h
|
# lwip is a public requirement because esp_http_client.h includes sys/socket.h
|
||||||
|
|||||||
@@ -42,13 +42,6 @@ menu "ESP HTTP client"
|
|||||||
This config option helps in setting the time in millisecond to wait for event to be posted to the
|
This config option helps in setting the time in millisecond to wait for event to be posted to the
|
||||||
system default event loop. Set it to -1 if you need to set timeout to portMAX_DELAY.
|
system default event loop. Set it to -1 if you need to set timeout to portMAX_DELAY.
|
||||||
|
|
||||||
config ESP_HTTP_CLIENT_PSA_CRYPTO_MIGRATE
|
|
||||||
depends on MBEDTLS_VER_4_X_SUPPORT
|
|
||||||
bool "Migrate ESP HTTP Client to use PSA Crypto"
|
|
||||||
default y
|
|
||||||
help
|
|
||||||
Migrate ESP HTTP Client to use PSA Crypto.
|
|
||||||
|
|
||||||
config ESP_HTTP_CLIENT_SAVE_RESPONSE_HEADERS
|
config ESP_HTTP_CLIENT_SAVE_RESPONSE_HEADERS
|
||||||
bool "Save response headers"
|
bool "Save response headers"
|
||||||
default n
|
default n
|
||||||
|
|||||||
@@ -18,11 +18,12 @@
|
|||||||
|
|
||||||
#include "http_utils.h"
|
#include "http_utils.h"
|
||||||
#include "http_auth.h"
|
#include "http_auth.h"
|
||||||
#include "http_crypto.h"
|
|
||||||
|
|
||||||
#include "psa/crypto.h"
|
#include "psa/crypto.h"
|
||||||
|
|
||||||
#define MD5_MAX_LEN (33)
|
#define MD5_MAX_LEN (33)
|
||||||
|
#define SHA256_LEN (32)
|
||||||
|
#define SHA256_HEX_LEN (65)
|
||||||
#define HTTP_AUTH_BUF_LEN (1024)
|
#define HTTP_AUTH_BUF_LEN (1024)
|
||||||
|
|
||||||
static const char *TAG = "HTTP_AUTH";
|
static const char *TAG = "HTTP_AUTH";
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "http_crypto.h"
|
|
||||||
#include "esp_rom_md5.h"
|
|
||||||
#include "esp_err.h"
|
|
||||||
#include "mbedtls/sha256.h"
|
|
||||||
#include "esp_log.h"
|
|
||||||
|
|
||||||
static const char *TAG = "http_crypto_mbedtls";
|
|
||||||
|
|
||||||
|
|
||||||
esp_err_t http_crypto_sha256(const uint8_t *data, size_t data_len, uint8_t *hash)
|
|
||||||
{
|
|
||||||
if (data == NULL || data_len == 0 || hash == NULL) {
|
|
||||||
ESP_LOGE(TAG, "Invalid input parameters");
|
|
||||||
return ESP_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
esp_err_t err = ESP_FAIL;
|
|
||||||
mbedtls_sha256_context ctx;
|
|
||||||
mbedtls_sha256_init(&ctx);
|
|
||||||
|
|
||||||
if (mbedtls_sha256_starts(&ctx, false) != 0) {
|
|
||||||
ESP_LOGE(TAG, "Failed to start SHA-256 hash");
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mbedtls_sha256_update(&ctx, data, data_len) != 0) {
|
|
||||||
ESP_LOGE(TAG, "Failed to update SHA-256 hash");
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mbedtls_sha256_finish(&ctx, hash) != 0) {
|
|
||||||
ESP_LOGE(TAG, "Failed to finish SHA-256 hash");
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = ESP_OK;
|
|
||||||
|
|
||||||
exit:
|
|
||||||
mbedtls_sha256_free(&ctx);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "esp_err.h"
|
|
||||||
#include "http_crypto.h"
|
|
||||||
#include "psa/crypto.h"
|
|
||||||
#include "esp_log.h"
|
|
||||||
|
|
||||||
static const char *TAG = "http_crypto_psa";
|
|
||||||
|
|
||||||
esp_err_t http_crypto_sha256(const uint8_t *data, size_t data_len, uint8_t *hash)
|
|
||||||
{
|
|
||||||
if (data == NULL || data_len == 0 || hash == NULL) {
|
|
||||||
ESP_LOGE(TAG, "Invalid input parameters");
|
|
||||||
return ESP_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t hash_len = 0;
|
|
||||||
psa_status_t status = psa_hash_compute(PSA_ALG_SHA_256, data, data_len, hash, SHA256_LEN, &hash_len);
|
|
||||||
if (status != PSA_SUCCESS || hash_len != SHA256_LEN) {
|
|
||||||
ESP_LOGE(TAG, "Failed to compute SHA-256 hash");
|
|
||||||
return ESP_FAIL;
|
|
||||||
}
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include "esp_err.h"
|
|
||||||
|
|
||||||
|
|
||||||
#define SHA256_LEN (32)
|
|
||||||
#define SHA256_HEX_LEN (65)
|
|
||||||
|
|
||||||
esp_err_t http_crypto_sha256(const uint8_t *data, size_t data_len, uint8_t *hash);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -75,7 +75,7 @@ def test_examples_protocol_esp_http_client(dut: Dut) -> None:
|
|||||||
],
|
],
|
||||||
indirect=True,
|
indirect=True,
|
||||||
)
|
)
|
||||||
@idf_parametrize('target', ['esp32s3'], indirect=['target'])
|
@idf_parametrize('target', ['esp32'], indirect=['target'])
|
||||||
def test_examples_protocol_esp_http_client_dynamic_buffer(dut: Dut) -> None:
|
def test_examples_protocol_esp_http_client_dynamic_buffer(dut: Dut) -> None:
|
||||||
# test mbedtls dynamic resource
|
# test mbedtls dynamic resource
|
||||||
# check and log bin size
|
# check and log bin size
|
||||||
|
|||||||
Reference in New Issue
Block a user