From 0d208aababe8e4c9775f9ef325db8cb9ecdff6f4 Mon Sep 17 00:00:00 2001 From: Mahavir Jain Date: Tue, 21 Apr 2020 15:27:53 +0530 Subject: [PATCH] mbedtls: esp32s2: check and reallocate output buffer if its from non-DMA range Earlier check was for only input buffer but it is quite likely to have output buffer also from non-DMA memory range and hence requirement to reallocate and then copy data from AES engine. --- components/mbedtls/port/esp32s2/aes.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/mbedtls/port/esp32s2/aes.c b/components/mbedtls/port/esp32s2/aes.c index 9f0450f1ae..6ac113c88e 100644 --- a/components/mbedtls/port/esp32s2/aes.c +++ b/components/mbedtls/port/esp32s2/aes.c @@ -448,6 +448,10 @@ static int esp_aes_process_dma(esp_aes_context *ctx, const unsigned char *input, input_needs_realloc = true; } + if (!esp_ptr_dma_ext_capable(output) && !esp_ptr_dma_capable(output)) { + output_needs_realloc = true; + } + /* If either input or output is unaccessible to the DMA then they need to be reallocated */ if (input_needs_realloc || output_needs_realloc) { return esp_aes_process_dma_ext_ram(ctx, input, output, len, stream_out, input_needs_realloc, output_needs_realloc);