unable to read efuse key block after writing
Posted: Fri Dec 02, 2022 9:42 pm
Hello,
I am currently working on generating and storing a 256-bit key in eFuse key block 0. I am using the ESP32S3. My goal is to store a key in efuse with the upstream purpose (ESP_EFUSE_KEY_PURPOSE_HMAC_UP), use it for HMAC calculation, as well as read the key from eFuses when necessary.
Here is the approach I use to generate and program the key:
Running this code produced this log message:
I tested writing keys with these settings using the virtual efuse manager before using hardware efuses, and the virtual efuses behaved as expected. I was able to read keys after burning fuses. I would like to achieve this same result with hardware fuses if possible. Thanks in advance for your help!
I am currently working on generating and storing a 256-bit key in eFuse key block 0. I am using the ESP32S3. My goal is to store a key in efuse with the upstream purpose (ESP_EFUSE_KEY_PURPOSE_HMAC_UP), use it for HMAC calculation, as well as read the key from eFuses when necessary.
Here is the approach I use to generate and program the key:
- Fill a 32-byte buffer with random data with esp_fill_random
- write this 32-byte key to efuse block KEY0 with HMAC UPSTREAM purpose, using esp_efuse_write_key
- set key write disabled bit to prevent modifications using esp_efuse_set_key_dis_write
- set key purpose write disabled bit to prevent modifications using esp_efuse_set_keypurpose_dis_write
Code: Select all
bool unused = esp_efuse_key_block_unused(SECRET_KEY_EFUSE_BLOCK);
bool empty = esp_efuse_block_is_empty(SECRET_KEY_EFUSE_BLOCK);
esp_efuse_purpose_t purpose = esp_efuse_get_key_purpose(SECRET_KEY_EFUSE_BLOCK);
bool wprot = esp_efuse_get_key_dis_write(SECRET_KEY_EFUSE_BLOCK);
bool rprot = esp_efuse_get_key_dis_read(SECRET_KEY_EFUSE_BLOCK);
logw("unused:%d empty:%d purpose:%d wprotect:%d rprotect:%d", unused, empty, purpose, wprot, rprot);
So somehow the read protection bit is being set. Do you know why the read protection bit is set when writing a key? Is there any way to avoid disabling user read functionality while enabling HMAC upstream mode?unused:0 empty:1 purpose:8 wprotect:1 rprotect:1
I tested writing keys with these settings using the virtual efuse manager before using hardware efuses, and the virtual efuses behaved as expected. I was able to read keys after burning fuses. I would like to achieve this same result with hardware fuses if possible. Thanks in advance for your help!