[pentest] Ensure KMAC reset - #31083
Conversation
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>
| for (uint32_t i = 0; i < uj_data.num_enc; ++i) { | ||
| kmac_reset(); | ||
|
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
The test
sca_sha3_python_testwas failing due to a missing KMAC reset insha3_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 ;)