opentitan icon indicating copy to clipboard operation
opentitan copied to clipboard

[kmac] EDN clarifications

Open udinator opened this issue 5 years ago • 3 comments

Hi Eunchan,

I ran across a weird-ish scenario when testing EDN entropy expansion that brought up a couple of questions. The waves are below:

Screenshot from 2021-04-30 01-32-02

Context:

  • We are currently running a KMAC hash directly after running a SHAKE hash, both using the EDN for entropy, and both are SW controlled
  • Fast entropy is enabled
  • We currently have sent both CmdStart and CmdProcess to KMAC, and are currently in the middle of processing the secret key block
  • The entropy refresh operation after completing the previous SHAKE hash has not yet completed, and the entropy_ack for this operation goes high in the middle of processing the keyblock for the KMAC hash
  • Both entropy timers are disabled (set to 0)

I had a few questions that I wanted to clarify about this scenario:

  • Is it correct/expected behavior in the first place to start another hashing operation before the entropy refresh operation at the end of the previous hash has finished?
  • Although fast entropy is enabled entropy should be still fully expanded while processing the secret keys - however, as you can see from the waves for some reason we're not expanding entropy for each keccak round until the refresh operation has finished. Is this because of some side effect of not waiting for the entropy refresh operation to finish, or is there some other expected behavior here?

Thanks!

udinator avatar Apr 30 '21 09:04 udinator

It definitely is a bug. regardless of fast entropy, the keyblock should expand the entropy in every rounds. Let me dig the logic in detail.

eunchan avatar Apr 30 '21 18:04 eunchan

@eunchan sorry to reopen this one...I was looking into some more waveforms, and I'm now seeing this behavior:

Screenshot from 2021-04-30 17-37-22

Context:

  • this is the prefix processing step of a KMAC hash, following a successful SHAKE hash
  • fast entropy enabled
  • similar to the original issue, after SHAKE hash the DUT requests entropy refresh, which has not completed yet

However in this new situation after #6401 was merged, we see that the first round completed and only then does the entropy module block until fresh entropy is received from EDN. Is this a bug as well? My understanding is that no keccak round can progress until entropy is refreshed (entropy_req_o is high for the duration) so the round 0 of prefix processing itself should block until whenever EDN provides valid entropy, instead of using partial stale entropy and then waiting for partial fresh entropy.

udinator avatar May 01 '21 00:05 udinator

Yes. This behavior is intended. We could revise the FSM to be fully asynchronous (EDN request and internal entropy prep) but currently they are synchronous.

eunchan avatar May 03 '21 05:05 eunchan