mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'fix/mbedtls_port_sanity_checks_and_return_values_v4.4' into 'release/v4.4'
mbedtls/port: refactor sanity checks and their return values (v4.4) See merge request espressif/esp-idf!22128
This commit is contained in:
commit
0e4c086a35
@ -991,6 +991,11 @@ int esp_aes_crypt_ctr(esp_aes_context *ctx,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!stream_block) {
|
||||
ESP_LOGE(TAG, "No stream supplied");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!nonce_counter) {
|
||||
ESP_LOGE(TAG, "No nonce supplied");
|
||||
return -1;
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "esp_heap_caps.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
|
||||
#include "mbedtls/error.h"
|
||||
#include <string.h>
|
||||
|
||||
#define ESP_PUT_BE64(a, val) \
|
||||
@ -257,6 +258,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;
|
||||
}
|
||||
@ -471,6 +477,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 );
|
||||
@ -482,7 +489,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