Skip to content

Commit b4472f9

Browse files
committed
[ot] hw/opentitan: ot_flash: Fix keymgr secret seed reads
It turns out I completely misunderstood how `ot_fifo32_pop_buf` worked and had mistakenly conflated it with the current `fifo8_pop_buf` function which has a different signature. Correctly read out the flash secret by repeatedly popping the correct number of words out of the FIFO instead. Signed-off-by: Alex Jones <[email protected]>
1 parent 929d7bc commit b4472f9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

hw/opentitan/ot_flash.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1937,8 +1937,13 @@ static void ot_flash_read_keymgr_seed(OtFlashState *s, unsigned page,
19371937

19381938
ot_flash_op_start(s);
19391939

1940-
uint32_t seed_words[FLASH_SEED_WORDS] = { 0 };
1941-
ot_fifo32_pop_buf(&s->hw_rd_fifo, FLASH_SEED_WORDS, seed_words);
1940+
uint32_t words_read = ot_fifo32_num_used(&s->hw_rd_fifo);
1941+
g_assert(words_read == FLASH_SEED_WORDS);
1942+
1943+
uint32_t seed_words[FLASH_SEED_WORDS];
1944+
for (size_t ix = 0; ix < FLASH_SEED_WORDS; ix++) {
1945+
seed_words[ix] = ot_fifo32_pop(&s->hw_rd_fifo);
1946+
}
19421947
memcpy(seed->secret, seed_words, FLASH_SEED_BYTES);
19431948
seed->valid = !s->op.failed;
19441949

0 commit comments

Comments
 (0)