[Repo Assist] feat: add l_hmac_sha256 — HMAC-SHA-256 message authentication#154
Draft
github-actions[bot] wants to merge 1 commit intomainfrom
Draft
Conversation
Adds l_hmac_sha256() as a natural companion to the existing l_sha256 family. HMAC (RFC 2104) is a widely-used message authentication code; having it in l_os.h means TLS helpers, cookie signing, and API clients no longer need an external dependency. Implementation follows RFC 2104: - Keys > 64 bytes are pre-hashed (block size = 64 for SHA-256) - Inner hash: H(ipad ^ k || message) - Outer hash: H(opad ^ k || inner) - Zero-allocation: 2 × 64-byte stack arrays + reused L_Sha256 context Tests in test_utils.c cover three RFC 4231 vectors (verified against Python hmac + OpenSSL): - TC1: 20-byte 0x0b key, "Hi There" - TC2: "Jefe" key, "what do ya want for nothing?" - TC5: 131-byte 0xaa key (> block size), longer message Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Apr 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated PR from Repo Assist.
Summary
Adds
l_hmac_sha256()as a companion to the existingl_sha256family. HMAC-SHA-256 (RFC 2104) is the industry-standard message authentication primitive — useful for cookie signing, API authentication, token generation, and TLS helpers.API addition:
Implementation
Follows RFC 2104:
L_Sha256contextTests
Added
test_hmac_sha256()intests/test_utils.cwith three vectors cross-verified against Pythonhmacand OpenSSL:Test Status
✅ Local Linux (gcc):
bash Taskfile testtest_utils: 271/271 tests passed (24 new HMAC-SHA-256 assertions)-Wall -Wextra -Wpedantic