From 730e76af756e899775727583daba794fb9b09dcf Mon Sep 17 00:00:00 2001 From: Pol Henarejos Date: Sun, 10 Nov 2024 01:07:31 +0100 Subject: [PATCH] Enable OTP master key for ESP32-S3. Signed-off-by: Pol Henarejos --- src/fido/fido.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/fido/fido.c b/src/fido/fido.c index 67a3a1e..e59d3c2 100644 --- a/src/fido/fido.c +++ b/src/fido/fido.c @@ -188,11 +188,9 @@ int load_keydev(uint8_t *key) { } else { memcpy(key, file_get_data(ef_keydev), file_get_size(ef_keydev)); -#ifdef PICO_RP2350 - if (aes_decrypt(otp_key_1, NULL, 32 * 8, PICO_KEYS_AES_MODE_CBC, key, 32) != PICOKEY_OK) { + if (otp_key_1 && aes_decrypt(otp_key_1, NULL, 32 * 8, PICO_KEYS_AES_MODE_CBC, key, 32) != PICOKEY_OK) { return PICOKEY_EXEC_ERROR; } -#endif } //return mkek_decrypt(key, file_get_size(ef_keydev)); @@ -303,9 +301,9 @@ int scan_files() { if (ret != PICOKEY_OK) { return ret; } -#ifdef PICO_RP2350 - ret = aes_encrypt(otp_key_1, NULL, 32 * 8, PICO_KEYS_AES_MODE_CBC, kdata, 32); -#endif + if (otp_key_1) { + ret = aes_encrypt(otp_key_1, NULL, 32 * 8, PICO_KEYS_AES_MODE_CBC, kdata, 32); + } ret = file_put_data(ef_keydev, kdata, (uint16_t)key_size); mbedtls_platform_zeroize(kdata, sizeof(kdata)); mbedtls_ecdsa_free(&ecdsa);