Skip to content

[Repo Assist] test: add NIST FIPS 180-4 SHA-256 test vectors#148

Draft
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/test-sha256-nist-vectors-c7437bcb844c81a0
Draft

[Repo Assist] test: add NIST FIPS 180-4 SHA-256 test vectors#148
github-actions[bot] wants to merge 1 commit intomainfrom
repo-assist/test-sha256-nist-vectors-c7437bcb844c81a0

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Adds three additional SHA-256 test vectors from NIST FIPS 180-4 to tests/test_utils.c, strengthening confidence in the correctness of the freestanding SHA-256 implementation across all input sizes.

Changes

````tests/test_utils.c``` — extended test_sha256() with:

  1. 56-byte padding-boundary vector"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" (56 bytes), which crosses the SHA-256 padding boundary (pad block needed). Expected: 248d6a61...db06c1

  2. 112-byte two-block vector"abcdefghbcdefghicdefghij..." (112 bytes), two full 512-bit processing blocks. Expected: cf5b16a7...fee9d1

  3. 1,000,000 × 'a' via incremental API — 1000 calls of 1000 bytes each to l_sha256_update, exercising l_sha256_init / l_sha256_update / l_sha256_final with a very large input. Expected: cdc76e5c...2cd0

All 32 bytes of each expected hash are verified via l_memcmp.

Motivation

The existing tests only covered the empty string and "abc" (both fit in a single 512-bit block). These new vectors exercise:

  • Inputs that require a second padding block (56–63 bytes)
  • Multi-block inputs
  • Large inputs accumulated through the incremental API

Test Status

✅ All tests pass on Linux x86_64 (gcc):

Testing l_sha256...
  [OK] sha256 nist 56-byte vector
  [OK] sha256 nist 112-byte vector
  [OK] sha256 nist 1M-a incremental
  L_Sha256 tests: PASSED

Full ./Taskfile test suite passes.

Generated by 🌈 Repo Assist at {run-started}. Learn more.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@1f672aef974f4246124860fc532f82fe8a93a57e

Add three additional SHA-256 test vectors from NIST FIPS 180-4:

- 56-byte input crossing the SHA-256 padding boundary
  ("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq")
  Expected: 248d6a61...db06c1

- 112-byte input spanning two full 512-bit blocks
  ("abcdefghbcdefghicdefghij...")
  Expected: cf5b16a7...fee9d1

- 1,000,000 'a' characters via incremental API
  Expected: cdc76e5c...112cd0

These exercise the padding boundary, multi-block processing, and
the incremental l_sha256_init/l_sha256_update/l_sha256_final API
with large inputs. All 32 bytes of each expected hash are verified
via l_memcmp.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants