Skip to content

Improve SHA3 test#1

Open
mdcornu wants to merge 4 commits into
mainfrom
tests/improve_sha3_test
Open

Improve SHA3 test#1
mdcornu wants to merge 4 commits into
mainfrom
tests/improve_sha3_test

Conversation

@mdcornu
Copy link
Copy Markdown
Owner

@mdcornu mdcornu commented May 27, 2026

Add extra test vector to SHA3 test and remove duplicated per test message vector definitions.

  • Does this PR change the input/output behaviour of a cryptographic algorithm (i.e., does it change known answer test values)? (If so, a version bump will be required from x.y.z to x.(y+1).0.)
  • Does this PR change the list of algorithms available -- either adding, removing, or renaming? Does this PR otherwise change an API? (If so, PRs in fully supported downstream projects dependent on these, i.e., oqs-provider will also need to be ready for review and merge by the time this is merged. Also, make sure to update the list of algorithms in the continuous benchmarking files: .github/workflows/kem-bench.yml and sig-bench.yml)

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.c to 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.S to 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.

Comment thread tests/test_sha3.c Outdated
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>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.

Comment thread tests/test_sha3.c Outdated
Comment thread tests/test_sha3.c Outdated
Comment thread tests/test_sha3.c Outdated
Comment thread tests/test_sha3.c Outdated
@mdcornu mdcornu force-pushed the tests/improve_sha3_test branch 2 times, most recently from 34038c8 to 96ecb66 Compare May 28, 2026 15:43
@mdcornu mdcornu requested a review from Copilot May 28, 2026 16:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread tests/test_sha3.c Outdated
Comment thread tests/test_sha3.c Outdated
@mdcornu
Copy link
Copy Markdown
Owner Author

mdcornu commented May 28, 2026

@tkanteck Can you have a scan of this? For some reason I can't add you as a reviewer.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@coveralls
Copy link
Copy Markdown

Coverage Report for CI Build 26588835144

Warning

No base build found for commit f986aea on main.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 82.181%

Details

  • Patch coverage: No coverable lines changed in this PR.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 252643
Covered Lines: 207625
Line Coverage: 82.18%
Coverage Strength: 8216708.87 hits per line

💛 - Coveralls

mdcornu added 3 commits May 29, 2026 02:18
…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>
Copy link
Copy Markdown

@tkanteck tkanteck left a comment

Choose a reason for hiding this comment

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

cool - just thinking it could potentially be a bit improved

Comment thread tests/test_sha3.c Outdated
Comment thread tests/test_sha3.c Outdated
Comment thread tests/test_sha3.c Outdated

/* 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];
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

same as above, there is potentially to make the code more compact and test bit more

@mdcornu mdcornu force-pushed the tests/improve_sha3_test branch from 2ffb62f to bb3b9aa Compare May 29, 2026 14:58
@mdcornu mdcornu requested a review from Copilot May 29, 2026 15:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@mdcornu mdcornu force-pushed the tests/improve_sha3_test branch from bb3b9aa to a19c60e Compare May 29, 2026 16:10
@mdcornu mdcornu requested a review from Copilot May 29, 2026 16:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

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.

4 participants