Skip to content

Commit 591848e

Browse files
committed
[ot] hw/opentitan: ot_keymgr: Add property to disable flash seed check
Support a wider range of use cases with unprovisioned flash via an optional property that makes minimal changes to the code. Signed-off-by: Alex Jones <[email protected]>
1 parent ab75982 commit 591848e

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

hw/opentitan/ot_keymgr.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ typedef struct OtKeyMgrState {
457457
DeviceState *key_sinks[KEYMGR_KEY_SINK_COUNT];
458458
char *seed_xstrs[KEYMGR_SEED_COUNT];
459459
bool use_default_entropy_seed; /* flag to seed PRNG with default seed */
460+
bool disable_flash_seed_check; /* disable all-0/1 check for flash seeds */
460461
} OtKeyMgrState;
461462

462463
struct OtKeyMgrClass {
@@ -1095,6 +1096,18 @@ ot_keymgr_kdf_append_flash_seed(OtKeyMgrState *s, OtFlashKeyMgrSecretType type,
10951096
ot_keymgr_kdf_push_bytes(s, seed.secret, OT_FLASH_KEYMGR_SECRET_BYTES);
10961097
bool data_valid =
10971098
ot_keymgr_valid_data_check(seed.secret, OT_FLASH_KEYMGR_SECRET_BYTES);
1099+
1100+
/*
1101+
* Unprovisioned flash will not contain valid secrets, and will return all
1102+
* 1s (failing the validity check) if scrambling/ECCs are disabled. Using
1103+
* the `disable-flash-seed-check` property allows you to optionally bypass
1104+
* these errors for unprovisioned environments where flash info page
1105+
* splicing is not available.
1106+
*/
1107+
if (!data_valid && s->disable_flash_seed_check) {
1108+
trace_ot_keymgr_bypass_failure(s->ot_id, seed_name);
1109+
data_valid = true;
1110+
}
10981111
if (!seed.valid || !data_valid) {
10991112
s->regs[R_DEBUG] |= debug_mask;
11001113
s->op_state.valid_inputs = false;
@@ -2351,6 +2364,8 @@ static Property ot_keymgr_properties[] = {
23512364
seed_xstrs[KEYMGR_SEED_NONE]),
23522365
DEFINE_PROP_BOOL("use-default-entropy-seed", OtKeyMgrState,
23532366
use_default_entropy_seed, false),
2367+
DEFINE_PROP_BOOL("disable-flash-seed-check", OtKeyMgrState,
2368+
disable_flash_seed_check, false),
23542369
DEFINE_PROP_END_OF_LIST(),
23552370
};
23562371

hw/opentitan/trace-events

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ ot_ibex_wrapper_update_exec(const char *id, uint32_t bm, bool esc_rx, bool halte
280280

281281
# ot_keymgr.c
282282
ot_keymgr_advance(const char *id, const char *stage, int nstage, const char *cdi, int ncdi) "%s: [%s:%d], [%s:%d]"
283+
ot_keymgr_bypass_failure(const char *id, const char *what) "%s: bypass failure for %s due to enabled properties"
283284
ot_keymgr_change_main_fsm_state(const char *id, int line, const char *old, int nold, const char *new, int nnew) "%s: @ %d [%s:%d] -> [%s:%d]"
284285
ot_keymgr_change_op_status(const char *id, int line, const char *old, int nold, const char *new, int nnew) "%s: @ %d [%s:%d] -> [%s:%d]"
285286
ot_keymgr_change_working_state(const char *id, int line, const char *old, int nold, const char *new, int nnew) "%s: @ %d [%s:%d] -> [%s:%d]"

0 commit comments

Comments
 (0)