From 48840d04f08579c15de62dc418690c6afda3b2f9 Mon Sep 17 00:00:00 2001 From: "harshal.patil" Date: Thu, 8 Dec 2022 10:26:25 +0530 Subject: [PATCH] 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 873f14fea2..13be7f4e55 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; }