Merge branch 'fix/build_failure_when_hardware_gcm_is_disabled_v5.0' into 'release/v5.0'

fix(mbedtls/gcm): Fix build failure when config `MBEDTLS_HARDWARE_GCM` is disabled (v5.0)

See merge request espressif/esp-idf!29069
This commit is contained in:
Mahavir Jain 2024-02-23 14:47:49 +08:00
commit f01e9be6d5
3 changed files with 6 additions and 10 deletions

View File

@ -229,7 +229,7 @@ if(CONFIG_MBEDTLS_HARDWARE_SHA)
) )
endif() endif()
if(CONFIG_MBEDTLS_HARDWARE_GCM OR (NOT CONFIG_SOC_AES_SUPPORT_GCM AND CONFIG_MBEDTLS_HARDWARE_AES)) if(CONFIG_MBEDTLS_HARDWARE_GCM OR CONFIG_MBEDTLS_HARDWARE_AES)
target_sources(mbedcrypto PRIVATE "${COMPONENT_DIR}/port/aes/esp_aes_gcm.c") target_sources(mbedcrypto PRIVATE "${COMPONENT_DIR}/port/aes/esp_aes_gcm.c")
endif() endif()

View File

@ -53,10 +53,6 @@
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "freertos/semphr.h" #include "freertos/semphr.h"
#if SOC_AES_SUPPORT_GCM
#include "aes/esp_aes_gcm.h"
#endif
#if SOC_AES_GDMA #if SOC_AES_GDMA
#define AES_LOCK() esp_crypto_sha_aes_lock_acquire() #define AES_LOCK() esp_crypto_sha_aes_lock_acquire()
#define AES_RELEASE() esp_crypto_sha_aes_lock_release() #define AES_RELEASE() esp_crypto_sha_aes_lock_release()
@ -476,7 +472,7 @@ cleanup:
} }
#if SOC_AES_SUPPORT_GCM #if CONFIG_MBEDTLS_HARDWARE_GCM
/* Encrypt/decrypt with AES-GCM the input using DMA /* Encrypt/decrypt with AES-GCM the input using DMA
* The function esp_aes_process_dma_gcm zeroises the output buffer in the case of following conditions: * The function esp_aes_process_dma_gcm zeroises the output buffer in the case of following conditions:
@ -607,7 +603,7 @@ cleanup:
return ret; return ret;
} }
#endif //SOC_AES_SUPPORT_GCM #endif //CONFIG_MBEDTLS_HARDWARE_GCM
static int esp_aes_validate_input(esp_aes_context *ctx, const unsigned char *input, static int esp_aes_validate_input(esp_aes_context *ctx, const unsigned char *input,
unsigned char *output ) unsigned char *output )

View File

@ -371,7 +371,7 @@ int esp_aes_gcm_starts( esp_gcm_context *ctx,
/* H and the lookup table are only generated once per ctx */ /* H and the lookup table are only generated once per ctx */
if (ctx->gcm_state == ESP_AES_GCM_STATE_INIT) { if (ctx->gcm_state == ESP_AES_GCM_STATE_INIT) {
/* Lock the AES engine to calculate ghash key H in hardware */ /* Lock the AES engine to calculate ghash key H in hardware */
#if SOC_AES_SUPPORT_GCM #if CONFIG_MBEDTLS_HARDWARE_GCM
esp_aes_acquire_hardware(); esp_aes_acquire_hardware();
ctx->aes_ctx.key_in_hardware = aes_hal_setkey(ctx->aes_ctx.key, ctx->aes_ctx.key_bytes, mode); ctx->aes_ctx.key_in_hardware = aes_hal_setkey(ctx->aes_ctx.key, ctx->aes_ctx.key_bytes, mode);
aes_hal_mode_init(ESP_AES_BLOCK_MODE_GCM); aes_hal_mode_init(ESP_AES_BLOCK_MODE_GCM);
@ -529,7 +529,7 @@ int esp_aes_gcm_finish( esp_gcm_context *ctx,
return esp_aes_crypt_ctr(&ctx->aes_ctx, tag_len, &nc_off, ctx->ori_j0, stream, ctx->ghash, tag); return esp_aes_crypt_ctr(&ctx->aes_ctx, tag_len, &nc_off, ctx->ori_j0, stream, ctx->ghash, tag);
} }
#if SOC_AES_SUPPORT_GCM #if CONFIG_MBEDTLS_HARDWARE_GCM
/* Due to restrictions in the hardware (e.g. need to do the whole conversion in one go), /* Due to restrictions in the hardware (e.g. need to do the whole conversion in one go),
some combinations of inputs are not supported */ some combinations of inputs are not supported */
static bool esp_aes_gcm_input_support_hw_accel(size_t length, const unsigned char *aad, size_t aad_len, static bool esp_aes_gcm_input_support_hw_accel(size_t length, const unsigned char *aad, size_t aad_len,
@ -607,7 +607,7 @@ int esp_aes_gcm_crypt_and_tag( esp_gcm_context *ctx,
size_t tag_len, size_t tag_len,
unsigned char *tag ) unsigned char *tag )
{ {
#if SOC_AES_SUPPORT_GCM #if CONFIG_MBEDTLS_HARDWARE_GCM
int ret; int ret;
lldesc_t aad_desc[2] = {}; lldesc_t aad_desc[2] = {};
lldesc_t *aad_head_desc = NULL; lldesc_t *aad_head_desc = NULL;