Add FIPS 180-4 SHA-256 #4

Merged
fputs merged 1 commit from fputs/sha256 into master 2026-11-05 09:59:27 -08:00 AGit
Owner

Adds FIPS 180-4 SHA-256 in lfsha256.h. It is not declared from lfcrypto.h or lfpuzzle.h. The hasher does not allocate and returns 32 raw bytes. Hex stays in lfcodec.h.

A successful final poisons the context (block_len > 64). Later update or final returns -1 until init. A NULL out does not finish the context. Bit-length overflow is rejected before the context changes.

Tests cover the empty, abc, 56-byte, and one-million-a vectors, including a chunked million-a feed.

Tested with -DCMAKE_BUILD_TYPE=Debug -DFLINT_SANITIZE=ON -DCMAKE_C_EXTENSIONS=OFF. ctest --label-exclude slow: 26/26 passed.

Adds FIPS 180-4 SHA-256 in `lfsha256.h`. It is not declared from `lfcrypto.h` or `lfpuzzle.h`. The hasher does not allocate and returns 32 raw bytes. Hex stays in `lfcodec.h`. A successful `final` poisons the context (`block_len > 64`). Later `update` or `final` returns `-1` until `init`. A NULL `out` does not finish the context. Bit-length overflow is rejected before the context changes. Tests cover the empty, `abc`, 56-byte, and one-million-`a` vectors, including a chunked million-`a` feed. Tested with `-DCMAKE_BUILD_TYPE=Debug -DFLINT_SANITIZE=ON -DCMAKE_C_EXTENSIONS=OFF`. `ctest --label-exclude slow`: 26/26 passed.
Add FIPS 180-4 SHA-256
All checks were successful
test / test (pull_request) Successful in 15s
test / sanitize (pull_request) Successful in 15s
6737977bbf
fputs force-pushed fputs/sha256 from 6737977bbf
All checks were successful
test / test (pull_request) Successful in 15s
test / sanitize (pull_request) Successful in 15s
to 252143ac07
All checks were successful
test / test (pull_request) Successful in 13s
test / sanitize (pull_request) Successful in 18s
2026-11-05 09:39:15 -08:00
Compare
fputs force-pushed fputs/sha256 from 252143ac07
All checks were successful
test / test (pull_request) Successful in 13s
test / sanitize (pull_request) Successful in 18s
to b7f8ee2ff3
All checks were successful
test / test (pull_request) Successful in 19s
test / sanitize (pull_request) Successful in 16s
2026-11-05 09:58:52 -08:00
Compare
fputs merged commit 4dd59664fd into master 2026-11-05 09:59:27 -08:00
fputs referenced this pull request from a commit 2026-11-05 09:59:28 -08:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
fputs/libflint!4
No description provided.