Skip to content

[pentest] Ensure KMAC reset - #31083

Open
luismarques wants to merge 1 commit into
lowRISC:earlgrey_1.0.0from
luismarques:fix-sca_sha3_python_test
Open

[pentest] Ensure KMAC reset#31083
luismarques wants to merge 1 commit into
lowRISC:earlgrey_1.0.0from
luismarques:fix-sca_sha3_python_test

Conversation

@luismarques

Copy link
Copy Markdown
Contributor

The test sca_sha3_python_test was failing due to a missing KMAC reset in sha3_sca.c. The file also had inconsistent pre- and post-absorb reset strategies. Fix it by moving the one pre-absorb reset to a post-absorb reset.

@nasahlpa @siemen11 Although unrelated, this is a spiritual follow up to #31019, to help with CI ;)

The test sca_sha3_python_test was failing due to a missing KMAC reset in
`sha3_sca.c`. The file also had inconsistent pre- and post-absorb reset
strategies. Fix it by moving the one pre-absorb reset to a post-absorb
reset.

Signed-off-by: Luís Marques <luismarques@lowrisc.org>
@luismarques
luismarques requested a review from a team as a code owner August 21, 2026 17:06
@luismarques
luismarques requested review from pamaury and removed request for a team August 21, 2026 17:06
Comment on lines 529 to -531
for (uint32_t i = 0; i < uj_data.num_enc; ++i) {
kmac_reset();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not very familiar, but should there not be a kmac_reset at the start outside the loop? Otherwise it looks like the KMAC state is inconsistent before the first iteration, rather than after the last, which seems like it just moves the issue.

@luismarques luismarques Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A reset after the absorb was the most prevalent approach (see kmac_sca.c), this one was the outlier, so moving this reset to after the absorb seemed like the obvious choice. I was assuming that this would preserve the necessary invariants, with all previous commands and state changes leaving it reset/idle (so this would be a systematic approach), but I'm happy to be corrected if that's not the case.

@nasahlpa @siemen11 will know best, so I defer to them to specify what the approach should be.

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.

2 participants