mirror of
https://github.com/espressif/esp-idf.git
synced 2026-08-18 06:35:35 +03:00
Merge branch 'fix/nvs-encrypted-partition-destructor-zeroize' into 'master'
fix(nvs_flash): zeroize XTS contexts when encrypted partition is destroyed See merge request espressif/esp-idf!47585
This commit is contained in:
@@ -13,12 +13,28 @@ namespace nvs {
|
||||
|
||||
#ifdef CONFIG_NVS_BDL_STACK
|
||||
NVSEncryptedPartition::NVSEncryptedPartition(const char* label, const esp_blockdev_handle_t bdl, const bool managed_bdl)
|
||||
: NVSPartition(label, bdl, managed_bdl) { }
|
||||
: NVSPartition(label, bdl, managed_bdl)
|
||||
{
|
||||
XTS_FUNC(xts_init)(&mEctxt);
|
||||
XTS_FUNC(xts_init)(&mDctxt);
|
||||
}
|
||||
#else
|
||||
NVSEncryptedPartition::NVSEncryptedPartition(const esp_partition_t *partition)
|
||||
: NVSPartition(partition) { }
|
||||
: NVSPartition(partition)
|
||||
{
|
||||
XTS_FUNC(xts_init)(&mEctxt);
|
||||
XTS_FUNC(xts_init)(&mDctxt);
|
||||
}
|
||||
#endif // CONFIG_NVS_BDL_STACK
|
||||
|
||||
NVSEncryptedPartition::~NVSEncryptedPartition()
|
||||
{
|
||||
/* Wipe AES round keys derived from the NVS encryption key so they are not
|
||||
* left in DRAM after the partition object is destroyed. */
|
||||
XTS_FUNC(xts_free)(&mEctxt);
|
||||
XTS_FUNC(xts_free)(&mDctxt);
|
||||
}
|
||||
|
||||
esp_err_t NVSEncryptedPartition::init(nvs_sec_cfg_t* cfg)
|
||||
{
|
||||
uint8_t* eky = reinterpret_cast<uint8_t*>(cfg);
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
NVSEncryptedPartition(const esp_partition_t *partition);
|
||||
#endif
|
||||
|
||||
virtual ~NVSEncryptedPartition() { }
|
||||
virtual ~NVSEncryptedPartition();
|
||||
|
||||
/**
|
||||
* Initializes the AES encryption components with the provided configuration.
|
||||
|
||||
Reference in New Issue
Block a user