Aes CBC crashes
Posted: Mon Jul 09, 2018 2:13 pm
This is my code but it crashes:
It gave me this error:
Can you say where I made a mistake?
Code: Select all
mbedtls_aes_context aes;
size_t _length = 16;
unsigned char iv[16] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
unsigned char key[16] = {0xff, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
unsigned char input[16] = "HelloEsp32AES**";
unsigned char encrypt_output[48];
unsigned char decrypt_output[48];
void app_main()
{
int temp = nvs_flash_init();
if (temp == ESP_ERR_NVS_NO_FREE_PAGES) {
ESP_ERROR_CHECK(nvs_flash_erase());
temp = nvs_flash_init();
}
memset(encrypt_output, 0, 48);
memset(decrypt_output, 0, 48);
size_t iv_offset = 0;
mbedtls_aes_init(&aes);
mbedtls_aes_setkey_enc(&aes, key, 128);
mbedtls_aes_crypt_cfb128(&aes, MBEDTLS_AES_ENCRYPT, 128, &iv_offset, iv, input, encrypt_output);
mbedtls_aes_free(&aes);
}
Code: Select all
Guru Meditation Error: Core 0 panic'ed (StoreProhibited)
. Exception was unhandled.