From 52437b1fc838f7d1aed2a5ad40cd0954f07bbd6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Vejpustek?= Date: Fri, 19 Jul 2024 13:31:54 +0200 Subject: [PATCH] feat(core): improve optiga initialization error handling [no changelog] --- core/embed/firmware/main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/embed/firmware/main.c b/core/embed/firmware/main.c index 253cc00eec..4785fce6dd 100644 --- a/core/embed/firmware/main.c +++ b/core/embed/firmware/main.c @@ -228,11 +228,17 @@ int main(void) { #endif optiga_init(); - optiga_open_application(); if (sectrue == secret_ok) { - optiga_sec_chan_handshake(secret, sizeof(secret)); + // If the shielded connection cannot be established, reset Optiga and + // continue without it. In this case, OID_KEY_FIDO and OID_KEY_DEV cannot be + // used, which means device and FIDO attestation will not work. + if (optiga_sec_chan_handshake(secret, sizeof(secret)) != OPTIGA_SUCCESS) { + optiga_soft_reset(); + } } memzero(secret, sizeof(secret)); + ensure(sectrue * (optiga_open_application() == OPTIGA_SUCCESS), + "Cannot initialize optiga."); #endif #if !defined TREZOR_MODEL_1