From bc899d0badeb544f0c54316a0deef3f1b9f7ffed Mon Sep 17 00:00:00 2001 From: "harshal.patil" Date: Sun, 3 Mar 2024 15:56:40 +0530 Subject: [PATCH] ci(esp-tls): Fix test-specific leak for ESP32-P4 --- components/esp-tls/test_apps/main/app_main.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/components/esp-tls/test_apps/main/app_main.c b/components/esp-tls/test_apps/main/app_main.c index d84480083f..aad946e1f1 100644 --- a/components/esp-tls/test_apps/main/app_main.c +++ b/components/esp-tls/test_apps/main/app_main.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -27,19 +27,25 @@ /* setUp runs before every test */ void setUp(void) { +#if SOC_SHA_SUPPORTED // Execute esp_sha operation to allocate internal SHA semaphore (in case of ESP32) // and initial DMA setup memory which is considered as leaked otherwise -#if SOC_SHA_SUPPORTED const uint8_t input_buffer[64] = {0}; uint8_t output_buffer[64]; esp_sha(SHA_TYPE, input_buffer, sizeof(input_buffer), output_buffer); #endif // SOC_SHA_SUPPORTED +#if SOC_AES_SUPPORTED // Execute mbedtls_aes_init operation to allocate AES interrupt // allocation memory which is considered as leak otherwise -#if SOC_AES_SUPPORTED + const uint8_t plaintext[16] = {0}; + uint8_t ciphertext[16]; + const uint8_t key[16] = { 0 }; mbedtls_aes_context ctx; mbedtls_aes_init(&ctx); + mbedtls_aes_setkey_enc(&ctx, key, 128); + mbedtls_aes_crypt_ecb(&ctx, MBEDTLS_AES_ENCRYPT, plaintext, ciphertext); + mbedtls_aes_free(&ctx); #endif // SOC_AES_SUPPORTED test_utils_record_free_mem();