From 6fe0501b2954d4018ebe0167a06e4a2fede84301 Mon Sep 17 00:00:00 2001 From: Andrea Caforio Date: Wed, 18 Dec 2024 15:34:49 +0100 Subject: [PATCH] [hmac, rtl] Do not skip padding after a hash stop command This commit removes some conditional FSM states transition that were deemed undesirable in `prim_sha2_pad`, see #23936. They made it possible to cancel an ongoing padding operation, which is disallowed by the HMAC module. This change makes it impossible to transition into the `StFifoReceive` state from either `StPad80`, `StPad00`, `StLenHi` or `StLenLo` by asserting the `hash_go` signal. Signed-off-by: Andrea Caforio --- hw/ip/prim/rtl/prim_sha2_pad.sv | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/ip/prim/rtl/prim_sha2_pad.sv b/hw/ip/prim/rtl/prim_sha2_pad.sv index 1dc010dfefabe..242698d7b0f27 100644 --- a/hw/ip/prim/rtl/prim_sha2_pad.sv +++ b/hw/ip/prim/rtl/prim_sha2_pad.sv @@ -337,8 +337,13 @@ module prim_sha2_pad import prim_sha2_pkg::*; end endcase - if (!sha_en_i) st_d = StIdle; - else if (hash_go) st_d = StFifoReceive; + if (!sha_en_i) begin + st_d = StIdle; + // We do not allow the cancellation of an ongoing padding operation, i.e., reverting back to the + // `StFifoReceive` state while being in the states `StPad80`, `StPad00`, `StLenHi` or `StLenLo`. + end else if (hash_go && (st_q == StIdle || st_q == StFifoReceive)) begin + st_d = StFifoReceive; + end end // tx_count