Improve SHA3 test#1
Conversation
86f381c to
51c0822
Compare
There was a problem hiding this comment.
Pull request overview
This PR improves SHA3/SHAKE test coverage by deduplicating shared KAT input messages and adding an additional SHA3 test vector (896-bit / 112-byte message). It also fixes a correctness/safety bug in the AVX512VL SHA3 incremental absorb path when completing a partial block and permuting.
Changes:
- Refactor
tests/test_sha3.cto share common KAT input messages across tests and add SHA3-256/384/512 KAT coverage for a 112-byte (896-bit) message, including additional incremental “chunked absorb” checks. - Fix AVX512VL incremental absorb logic in
SHA3-AVX512VL.Sto correctly decrement the remaining message length before the partial-fill-and-permute step (preventing double-absorb and potential out-of-bounds reads).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/test_sha3.c | Centralizes shared SHA3/SHAKE test messages and adds new msg896 KATs plus chunked incremental-absorb test cases. |
| src/common/sha3/avx512vl_low/SHA3-AVX512VL.S | Corrects the partial-fill-and-permute absorb path to maintain the correct remaining-length accounting (avoids double-absorb / OOB). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Move msg0, msg24, msg448, msg896, and msg1600 from local declarations repeated in each of the seven test functions into static const globals. This removes 140 lines of duplicated initialisers and makes it easier to extend the test suite without repeating the same byte arrays across sha3_256, sha3_384, sha3_512, shake_128, shake_256, shake_128_x4 and shake_256_x4. Signed-off-by: Cornu, Marcel D <marcel.d.cornu@intel.com>
51c0822 to
f796c28
Compare
34038c8 to
96ecb66
Compare
c7995ad to
2ffb62f
Compare
|
@tkanteck Can you have a scan of this? For some reason I can't add you as a reviewer. |
Coverage Report for CI Build 26588835144Warning No base build found for commit Coverage: 82.181%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats
💛 - Coveralls |
…idation Add 896-bit NIST vector and cross-validate inc API against one-shot API. Signed-off-by: Cornu, Marcel D <marcel.d.cornu@intel.com>
Cross-validate SHAKE inc API against one-shot using absorb sweep (1..168) and squeeze sweep (1..512), covering all code paths and rate-boundary transitions. Add distinct x4 lane inputs to the four-way tests. Signed-off-by: Cornu, Marcel D <marcel.d.cornu@intel.com>
Signed-off-by: Cornu, Marcel D <marcel.d.cornu@intel.com>
tkanteck
left a comment
There was a problem hiding this comment.
cool - just thinking it could potentially be a bit improved
|
|
||
| /* Verify ctx_reset: absorb msg24, finalize, then reset and re-absorb msg24; | ||
| result must equal a fresh inc_init hash of msg24. */ | ||
| uint8_t hash_fresh[48]; |
There was a problem hiding this comment.
same as above, there is potentially to make the code more compact and test bit more
2ffb62f to
bb3b9aa
Compare
bb3b9aa to
a19c60e
Compare
a19c60e to
e59598d
Compare
Add extra test vector to SHA3 test and remove duplicated per test message vector definitions.