[kmac] Clear the entropy in StRandEdn
This commit addresses the issue #6393 reported by @udinator
As the comment in the code explains, if SW initiates a new hash
operation while the Entropy FSM is refreshing the internal entropy
(waiting for the EDN response), the logic keeps sending same entropy to
the hash logic.
This commit fixed the behavior to clear the entropy valid signal if
following logic consumes the entropy. Then, the logic will wait until
the EDN response comes back.
Signed-off-by: Eunchan Kim <eunchan@opentitan.org>
diff --git a/hw/ip/kmac/rtl/kmac_entropy.sv b/hw/ip/kmac/rtl/kmac_entropy.sv
index 818d503..8da19ab 100644
--- a/hw/ip/kmac/rtl/kmac_entropy.sv
+++ b/hw/ip/kmac/rtl/kmac_entropy.sv
@@ -501,6 +501,15 @@
storage_idx_clear = 1'b 1;
// TODO: check fips?
+ end else if (rand_consumed_i) begin
+ // Somehow, while waiting the EDN entropy, the KMAC or SHA3 logic
+ // consumed the remained entropy. This can happen when the previous
+ // SHA3/ KMAC op completed and this Entropy FSM has moved to this
+ // state to refresh the entropy and the SW initiates another hash
+ // operation while waiting for the EDN response.
+ st_d = StRandEdn;
+
+ rand_valid_clear = 1'b 1;
end else begin
st_d = StRandEdn;
end