mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(mbedtls/aes): Check location of the buffer only for SOC_AXI_DMA_EXT_MEM_ENC_ALIGNMENT
When buffer_needs_realloc in the AES driver, check the location of the buffer only in case of SOC_AXI_DMA_EXT_MEM_ENC_ALIGNMENT for allocating the newer buffer, otherwise use generic DMA capable memory (as was done earlier)
This commit is contained in:
parent
57e8031e65
commit
141cdac87e
@ -207,7 +207,8 @@ static int esp_aes_process_dma_ext_ram(esp_aes_context *ctx, const unsigned char
|
|||||||
size_t chunk_len;
|
size_t chunk_len;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
uint32_t heap_caps = 0;
|
uint32_t input_heap_caps = MALLOC_CAP_DMA;
|
||||||
|
uint32_t output_heap_caps = MALLOC_CAP_DMA;
|
||||||
unsigned char *input_buf = NULL;
|
unsigned char *input_buf = NULL;
|
||||||
unsigned char *output_buf = NULL;
|
unsigned char *output_buf = NULL;
|
||||||
const unsigned char *dma_input;
|
const unsigned char *dma_input;
|
||||||
@ -223,14 +224,15 @@ static int esp_aes_process_dma_ext_ram(esp_aes_context *ctx, const unsigned char
|
|||||||
if (esp_ptr_external_ram(input) || esp_ptr_external_ram(output) || esp_ptr_in_drom(input) || esp_ptr_in_drom(output)) {
|
if (esp_ptr_external_ram(input) || esp_ptr_external_ram(output) || esp_ptr_in_drom(input) || esp_ptr_in_drom(output)) {
|
||||||
input_alignment = MAX(get_cache_line_size(input), SOC_AXI_DMA_EXT_MEM_ENC_ALIGNMENT);
|
input_alignment = MAX(get_cache_line_size(input), SOC_AXI_DMA_EXT_MEM_ENC_ALIGNMENT);
|
||||||
output_alignment = MAX(get_cache_line_size(output), SOC_AXI_DMA_EXT_MEM_ENC_ALIGNMENT);
|
output_alignment = MAX(get_cache_line_size(output), SOC_AXI_DMA_EXT_MEM_ENC_ALIGNMENT);
|
||||||
|
|
||||||
|
input_heap_caps = MALLOC_CAP_8BIT | (esp_ptr_external_ram(input) ? MALLOC_CAP_SPIRAM : MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
|
||||||
|
output_heap_caps = MALLOC_CAP_8BIT | (esp_ptr_external_ram(output) ? MALLOC_CAP_SPIRAM : MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* SOC_AXI_DMA_EXT_MEM_ENC_ALIGNMENT */
|
#endif /* SOC_AXI_DMA_EXT_MEM_ENC_ALIGNMENT */
|
||||||
|
|
||||||
if (realloc_input) {
|
if (realloc_input) {
|
||||||
heap_caps = MALLOC_CAP_8BIT | (esp_ptr_external_ram(input) ? MALLOC_CAP_SPIRAM : MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
|
input_buf = heap_caps_aligned_alloc(input_alignment, chunk_len, input_heap_caps);
|
||||||
input_buf = heap_caps_aligned_alloc(input_alignment, chunk_len, heap_caps);
|
|
||||||
|
|
||||||
if (input_buf == NULL) {
|
if (input_buf == NULL) {
|
||||||
mbedtls_platform_zeroize(output, len);
|
mbedtls_platform_zeroize(output, len);
|
||||||
ESP_LOGE(TAG, "Failed to allocate memory");
|
ESP_LOGE(TAG, "Failed to allocate memory");
|
||||||
@ -239,9 +241,7 @@ static int esp_aes_process_dma_ext_ram(esp_aes_context *ctx, const unsigned char
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (realloc_output) {
|
if (realloc_output) {
|
||||||
heap_caps = MALLOC_CAP_8BIT | (esp_ptr_external_ram(output) ? MALLOC_CAP_SPIRAM : MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL);
|
output_buf = heap_caps_aligned_alloc(output_alignment, chunk_len, output_heap_caps);
|
||||||
output_buf = heap_caps_aligned_alloc(output_alignment, chunk_len, heap_caps);
|
|
||||||
|
|
||||||
if (output_buf == NULL) {
|
if (output_buf == NULL) {
|
||||||
mbedtls_platform_zeroize(output, len);
|
mbedtls_platform_zeroize(output, len);
|
||||||
ESP_LOGE(TAG, "Failed to allocate memory");
|
ESP_LOGE(TAG, "Failed to allocate memory");
|
||||||
|
Loading…
Reference in New Issue
Block a user