mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
mbedtls: fix esp_aes_crypt_ctr writing to null stream block
This commit is contained in:
parent
06bb0ee077
commit
48840d04f0
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user