From c15b36b9c49fd3151080667bbf144411cc2f3d2f Mon Sep 17 00:00:00 2001 From: "harshal.patil" Date: Wed, 7 Dec 2022 11:34:43 +0530 Subject: [PATCH 1/6] mbedtls: populate mbedtls_gcm_update() output_length paramater --- components/mbedtls/port/aes/esp_aes_gcm.c | 11 +++++++++-- components/mbedtls/test_apps/main/test_aes_gcm.c | 12 ++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/components/mbedtls/port/aes/esp_aes_gcm.c b/components/mbedtls/port/aes/esp_aes_gcm.c index 652a72ffca6..31e5835fe30 100644 --- a/components/mbedtls/port/aes/esp_aes_gcm.c +++ b/components/mbedtls/port/aes/esp_aes_gcm.c @@ -425,6 +425,12 @@ int esp_aes_gcm_update( esp_gcm_context *ctx, uint8_t nonce_counter[AES_BLOCK_BYTES] = {0}; uint8_t stream[AES_BLOCK_BYTES] = {0}; + if (!output_length) { + ESP_LOGE(TAG, "No output length supplied"); + return -1; + } + *output_length = input_length; + if (!ctx) { ESP_LOGE(TAG, "No GCM context supplied"); return -1; @@ -543,6 +549,7 @@ static int esp_aes_gcm_crypt_and_tag_partial_hw( esp_gcm_context *ctx, unsigned char *tag ) { int ret = 0; + size_t olen; if ( ( ret = esp_aes_gcm_starts( ctx, mode, iv, iv_len ) ) != 0 ) { return ( ret ); @@ -552,11 +559,11 @@ static int esp_aes_gcm_crypt_and_tag_partial_hw( esp_gcm_context *ctx, return ( ret ); } - if ( ( ret = esp_aes_gcm_update( ctx, input, length, output, 0, NULL ) ) != 0 ) { + if ( ( ret = esp_aes_gcm_update( ctx, input, length, output, 0, &olen ) ) != 0 ) { return ( ret ); } - if ( ( ret = esp_aes_gcm_finish( ctx, output, 0, NULL, tag, tag_len ) ) != 0 ) { + if ( ( ret = esp_aes_gcm_finish( ctx, output, 0, &olen, tag, tag_len ) ) != 0 ) { return ( ret ); } diff --git a/components/mbedtls/test_apps/main/test_aes_gcm.c b/components/mbedtls/test_apps/main/test_aes_gcm.c index 115a67cf411..3b0e5cb97bc 100644 --- a/components/mbedtls/test_apps/main/test_aes_gcm.c +++ b/components/mbedtls/test_apps/main/test_aes_gcm.c @@ -105,13 +105,13 @@ TEST_CASE("mbedtls GCM stream test", "[aes-gcm]") mbedtls_gcm_starts( &ctx, MBEDTLS_AES_ENCRYPT, nonce, sizeof(nonce) ); mbedtls_gcm_update_ad( &ctx, NULL, 0 ); + size_t olen; // Encrypt for (int idx = 0; idx < SZ; idx = idx + bytes_to_process) { // Limit length of last call to avoid exceeding buffer size size_t length = (idx + bytes_to_process > SZ) ? (SZ - idx) : bytes_to_process; - mbedtls_gcm_update(&ctx, plaintext + idx, length, ciphertext + idx, 0, NULL); + mbedtls_gcm_update(&ctx, plaintext + idx, length, ciphertext + idx, 0, &olen); } - size_t olen; mbedtls_gcm_finish( &ctx, NULL, 0, &olen, tag, sizeof(tag) ); TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher, ciphertext, SZ); TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_tag, tag, sizeof(tag)); @@ -129,7 +129,7 @@ TEST_CASE("mbedtls GCM stream test", "[aes-gcm]") // Limit length of last call to avoid exceeding buffer size size_t length = (idx + bytes_to_process > SZ) ? (SZ - idx) : bytes_to_process; - mbedtls_gcm_update(&ctx, ciphertext + idx, length, decryptedtext + idx, 0, NULL); + mbedtls_gcm_update(&ctx, ciphertext + idx, length, decryptedtext + idx, 0, &olen); } mbedtls_gcm_finish( &ctx, NULL, 0, &olen, tag, sizeof(tag) ); TEST_ASSERT_EQUAL_HEX8_ARRAY(plaintext, decryptedtext, SZ); @@ -199,7 +199,7 @@ static void aes_gcm_test(aes_gcm_test_cfg_t *cfg, aes_gcm_test_expected_res_t *r } else if (aes_gcm_type == AES_GCM_TEST_START_UPDATE_FINISH) { TEST_ASSERT(mbedtls_gcm_starts( &ctx, MBEDTLS_AES_ENCRYPT, iv_buf, cfg->iv_length) == 0 ); TEST_ASSERT(mbedtls_gcm_update_ad( &ctx, cfg->add_buf, cfg->add_length) == 0 ); - TEST_ASSERT(mbedtls_gcm_update( &ctx, cfg->plaintext, cfg->plaintext_length, ciphertext, 0, NULL) == 0 ); + TEST_ASSERT(mbedtls_gcm_update( &ctx, cfg->plaintext, cfg->plaintext_length, ciphertext, 0, &olen) == 0 ); TEST_ASSERT(mbedtls_gcm_finish( &ctx, NULL, 0, &olen, tag_buf_encrypt, cfg->tag_len) == 0 ); } size_t offset = cfg->plaintext_length > 16 ? cfg->plaintext_length - 16 : 0; @@ -214,7 +214,7 @@ static void aes_gcm_test(aes_gcm_test_cfg_t *cfg, aes_gcm_test_expected_res_t *r } else if (aes_gcm_type == AES_GCM_TEST_START_UPDATE_FINISH) { TEST_ASSERT(mbedtls_gcm_starts( &ctx, MBEDTLS_AES_DECRYPT, iv_buf, cfg->iv_length) == 0 ); TEST_ASSERT(mbedtls_gcm_update_ad( &ctx, cfg->add_buf, cfg->add_length) == 0 ); - TEST_ASSERT(mbedtls_gcm_update( &ctx, ciphertext, cfg->plaintext_length, output, 0, NULL) == 0 ); + TEST_ASSERT(mbedtls_gcm_update( &ctx, ciphertext, cfg->plaintext_length, output, 0, &olen) == 0 ); TEST_ASSERT(mbedtls_gcm_finish( &ctx, NULL, 0, &olen, tag_buf_decrypt, cfg->tag_len) == 0 ); /* mbedtls_gcm_auth_decrypt already checks tag so only needed for AES_GCM_TEST_START_UPDATE_FINISH */ @@ -439,7 +439,7 @@ TEST_CASE("mbedtls AES GCM performance, start, update, ret", "[aes-gcm]") TEST_ASSERT(mbedtls_gcm_starts( &ctx, MBEDTLS_AES_ENCRYPT, iv, sizeof(iv) ) == 0 ); TEST_ASSERT(mbedtls_gcm_update_ad( &ctx, aad, sizeof(aad)) == 0 ); - TEST_ASSERT(mbedtls_gcm_update( &ctx, buf, CALL_SZ, buf, 0, NULL) == 0 ); + TEST_ASSERT(mbedtls_gcm_update( &ctx, buf, CALL_SZ, buf, 0, &olen) == 0 ); TEST_ASSERT(mbedtls_gcm_finish( &ctx, NULL, 0, &olen, tag_buf, 16 ) == 0 ); elapsed_usec = ccomp_timer_stop(); From e0f31edab58a5fee0e4e1ae52d1e1500d152dc50 Mon Sep 17 00:00:00 2001 From: "harshal.patil" Date: Thu, 8 Dec 2022 17:13:03 +0530 Subject: [PATCH 2/6] test_aes_gcm: fix output_size paramter in mbedtls_get_update() mbedtls_get_update() returned MBEDTLS_ERR_GCM_BUFFER_TOO_SMALL, as 0 used to get passed in the output_size paramter. --- components/mbedtls/test_apps/main/test_aes_gcm.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/components/mbedtls/test_apps/main/test_aes_gcm.c b/components/mbedtls/test_apps/main/test_aes_gcm.c index 3b0e5cb97bc..48658eb3ae2 100644 --- a/components/mbedtls/test_apps/main/test_aes_gcm.c +++ b/components/mbedtls/test_apps/main/test_aes_gcm.c @@ -110,7 +110,7 @@ TEST_CASE("mbedtls GCM stream test", "[aes-gcm]") for (int idx = 0; idx < SZ; idx = idx + bytes_to_process) { // Limit length of last call to avoid exceeding buffer size size_t length = (idx + bytes_to_process > SZ) ? (SZ - idx) : bytes_to_process; - mbedtls_gcm_update(&ctx, plaintext + idx, length, ciphertext + idx, 0, &olen); + mbedtls_gcm_update(&ctx, plaintext + idx, length, ciphertext + idx, length, &olen); } mbedtls_gcm_finish( &ctx, NULL, 0, &olen, tag, sizeof(tag) ); TEST_ASSERT_EQUAL_HEX8_ARRAY(expected_cipher, ciphertext, SZ); @@ -129,7 +129,7 @@ TEST_CASE("mbedtls GCM stream test", "[aes-gcm]") // Limit length of last call to avoid exceeding buffer size size_t length = (idx + bytes_to_process > SZ) ? (SZ - idx) : bytes_to_process; - mbedtls_gcm_update(&ctx, ciphertext + idx, length, decryptedtext + idx, 0, &olen); + mbedtls_gcm_update(&ctx, ciphertext + idx, length, decryptedtext + idx, length, &olen); } mbedtls_gcm_finish( &ctx, NULL, 0, &olen, tag, sizeof(tag) ); TEST_ASSERT_EQUAL_HEX8_ARRAY(plaintext, decryptedtext, SZ); @@ -199,7 +199,7 @@ static void aes_gcm_test(aes_gcm_test_cfg_t *cfg, aes_gcm_test_expected_res_t *r } else if (aes_gcm_type == AES_GCM_TEST_START_UPDATE_FINISH) { TEST_ASSERT(mbedtls_gcm_starts( &ctx, MBEDTLS_AES_ENCRYPT, iv_buf, cfg->iv_length) == 0 ); TEST_ASSERT(mbedtls_gcm_update_ad( &ctx, cfg->add_buf, cfg->add_length) == 0 ); - TEST_ASSERT(mbedtls_gcm_update( &ctx, cfg->plaintext, cfg->plaintext_length, ciphertext, 0, &olen) == 0 ); + TEST_ASSERT(mbedtls_gcm_update( &ctx, cfg->plaintext, cfg->plaintext_length, ciphertext, cfg->plaintext_length, &olen) == 0 ); TEST_ASSERT(mbedtls_gcm_finish( &ctx, NULL, 0, &olen, tag_buf_encrypt, cfg->tag_len) == 0 ); } size_t offset = cfg->plaintext_length > 16 ? cfg->plaintext_length - 16 : 0; @@ -214,7 +214,7 @@ static void aes_gcm_test(aes_gcm_test_cfg_t *cfg, aes_gcm_test_expected_res_t *r } else if (aes_gcm_type == AES_GCM_TEST_START_UPDATE_FINISH) { TEST_ASSERT(mbedtls_gcm_starts( &ctx, MBEDTLS_AES_DECRYPT, iv_buf, cfg->iv_length) == 0 ); TEST_ASSERT(mbedtls_gcm_update_ad( &ctx, cfg->add_buf, cfg->add_length) == 0 ); - TEST_ASSERT(mbedtls_gcm_update( &ctx, ciphertext, cfg->plaintext_length, output, 0, &olen) == 0 ); + TEST_ASSERT(mbedtls_gcm_update( &ctx, ciphertext, cfg->plaintext_length, output, cfg->plaintext_length, &olen) == 0 ); TEST_ASSERT(mbedtls_gcm_finish( &ctx, NULL, 0, &olen, tag_buf_decrypt, cfg->tag_len) == 0 ); /* mbedtls_gcm_auth_decrypt already checks tag so only needed for AES_GCM_TEST_START_UPDATE_FINISH */ @@ -222,7 +222,7 @@ static void aes_gcm_test(aes_gcm_test_cfg_t *cfg, aes_gcm_test_expected_res_t *r } TEST_ASSERT_EQUAL_HEX8_ARRAY(cfg->plaintext, output, cfg->plaintext_length); - + mbedtls_gcm_free( &ctx ); free(ciphertext); free(output); } @@ -439,7 +439,7 @@ TEST_CASE("mbedtls AES GCM performance, start, update, ret", "[aes-gcm]") TEST_ASSERT(mbedtls_gcm_starts( &ctx, MBEDTLS_AES_ENCRYPT, iv, sizeof(iv) ) == 0 ); TEST_ASSERT(mbedtls_gcm_update_ad( &ctx, aad, sizeof(aad)) == 0 ); - TEST_ASSERT(mbedtls_gcm_update( &ctx, buf, CALL_SZ, buf, 0, &olen) == 0 ); + TEST_ASSERT(mbedtls_gcm_update( &ctx, buf, CALL_SZ, buf, CALL_SZ, &olen) == 0 ); TEST_ASSERT(mbedtls_gcm_finish( &ctx, NULL, 0, &olen, tag_buf, 16 ) == 0 ); elapsed_usec = ccomp_timer_stop(); From 06bb0ee077f71c5276058a2689d4d6af8880133a Mon Sep 17 00:00:00 2001 From: "harshal.patil" Date: Wed, 7 Dec 2022 14:22:52 +0530 Subject: [PATCH 3/6] mbedtls: added SOC_AES_SUPPORT_AES_192 check in esp_aes_gcm_setkey() --- components/mbedtls/port/aes/esp_aes_gcm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/mbedtls/port/aes/esp_aes_gcm.c b/components/mbedtls/port/aes/esp_aes_gcm.c index 31e5835fe30..873f14fea2f 100644 --- a/components/mbedtls/port/aes/esp_aes_gcm.c +++ b/components/mbedtls/port/aes/esp_aes_gcm.c @@ -28,6 +28,7 @@ #include "esp_heap_caps.h" #include "soc/soc_memory_layout.h" +#include "mbedtls/error.h" #include #define ESP_PUT_BE64(a, val) \ @@ -245,6 +246,11 @@ int esp_aes_gcm_setkey( esp_gcm_context *ctx, const unsigned char *key, unsigned int keybits ) { +#if !SOC_AES_SUPPORT_AES_192 + if (keybits == 192) { + return MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED; + } +#endif if (keybits != 128 && keybits != 192 && keybits != 256) { return MBEDTLS_ERR_AES_INVALID_KEY_LENGTH; } From 48840d04f08579c15de62dc418690c6afda3b2f9 Mon Sep 17 00:00:00 2001 From: "harshal.patil" Date: Thu, 8 Dec 2022 10:26:25 +0530 Subject: [PATCH 4/6] mbedtls: fix esp_aes_crypt_ctr writing to null stream block --- components/mbedtls/port/aes/esp_aes_gcm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/mbedtls/port/aes/esp_aes_gcm.c b/components/mbedtls/port/aes/esp_aes_gcm.c index 873f14fea2f..13be7f4e552 100644 --- a/components/mbedtls/port/aes/esp_aes_gcm.c +++ b/components/mbedtls/port/aes/esp_aes_gcm.c @@ -496,6 +496,7 @@ int esp_aes_gcm_finish( esp_gcm_context *ctx, { size_t nc_off = 0; uint8_t len_block[AES_BLOCK_BYTES] = {0}; + uint8_t stream[AES_BLOCK_BYTES] = {0}; if ( tag_len > 16 || tag_len < 4 ) { return ( MBEDTLS_ERR_GCM_BAD_INPUT ); @@ -507,7 +508,7 @@ int esp_aes_gcm_finish( esp_gcm_context *ctx, esp_gcm_ghash(ctx, len_block, AES_BLOCK_BYTES, ctx->ghash); /* Tag T = GCTR(J0, ) where T is truncated to tag_len */ - esp_aes_crypt_ctr(&ctx->aes_ctx, tag_len, &nc_off, ctx->ori_j0, 0, ctx->ghash, tag); + esp_aes_crypt_ctr(&ctx->aes_ctx, tag_len, &nc_off, ctx->ori_j0, stream, ctx->ghash, tag); return 0; } From f9f10c2590b9c0e0267fdc3c538c3ed401cb3eb0 Mon Sep 17 00:00:00 2001 From: "harshal.patil" Date: Fri, 23 Dec 2022 16:18:33 +0530 Subject: [PATCH 5/6] mbedtls: fix `esp_aes_gcm_update_ad()` API implementation --- components/mbedtls/port/aes/esp_aes_gcm.c | 29 +++++++++++------------ 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/components/mbedtls/port/aes/esp_aes_gcm.c b/components/mbedtls/port/aes/esp_aes_gcm.c index 13be7f4e552..fea793ada1c 100644 --- a/components/mbedtls/port/aes/esp_aes_gcm.c +++ b/components/mbedtls/port/aes/esp_aes_gcm.c @@ -352,6 +352,8 @@ int esp_aes_gcm_starts( esp_gcm_context *ctx, /* Initialize AES-GCM context */ memset(ctx->ghash, 0, sizeof(ctx->ghash)); ctx->data_len = 0; + ctx->aad = NULL; + ctx->aad_len = 0; ctx->iv = iv; ctx->iv_len = iv_len; @@ -371,6 +373,15 @@ int esp_aes_gcm_starts( esp_gcm_context *ctx, gcm_gen_table(ctx); } + /* Once H is obtained we need to derive J0 (Initial Counter Block) */ + esp_gcm_derive_J0(ctx); + + /* The initial counter block keeps updating during the esp_gcm_update call + * however to calculate final authentication tag T we need original J0 + * so we make a copy here + */ + memcpy(ctx->ori_j0, ctx->J0, 16); + ctx->gcm_state = ESP_AES_GCM_STATE_START; return ( 0 ); @@ -395,26 +406,14 @@ int esp_aes_gcm_update_ad( esp_gcm_context *ctx, return -1; } - /* Initialize AES-GCM context */ - memset(ctx->ghash, 0, sizeof(ctx->ghash)); - ctx->data_len = 0; - - ctx->aad = aad; - ctx->aad_len = aad_len; - if (ctx->gcm_state != ESP_AES_GCM_STATE_START) { ESP_LOGE(TAG, "AES context in invalid state!"); return -1; } - /* Once H is obtained we need to derive J0 (Initial Counter Block) */ - esp_gcm_derive_J0(ctx); - - /* The initial counter block keeps updating during the esp_gcm_update call - * however to calculate final authentication tag T we need original J0 - * so we make a copy here - */ - memcpy(ctx->ori_j0, ctx->J0, 16); + /* Initialise associated data */ + ctx->aad = aad; + ctx->aad_len = aad_len; esp_gcm_ghash(ctx, ctx->aad, ctx->aad_len, ctx->ghash); From 5c93fe47cb60d4a7dd57a4859a9ddb9e5de3746d Mon Sep 17 00:00:00 2001 From: LiPeng Date: Tue, 28 Jun 2022 11:19:58 +0800 Subject: [PATCH 6/6] mbedtls: GCM implementation is replaced with CTR-based calculation - GCM operation in mbedtls used ECB, which calculated only 16 bytes of data each time. - Therefore, when processing a large amount of data, it is necessary to frequently set hardware acceleration calculations, - which could not make good use of the AES DMA function to improve efficiency. - Hence, GCM implementation is replaced with CTR-based calculation which utilizes AES DMA to improve efficiency. --- components/mbedtls/CMakeLists.txt | 2 +- components/mbedtls/port/aes/esp_aes_gcm.c | 15 +++++++++++---- components/mbedtls/port/include/gcm_alt.h | 4 +--- .../mbedtls/port/include/mbedtls/esp_config.h | 4 +--- components/mbedtls/test_apps/main/test_aes_gcm.c | 4 ++-- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/components/mbedtls/CMakeLists.txt b/components/mbedtls/CMakeLists.txt index 881c34b5ab6..bb1c11f8df5 100644 --- a/components/mbedtls/CMakeLists.txt +++ b/components/mbedtls/CMakeLists.txt @@ -219,7 +219,7 @@ if(CONFIG_MBEDTLS_HARDWARE_SHA) ) endif() -if(CONFIG_MBEDTLS_HARDWARE_GCM) +if(CONFIG_MBEDTLS_HARDWARE_GCM OR (NOT CONFIG_SOC_AES_SUPPORT_GCM AND CONFIG_MBEDTLS_HARDWARE_AES)) target_sources(mbedcrypto PRIVATE "${COMPONENT_DIR}/port/aes/esp_aes_gcm.c") endif() diff --git a/components/mbedtls/port/aes/esp_aes_gcm.c b/components/mbedtls/port/aes/esp_aes_gcm.c index fea793ada1c..6a5627b7c34 100644 --- a/components/mbedtls/port/aes/esp_aes_gcm.c +++ b/components/mbedtls/port/aes/esp_aes_gcm.c @@ -16,7 +16,6 @@ */ #include "soc/soc_caps.h" -#if SOC_AES_SUPPORT_GCM #include "aes/esp_aes.h" #include "aes/esp_aes_gcm.h" @@ -362,6 +361,7 @@ int esp_aes_gcm_starts( esp_gcm_context *ctx, /* H and the lookup table are only generated once per ctx */ if (ctx->gcm_state == ESP_AES_GCM_STATE_INIT) { /* Lock the AES engine to calculate ghash key H in hardware */ +#if SOC_AES_SUPPORT_GCM esp_aes_acquire_hardware(); 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); @@ -369,7 +369,10 @@ int esp_aes_gcm_starts( esp_gcm_context *ctx, aes_hal_gcm_calc_hash(ctx->H); esp_aes_release_hardware(); - +#else + memset(ctx->H, 0, sizeof(ctx->H)); + esp_aes_crypt_ecb(&ctx->aes_ctx, MBEDTLS_AES_ENCRYPT, ctx->H, ctx->H); +#endif gcm_gen_table(ctx); } @@ -512,6 +515,7 @@ int esp_aes_gcm_finish( esp_gcm_context *ctx, return 0; } +#if SOC_AES_SUPPORT_GCM /* Due to restrictions in the hardware (e.g. need to do the whole conversion in one go), 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, @@ -541,6 +545,7 @@ static bool esp_aes_gcm_input_support_hw_accel(size_t length, const unsigned cha return support_hw_accel; } +#endif static int esp_aes_gcm_crypt_and_tag_partial_hw( esp_gcm_context *ctx, int mode, @@ -588,6 +593,7 @@ int esp_aes_gcm_crypt_and_tag( esp_gcm_context *ctx, size_t tag_len, unsigned char *tag ) { +#if SOC_AES_SUPPORT_GCM int ret; lldesc_t aad_desc[2] = {}; lldesc_t *aad_head_desc = NULL; @@ -686,6 +692,9 @@ int esp_aes_gcm_crypt_and_tag( esp_gcm_context *ctx, esp_aes_release_hardware(); return ( ret ); +#else + return esp_aes_gcm_crypt_and_tag_partial_hw(ctx, mode, length, iv, iv_len, aad, aad_len, input, output, tag_len, tag); +#endif } @@ -723,5 +732,3 @@ int esp_aes_gcm_auth_decrypt( esp_gcm_context *ctx, return ( 0 ); } - -#endif //SOC_AES_SUPPORT_GCM diff --git a/components/mbedtls/port/include/gcm_alt.h b/components/mbedtls/port/include/gcm_alt.h index c4aa7c9925f..f76970944bc 100644 --- a/components/mbedtls/port/include/gcm_alt.h +++ b/components/mbedtls/port/include/gcm_alt.h @@ -18,7 +18,7 @@ extern "C" { #if defined(MBEDTLS_GCM_ALT) -#if SOC_AES_SUPPORT_GCM + #include "aes/esp_aes_gcm.h" @@ -34,8 +34,6 @@ typedef esp_gcm_context mbedtls_gcm_context; #define mbedtls_gcm_auth_decrypt esp_aes_gcm_auth_decrypt #define mbedtls_gcm_crypt_and_tag esp_aes_gcm_crypt_and_tag -#endif // SOC_AES_SUPPORT_GCM - #endif /* MBEDTLS_GCM_ALT */ #ifdef __cplusplus diff --git a/components/mbedtls/port/include/mbedtls/esp_config.h b/components/mbedtls/port/include/mbedtls/esp_config.h index 4a8387ba8b6..a04c62bb439 100644 --- a/components/mbedtls/port/include/mbedtls/esp_config.h +++ b/components/mbedtls/port/include/mbedtls/esp_config.h @@ -137,10 +137,8 @@ #undef MBEDTLS_AES_ALT #endif -#ifdef CONFIG_MBEDTLS_HARDWARE_GCM +#ifdef CONFIG_MBEDTLS_HARDWARE_AES #define MBEDTLS_GCM_ALT -#else -#undef MBEDTLS_GCM_ALT #endif /* MBEDTLS_SHAxx_ALT to enable hardware SHA support diff --git a/components/mbedtls/test_apps/main/test_aes_gcm.c b/components/mbedtls/test_apps/main/test_aes_gcm.c index 48658eb3ae2..3d181fd8bb2 100644 --- a/components/mbedtls/test_apps/main/test_aes_gcm.c +++ b/components/mbedtls/test_apps/main/test_aes_gcm.c @@ -17,7 +17,7 @@ #include "ccomp_timer.h" #include "sys/param.h" -#if CONFIG_MBEDTLS_HARDWARE_GCM +#if CONFIG_MBEDTLS_HARDWARE_AES /* Python example code for generating test vectors @@ -830,4 +830,4 @@ TEST_CASE("mbedtls AES GCM - Combine different IV/Key/Plaintext/AAD lengths", "[ } } -#endif //CONFIG_MBEDTLS_HARDWARE_GCM +#endif //CONFIG_MBEDTLS_HARDWARE_AES