Skip to content

digest: register SHAKE-128 - #520

Open
ColtonWilley wants to merge 3 commits into
wolfSSL:masterfrom
ColtonWilley:fix/shake128
Open

ColtonWilley wants to merge 3 commits into
wolfSSL:masterfrom
ColtonWilley:fix/shake128

Conversation

@ColtonWilley

Copy link
Copy Markdown
Contributor

wolfCrypt has SHAKE-128 but only SHAKE-256 was exposed, so in replace-default mode Python's import hashlib logs a traceback, hashlib.shake_128 is missing and openssl dgst -shake128 fails. Registers SHAKE-128 (wolfSSL 5.5.1+; FIPS v5 has no SHAKE, FIPS Ready does), adds EVP_DigestSqueeze (OpenSSL 3.3+, used by ML-KEM/ML-DSA) and OpenSSL 3.4's no-default-length rule for both SHAKEs, and enables the SHAKE128 evp_test vectors. Covered by unit tests comparing against the default provider.

Closes #434.

Add the squeeze call OpenSSL 3.3+ uses (ML-KEM, ML-DSA) and match the
default provider's output length handling: no default length or digest
size from 3.4, xoflen/size readable from the context. Mark the
AlgorithmIdentifier parameters absent; no absorbing after output starts.
wolfCrypt builds with WOLFSSL_SHAKE128 but only SHAKE-256 was exposed,
so SHAKE-128 fetches (openssl dgst -shake128, Python hashlib) failed.
Reuse the SHAKE-256 XOF code with the wc_Shake128 functions.
Mirror test_shake_256 for SHAKE-128 and compare default length final,
squeeze across block boundaries and flags with OpenSSL for both SHAKEs.
Enable the SHAKE128 evp_test vectors.
Copilot AI balanced review requested due to automatic review settings October 27, 2026 21:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Shared cryptographic state-machine changes warrant human review and runtime validation across supported OpenSSL, wolfSSL, and FIPS configurations.

No open issues 🎉

What changed in this PR

Exposes SHAKE-128 through wolfProvider to address the missing digest reported in #434, and updates shared SHAKE behavior for newer OpenSSL APIs.

Changes:

  • Registers SHAKE-128 with feature gating, aliases, and documentation.
  • Adds incremental squeezing and OpenSSL 3.4 output-length behavior for both SHAKE variants.
  • Expands default-provider parity tests and enables SHAKE-128 test vectors.
File Description
test/​unit.h Declares the SHAKE-128 unit test.
test/​unit.c Registers the SHAKE-128 unit test.
test/​test_digest.c Tests SHAKE parity, squeezing, lifecycle, and context copying.
src/​wp_wolfprov.c Registers SHAKE-128 in the provider digest table.
src/​wp_digests.c Implements SHAKE-128 and shared SHAKE state and output handling.
scripts/​evp_test/​evpmd_sha.txt Enables SHAKE-128 digest vectors.
README.md Lists SHAKE-128 as supported.
include/​wolfprovider/​settings.h Gates SHAKE-128 on wolfSSL version and features.
include/​wolfprovider/​alg_funcs.h Adds SHAKE-128 aliases and dispatch declaration.

Review effort: Balanced

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.

Expose SHAKE-128 digest (SHA-3 family and SHAKE-256 are registered; SHAKE-128 is not)

2 participants