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,dv/rtl] Implement DV checks for new digest sizes/key lengths #23108

Merged
merged 3 commits into from
May 22, 2024

Conversation

gdessouky
Copy link
Contributor

@gdessouky gdessouky commented May 14, 2024

This PR implements scoreboard checks for the new HMAC digest sizes and key lengths for normal operation and whenever secure wiping is triggered. For ease of DV checks and consistency across configuration changes where previous digests remain held in CSRs until HMAC starts a new operation, this PR also removes the clearing of redundant digest values for the smaller digest sizes in the RTL. It also updates the documentation to clarify that SW should only read the relevant digest CSRs for the digest size configured - @ballifatih (only read digests 0..7 for SHA-2 256 and digests 0..11 for SHA-2 384, i.e., do not assume the redundant digest values in these sizes will be all-zero.)

This should also fix the failing hmac_wipe_secret test (#23053) and close other pending DV TODOS.

Copy link
Contributor

@martin-velay martin-velay left a comment

Choose a reason for hiding this comment

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

I have only minor change suggestions

@@ -367,19 +367,15 @@ constraint key_digest_c {
// since HMAC digest size is max 512 bits.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you plan to extend this task later to support 384/512 digest sizes? (remind also to release constraints into hmac_test_vectors_sha_vseq.sv file)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, the compare_digest in hmac_base_vseg.sv is only relevant anyway for hmac_test_vectors_sha_vseq.sv, so we'll have to extend it once we release the constraints in these tests (captured already in issue #22932), but will add a TODO there with link to issue # as well.

hw/ip/hmac/dv/env/hmac_scoreboard.sv Outdated Show resolved Hide resolved
hw/ip/hmac/dv/env/hmac_scoreboard.sv Outdated Show resolved Hide resolved
hw/ip/hmac/dv/env/hmac_scoreboard.sv Outdated Show resolved Hide resolved
hw/ip/hmac/dv/env/hmac_scoreboard.sv Outdated Show resolved Hide resolved
if (digest_idx < 8) begin
`DV_CHECK_EQ(real_digest_val, exp_digest[digest_idx]);
end else begin
`DV_CHECK_EQ(real_digest_val, '0);
end
end else if (expected_digest_size == SHA2_512) begin
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you swap the section related to 384 with 512, to be consistent? I can live with that, but still 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They can actually be merged as well.

Copy link
Contributor

@andreaskurth andreaskurth left a comment

Choose a reason for hiding this comment

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

RTL and spec changes LGTM, thx @gdessouky. I'll let the DV experts judge the DV changes, though I didn't notice any obvious mistake from a quick glance

This removes the clearing of the additional digest values
for digest sizes 256 and 384, which also simplifies
the DV checks across different configuration changes.

Signed-off-by: Ghada Dessouky <[email protected]>
This updates the scoreboard for checks for different digest
sizes and key lengths, in normal operation and in secure
wiping.

Signed-off-by: Ghada Dessouky <[email protected]>
This updates the HMAC documentation to correspond
with the changes in the commits above as well as
commits minor fixes.

Signed-off-by: Ghada Dessouky <[email protected]>
@gdessouky
Copy link
Contributor Author

gdessouky commented May 22, 2024

Thanks @martin-velay for the DV comments, I've addressed them in my last forced push since yesterday. Rebasing and running CI again and hoping for a better CI day today :-) Would be great to merge soon; I have many dependent PRs I'm afraid it will get confusing soon...

@gdessouky
Copy link
Contributor Author

The failing test in CI has nothing to do with the changes in this PR, can we please merge :-) @andreaskurth?

@andreaskurth
Copy link
Contributor

Agreed, thanks @gdessouky!

@andreaskurth andreaskurth merged commit e01609e into lowRISC:master May 22, 2024
30 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants