mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
s2 sha hw: Fix bug where alloc would fail if input were of len 0
This commit is contained in:
parent
493cdf53b9
commit
16b6a7a903
@ -208,7 +208,7 @@ menu "mbedTLS"
|
|||||||
config MBEDTLS_HARDWARE_GCM
|
config MBEDTLS_HARDWARE_GCM
|
||||||
bool "Enable partially hardware accelerated GCM"
|
bool "Enable partially hardware accelerated GCM"
|
||||||
depends on IDF_TARGET_ESP32S2 && MBEDTLS_HARDWARE_AES
|
depends on IDF_TARGET_ESP32S2 && MBEDTLS_HARDWARE_AES
|
||||||
default y
|
default n
|
||||||
help
|
help
|
||||||
Enable partially hardware accelerated GCM. GHASH calculation is still done
|
Enable partially hardware accelerated GCM. GHASH calculation is still done
|
||||||
in software.
|
in software.
|
||||||
|
@ -236,19 +236,19 @@ int esp_sha_dma(esp_sha_type sha_type, const void *input, uint32_t ilen,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* DMA cannot access memory in the iCache range, copy data to temporary buffers before transfer */
|
/* DMA cannot access memory in the iCache range, copy data to temporary buffers before transfer */
|
||||||
if (!esp_ptr_dma_ext_capable(input) && !esp_ptr_dma_capable(input)) {
|
if (!esp_ptr_dma_ext_capable(input) && !esp_ptr_dma_capable(input) && (ilen != 0)) {
|
||||||
non_icache_input = malloc(sizeof(unsigned char) * MIN(ilen, SHA_DMA_MAX_BYTES));
|
non_icache_input = heap_caps_malloc(sizeof(unsigned char) * MIN(ilen, SHA_DMA_MAX_BYTES), MALLOC_CAP_DMA);
|
||||||
if (non_icache_input == NULL) {
|
if (non_icache_input == NULL) {
|
||||||
ESP_LOGE(TAG, "Failed to allocate memory");
|
ESP_LOGE(TAG, "Failed to allocate input memory");
|
||||||
ret = ESP_ERR_NO_MEM;
|
ret = ESP_ERR_NO_MEM;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!esp_ptr_dma_ext_capable(buf) && !esp_ptr_dma_capable(buf)) {
|
if (!esp_ptr_dma_ext_capable(buf) && !esp_ptr_dma_capable(buf) && (buf_len != 0)) {
|
||||||
non_icache_buf = malloc(sizeof(unsigned char) * buf_len);
|
non_icache_buf = heap_caps_malloc(sizeof(unsigned char) * buf_len, MALLOC_CAP_DMA);
|
||||||
if (non_icache_buf == NULL) {
|
if (non_icache_buf == NULL) {
|
||||||
ESP_LOGE(TAG, "Failed to allocate memory");
|
ESP_LOGE(TAG, "Failed to allocate buf memory");
|
||||||
ret = ESP_ERR_NO_MEM;
|
ret = ESP_ERR_NO_MEM;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user