Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions sw/device/tests/penetrationtests/firmware/sca/sha3_sca.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,6 @@ status_t handle_sha3_sca_batch(ujson_t *uj) {
}

for (uint32_t i = 0; i < uj_data.num_enc; ++i) {
kmac_reset();

Comment on lines 529 to -531

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.

if (sha3_serial_absorb(sha3_batch_messages[i], kMessageLength) !=
sha3ScaOk) {
return ABORTED();
Expand All @@ -545,6 +543,10 @@ status_t handle_sha3_sca_batch(ujson_t *uj) {
for (uint32_t j = 0; j < kDigestLength; ++j) {
batch_digest[j] ^= out[j];
}

// Reset before the next absorb since KMAC must be idle before starting
// another absorb.
kmac_reset();
}

// Acknowledge the batch command. This is crucial to be in sync with the host
Expand Down
Loading