From 5eb68975d9029f7768113c3536b8b9c5839d71c9 Mon Sep 17 00:00:00 2001 From: tychovrahe Date: Thu, 5 Sep 2024 16:18:46 +0200 Subject: [PATCH] fix(core/prodtest): fix prodtest run with unlocked bootloader [no changelog] --- core/embed/prodtest/optiga_prodtest.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/embed/prodtest/optiga_prodtest.c b/core/embed/prodtest/optiga_prodtest.c index 616a0d4465..bdcdb9f77a 100644 --- a/core/embed/prodtest/optiga_prodtest.c +++ b/core/embed/prodtest/optiga_prodtest.c @@ -143,6 +143,12 @@ void pair_optiga(void) { uint8_t secret[SECRET_OPTIGA_KEY_LEN] = {0}; if (secret_optiga_get(secret) != sectrue) { + if (secret_optiga_writable() != sectrue) { + // optiga pairing secret is unwritable, so fail + optiga_pairing_state = OPTIGA_PAIRING_ERR_WRITE_FLASH; + return; + } + // Generate the pairing secret. if (OPTIGA_SUCCESS != optiga_get_random(secret, sizeof(secret))) { optiga_pairing_state = OPTIGA_PAIRING_ERR_RNG;