Code: Select all
esp-aes: Failed to allocate memory
Some data to locate chip and idf ver:
Code: Select all
I (1063) cpu_start: ESP-IDF: 4.4.5
I (1068) cpu_start: Min chip rev: v0.0
I (1073) cpu_start: Max chip rev: v1.99
I (1078) cpu_start: Chip rev: v0.0
I (1082) heap_init: Initializing. RAM available for dynamic allocation:
I (1090) heap_init: At 3FFD5EE0 len 00026120 (152 KiB): DRAM
I (1096) heap_init: At 3FFFC000 len 00003A10 (14 KiB): DRAM
I (1102) heap_init: At 3FF9E000 len 00002000 (8 KiB): RTCRAM
I (1109) spiram: Adding pool of 2048K of external SPI memory to heap allocator
Code: Select all
int aes256_hw_accel_crypt(
unsigned char* plaintext, int plaintext_len, unsigned char* key,
unsigned char* iv, unsigned char* ciphertext)
{
int res;
esp_aes_context ctx;
esp_aes_init(&ctx);
esp_aes_setkey(&ctx, key, 256);
res = esp_aes_crypt_cbc(
&ctx,
ESP_AES_ENCRYPT,
plaintext_len,
iv,
(uint8_t*)plaintext,
(uint8_t*)ciphertext);
esp_aes_free(&ctx);
if (res == 0)
{
return plaintext_len;
}
return 0;
}
int aes256_hw_accel_decrypt(
unsigned char* ciphertext, int ciphertext_len, unsigned char* key,
unsigned char* iv, unsigned char* plaintext)
{
int res;
esp_aes_context ctx;
esp_aes_init(&ctx);
esp_aes_setkey(&ctx, key, 256);
res = esp_aes_crypt_cbc(
&ctx,
ESP_AES_DECRYPT,
ciphertext_len,
iv,
(uint8_t*)ciphertext,
(uint8_t*)plaintext);
esp_aes_free(&ctx);
if (res == 0)
{
return ciphertext_len;
}
return 0;
}
Thanks in advice