mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-01 19:54:32 +02:00
Fix nvs_flash_generate_keys
Merges https://github.com/espressif/esp-idf/pull/6478
This commit is contained in:
@@ -571,16 +571,24 @@ extern "C" esp_err_t nvs_flash_generate_keys(const esp_partition_t* partition, n
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(uint8_t cnt = 0; cnt < NVS_KEY_SIZE; cnt++) {
|
for(uint8_t cnt = 0; cnt < NVS_KEY_SIZE; cnt++) {
|
||||||
cfg->eky[cnt] = 0xff;
|
/* Adjacent 16-byte blocks should be different */
|
||||||
cfg->tky[cnt] = 0xee;
|
if (((cnt / 16) & 1) == 0) {
|
||||||
|
cfg->eky[cnt] = 0xff;
|
||||||
|
cfg->tky[cnt] = 0xee;
|
||||||
|
} else {
|
||||||
|
cfg->eky[cnt] = 0x99;
|
||||||
|
cfg->tky[cnt] = 0x88;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_partition_write(partition, 0, cfg->eky, NVS_KEY_SIZE);
|
/* Write without encryption */
|
||||||
|
err = esp_partition_write_raw(partition, 0, cfg->eky, NVS_KEY_SIZE);
|
||||||
if(err != ESP_OK) {
|
if(err != ESP_OK) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = esp_partition_write(partition, NVS_KEY_SIZE, cfg->tky, NVS_KEY_SIZE);
|
/* Write without encryption */
|
||||||
|
err = esp_partition_write_raw(partition, NVS_KEY_SIZE, cfg->tky, NVS_KEY_SIZE);
|
||||||
if(err != ESP_OK) {
|
if(err != ESP_OK) {
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user