Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hmac] Wipe secret assertions and spec update #25674

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

martin-velay
Copy link
Contributor

- fix doc to be aligned with the RTL as the FSMs are not affected by the
wipe secret triggering. But this is not a security issue.

Signed-off-by: Martin Velay <[email protected]>
- 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]>
@martin-velay martin-velay marked this pull request as ready for review December 17, 2024 09:41
@martin-velay
Copy link
Contributor Author

@andreaskurth, as discussed the doc update should fall into the earlgrey_1.0.0 as well. What about the assertions? Should I better split this PR in 2 pieces or that OK to update the "RTL" (which is not really an RTL change)? (BTW, that's a case where the assertions binding is preferable IMO).

@@ -420,7 +420,7 @@
{ name: "WIPE_SECRET",
desc: '''Clear internal secret registers.

If CPU writes a value into the register, the value is used to clear the internal variables such as the secret key, internal state machine, or hash value.
If CPU writes a value into the register, the value is used to clear the internal variables such as the secret key, intermediate hash results, digest and the internal message scheduling array.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good but it might be worth fixing the grammar slightly since we're touching the line. We probably want an article before CPU ("If the CPU ..." or "If a CPU ...") and we've got a spare one before "internal". The sentence is trying to say that we use the value to clear some of the internal variables. Putting "the" in makes it sound like we're wiping the whole lot of them.

// 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)}}))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the computed replication constant! (and it's neater than just putting in an integer. Nice!)

// 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)}}))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably drop the ,1. That's the default behaviour of $past and it might be marginally more obvious? (Similarly in prim_sha2.sv)

@@ -178,6 +178,20 @@ module prim_sha2 import prim_sha2_pkg::*;
// assign digest to output
assign digest_o = digest_q;

`ifndef VERILATOR
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need the ifndef VERILATOR around assertions like this? (I think it's needed in hmac.sv because of the use of property)

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably make this more descriptive than prescriptive :-) Maybe "When wipe_secret is high, sensitive internal variables are cleared by ..." ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants