Skip to content

Add SHAKE-128 and SHAKE-256 (FIPS 202 XOF) MessageDigest support - #274

Open
cconlon wants to merge 1 commit into
wolfSSL:masterfrom
cconlon:shake
Open

Add SHAKE-128 and SHAKE-256 (FIPS 202 XOF) MessageDigest support#274
cconlon wants to merge 1 commit into
wolfSSL:masterfrom
cconlon:shake

Conversation

@cconlon

@cconlon cconlon commented Sep 1, 2026

Copy link
Copy Markdown
Member

This PR adds SHAKE-128 and SHAKE-256 support at both the JNI and JCE levels:

  • JNI: new com.wolfssl.wolfcrypt.Shake class and jni/jni_shake.c wrapping the native wc_Shake128/256 API, with arbitrary-length XOF output, clone() support, and native state zeroized on free.
  • JCE: MessageDigest services SHAKE128-256 (32-byte) and SHAKE256-512 (64-byte), with SHAKE128/SHAKE256 and NIST OID aliases.
  • Tests: ShakeTest (JNI) and WolfCryptMessageDigestShakeTest (JCE)
  • Example: examples/provider/ShakeExample.java/.sh.

Requires native wolfSSL with SHA-3/SHAKE enabled (default with --enable-sha3).

@cconlon cconlon self-assigned this Sep 1, 2026
Copilot AI lite review requested due to automatic review settings September 1, 2026 20:08

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Pull request overview

Adds SHAKE-128/SHAKE-256 (FIPS 202 XOF) support across the wolfCrypt JNI wrapper and the wolfJCE provider, including feature detection, provider registration, tests, and examples.

Changes:

  • Introduces com.wolfssl.wolfcrypt.Shake with JNI bindings (jni_shake.c) and feature-detect toggles for SHAKE128/SHAKE256.
  • Registers JCE MessageDigest algorithms SHAKE128-256 and SHAKE256-512 plus aliases (short names + NIST OIDs).
  • Adds comprehensive JNI/JCE test suites and a provider example for SHAKE usage.

Reviewed changes

Copilot reviewed 21 out of 23 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/test/java/com/wolfssl/wolfcrypt/test/WolfCryptTestSuite.java Adds ShakeTest to the wolfCrypt JNI test suite.
src/test/java/com/wolfssl/wolfcrypt/test/ShakeTest.java Adds JNI-level SHAKE KATs, XOF length tests, ByteBuffer coverage, clone/release/threading tests.
src/test/java/com/wolfssl/provider/jce/test/WolfJCETestSuite.java Adds WolfCryptMessageDigestShakeTest to the wolfJCE test suite.
src/test/java/com/wolfssl/provider/jce/test/WolfCryptMessageDigestShakeTest.java Adds JCE-level SHAKE tests for digests, aliases, clone/reset, interop, and threading.
src/main/java/com/wolfssl/wolfcrypt/Shake.java Adds the JNI-backed SHAKE wrapper with configurable XOF output length and clone support.
src/main/java/com/wolfssl/wolfcrypt/FeatureDetect.java Adds native feature-detect methods for SHAKE128/SHAKE256 availability.
src/main/java/com/wolfssl/provider/jce/WolfCryptProvider.java Registers SHAKE MessageDigest services and alias mappings (including OIDs).
src/main/java/com/wolfssl/provider/jce/WolfCryptMessageDigestShake.java Adds JCE MessageDigestSpi wrapper for fixed-length SHAKE128-256 and SHAKE256-512.
spotbugs-exclude.xml Suppresses SpotBugs findings for new SHAKE classes (constructor-throw + clone patterns).
scripts/infer.sh Adds new classes to Infer static analysis compilation list.
makefile.macosx Links jni_shake.o into the macOS JNI library build.
makefile.linux Links jni_shake.o into the Linux JNI library build.
jni/jni_shake.c Implements JNI glue for SHAKE init/update/final/copy/free for both variants.
jni/jni_feature_detect.c Implements native checks for SHAKE128/SHAKE256 compile-time availability.
examples/provider/ShakeExample.sh Adds a runnable script for the SHAKE provider example.
examples/provider/ShakeExample.java Adds a Java example demonstrating fixed-length JCE and variable-length JNI XOF usage.
examples/provider/CryptoBenchmark.java Adds SHAKE enablement gating for benchmark selection.
README_JCE.md Documents SHAKE algorithms and their OID aliases in supported JCE algorithms list.
IDE/WIN/wolfcryptjni.vcxproj.filters Adds jni_shake.c to the Windows project filters.
IDE/WIN/wolfcryptjni.vcxproj Adds jni_shake.c to the Windows build.
IDE/Android/app/src/main/cpp/CMakeLists.txt Adds jni_shake.c to the Android JNI build.
Files not reviewed (2)
  • jni/include/com_wolfssl_wolfcrypt_FeatureDetect.h: Generated file
  • jni/include/com_wolfssl_wolfcrypt_Shake.h: Generated file

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread jni/jni_shake.c
Comment thread src/test/java/com/wolfssl/provider/jce/test/WolfCryptMessageDigestShakeTest.java Outdated
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.

2 participants