opentitan icon indicating copy to clipboard operation
opentitan copied to clipboard

[kmac] incorrect entropy configuration after previously completed hashes

Open udinator opened this issue 5 years ago • 8 comments

Hi Eunchan,

I see the following when I incorrectly configure entropy_mode after a previous hashing operation has already completed:

Screenshot from 2021-06-04 03-38-34

The entropy FSM stays in StRandReady after completing the previous hash, so when I write EntropyModeNone to the CFG csr the entropy module never detects a configuration error here, which seems to be incorrect.

WDYT?

udinator avatar Jun 04 '21 10:06 udinator

Thanks for the issue. The current entropy FSM only checks the mode when the SW sets entropy_ready bit. I think, it is good to move FSM back to StReset when SW clears the entropy_ready so that it can check the mode again.

And latch the Entropy mode only when it moves from StReset to other state so that the seed cannot be abruptly changed to '0 in case of EntropyModeNone while operating.

eunchan avatar Jul 08 '21 23:07 eunchan

One issue I am thinking of: If we ever let the state machine back to StReset, then the entropy module generates dummy entropy to the following modules. It is mainly for ROM_CTRL to check the rom image when no entropy_src , csrng, edn are ready. Issue #6285 describes it.

So, I think we just stick to whatever programmed when the FSM is out from StReset and never go back. WDYT @udinator ?

eunchan avatar Jul 12 '21 18:07 eunchan

hmm. That makes sense to me - so we would just configure an entropy mode once per reset.

udinator avatar Jul 12 '21 20:07 udinator

adding @cindychip for visibility

udinator avatar Oct 08 '21 00:10 udinator

@eunchan i think this was already fixed? could you close if that's the case?

tjaychen avatar Feb 07 '22 20:02 tjaychen

@eunchan sorry for being late for the discussion. I totally agree with the conclusion - "So, I think we just stick to whatever programmed when the FSM is out from StReset and never go back."

Just to clarify: Basically we cannot change the entropy_mode unless 1). KMAC being reset 2). In error states with err_processed issued.

Do you think we should document it in KMAC spec to clarify the behavior? Thanks, Cindy

cindychip avatar Feb 08 '22 00:02 cindychip

OK. Let me add that to register spec.

eunchan avatar Feb 08 '22 01:02 eunchan

Thanks Eunchan, appreciate it :)

cindychip avatar Feb 08 '22 01:02 cindychip