Add sha3 and icsf tests#594
Draft
1000TurquoisePogs wants to merge 1 commit into
Draft
Conversation
Signed-off-by: 1000TurquoisePogs <sgrady@rocketsoftware.com>
|
7 tasks
Comment on lines
+4
to
+6
| - Bugfix: `icsfDigestInit` in `icsf.c` contained a typo in the SHA-256 ICSF rule array keyword (`"SHA246"` instead of `"SHA256"`), causing SHA-256 hashing to fail. | ||
| - Bugfix: `ICSFDigest.hash` buffer in `icsf.h` was 32 bytes, too small for SHA-384 (48 bytes) and SHA-512 (64 bytes). Increased to 64 bytes to prevent buffer overflow. | ||
| - Enhancement: Added SHA-3 (Keccak) algorithm support to the ICSF digest wrapper: `ICSF_DIGEST_SHA3_224`, `ICSF_DIGEST_SHA3_256`, `ICSF_DIGEST_SHA3_384`, `ICSF_DIGEST_SHA3_512` with corresponding cases in `icsfDigestInit`, `icsfDigestUpdate`, and `icsfDigestFinish`. |
Contributor
There was a problem hiding this comment.
Could you, please, add the PR or issue number?
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.


Proposed changes
Fix three bugs in the ICSF digest wrapper (
icsf.h/icsf.c) and add SHA-3 algorithm support.Bug fixes
SHA-256 typo (
icsf.c): TheicsfDigestInitrule array forICSF_DIGEST_SHA256contained"SHA246"instead of"SHA256". This caused SHA-256 hashing to fail at the ICSF callable service level with a bad rule array keyword. Fixed by correcting the string to"SHA256 FIRST ".Hash buffer overflow (
icsf.h): Thehashfield inICSFDigestwas declared aschar hash[32], which is too small for SHA-384 (48 bytes) and SHA-512 (64 bytes). Writing the hash output would overflow into adjacent struct memory. Fixed by increasing tochar hash[64].Context buffer too small for SHA-3 (
icsf.h):ICSF_HASH_CONTEXT_LENGTHwas 128 bytes, which is insufficient for SHA-3's Keccak state (requires ~200+ bytes). Increased to 512 bytes to accommodate all current and foreseeable ICSF algorithm context sizes.New feature: SHA-3 support
Added SHA-3 (Keccak) family algorithms to the ICSF digest wrapper:
ICSF_DIGEST_SHA3_224SHA3-224ICSF_DIGEST_SHA3_256SHA3-256ICSF_DIGEST_SHA3_384SHA3-384ICSF_DIGEST_SHA3_512SHA3-512Cases added to all three streaming functions:
icsfDigestInit,icsfDigestUpdate,icsfDigestFinish.Files changed
h/icsf.hICSF_HASH_CONTEXT_LENGTH(128->512),hash[32]->hash[64], added SHA-3 constantsc/icsf.c"SHA246"typo, added SHA-3 cases to Init/Update/FinishType of change
PR Checklist
Testing
Try out tests/icsftest.c
Further comments
The SHA-256 typo (
"SHA246") has been present since the original code. Any existing callers usingICSF_DIGEST_SHA256through this wrapper were silently getting ICSF errors. The SHA-384/SHA-512 buffer overflow was a latent bug that could cause memory corruption when those algorithms were used.The context length increase from 128 to 512 bytes increases the
ICSFDigeststruct size. Callers allocating this struct on the stack should have sufficient stack space (the struct is now approximately 640 bytes total).