Skip to content

Add AES Key Wrap (RFC 3394) Cipher support - #269

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

Add AES Key Wrap (RFC 3394) Cipher support#269
cconlon wants to merge 1 commit into
wolfSSL:masterfrom
cconlon:aesKw

Conversation

@cconlon

@cconlon cconlon commented Aug 28, 2026

Copy link
Copy Markdown
Member

This PR adds AES Key Wrap (RFC 3394 / NIST SP 800-38F KW) to wolfCrypt JNI and wolfJCE, via native wc_AesKeyWrap_ex() / wc_AesKeyUnWrap_ex().

  • New JNI AesKeyWrap class (jni_aeskeywrap.c)
  • Adds FeatureDetect.AesKeyWrapEnabled()
  • JCE Cipher services: AESWrap (aliases AES/KW/NoPadding, AESKW), AESWrap_128/192/256 (AES_NNN/KW/NoPadding, NIST OIDs), and AES/KW/PKCS5Padding
  • JCE WRAP/UNWRAP and ENCRYPT/DECRYPT modes, optional 8-byte IV via IvParameterSpec

Requires native wolfSSL built with --enable-aeskeywrap (included in --enable-all) to be enabled/registered. RFC 5649 KWP is not available in native wolfSSL and is out of scope.

JUnit tests added, IDE projects updated, simple example app added (AesKeyWrapExample).

Copilot AI lite review requested due to automatic review settings August 28, 2026 20:09
@cconlon cconlon changed the title dd AES Key Wrap (RFC 3394) Cipher support Add AES Key Wrap (RFC 3394) Cipher support Aug 28, 2026
@cconlon cconlon self-assigned this Aug 28, 2026

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.

Pull request overview

Adds AES Key Wrap (RFC 3394 / NIST SP 800-38F “KW”) support across the wolfCrypt JNI layer and the wolfJCE provider, including feature detection, provider registrations/aliases, AlgorithmParameters handling for 8-byte KW IVs, tests, and examples.

Changes:

  • Introduces native + Java JNI wrapper AesKeyWrap backed by wc_AesKeyWrap_ex() / wc_AesKeyUnWrap_ex(), plus FeatureDetect.AesKeyWrapEnabled().
  • Registers new wolfJCE Cipher services/aliases for AESWrap / AES/KW/* (including PKCS5Padding) and size-locked variants with NIST OIDs.
  • Adds extensive JUnit coverage (JNI + JCE), documentation updates, and build/IDE integration updates.

Reviewed changes

Copilot reviewed 26 out of 28 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/test/java/com/wolfssl/wolfcrypt/test/WolfCryptTestSuite.java Adds AesKeyWrapTest to the wolfCrypt JNI test suite.
src/test/java/com/wolfssl/wolfcrypt/test/AesKeyWrapTest.java New JNI-level AES Key Wrap test vectors, argument validation, offsets, and threading tests.
src/test/java/com/wolfssl/provider/jce/test/WolfJCETestSuite.java Adds WolfCryptCipherAesWrapTest to the wolfJCE test suite.
src/test/java/com/wolfssl/provider/jce/test/WolfCryptCipherTest.java Extends generic cipher tests to include AES Key Wrap services and excludes KW from IV-consistency test.
src/test/java/com/wolfssl/provider/jce/test/WolfCryptCipherAesWrapTest.java New wolfJCE AESWrap/AES-KW test coverage including interop, IV handling, and PKCS5Padding behavior.
src/test/java/com/wolfssl/provider/jce/test/WolfCryptAlgorithmParametersTest.java Adds tests validating 8-byte KW IV support in AES AlgorithmParameters (DER + spec paths).
src/main/java/com/wolfssl/wolfcrypt/FeatureDetect.java Adds native AesKeyWrapEnabled() feature detection hook.
src/main/java/com/wolfssl/wolfcrypt/AesKeyWrap.java New Java JNI wrapper for AES Key Wrap with keying, wrap/unwrap APIs, and argument validation.
src/main/java/com/wolfssl/provider/jce/WolfCryptProvider.java Registers AESWrap / AES-KW cipher services, aliases, OIDs, and size-locked variants when enabled.
src/main/java/com/wolfssl/provider/jce/WolfCryptCipher.java Implements AES Key Wrap mode in the provider cipher engine (modes, padding, IV params, wrap/unwrap integration).
src/main/java/com/wolfssl/provider/jce/WolfCryptAesParameters.java Expands AES AlgorithmParameters to accept/encode/decode both 16-byte AES IVs and 8-byte KW IVs.
spotbugs-exclude.xml Suppresses SpotBugs “constructor throws” warning for AesKeyWrap.
scripts/infer.sh Adds AesKeyWrap.java to the Infer static analysis compile list.
README.md Documents build/configure requirements for enabling AES Key Wrap in native wolfSSL for wolfJCE services.
README_JCE.md Documents AESWrap/AES-KW service names, behavior, IV handling, exceptions, and usage notes.
makefile.macosx Adds jni_aeskeywrap.o to native build object list.
makefile.linux Adds jni_aeskeywrap.o to native build object list.
jni/jni_feature_detect.c Implements FeatureDetect.AesKeyWrapEnabled() native binding.
jni/jni_aeskeywrap.c New JNI implementation bridging Java AesKeyWrap to wolfCrypt KW APIs with argument checks and zeroization.
jni/include/com_wolfssl_wolfcrypt_FeatureDetect.h Declares JNI header for AesKeyWrapEnabled.
jni/include/com_wolfssl_wolfcrypt_AesKeyWrap.h New generated JNI header for AesKeyWrap.
IDE/WIN/wolfcryptjni.vcxproj.filters Adds AES Key Wrap JNI header/source to Visual Studio project filters.
IDE/WIN/wolfcryptjni.vcxproj Adds AES Key Wrap JNI header/source to Visual Studio project.
IDE/WIN/README.md Documents Windows build defines enabling AES Key Wrap.
IDE/Android/app/src/main/cpp/CMakeLists.txt Enables HAVE_AES_KEYWRAP and includes jni_aeskeywrap.c in the Android build.
examples/provider/AesKeyWrapExample.sh New script to run the AES Key Wrap provider example.
examples/provider/AesKeyWrapExample.java New example demonstrating AESWrap usage, explicit IV, and PKCS5Padding for non-8-multiple encodings.
.github/workflows/windows-vs.yml Updates CI user_settings.h defines to enable AES Key Wrap for Windows builds.
Files not reviewed (2)
  • jni/include/com_wolfssl_wolfcrypt_AesKeyWrap.h: Generated file
  • jni/include/com_wolfssl_wolfcrypt_FeatureDetect.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 src/main/java/com/wolfssl/provider/jce/WolfCryptCipher.java
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