Skip to content

Commit

Permalink
[hmac,dv] Wipe secret assertions
Browse files Browse the repository at this point in the history
- add multiple assertions to ensure that the specified internal
variables are cleared when a wipe secret operation is triggered.

Signed-off-by: Martin Velay <[email protected]>
  • Loading branch information
martin-velay committed Dec 17, 2024
1 parent ee23638 commit 818af47
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hw/ip/hmac/rtl/hmac.sv
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,11 @@ module hmac
`ASSERT(ValidHmacEnConditionAssert,
hmac_en != $past(hmac_en) |-> !in_process && !initiated)

// When wipe_secret is triggered, clear sensitive internal variables by extending the wipe
// value specifed in the register
`ASSERT(WipeSecretKeyAssert,
wipe_secret |=> (secret_key == {($bits(secret_key)/$bits(wipe_v)){$past(wipe_v,1)}}))

// All outputs should be known value after reset
`ASSERT_KNOWN(IntrHmacDoneOKnown, intr_hmac_done_o)
`ASSERT_KNOWN(IntrFifoEmptyOKnown, intr_fifo_empty_o)
Expand Down
29 changes: 29 additions & 0 deletions hw/ip/prim/rtl/prim_sha2.sv
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,20 @@ module prim_sha2 import prim_sha2_pkg::*;
// assign digest to output
assign digest_o = digest_q;

`ifndef VERILATOR
`ifndef SYNTHESIS

// When wipe_secret is triggered, clear sensitive internal variables by extending the wipe
// value specifed in the register
`ASSERT(WipeHashAssert,
wipe_secret_i |=> (hash_q == {($bits(hash_q)/$bits(wipe_v_i)){$past(wipe_v_i,1)}}))
`ASSERT(WipeMsgSchArrAssert,
wipe_secret_i |=> (w_q == {($bits(w_q)/$bits(wipe_v_i)){$past(wipe_v_i,1)}}))
`ASSERT(WipeDigestAssert,
wipe_secret_i |=> (digest_q == {($bits(digest_q)/$bits(wipe_v_i)){$past(wipe_v_i,1)}}))

`endif // SYNTHESIS
`endif // VERILATOR
end else begin : gen_256 // MultimodeEn = 0
// datapath signal definitions for SHA-2 256 only
sha_word32_t shaf_rdata256;
Expand Down Expand Up @@ -264,6 +278,21 @@ module prim_sha2 import prim_sha2_pkg::*;
assign digest_o[i][31:0] = digest256_q[i];
assign digest_o[i][63:32] = 32'b0;
end

`ifndef VERILATOR
`ifndef SYNTHESIS

// When wipe_secret is triggered, clear sensitive internal variables by extending the wipe
// value specifed in the register
`ASSERT(WipeHashAssert,
wipe_secret_i |=> (hash256_q == {($bits(hash256_q)/$bits(wipe_v_i)){$past(wipe_v_i,1)}}))
`ASSERT(WipeMsgSchArrAssert,
wipe_secret_i |=> (w256_q == {($bits(w256_q)/$bits(wipe_v_i)){$past(wipe_v_i,1)}}))
`ASSERT(WipeDigestAssert,
wipe_secret_i |=> (digest256_q == {($bits(digest256_q)/$bits(wipe_v_i)){$past(wipe_v_i,1)}}))

`endif // SYNTHESIS
`endif // VERILATOR
end

// compute round counter (shared)
Expand Down

0 comments on commit 818af47

Please sign in to comment.