Zeroize native private key copies before JNI byte array release - #263
Open
cconlon wants to merge 9 commits into
Open
Zeroize native private key copies before JNI byte array release#263cconlon wants to merge 9 commits into
cconlon wants to merge 9 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
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.
This PR hardens JNI key-handling by wiping native copies of sensitive key material before releasing JNI byte arrays (using JNI_ABORT to avoid modifying caller-provided Java arrays).
Changes:
- Add
getByteArrayIsCopy()andzeroizeByteArrayCopy()helpers to detect/correctly wipe only native JNI copies. - Update RSA/ECC/Ed25519/Curve25519/DH/3DES JNI paths to zeroize sensitive native copies before releasing arrays.
- Add a Java regression test to ensure raw RSA private-key import does not modify caller arrays.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/com/wolfssl/wolfcrypt/test/RsaTest.java | Adds a regression test ensuring RSA raw private import doesn’t mutate caller arrays. |
| jni/jni_rsa.c | Uses isCopy-aware byte access and zeroizes sensitive RSA-related native copies before JNI_ABORT release. |
| jni/jni_native_struct.c | Introduces isCopy-aware byte getter and a helper to zeroize native copies. |
| jni/jni_ed25519.c | Zeroizes native copies of Ed25519 private key input buffers before release. |
| jni/jni_ecc.c | Zeroizes native copies of ECC private key input buffers before release. |
| jni/jni_dh.c | Zeroizes native copies of DH private/PKCS8 buffers before release (including error paths). |
| jni/jni_des3.c | Zeroizes native copy of 3DES key material prior to releasing JNI array. |
| jni/jni_curve25519.c | Zeroizes native copies of Curve25519 private key input buffers before release. |
| jni/include/wolfcrypt_jni_NativeStruct.h | Exposes new JNI helper function declarations. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… private key copies before JNI release
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 PR includes 18 Fenrir fixes: