[kmac] switching entropy modes
Hi Eunchan,
The small wave snippet shown below is from the start of a SHAKE128 test iteration, where I have just written the CFG CSR to switch from EDN to SW entropy - however, this happens in the middle of the EDN entropy refreshing request from the previously completed hash operation.

As you can see even though the mode_i detects that the new entropy mode is from SW, the state machine remains in the EDN states.
This causes the first keccak round to block until EDN request returns, even though the SW entropy is immediately available.
Is there any requirement that entropy mode can only be switched from EDN to SW once a refreshing operation has completed, or is this an issue in the design?
Thanks, Udi
I expected SW to configure any CFG register fields when the KMAC IP is in idle state. Currently, there's no way to exit from RandEdn except the timer expire.
Maybe it is worth to check if Edn has a way to flush out current pending request? If not, I should consider adding emergency break from RandEdn by SW (not sure this is good idea or not). Or as a W/A, SW may set expire timer while in RandEdn state.
This scenario is with all timers disabled - to me, it makes sense to short-circuit from RandEdn to RandSw, but I don't know if there would be any major security/functional issues with doing this.
Maybe it is worth to check if Edn has a way to flush out current pending request?
I don't think this is possible given the current FSM design - it looks like we can only move from StRandEdn to either timer expiration, or entropy expansion.
I don't think this is possible given the current FSM design - it looks like we can only move from StRandEdn to either timer expiration, or entropy expansion.
I assume "current FSM design" is the FSM in EDN IP?
In KMAC, yes you are right. only receiving ack from EDN or timer expire lets FSM move to the next state.
I assume "current FSM design" is the FSM in EDN IP?
Sorry I should have been more clear - I mean the FSM in kmac_entropy.sv.
I assume "current FSM design" is the FSM in EDN IP?
Sorry I should have been more clear - I mean the FSM in
kmac_entropy.sv.
yeah right. KMAC has only the two options at this time. What I mentioned in the original comment was if the EDN IP has a way to flush in case of KMAC not receiving the response.
ahh got it, sorry for confusion - I think that's a good idea.
even if the EDN can flush requests, shouldn't kmac_entropy still support exiting RandEdn states if a sudden switch is made to SW entropy?
since even if the EDN can flush the request when KMAC goes into SwEntropy mode, I feel like keccak shouldn't have to wait until external module clears the spurious request - wdyt?
I think, the expire timer is a way to achieve that. If there's any chance the SW need to switch to SW Entropy mode, they should set EDN timer in the initialization function.
If SW needs to switch to SW Entropy mode, it means somehow EDN has a chance to be stuck. That is what EDN Wait timer is made for.
Hmm that makes sense, so SW entropy is sort of a backup for the EDN entropy. I'll update the existing tests accordingly until I implement the timer functionality in scoreboard. Thanks for the clarifications!
adding @cindychip for visibility