40
40
#include "esp_heap_caps.h"
41
41
#include "soc/soc_memory_layout.h"
42
42
43
+ #include "mbedtls/error.h"
43
44
#include <string.h>
44
45
45
46
#define ESP_PUT_BE64 (a , val ) \
@@ -257,6 +258,11 @@ int esp_aes_gcm_setkey( esp_gcm_context *ctx,
257
258
const unsigned char * key ,
258
259
unsigned int keybits )
259
260
{
261
+ #if !SOC_AES_SUPPORT_AES_192
262
+ if (keybits == 192 ) {
263
+ return MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED ;
264
+ }
265
+ #endif
260
266
if (keybits != 128 && keybits != 192 && keybits != 256 ) {
261
267
return MBEDTLS_ERR_AES_INVALID_KEY_LENGTH ;
262
268
}
@@ -471,6 +477,7 @@ int esp_aes_gcm_finish( esp_gcm_context *ctx,
471
477
{
472
478
size_t nc_off = 0 ;
473
479
uint8_t len_block [AES_BLOCK_BYTES ] = {0 };
480
+ uint8_t stream [AES_BLOCK_BYTES ] = {0 };
474
481
475
482
if ( tag_len > 16 || tag_len < 4 ) {
476
483
return ( MBEDTLS_ERR_GCM_BAD_INPUT );
@@ -482,7 +489,7 @@ int esp_aes_gcm_finish( esp_gcm_context *ctx,
482
489
esp_gcm_ghash (ctx , len_block , AES_BLOCK_BYTES , ctx -> ghash );
483
490
484
491
/* Tag T = GCTR(J0, ) where T is truncated to tag_len */
485
- esp_aes_crypt_ctr (& ctx -> aes_ctx , tag_len , & nc_off , ctx -> ori_j0 , 0 , ctx -> ghash , tag );
492
+ esp_aes_crypt_ctr (& ctx -> aes_ctx , tag_len , & nc_off , ctx -> ori_j0 , stream , ctx -> ghash , tag );
486
493
487
494
return 0 ;
488
495
}
0 commit comments