mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-06-06 05:14:45 +00:00
Merge branch 'nimble/mbedtls_aes_free_dma' into 'nimble-1.3.0-idf'
NimBLE: Free the AES context after use by calling `mbetls_aes_free` (Needed for C3) See merge request espressif/esp-nimble!64
This commit is contained in:
@@ -120,13 +120,16 @@ bt_encrypt_be(const uint8_t *key, const uint8_t *plaintext, uint8_t *enc_data)
|
||||
mbedtls_aes_init(&s);
|
||||
|
||||
if (mbedtls_aes_setkey_enc(&s, key, 128) != 0) {
|
||||
mbedtls_aes_free(&s);
|
||||
return BLE_HS_EUNKNOWN;
|
||||
}
|
||||
|
||||
if (mbedtls_aes_crypt_ecb(&s, MBEDTLS_AES_ENCRYPT, plaintext, enc_data) != 0) {
|
||||
mbedtls_aes_free(&s);
|
||||
return BLE_HS_EUNKNOWN;
|
||||
}
|
||||
|
||||
mbedtls_aes_free(&s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,14 +88,18 @@ ble_sm_alg_encrypt(const uint8_t *key, const uint8_t *plaintext,
|
||||
|
||||
mbedtls_aes_init(&s);
|
||||
if (mbedtls_aes_setkey_enc(&s, tmp, 128) != 0) {
|
||||
mbedtls_aes_free(&s);
|
||||
return BLE_HS_EUNKNOWN;
|
||||
}
|
||||
|
||||
swap_buf(tmp, plaintext, 16);
|
||||
|
||||
if (mbedtls_aes_crypt_ecb(&s, MBEDTLS_AES_ENCRYPT, tmp, enc_data) != 0) {
|
||||
mbedtls_aes_free(&s);
|
||||
return BLE_HS_EUNKNOWN;
|
||||
}
|
||||
|
||||
mbedtls_aes_free(&s);
|
||||
#else
|
||||
struct tc_aes_key_sched_struct s;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user